Ejemplo n.º 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.action_switch_view_mode:
        mWeekMode = !mWeekMode;
        if (mWeekMode) {
          menuItemSwitchView.setIcon(R.drawable.ic_action_day_view);
        } else {
          menuItemSwitchView.setIcon(R.drawable.ic_action_week_view);
        }
        attachSectionPagerAdapter();
        return true;
      case R.id.action_export_calendar:
        detachSectionPagerAdapter();
        exportCalendarToGoogle();

        // Enable automatic calendar synchronisation
        Utils.setInternalSetting(this, Const.SYNC_CALENDAR, true);
        supportInvalidateOptionsMenu();
        return true;
      case R.id.action_delete_calendar:
        deleteCalendarFromGoogle();
        return true;
      default:
        detachSectionPagerAdapter();
        isFetched = false;
        return super.onOptionsItemSelected(item);
    }
  }
 @Override
 protected void onLoadFinished(Boolean result) {
   if (result) {
     startNextActivity();
   } else {
     showLoadingEnded();
     Utils.showToast(this, R.string.key_not_activated);
   }
 }
  @Override
  protected Boolean onLoadInBackground(Void... arg) {
    ChatRoomManager manager = new ChatRoomManager(this);

    // Get member and private key from settings
    ChatMember member = Utils.getSetting(this, Const.CHAT_MEMBER, ChatMember.class);
    PrivateKey privateKey = Utils.getPrivateKeyFromSharedPrefs(this);
    if (privateKey == null || member == null) return false;

    // Try to restore already joined chat rooms from server
    try {
      List<ChatRoom> rooms =
          TUMCabeClient.getInstance(this)
              .getMemberRooms(member.getId(), new ChatVerification(privateKey, member));
      manager.replaceIntoRooms(rooms);
      return true;
    } catch (RetrofitError e) {
      Utils.log(e);
      return false;
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    disableRefresh();

    TextView status = (TextView) findViewById(R.id.tvSucc);
    ChatMember member = Utils.getSetting(this, Const.CHAT_MEMBER, ChatMember.class);
    status.setText(String.format(getString(R.string.public_key_mail), member.getLrzId()));

    // If called because app version changed remove "Step 4" and close on back pressed
    Intent i = getIntent();
    if (i != null && i.hasExtra(Const.TOKEN_IS_SETUP)) {
      tokenSetup = i.getBooleanExtra(Const.TOKEN_IS_SETUP, false);
    }
  }
Ejemplo n.º 5
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    // the Calendar export is not supported for API < 14
    if (android.os.Build.VERSION.SDK_INT < 14) {
      menuItemExportGoogle.setVisible(false);
      menuItemDeleteCalendar.setVisible(false);
    } else {
      menuItemExportGoogle = menu.findItem(R.id.action_export_calendar);
      menuItemDeleteCalendar = menu.findItem(R.id.action_delete_calendar);
      menuItemExportGoogle.setEnabled(isFetched);
      menuItemDeleteCalendar.setEnabled(isFetched);

      boolean bed = Utils.getInternalSettingBool(this, Const.SYNC_CALENDAR, false);
      menuItemExportGoogle.setVisible(!bed);
      menuItemDeleteCalendar.setVisible(bed);
    }
    return super.onPrepareOptionsMenu(menu);
  }