Esempio n. 1
0
 @Override
 public void onBackPressed() {
   // Check if we're not the default SMS app
   if (!Utils.isDefaultSmsApp(this)) {
     // Ask to become the default SMS app
     new DefaultSmsHelper(this, R.string.not_default_send)
         .showIfNotDefault((ViewGroup) getWindow().getDecorView().getRootView());
   } else if (mComposeFragment != null
       && !mComposeFragment.isReplyTextEmpty()
       && mComposeFragment.getRecipientAddresses().length == 0) {
     // If there is Draft message and no recipients are set
     new QKDialog()
         .setContext(this)
         .setMessage(R.string.discard_message_reason)
         .setPositiveButton(
             R.string.yes,
             v -> {
               super.onBackPressed();
             })
         .setNegativeButton(R.string.cancel, null)
         .show();
   } else {
     super.onBackPressed();
   }
 }
Esempio n. 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.title_compose);

    FragmentManager fm = getFragmentManager();
    mComposeFragment = (ComposeFragment) fm.findFragmentByTag(ComposeFragment.TAG);
    if (mComposeFragment == null) {
      mComposeFragment = new ComposeFragment();
    }

    fm.beginTransaction()
        .replace(R.id.content_frame, mComposeFragment, ComposeFragment.TAG)
        .commit();
  }