Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.time_dialog);
    etxtTime = (EditText) findViewById(R.id.etxtTime);
    spTimeUnit = (Spinner) findViewById(R.id.spTimeUnit);
    butConfirm = (Button) findViewById(R.id.butConfirm);
    butCancel = (Button) findViewById(R.id.butCancel);

    butConfirm.setText(R.string.set_sleeptimer_label);
    butCancel.setText(R.string.cancel_label);
    setTitle(R.string.set_sleeptimer_label);
    ArrayAdapter<String> spinnerAdapter =
        new ArrayAdapter<String>(
            this.getContext(), android.R.layout.simple_spinner_item, spinnerContent);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spTimeUnit.setAdapter(spinnerAdapter);
    spTimeUnit.setSelection(DEFAULT_SPINNER_POSITION);
    butCancel.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            dismiss();
          }
        });
    butConfirm.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            try {
              long input = readTimeMillis();
              onTimeEntered(input);
              dismiss();
            } catch (NumberFormatException e) {
              e.printStackTrace();
              Toast toast =
                  Toast.makeText(context, R.string.time_dialog_invalid_input, Toast.LENGTH_LONG);
              toast.show();
            }
          }
        });
    etxtTime.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void afterTextChanged(Editable s) {
            checkInputLength(s.length());
          }

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

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}
        });
    checkInputLength(etxtTime.getText().length());
  }
Esempio n. 2
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());
  }
Esempio n. 3
0
  @Override
  public void onCreate(Context ctx) {

    LinearLayout linearLayout = new LinearLayout(ctx);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    // beds
    Spinner spinnerTextField = new Spinner(ctx);
    ArrayAdapter<Integer> aa =
        new ArrayAdapter<Integer>(
            ctx, android.R.layout.simple_spinner_item, new Integer[] {1, 2, 3});
    aa.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
    spinnerTextField.setAdapter(aa);
    spinnerTextField.setOnItemSelectedListener(bedCountSpinnerItemSelectionListener);

    // options
    TableLayout amenitiesLayout = new TableLayout(ctx);
    amenitiesLayout.setColumnStretchable(0, false);
    amenitiesLayout.setColumnShrinkable(1, true);
    Amenity[] ams = Amenity.values();
    for (Amenity amenity : ams) {
      TableRow tableRow = buildAmenityTableRow(ctx, amenity);
      amenitiesLayout.addView(tableRow);
    }

    linearLayout.addView(
        Utils.buildLabelAndField(ctx, ctx.getString(R.string.beds_label), spinnerTextField));
    linearLayout.addView(
        Utils.buildLabelAndField(ctx, ctx.getString(R.string.amenities_label), amenitiesLayout));

    addView(linearLayout);
  }
Esempio n. 4
0
  private void setUpSpinnerAdapters() {
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.currencies, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    currency1Spinner.setAdapter(adapter);
    currency2Spinner.setAdapter(adapter);
    currency2Spinner.setSelection(1);
  }
  private void setupSpinner(Spinner spinner, int optionResourceId, int defaultSelection) {
    Context context = getContext();
    if (context != null) {
      ArrayAdapter<CharSequence> adapter =
          ArrayAdapter.createFromResource(
              context, optionResourceId, android.R.layout.simple_spinner_item);

      adapter.setDropDownViewResource(R.layout.spinner_centered_wrapped);
      spinner.setGravity(Gravity.CENTER);
      spinner.setAdapter(adapter);
      spinner.setSelection(defaultSelection);
    }
  }
  @Override
  public void onStart() {
    super.onStart();
    if (D) Log.d(TAG, "++ ON START ++");

    if (!mBluetoothAdapter.isEnabled()) {
      // ask the user to enable BlueTooth
      Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
      startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
    } else {
      // this only works if you already bonded with this device
      if (D) Log.d(TAG, "BT already enabled");

      final BluetoothDevice[] bondedDevices =
          new BluetoothDevice[mBluetoothAdapter.getBondedDevices().size()];
      mBluetoothAdapter.getBondedDevices().toArray(bondedDevices);

      List<CharSequence> devices = new ArrayList<CharSequence>();

      // update the "Select device" spinner
      for (BluetoothDevice btd : bondedDevices) {
        Log.d(TAG, "Found bonded device: " + btd.getName());
        devices.add(btd.getName());
      }

      ArrayAdapter spinnerAdapter =
          new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, devices);
      spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

      Spinner selectDeviceSpinner = (Spinner) findViewById(R.id.spinner);
      selectDeviceSpinner.setAdapter(spinnerAdapter);

      selectDeviceSpinner.setOnItemSelectedListener(
          new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
              if (D) Log.d(TAG, "Selected: " + bondedDevices[pos].getName());
              btDevice = bondedDevices[pos];
            }

            public void onNothingSelected(AdapterView<?> arg0) {}
          });
    }
  }
  protected void initVideoSpinners() {
    ArrayAdapter<CharSequence> adapter;

    // Video parameters spinners
    frameSizeSpinner = (Spinner) findViewById(R.id.frameSize_spinner);
    adapter =
        ArrayAdapter.createFromResource(
            this, R.array.frame_size_values, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    frameSizeSpinner.setAdapter(adapter);
    frameSizeSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            String[] frameSizeContainer =
                frameSizeSpinner.getSelectedItem().toString().split("x", 2);
            videoWidthOut = Integer.valueOf(frameSizeContainer[0].trim());
            videoHeightOut = Integer.valueOf(frameSizeContainer[1].trim());
          }

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

    videoBitRateSpinner = (Spinner) findViewById(R.id.videoBitRate_spinner);
    adapter =
        ArrayAdapter.createFromResource(
            this, R.array.video_bit_rate_values, android.R.layout.simple_spinner_item);
    videoBitRateSpinner.setAdapter(adapter);
    videoBitRateSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            videoBitRateInKBytes =
                Integer.valueOf(videoBitRateSpinner.getSelectedItem().toString());
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.masstab);

    spinnerFrom = (Spinner) findViewById(R.id.SpinnerFrom);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.weights, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerFrom.setAdapter(adapter);

    spinnerTo = (Spinner) findViewById(R.id.SpinnerTo);
    spinnerTo.setAdapter(adapter);

    final Button button = (Button) findViewById(R.id.Go_Button);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            calculate();
          }
        });
  }
Esempio n. 9
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceBundle) {
    Bundle args = getArguments();

    // If position == 0 then Owe, if == 1 then Owed
    position = args.getInt("pos");

    View v;
    v = inflater.inflate(R.layout.iou_info_edit_frag, container, false);

    // Find Views by id
    confirm = (Button) v.findViewById(R.id.iou_editconfirm);
    cancel = (Button) v.findViewById(R.id.iou_deletecancel);
    close = (ImageButton) v.findViewById(R.id.owe_done_button);
    date = (TextView) v.findViewById(R.id.owe_info_date);
    name = (TextView) v.findViewById(R.id.owe_dialog_name);
    amount = (TextView) v.findViewById(R.id.owe_dialog_amount);
    desc = (TextView) v.findViewById(R.id.owe_description);
    spinner = (Spinner) v.findViewById(R.id.add_subt_spinner);
    editBox = (LinearLayout) v.findViewById(R.id.edit_layout);

    // Set up Spinner Values
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            getActivity(), R.array.add_subt_array, R.layout.spinner_item);
    adapter.setDropDownViewResource(R.layout.spinner_dropdown);

    spinner.setAdapter(adapter);

    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0) {
              add = true;
            } else {
              add = false;
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });

    // Set the TextViews
    name.setText(args.getString("name"));
    amount.setText(String.valueOf(args.getDouble("amount")));
    if (args.getString("desc").length() != 0) {
      desc.setText(args.getString("desc"));
    } else {
      desc.setText("None");
    }
    date.setText(args.getString("date"));

    confirm.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            editBox.setVisibility(View.VISIBLE);
          }
        });

    return v;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_edit_automation);

    mUri = null;
    mDescriptionShoppingList = "?";

    mSpinnerAction = (Spinner) findViewById(R.id.spinner_action);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.automation_actions, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinnerAction.setAdapter(adapter);

    mSpinnerAction.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mDescriptionAction =
                getResources().getStringArray(R.array.automation_actions)[position];

            updateTextViews();
          }

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

    mButtonCountdown = (Button) findViewById(R.id.button_list);
    mButtonCountdown.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            pickList();
          }
        });

    mButtonOk = (Button) findViewById(R.id.button_ok);
    mButtonOk.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            doOk();
          }
        });

    mButtonOk.setEnabled(false);

    Button b = (Button) findViewById(R.id.button_cancel);
    b.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            doCancel();
          }
        });

    mTextCommand = (TextView) findViewById(R.id.command);
    // mTextSelectAction = (TextView) findViewById(R.id.select_action);
    // mTextSelectCountdown = (TextView)
    // findViewById(R.id.select_countdown);

    if (savedInstanceState != null) {
      if (savedInstanceState.containsKey(BUNDLE_ACTION)) {
        int i = savedInstanceState.getInt(BUNDLE_ACTION);
        mSpinnerAction.setSelection(i);
      }
      if (savedInstanceState.containsKey(BUNDLE_LIST_URI)) {
        mUri = Uri.parse(savedInstanceState.getString(BUNDLE_LIST_URI));
        setListNameFromUri();
      }
    } else {
      final Intent intent = getIntent();

      if (intent != null) {
        String action = intent.getStringExtra(ShoppingListIntents.EXTRA_ACTION);

        if (ShoppingListIntents.TASK_CLEAN_UP_LIST.equals(action)) {
          mSpinnerAction.setSelection(0);
        } else {
          // set default
          mSpinnerAction.setSelection(0);
        }

        // Get list:

        final String dataString = intent.getStringExtra(ShoppingListIntents.EXTRA_DATA);
        if (dataString != null) {
          mUri = Uri.parse(dataString);
        }
        setListNameFromUri();
      }
    }

    updateTextViews();
  }
  /** 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) {}
        });
  }
Esempio n. 12
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    data = new SectorDataSource(this);
    data.open();

    // Get the spinners to use later
    Spinner systemList = (Spinner) findViewById(R.id.systemList);
    Spinner gridAplhaList = (Spinner) findViewById(R.id.gridAlphaList);
    Spinner gridNumList = (Spinner) findViewById(R.id.gridNumList);

    // Make sure we can update the information when something is selected
    systemList.setOnItemSelectedListener(this);
    gridAplhaList.setOnItemSelectedListener(this);
    gridNumList.setOnItemSelectedListener(this);

    // Load up the last selected sector
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);

    // Pasted code begins here

    // Set up all the spinners. One for the system and another two for the coords. I hate how messy
    // this is
    ArrayAdapter<String> systemAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Static.systemList);
    systemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    systemList.setAdapter(systemAdapter);

    // Load the letter selection
    ArrayAdapter<String> gridAlphaAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Static.alphaCoordList);
    gridAlphaAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    gridAplhaList.setAdapter(gridAlphaAdapter);

    // And finally load the number selector
    ArrayAdapter<String> gridNumAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Static.numCoordList);
    gridNumAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    gridNumList.setAdapter(gridNumAdapter);

    // GOGO super uber messy nested method calls and casts!
    systemList.setSelection(
        ((ArrayAdapter<String>) systemList.getAdapter())
            .getPosition(settings.getString(PREF_LAST_SYSTEM, "")));
    gridAplhaList.setSelection(
        ((ArrayAdapter<String>) gridAplhaList.getAdapter())
            .getPosition(settings.getString(PREF_LAST_SECTOR_APLHA, "")));
    gridNumList.setSelection(
        ((ArrayAdapter<String>) gridNumList.getAdapter())
            .getPosition(settings.getString(PREF_LAST_SECTOR_NUM, "")));

    // Add a listener to the add button
    ((Button) findViewById(R.id.button_add_mineral)).setOnClickListener(this);

    // Add the listener to the mineral list
    ((ListView) findViewById(R.id.oreList)).setOnItemClickListener(this);

    // Add the assigned minerals to the list
    Spinner oreSpinner = (Spinner) findViewById(R.id.mineralList);
    // Set up the list
    mineralList = new ArrayList<String>(Static.mineralList);
    // Add it all in
    mineralAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mineralList);
    mineralAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    oreSpinner.setAdapter(mineralAdapter);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.certify_key_activity);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setHomeButtonEnabled(false);

    mSelectKeyFragment =
        (SelectSecretKeyLayoutFragment)
            getSupportFragmentManager().findFragmentById(R.id.sign_key_select_key_fragment);
    mSelectKeyFragment.setCallback(this);
    mSelectKeyFragment.setFilterCertify(true);

    mSelectKeyserverSpinner = (Spinner) findViewById(R.id.sign_key_keyserver);
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            this,
            android.R.layout.simple_spinner_item,
            Preferences.getPreferences(this).getKeyServers());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSelectKeyserverSpinner.setAdapter(adapter);

    mUploadKeyCheckbox = (CheckBox) findViewById(R.id.sign_key_upload_checkbox);
    if (!mUploadKeyCheckbox.isChecked()) {
      mSelectKeyserverSpinner.setEnabled(false);
    } else {
      mSelectKeyserverSpinner.setEnabled(true);
    }

    mUploadKeyCheckbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
              mSelectKeyserverSpinner.setEnabled(false);
            } else {
              mSelectKeyserverSpinner.setEnabled(true);
            }
          }
        });

    mSignButton = (BootstrapButton) findViewById(R.id.sign_key_sign_button);
    mSignButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (mPubKeyId != 0) {
              if (mMasterKeyId == 0) {
                mSelectKeyFragment.setError(getString(R.string.select_key_to_sign));
              } else {
                initiateSigning();
              }
            }
          }
        });

    mDataUri = getIntent().getData();
    if (mDataUri == null) {
      Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!");
      finish();
      return;
    }

    PGPPublicKeyRing signKey = (PGPPublicKeyRing) ProviderHelper.getPGPKeyRing(this, mDataUri);

    if (signKey != null) {
      mPubKeyId = PgpKeyHelper.getMasterKey(signKey).getKeyID();
      drawPublicKey();
    }
    if (mPubKeyId == 0) {
      Log.e(Constants.TAG, "this shouldn't happen. KeyId == 0!");
      finish();
      return;
    }
  }
Esempio n. 14
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    app = (App) getApplication();

    setContentView(R.layout.inbox);

    final String[] inboxTypeClasses =
        new String[] {
          "org.envaya.sms.ui.MessagingSmsInbox",
          "org.envaya.sms.ui.MessagingMmsInbox",
          "org.envaya.sms.ui.MessagingSentSms",
        };

    final String[] inboxTypeNames = new String[] {"SMS Inbox", "MMS Inbox", "Sent SMS"};

    Spinner spinner = (Spinner) findViewById(R.id.inbox_selector);

    ArrayAdapter<String> inboxTypeAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, inboxTypeNames);
    inboxTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(inboxTypeAdapter);

    final String className = this.getClass().getCanonicalName();
    int classIndex = Arrays.asList(inboxTypeClasses).indexOf(className);
    if (classIndex != -1) {
      spinner.setSelection(classIndex);
    }

    spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            String cls = inboxTypeClasses[pos];

            if (!className.equals(cls)) {
              try {
                finish();
                startActivity(new Intent(app, Class.forName(cls)));
              } catch (ClassNotFoundException ex) {
                app.logError(ex);
              }
            }
          }

          public void onNothingSelected(AdapterView parent) {}
        });

    initListAdapter();

    ListView listView = getListView();

    listView.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final IncomingMessage message = getMessageAtPosition(position);

            final CharSequence[] options = {"Forward to server", "Cancel"};

            new AlertDialog.Builder(MessagingForwarder.this)
                .setTitle(message.getDescription())
                .setItems(
                    options,
                    new OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                        if (which == 0) {
                          app.inbox.forwardMessage(message);
                          showToast("Forwarding " + message.getDescription() + " to server");
                        }
                        dialog.dismiss();
                      }
                    })
                .show();
          }
        });
  }