@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       return tabManager.onAndroidHome(item);
     case R.id.menu_login:
       Intent intent = new Intent(this, ConnectionAssistantActivity.class);
       lastTab = tabManager.getCurrentTab();
       //				tabManager.switchToTab(RallyeTabManager.TAB_WAIT_FOR_MODEL);
       startActivityForResult(intent, ConnectionAssistantActivity.REQUEST_CODE);
       break;
     case R.id.menu_logout:
       new AlertDialog.Builder(this)
           .setTitle(R.string.logout)
           .setMessage(R.string.are_you_sure)
           .setCancelable(true)
           .setNegativeButton(android.R.string.cancel, null)
           .setPositiveButton(
               android.R.string.ok,
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   server.logout();
                 }
               })
           .create()
           .show();
       server.tryLogout();
       break;
     case R.id.menu_upload_overview:
       intent = new Intent(this, UploadOverviewActivity.class);
       startActivity(intent);
       break;
     case R.id.menu_share_barcode:
       IntentIntegrator zx = new IntentIntegrator(this);
       ObjectMapper mapper = Serialization.getJsonInstance();
       try {
         zx.shareText(mapper.writeValueAsString(server.exportLogin()));
       } catch (JsonProcessingException e) {
         Log.e(THIS, "Could not serialize exported Login", e);
         Toast.makeText(this, R.string.export_barcode_error, Toast.LENGTH_SHORT).show();
       }
       break;
       //			case R.id.menu_reconnect: //there is no more temporary offline, we cannot know if push
       // messages will reach us
       //				model.reconnect();
       //				break;
     case R.id.menu_settings:
       intent = new Intent(this, SettingsActivity.class);
       startActivity(intent);
       break;
     default:
       return false;
   }
   return true;
 }
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ii = new IntentIntegrator(this);

    Bundle content = getIntent().getExtras();
    if (content != null) {
      String user = content.getString(LoginReferences.USERNAME),
          pass = content.getString(LoginReferences.PASSWORD);
      // TODO create format login
      ii.shareText(user + "\n" + pass);
    }
    finish();
  }
 /**
  * See {@link #shareText(Activity, CharSequence, CharSequence, CharSequence, CharSequence,
  * CharSequence)} -- same, but takes string IDs which refer to the {@link Activity}'s resource
  * bundle entries.
  */
 public static void shareText(
     Activity activity,
     CharSequence text,
     int stringTitle,
     int stringMessage,
     int stringButtonYes,
     int stringButtonNo) {
   shareText(
       activity,
       text,
       activity.getString(stringTitle),
       activity.getString(stringMessage),
       activity.getString(stringButtonYes),
       activity.getString(stringButtonNo));
 }
Exemplo n.º 4
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.scan:
       wrapInstallDialog(integrator.initiateScan(IntentIntegrator.QR_CODE_TYPES));
       break;
     case R.id.show:
       wrapInstallDialog(integrator.shareText(localFingerprint));
       break;
     case R.id.copy:
       ((ClipboardManager) getSystemService(CLIPBOARD_SERVICE))
           .setText(((TextView) findViewById(R.id.otr_local_fingerprint)).getText());
       break;
     default:
       break;
   }
 }
 /**
  * See {@link #shareText(Activity, CharSequence, CharSequence, CharSequence, CharSequence,
  * CharSequence)} -- same, but uses default English labels.
  */
 public static void shareText(Activity activity, CharSequence text) {
   shareText(activity, text, DEFAULT_TITLE, DEFAULT_MESSAGE, DEFAULT_YES, DEFAULT_NO);
 }