コード例 #1
0
 @Override
 protected void onResume() {
   super.onResume();
   Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
   Application.getInstance().addUIListener(OnContactChangedListener.class, this);
   update();
 }
コード例 #2
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.send:
       String question = showQuestion ? questionView.getText().toString() : null;
       String answer = ((TextView) findViewById(R.id.answer)).getText().toString();
       try {
         if (answerRequest) OTRManager.getInstance().respondSmp(account, user, question, answer);
         else OTRManager.getInstance().initSmp(account, user, question, answer);
       } catch (NetworkException e) {
         Application.getInstance().onError(e);
       }
       finish();
       break;
     case R.id.cancel:
       try {
         OTRManager.getInstance().abortSmp(account, user);
       } catch (NetworkException e) {
         Application.getInstance().onError(e);
       }
       finish();
     default:
       break;
   }
 }
コード例 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFinishing()) return;

    Intent intent = getIntent();
    account = QuestionViewer.getAccount(intent);
    user = QuestionViewer.getUser(intent);
    if (AccountManager.getInstance().getAccount(account) == null || user == null) {
      Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
      finish();
      return;
    }
    if (intent.getBooleanExtra(EXTRA_FIELD_CANCEL, false)) {
      try {
        OTRManager.getInstance().abortSmp(account, user);
      } catch (NetworkException e) {
        Application.getInstance().onError(e);
      }
      finish();
      return;
    }
    showQuestion = intent.getBooleanExtra(EXTRA_FIELD_SHOW_QUESTION, true);
    answerRequest = intent.getBooleanExtra(EXTRA_FIELD_ANSWER_REQUEST, false);
    if (showQuestion) {
      setContentView(R.layout.question_viewer);
      questionView = (EditText) findViewById(R.id.question);
      questionView.setEnabled(!answerRequest);
      if (answerRequest) questionView.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
      else findViewById(R.id.cancel).setVisibility(View.GONE);
    } else setContentView(R.layout.secret_viewer);
    findViewById(R.id.cancel).setOnClickListener(this);
    findViewById(R.id.send).setOnClickListener(this);
  }
コード例 #4
0
 public String getGroupName(String account, String group) {
   if (group == GroupManager.NO_GROUP)
     return Application.getInstance().getString(R.string.group_none);
   else if (group == GroupManager.IS_ROOM)
     return Application.getInstance().getString(R.string.group_room);
   else if (group == GroupManager.IS_ROOM_ROOM)
     return Application.getInstance().getString(R.string.group_room_room);
   else if (group == GroupManager.ACTIVE_CHATS)
     return Application.getInstance().getString(R.string.group_active_chat);
   else if (group == GroupManager.IS_ACCOUNT)
     return AccountManager.getInstance().getVerboseName(account);
   return group;
 }
コード例 #5
0
 @Override
 public void onLoad() {
   final NestedMap<GroupConfiguration> groupConfigurations = new NestedMap<GroupConfiguration>();
   Cursor cursor = GroupTable.getInstance().list();
   try {
     if (cursor.moveToFirst()) {
       do {
         GroupConfiguration rosterConfiguration = new GroupConfiguration();
         rosterConfiguration.setExpanded(GroupTable.isExpanded(cursor));
         rosterConfiguration.setShowOfflineMode(GroupTable.getShowOfflineMode(cursor));
         groupConfigurations.put(
             GroupTable.getAccount(cursor), GroupTable.getGroup(cursor), rosterConfiguration);
       } while (cursor.moveToNext());
     }
   } finally {
     cursor.close();
   }
   Application.getInstance()
       .runOnUiThread(
           new Runnable() {
             @Override
             public void run() {
               onLoaded(groupConfigurations);
             }
           });
 }
コード例 #6
0
 private void requestToWriteGroup(
     final String account,
     final String group,
     final boolean expanded,
     final ShowOfflineMode showOfflineMode) {
   Application.getInstance()
       .runInBackground(
           new Runnable() {
             @Override
             public void run() {
               GroupTable.getInstance().write(account, group, expanded, showOfflineMode);
             }
           });
 }
コード例 #7
0
 @Override
 protected void onPause() {
   super.onPause();
   Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
   Application.getInstance().removeUIListener(OnContactChangedListener.class, this);
 }
コード例 #8
0
 static {
   instance = new GroupManager();
   Application.getInstance().addManager(instance);
 }