Exemplo n.º 1
0
  private void attachFromCamera() {

    AnalyticsManager.getInstance()
        .sendEvent(
            AnalyticsManager.CATEGORY_MESSAGES, AnalyticsManager.ACTION_ATTACH_FROM_CAMERA, mLabel);

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (cameraIntent.resolveActivity(mContext.getPackageManager()) != null) {

      File file = null;
      try {
        file = createImageFile();
      } catch (IOException e) {
        e.printStackTrace();
      }

      if (file != null) {
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
        mActivityLauncher.startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA);
      }
    } else {
      // Send a toast saying there was a camera error
      if (mContext != null) {
        String message = mContext.getResources().getString(R.string.attachment_camera_error);
        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
      }
    }
  }
Exemplo n.º 2
0
 @Override
 protected void onPause() {
   super.onPause();
   sThreadShowing = 0;
   if (!mSlidingMenu.isMenuShowing()) {
     mContent.onContentClosed();
   }
 }
Exemplo n.º 3
0
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    FragmentManager m = getFragmentManager();

    // Save whether or not the mms setup fragment was dismissed
    if (m.findFragmentByTag(MMSSetupFragment.TAG) == null) {
      outState.putBoolean(KEY_MMS_SETUP_FRAGMENT_DISMISSED, true);
    }
  }
Exemplo n.º 4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    launchWelcomeActivity();

    setContentView(R.layout.activity_main);
    setTitle(R.string.title_conversation_list);
    ButterKnife.bind(this);

    setSlidingTabEnabled(mPrefs.getBoolean(SettingsFragment.SLIDING_TAB, false));
    mSlidingMenu.setListener(this);
    mSlidingMenu.setContent();
    mSlidingMenu.setMenu();
    mSlidingMenu.showContent(false);
    mSlidingMenu.showMenu(false);

    FragmentManager fm = getFragmentManager();

    mConversationList = (ConversationListFragment) fm.findFragmentById(R.id.menu_frame);
    if (mConversationList == null) {
      mConversationList = new ConversationListFragment();
    }
    mConversationList = new ConversationListFragment();
    FragmentTransaction menuTransaction = fm.beginTransaction();
    menuTransaction.replace(R.id.menu_frame, mConversationList);
    menuTransaction.commit();

    mContent = (ContentFragment) fm.findFragmentById(R.id.content_frame);
    if (mContent == null) {
      mContent = ComposeFragment.getInstance(null);
    }
    FragmentTransaction contentTransaction = fm.beginTransaction();
    contentTransaction.replace(R.id.content_frame, (Fragment) mContent);
    contentTransaction.commit();

    onNewIntent(getIntent());
    showDialogIfNeeded(savedInstanceState);

    LiveViewManager.registerView(
        QKPreference.BACKGROUND,
        this,
        key -> {
          // Update the background color. This code is important during the welcome screen setup,
          // when the activity
          // in the ThemeManager isn't the MainActivity
          mRoot.setBackgroundColor(ThemeManager.getBackgroundColor());
        });

    // Adds a small/non intrusive snackbar that asks the user to rate the app
    SnackEngage.from(this)
        .withSnack(new QKRateSnack().withDuration(BaseSnack.DURATION_LONG))
        .build()
        .engageWhenAppropriate();
  }
Exemplo n.º 5
0
  public ComposeView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mContext = (QKActivity) context;
    mPrefs = mContext.getPrefs();
    mRes = mContext.getResources();

    mDelayedMessagingEnabled = mPrefs.getBoolean(SettingsFragment.DELAYED, false);
    try {
      mDelayDuration = Integer.parseInt(mPrefs.getString(SettingsFragment.DELAY_DURATION, "3"));
      if (mDelayDuration < 1) {
        mDelayDuration = 1;
      } else if (mDelayDuration > 30) {
        mDelayDuration = 30;
      }
      mDelayDuration *= 1000;
    } catch (Exception e) {
      mDelayDuration = 3000;
    }
  }
Exemplo n.º 6
0
 @Override
 protected void onStart() {
   super.onStart();
   // Only mark screen if the screen is on. onStart() is still called if the app is in the
   // foreground and the screen is off
   // TODO this solution doesn't work if the activity is in the foreground but the lockscreen is on
   if (isScreenOn()) {
     SmsHelper.markSmsSeen(this);
     SmsHelper.markMmsSeen(this);
     NotificationManager.update(this);
   }
 }
Exemplo n.º 7
0
  @Override
  protected void onResume() {
    super.onResume();

    if (!mSlidingMenu.isMenuShowing()) {
      mContent.onContentOpened();
    }

    if (mContent != null && mContent instanceof MessageListFragment) {
      sThreadShowing = ((MessageListFragment) mContent).getThreadId();
      QKReplyActivity.dismiss(sThreadShowing);
    } else {
      sThreadShowing = 0;
    }

    NotificationManager.initQuickCompose(this, false, false);
  }
Exemplo n.º 8
0
  private void chooseAttachmentFromGallery() {

    AnalyticsManager.getInstance()
        .sendEvent(
            AnalyticsManager.CATEGORY_MESSAGES, AnalyticsManager.ACTION_ATTACH_IMAGE, mLabel);

    try {
      Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
      photoPickerIntent.setType("image/*");
      mActivityLauncher.startActivityForResult(photoPickerIntent, REQUEST_CODE_IMAGE);
    } catch (ActivityNotFoundException e) {
      // Send a toast saying no picture apps
      if (mContext != null) {
        String message = mContext.getResources().getString(R.string.attachment_app_not_found);
        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
      }
    }
  }
Exemplo n.º 9
0
 public void setComposeScreenViews(AutoCompleteContactView recipients, ComposeView composeView) {
   mRecipients = recipients;
   mComposeView = composeView;
   ((QKActivity) mContext).getLoaderManager().initLoader(0, null, this);
 }
Exemplo n.º 10
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   mIsDestroyed = true;
   DonationManager.getInstance(this).destroy();
 }
  @Override
  public void onItemLongClick(final Conversation conversation, View view) {
    if (mAdapter.isInMultiSelectMode()) {
      mAdapter.toggleSelection(conversation.getThreadId());
      return;
    }

    final long threadId = conversation.getThreadId();
    final String name = conversation.getRecipients().formatNames(", ");

    final ConversationPrefsHelper conversationPrefs =
        new ConversationPrefsHelper(mContext, threadId);
    final boolean muted = !conversationPrefs.getNotificationsEnabled();

    final QKDialog dialog = new QKDialog().setContext(mContext).setTitle(name);

    if (!mAdapter.isInMultiSelectMode()) {
      dialog.addMenuItem(R.string.menu_multi_select, MENU_MULTI_SELECT);
    }

    if (muted) {
      dialog.addMenuItem(R.string.menu_unmute_conversation, MENU_UNMUTE_CONVERSATION);
    } else {
      dialog.addMenuItem(R.string.menu_mute_conversation, MENU_MUTE_CONVERSATION);
    }

    if (conversation.hasUnreadMessages()) {
      dialog.addMenuItem(R.string.menu_mark_read, MENU_MARK_READ);
    } else {
      dialog.addMenuItem(R.string.menu_mark_unread, MENU_MARK_UNREAD);
    }

    dialog.addMenuItem(R.string.menu_notification_settings, MENU_NOTIFICATION_SETTINGS);
    dialog.addMenuItem(R.string.menu_view_details, MENU_VIEW_DETAILS);

    if (conversation.hasError()) {
      dialog.addMenuItem(R.string.delete_all_failed, MENU_DELETE_FAILED);
    }

    dialog.addMenuItem(R.string.menu_delete_conversation, MENU_DELETE_CONVERSATION);

    dialog
        .buildMenu(
            new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch ((int) id) {
                  case MENU_MUTE_CONVERSATION:
                    conversationPrefs.putBoolean(SettingsFragment.NOTIFICATIONS, false);
                    mAdapter.notifyDataSetChanged();
                    break;

                  case MENU_UNMUTE_CONVERSATION:
                    conversationPrefs.putBoolean(SettingsFragment.NOTIFICATIONS, true);
                    mAdapter.notifyDataSetChanged();
                    break;

                  case MENU_NOTIFICATION_SETTINGS:
                    ConversationNotificationSettingsDialog.newInstance(threadId, name)
                        .setContext(mContext)
                        .show(((MainActivity) mContext).getFragmentManager(), "notification prefs");
                    break;

                  case MENU_VIEW_DETAILS:
                    mConversationDetailsDialog.showDetails(conversation);
                    break;

                  case MENU_MARK_READ:
                    new ConversationLegacy(mContext, threadId).markRead();
                    break;

                  case MENU_MARK_UNREAD:
                    new ConversationLegacy(mContext, threadId).markUnread();
                    break;

                  case MENU_MULTI_SELECT:
                    mAdapter.setSelected(threadId);
                    break;

                  case MENU_DELETE_CONVERSATION:
                    DialogHelper.showDeleteConversationDialog((MainActivity) mContext, threadId);
                    break;
                  case MENU_DELETE_FAILED:
                    // Deletes all failed messages from all conversations
                    DialogHelper.showDeleteFailedMessagesDialog((MainActivity) mContext, threadId);
                    break;
                }
              }
            })
        .show(mContext.getFragmentManager(), "conversation options");
  }