Exemplo n.º 1
0
  private Dialog locationPicker() {
    AlertDialog.Builder locationPickerBuilder = new AlertDialog.Builder(this);
    locationPickerBuilder.setTitle("Set task location");

    View content =
        getLayoutInflater()
            .inflate(R.layout.editlocation, (ViewGroup) findViewById(R.id.editLocation));
    locationPickerBuilder.setView(content);

    EditText longitudeText = (EditText) content.findViewById(R.id.longitudeText);
    EditText latitudeText = (EditText) content.findViewById(R.id.latitudeText);

    latitudeText.setText(String.valueOf(location().latitude()));
    longitudeText.setText(String.valueOf(location().longitude()));

    locationPickerBuilder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            Dialog locationPicker = (Dialog) dialogInterface;
            EditText longitudeText = (EditText) locationPicker.findViewById(R.id.longitudeText);
            EditText latitudeText = (EditText) locationPicker.findViewById(R.id.latitudeText);
            double longitude = Double.valueOf(longitudeText.getText().toString());
            double latitude = Double.valueOf(latitudeText.getText().toString());
            task.add(TaskAdapter.LOCATION, new CMGeoPoint(longitude, latitude));
            setLocation();
          }
        });

    return locationPickerBuilder.create();
  }
Exemplo n.º 2
0
  @Override
  protected void onInflate(Bundle savedInstanceState) {
    setContentView(R.layout.contact_add);

    ListView listView = getListView();
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.contact_add_header, listView, false);
    listView.addHeaderView(view, null, false);

    accountView = (Spinner) view.findViewById(R.id.contact_account);
    accountView.setAdapter(new AccountChooseAdapter(this));
    accountView.setOnItemSelectedListener(this);
    userView = (EditText) view.findViewById(R.id.contact_user);
    nameView = (EditText) view.findViewById(R.id.contact_name);
    ((Button) view.findViewById(R.id.ok)).setOnClickListener(this);

    String name;
    Intent intent = getIntent();
    if (savedInstanceState != null) {
      account = savedInstanceState.getString(SAVED_ACCOUNT);
      user = savedInstanceState.getString(SAVED_USER);
      name = savedInstanceState.getString(SAVED_NAME);
    } else {
      account = getAccount(intent);
      user = getUser(intent);
      if (account == null || user == null) name = null;
      else {
        name = RosterManager.getInstance().getName(account, user);
        if (user.equals(name)) name = null;
      }
    }
    if (account == null) {
      Collection<String> accounts = AccountManager.getInstance().getAccounts();
      if (accounts.size() == 1) account = accounts.iterator().next();
    }
    if (account != null) {
      for (int position = 0; position < accountView.getCount(); position++)
        if (account.equals(accountView.getItemAtPosition(position))) {
          accountView.setSelection(position);
          break;
        }
    }
    if (user != null) userView.setText(user);
    if (name != null) nameView.setText(name);
    if (ACTION_SUBSCRIPTION_REQUEST.equals(intent.getAction())) {
      subscriptionRequest = PresenceManager.getInstance().getSubscriptionRequest(account, user);
      if (subscriptionRequest == null) {
        Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
        finish();
        return;
      }
    } else {
      subscriptionRequest = null;
    }
  }
Exemplo n.º 3
0
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
          myYear = year;
          myMonth = monthOfYear;
          myDay = dayOfMonth;
          if (editTextDateStart.getText().length() == 0) {
            editTextDateStart.setText(myDay + "/" + myMonth + "/" + myYear);
            editTextDateStart.setTextColor(Color.BLACK);
          }

          if (editTextDateEnd.getText().length() == 0) {
            editTextDateEnd.setText(myDay + "/" + myMonth + "/" + myYear);
            editTextDateEnd.setTextColor(Color.BLACK);
          }
        }
Exemplo n.º 4
0
  private void initView() {
    mSessionEditText = (EditText) findViewById(R.id.et_sessionid);
    mUserIdEditText = (EditText) findViewById(R.id.et_userid);
    mRadioGroup = (RadioGroup) findViewById(R.id.rb_orientation);
    mStartBtn = (Button) findViewById(R.id.btnStart);
    mStartBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String sessionId = mSessionEditText.getText().toString().trim();
            String userId = mUserIdEditText.getText().toString().trim();
            if (TextUtils.isEmpty(sessionId)) {
              Toast.makeText(MyActivity.this, "pls input the sessionId!", Toast.LENGTH_SHORT)
                  .show();
              return;
            }
            int id = mRadioGroup.getCheckedRadioButtonId();
            int orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
            if (id == R.id.rb_hor) {
              orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            } else if (id == R.id.rb_ver) orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;

            GameActivity.start(MyActivity.this, sessionId, userId, orientation);
          }
        });

    String userId = String.valueOf((int) (Math.random() * 10 + 1));
    mUserIdEditText.setText(userId);
    mHelper = ArcVoiceHelper.getInstance(getApplicationContext());
    mHelper.init(ARC_APP_ID, ARC_APP_CREDENTIALS, ARC_REGION, userId);
  }
Exemplo n.º 5
0
  private LinearLayout getMainBody() {
    LinearLayout llMainBody = new LinearLayout(getContext());
    llMainBody.setOrientation(LinearLayout.VERTICAL);
    LayoutParams lpMain = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpMain.weight = 1;
    int dp_4 = dipToPx(getContext(), 4);
    lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
    llMainBody.setLayoutParams(lpMain);

    LinearLayout llContent = new LinearLayout(getContext());
    LayoutParams lpContent = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpContent.weight = 1;
    llMainBody.addView(llContent, lpContent);

    // share content editor
    etContent = new EditText(getContext());
    etContent.setGravity(Gravity.LEFT | Gravity.TOP);
    etContent.setBackgroundDrawable(null);
    etContent.setText(String.valueOf(shareParamMap.get("text")));
    etContent.addTextChangedListener(this);
    LayoutParams lpEt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpEt.weight = 1;
    etContent.setLayoutParams(lpEt);
    llContent.addView(etContent);

    llContent.addView(getThumbView());
    llMainBody.addView(getBodyBottom());

    return llMainBody;
  }
Exemplo n.º 6
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings);

    saveBoton = (Button) findViewById(R.id.button1);
    cancelBoton = (Button) findViewById(R.id.button2);

    et = (EditText) findViewById(R.id.editText1);

    prefs = getSharedPreferences("preferences", Context.MODE_PRIVATE);

    et.setText(String.valueOf(prefs.getLong("rad", 100)));

    spin = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(this, R.array.units, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spin.setAdapter(adapter);
    spin.setOnItemSelectedListener(new MyOnItemSelectedListener());

    saveBoton.setOnClickListener(new OnClickSaveListener());

    cancelBoton.setOnClickListener(new OnClickCancelListener());
  }
Exemplo n.º 7
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
Exemplo n.º 8
0
 private EditText createRenameEditText(String fileName) {
   EditText editText = new EditText(this);
   editText.setText(
       fileName.substring(0, fileName.length() - FileController.FILE_EXTENSION.length()));
   editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
   editText.setSelection(editText.getText().length());
   return editText;
 }
 private boolean handleIncorrectPassphrase(GeneralSecurityException e) {
   Log.e(TAG, "Cacheword pass verification failed: " + e.getMessage());
   enterPassphraseEditText.setText("");
   Toast.makeText(
           LockScreenActivity.this, R.string.lock_screen_passphrase_incorrect, Toast.LENGTH_SHORT)
       .show();
   return false;
 }
  private void updatePortFromSecurityType() {
    ConnectionSecurity securityType = getSelectedSecurity();
    updateAuthPlainTextFromSecurityType(securityType);

    // Remove listener so as not to trigger validateFields() which is called
    // elsewhere as a result of user interaction.
    mPortView.removeTextChangedListener(validationTextWatcher);
    mPortView.setText(String.valueOf(AccountCreator.getDefaultPort(securityType, mStoreType)));
    mPortView.addTextChangedListener(validationTextWatcher);
  }
 /*
  * (non-Javadoc)
  *
  * @see android.app.Activity#onBackPressed()
  */
 @Override
 public void onBackPressed() {
   if (filtered) {
     ContactListActivity.this.contact_adapter.getFilter().filter("");
     EditText search_box = (EditText) findViewById(R.id.search_box);
     search_box.setText("");
     filtered = false;
   } else {
     super.onBackPressed();
   }
 }
Exemplo n.º 12
0
 private void bindDataOnView(int position) {
   Vehicle temp = vehicleList.get(position);
   etName.setText(temp.getName());
   edtRego.setText(temp.getRego());
   edtMake.setText(temp.getMake());
   edtModel.setText(temp.getModel());
   edtPhone.setText(temp.getYourPhone());
   edtAddress.setText(temp.getYourAddress());
   edtRegoDate.setText(temp.getRegoReminder());
 }
Exemplo n.º 13
0
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
          myHour = hourOfDay;
          myMinute = minute;

          if (editTextTimeStart.getText().length() == 0) {
            if (myMinute < 10) {
              editTextTimeStart.setText(myHour + ":" + "0" + myMinute);
            } else {
              editTextTimeStart.setText(myHour + ":" + myMinute);
            }
            editTextTimeStart.setTextColor(Color.BLACK);
          }

          if (editTextTimeEnd.getText().length() == 0) {
            if (myMinute < 10) {
              editTextTimeEnd.setText(myHour + ":" + "0" + myMinute);
            } else {
              editTextTimeEnd.setText(myHour + ":" + myMinute);
            }
            editTextTimeEnd.setTextColor(Color.BLACK);
          }
        }
Exemplo n.º 14
0
 public void cleanEdite() {
   mEdittext.setText("");
   SoftkeyboardUtil.hideSoftKeyBoard(getContext(), mEdittext);
   mAppendframe.setVisibility(GONE);
   mSend.setVisibility(VISIBLE);
   mRedpoint.setVisibility(GONE);
   mHoldtospeek.setText(R.string.press_say);
   mGameIcon.setImageResource(R.drawable.icon_addgame);
   mImageIcon.setImageResource(R.drawable.icon_addimage);
   mRedpoint.setVisibility(GONE);
   mClear1.setVisibility(GONE);
   mClear2.setVisibility(GONE);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View shippingDetailsView = inflater.inflate(R.layout.shipping_details, container, false);

    Button placeOrder = (Button) shippingDetailsView.findViewById(R.id.placeOrder);

    phoneNumberField = (EditText) shippingDetailsView.findViewById(R.id.phone);
    phoneNumberField.setText(user.getPhone());

    firstNameField = (EditText) shippingDetailsView.findViewById(R.id.firstName);
    firstNameField.setText(user.getFirstName());

    lastNameField = (EditText) shippingDetailsView.findViewById(R.id.lastName);
    lastNameField.setText(user.getLastName());

    address1Field = (EditText) shippingDetailsView.findViewById(R.id.streetAddress1);
    address1Field.setText(user.getAddress1());

    address2Field = (EditText) shippingDetailsView.findViewById(R.id.streetAddress2);
    address2Field.setText(user.getAddress2());

    cityField = (EditText) shippingDetailsView.findViewById(R.id.city);
    cityField.setText(user.getCity());

    stateField = (AutoCompleteTextView) shippingDetailsView.findViewById(R.id.state);
    stateField.setText(user.getState());

    zipCodeField = (EditText) shippingDetailsView.findViewById(R.id.postalCode);
    zipCodeField.setText(user.getZipCode());

    countryField = (AutoCompleteTextView) shippingDetailsView.findViewById(R.id.country);
    user.setCountry(user.getCountry() != null ? user.getCountry() : "United States");
    countryField.setText(user.getCountry());
    countryField.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            loadStates();
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    placeOrder.setOnClickListener((b) -> placeOrder());

    loadCountries();
    loadStates();
    return shippingDetailsView;
  }
Exemplo n.º 16
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode == RESULT_OK) {
     String classify = data.getStringExtra("reminderResult");
     if (requestCode == ADD_TIME_REMINDER) {
       if (classify != null && classify.equals("bookDateTime")) {
         tvBookDate.setText(data.getStringExtra("timeReminderResult"));
       } else {
         edtRegoDate.setText(data.getStringExtra("timeReminderResult"));
       }
     } else if (requestCode == ADD_OTHER_WORK) {
       tvOtherWork.setText(data.getStringExtra("otherWorkResult"));
     }
   }
 }
Exemplo n.º 17
0
  public void doNav() {

    String url = urlField.getText().toString();

    if (URLUtil.isValidUrl(url) == false) {
      url = "http://" + url;
    }

    urlField.setText(url);

    webView.requestFocus();

    webView.loadUrl(url);

    navbar.startAnimation(slideUp);
  }
Exemplo n.º 18
0
  private void getPhoneNumber() {
    TelephonyManager telephonyMgr =
        (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
    String tel = null;
    tel = telephonyMgr.getLine1Number();

    if (tel == null) {
      Toast.makeText(getApplicationContext(), "手机号码获取失败请自行进行设定", Toast.LENGTH_SHORT).show();
      return;
    } else
      for (int i = 0; i != tel.length(); i++)
        if (tel.charAt(i) == '*') {
          Toast.makeText(getApplicationContext(), "手机号码获取失败请自行进行设定", Toast.LENGTH_SHORT).show();
          return;
        }
    phoneNumber.setText(tel);
  }
  protected void dialogSave(final LedMatrixModel mtx) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(getResources().getString(R.string.save_confirm));
    // builder.

    editNameInDialog = new EditText(this);
    editNameInDialog.setSingleLine(true);
    editNameInDialog.setFocusable(true);
    editNameInDialog.setSelectAllOnFocus(true);
    editNameInDialog.setText(mtx.getName());

    builder.setView(editNameInDialog);

    builder.setPositiveButton(
        getString(R.string.ok).toUpperCase(),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            updateMatrixInfo(mtx);
            mtx.setName(editNameInDialog.getText().toString());

            if (mtx.getId() > 0) {
              mtxDAO.update(mtx);
              Log.v(TAG, "Updated: " + " " + currMatrix.toString());
            } else {
              long ret = mtxDAO.save(currMatrix);
              mtx.setId((int) ret);
              Log.v(TAG, "Saved: " + ret + " " + currMatrix.toString());
            }

            getActionBar().setTitle(getString(R.string.title_image) + ":" + currMatrix.getName());
          }
        });

    builder.setNegativeButton(
        getString(R.string.cancel).toUpperCase(),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        });
    builder.create().show();
  }
Exemplo n.º 20
0
  private void setUpNoteFromDatabase(Intent intent) {
    long id = intent.getLongExtra(EXTRA_NOTE_ID, 1);
    Log.d(TAG, "Got ID " + id + " from intent extra");

    note = noteProvider.getNote(id);
    Log.d(TAG, "Retrieved the following Note from the database: " + note.toString());

    if (note.getTitle().equals(PLACEHOLDER_TEXT_FOR_DATABASE)) {
      note.setTitle("");
    }
    if (note.getBody().equals(PLACEHOLDER_TEXT_FOR_DATABASE)) {
      note.setBody("");
    }

    titleEditText.setText(note.getTitle());
    bodyEditText.setText(note.getBody());

    noteExistsInDatabase = true;
  }
 @Override
 public void onExprItemClick(String exprInfo, boolean isDel) {
   SpannableString ss;
   int textSize = (int) editText.getTextSize();
   if (isDel) {
     HashMap<String, Integer> mExprFilenameIdData =
         XWExpressionManager.getInstance().getmExprInfoIdValuesCN(getActivity());
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(),
             XWExpressionUtil.deleteOneWord(editText.getText().toString(), mExprFilenameIdData),
             textSize);
   } else {
     String content = editText.getText() + exprInfo;
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(), content, textSize);
   }
   editText.setText(ss);
   editText.setSelection(ss.length());
 }
Exemplo n.º 22
0
 public void mOnClick(View v) {
   switch (v.getId()) {
     case R.id.test:
       String rootdir = Environment.getRootDirectory().getAbsolutePath();
       String datadir = Environment.getDataDirectory().getAbsolutePath();
       String cachedir = Environment.getDownloadCacheDirectory().getAbsolutePath();
       mEdit.setText(
           String.format(
               "ext = %s\nroot=%s\ndata=%s\ncache=%s", mSdPath, rootdir, datadir, cachedir));
       break;
     case R.id.save:
       File dir = new File(mSdPath + "/dir");
       dir.mkdir();
       File file = new File(mSdPath + "/dir/file.txt");
       try {
         FileOutputStream fos = new FileOutputStream(file);
         String str = "This file exists in SDcard";
         fos.write(str.getBytes());
         fos.close();
         mEdit.setText("write success");
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found." + e.getMessage());
       } catch (SecurityException e) {
         mEdit.setText("Security Exception");
       } catch (Exception e) {
         mEdit.setText(e.getMessage());
       }
       break;
     case R.id.load:
       try {
         FileInputStream fis = new FileInputStream(mSdPath + "/dir/file.txt");
         byte[] data = new byte[fis.available()];
         while (fis.read(data) != -1) {;
         }
         fis.close();
         mEdit.setText(new String(data));
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found");
       } catch (Exception e) {;
       }
       break;
   }
 }
Exemplo n.º 23
0
  @Override
  public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent);

    if ((actionId == EditorInfo.IME_ACTION_DONE)
        || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
      Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER");
      String input = textView.getText().toString().trim();

      if (input.length() > 0) {
        String result = "";

        try {
          result += calculator.calculate(input);
        } catch (Exception e) {
          result = "no result (" + e.getMessage() + ")";
        }

        if (listAdapter.getCount() > 0) {
          listAdapter.add("");
        }

        listAdapter.add(input + " =");
        if (input.indexOf("@") > -1) {
          listAdapter.add(calculator.getEquation() + " =");
        }
        listAdapter.add(result);
        listAdapter.notifyDataSetChanged();

        inputView.endBatchEdit();
        inputView.setText("");
        hideKeyboard();
      }
    }

    return false;
  }
Exemplo n.º 24
0
  public void sendMessage(View view) {
    EditText et = (EditText) findViewById(R.id.editText1);
    final String msg = et.getText().toString();
    et.setText("");
    new Thread(
            new Runnable() {
              public void run() {
                Socket sock = null;
                try {
                  sock = new Socket(ipAddr, sendPort);
                  Log.v(
                      TAG,
                      "send sock: "
                          + sock.getInetAddress().getHostAddress()
                          + sock.isConnected()
                          + Integer.toString(sock.getPort()));
                } catch (UnknownHostException e) {
                  Log.v(ERRORTAG, "" + e.getMessage());
                  e.printStackTrace();
                } catch (IOException e) {
                  Log.v(ERRORTAG, "" + e.getMessage());
                  e.printStackTrace();
                }

                try {
                  PrintWriter out = new PrintWriter(sock.getOutputStream(), true);
                  out.println(msg);
                  updateTextView("<font color=\"#800000\"> <b>Sent: </b></font>" + msg);
                } catch (IOException e) {
                  Log.v(ERRORTAG, "" + e.getMessage());
                  e.printStackTrace();
                }
              }
            })
        .start();
  }
Exemplo n.º 25
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.zip_picker);

    LoggerManager.setLoggerFactory(new AndroidLoggerFactory());

    logger = (AndroidLogger) LoggerManager.getLogger(this.getClass().getName());
    // enable toasts for info level logging.  toasts are default for error and warnings.
    logger.setToastContext(getBaseContext());
    logger.setInfoToastEnabled(true);

    Button createButton = (Button) findViewById(R.id.SignButton);
    createButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View view) {
            invokeZipSignerActivity();
          }
        });

    String extStorageDir = Environment.getExternalStorageDirectory().toString();
    // Strip /mnt from /sdcard
    if (extStorageDir.startsWith("/mnt/sdcard")) extStorageDir = extStorageDir.substring(4);

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String inputFile = prefs.getString(PREFERENCE_IN_FILE, extStorageDir + "/unsigned.zip");
    String outputFile = prefs.getString(PREFERENCE_OUT_FILE, extStorageDir + "/signed.zip");
    int keyIndex = prefs.getInt(PREFERENCE_KEY_INDEX, 0);

    EditText inputText = (EditText) findViewById(R.id.InFileEditText);
    inputText.setText(inputFile);

    EditText outputText = (EditText) findViewById(R.id.OutFileEditText);
    outputText.setText(outputFile);

    Button button = (Button) findViewById(R.id.OpenPickButton);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View arg0) {
            pickInputFile();
          }
        });

    button = (Button) findViewById(R.id.SaveAsPickButton);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View arg0) {
            pickOutputFile();
          }
        });

    button = (Button) findViewById(R.id.InOutPickButton);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View arg0) {
            pickInputOutputFiles();
          }
        });

    Spinner spinner = (Spinner) findViewById(R.id.KeyModeSpinner);
    keyModeSpinnerAdapter =
        KeyListSpinnerAdapter.createInstance(this, android.R.layout.simple_spinner_item);
    keyModeSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(keyModeSpinnerAdapter);
    if (keyIndex >= keyModeSpinnerAdapter.getCount()) keyIndex = 0;
    spinner.setSelection(keyIndex);
    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt(PREFERENCE_KEY_INDEX, position);
            editor.commit();
            updateAlgorithmSpinner(position);
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapter) {}
        });

    algorithmSpinner = (Spinner) findViewById(R.id.CertSignatureAlgorithm);
    sha1WithRsaSpinnerAdapter =
        ArrayAdapter.createFromResource(
            this, R.array.Sha1WithRsaAlgorithmArray, android.R.layout.simple_spinner_item);
    sha1WithRsaSpinnerAdapter.setDropDownViewResource(
        android.R.layout.simple_spinner_dropdown_item);
    allAlgorithmsSpinnerAdapter =
        ArrayAdapter.createFromResource(
            this, R.array.AllShaWithRsaAlgorithmsArray, android.R.layout.simple_spinner_item);
    allAlgorithmsSpinnerAdapter.setDropDownViewResource(
        android.R.layout.simple_spinner_dropdown_item);

    updateAlgorithmSpinner(keyIndex);

    algorithmSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
            if (algorithmSpinnerAdapter.getCount() > 1) {
              SharedPreferences.Editor editor = prefs.edit();
              editor.putInt(PREFERENCE_ALG_INDEX, position);
              editor.commit();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapter) {}
        });
  }
 public void handleEurosClick(View view) {
   EditText txt = (EditText) findViewById(R.id.editText1);
   double dollars = Double.parseDouble(txt.getText().toString());
   double euros = dollars / 1.27; // conversion here
   txt.setText(String.valueOf(euros));
 }
Exemplo n.º 27
0
  private String nameDialog(String dialogTitle, String nameTxt) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(this);
    final EditText nameInput = new EditText(this);
    final Long id2;
    //        String nameTxt;

    //        nameInput.setInputType(0x00080000 | 0x00000002);
    nameInput.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

    if (nameTxt == null) {
      nameTxt = "";
      nameInput.setHint("Enter filename");
    }

    nameInput.setText(nameTxt);
    alert.setTitle(dialogTitle);
    alert.setView(nameInput);

    alert.setPositiveButton(
        "Ok",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            String value = nameInput.getText().toString().trim();
            Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show();
            try {
              int x = mItem;
              boolean xb = (value != null);
              xb = !(value.equals(""));
              if ((value != null) && !(value.equals(""))) {
                fileNameIn = value;
                // getDir(sdcard);
                switch (mItem) {
                  case mCopy:
                    fileName = root + value; // TODO: Check for dir
                    cpDb(fileName);
                    finish();
                    break;
                  case mDelete:
                    deleteDatabase(CreateShopDatabase.DATABASE_NAME);

                    finish();
                    break;

                  case mExport:
                    fileName = selectFile + "/" + value + ".abb"; // TODO: Check for dir
                    cpDb(fileName);
                    finish();
                    break;
                }
                // do something with value
              }
            } catch (Exception ignored) {
            }
          }
        });

    alert.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
          }
        });
    alert.show();
    return nameTxt;
  }
 public void prePopulateEmail(String email) {
   EditText emailEditText = (EditText) findViewById(R.id.email);
   emailEditText.setText(email);
   this.email = email;
 }
Exemplo n.º 29
0
  @Override
  public void onClick(View v) {
    TextView txtManageLabel, txtBrowseLabel, txtRefreshLabel, txtSearchLabel;
    txtManageLabel = (TextView) findViewById(R.id.txt_manage_label);
    txtBrowseLabel = (TextView) findViewById(R.id.txt_browse_label);
    txtRefreshLabel = (TextView) findViewById(R.id.txt_refresh_label);
    txtSearchLabel = (TextView) findViewById(R.id.txt_search_label);
    txtSearch.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            new AsyncTask<String, Void, ArrayList<RssItem>>() {
              @Override
              protected ArrayList<RssItem> doInBackground(String... params) {
                return dbQuery.searchRssItem(params[0]);
              }

              @Override
              protected void onPostExecute(ArrayList<RssItem> result) {
                rssList.clear();
                rssList.addAll(result);
                rssAdapter.config().notifyDataSetChanged();
              }
            }.execute(s.toString());
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
    txtSearch.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) return true;
            return false;
          }
        });
    switch (v.getId()) {
      case R.id.btn_manage:
        startActivityForResult(
            new Intent(RssReaderActivity.this, RssManageActivity.class), REQ_RSS_MANAGE);
        break;

      case R.id.btn_browse:
        rssProvider = dbQuery.getRssProviderList(null);
        int length = rssProvider.getProviderNames().length;
        if (length == 0) break;

        String[] providers = new String[length + 1];
        providers[0] = "All";
        for (int i = 0; i < length; i++) providers[i + 1] = rssProvider.getProviderNames()[i];
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder
            .setTitle(R.string.rss_choose_provider)
            .setItems(
                providers,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int item) {
                    if (item == 0) {
                      loadData(null, true, false, false);
                      return;
                    }
                    loadData(rssProvider.getProviderNames()[item - 1], false, false, false);
                    curProvider = item - 1;
                    updateListView();
                  }
                });
        builder.create().show();
        break;

      case R.id.btn_refresh:
        if (curProvider == -1) loadData(null, true, true, true);
        else
          loadData(
              dbQuery.getRssProviderList(null).getProviderNames()[curProvider], false, true, true);
        break;

      case R.id.btn_search:
        if (txtSearchLabel.getText().toString().equals(getString(R.string.btn_search_text))) {
          btnManage.setVisibility(View.GONE);
          txtManageLabel.setVisibility(View.GONE);
          btnBrowse.setVisibility(View.GONE);
          txtBrowseLabel.setVisibility(View.GONE);
          btnRefresh.setVisibility(View.GONE);
          txtRefreshLabel.setVisibility(View.GONE);
          btnSearch.setBackgroundResource(R.drawable.btn_done_background);
          txtSearchLabel.setText(R.string.btn_done_text);
          txtSearch.setVisibility(View.VISIBLE);
          txtSearch.requestFocus();
        } else {
          btnManage.setVisibility(View.VISIBLE);
          txtManageLabel.setVisibility(View.VISIBLE);
          btnBrowse.setVisibility(View.VISIBLE);
          txtBrowseLabel.setVisibility(View.VISIBLE);
          btnRefresh.setVisibility(View.VISIBLE);
          txtRefreshLabel.setVisibility(View.VISIBLE);
          btnSearch.setBackgroundResource(R.drawable.btn_search_background);
          txtSearchLabel.setText(R.string.btn_search_text);
          txtSearch.setVisibility(View.GONE);
          txtSearch.setText("");
          loadData(null, true, false, false);
        }
        break;
      default:
        break;
    }
  }
Exemplo n.º 30
0
  private void promptForAddEdit(final MessageEntry messageEntry) {
    final boolean isEdit = messageEntry != null;
    String message = messageEntry == null ? "" : messageEntry.getMessage();

    final EditText text = new EditText(ExampleActivity.this);
    text.setText(message);
    String promptText = isEdit ? "Edit" : "Add";
    new AlertDialog.Builder(ExampleActivity.this)
        .setTitle(promptText + " a message")
        .setMessage(promptText + " text:")
        .setView(text)
        .setNeutralButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
              }
            })
        .setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(final DialogInterface dialogInterface, int i) {
                String value = text.getText().toString().trim();
                if (StringUtils.isNotEmpty(value)) {
                  new AsyncTask() {
                    @Override
                    protected Object doInBackground(Object... objects) {
                      try {
                        String messString = text.getText().toString();

                        MessageEntry localEntry = messageEntry;
                        if (localEntry == null) {
                          localEntry =
                              new MessageEntry(null, null, System.currentTimeMillis(), messString);
                        }
                        localEntry.setMessage(messString);
                        callUpdate(localEntry);
                      } catch (StorageException e) {
                        throw new RuntimeException(e);
                      }
                      return null;
                    }

                    @Override
                    protected void onPostExecute(Object o) {
                      dialogInterface.dismiss();
                    }
                  }.execute();
                }
              }
            })
        .setNegativeButton(
            "Delete",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {
                new AsyncTask() {
                  @Override
                  protected Object doInBackground(Object... objects) {

                    try {

                      MessageEntry localEntry = messageEntry;

                      localEntry.setPosted(-1l);

                      callUpdate(localEntry);

                    } catch (StorageException e) {
                      e.printStackTrace(); // To change body of catch statement use File |
                      // Settings | File Templates.
                    }
                    return null;
                  }
                }.execute();
              }
            })
        .show();
  }