@Override
 public void onItemClick(Conversation conversation, View view) {
   if (mAdapter.isInMultiSelectMode()) {
     mAdapter.toggleSelection(conversation.getThreadId());
   } else {
     ((MainActivity) mContext).setConversation(conversation.getThreadId(), -1, null, true);
   }
 }
Exemple #2
0
  public static int getFontWeight(Context context, boolean heavy) {
    SharedPreferences prefs = MainActivity.getPrefs(context);
    int fontWeight = Integer.parseInt(prefs.getString(SettingsFragment.FONT_WEIGHT, "0"));
    int fontFamily = getFontFamily(context);

    if (!heavy) {
      return fontWeight;
    }

    // Otherwise, get the heavy font weight.
    if (fontWeight == RobotoTypefaceManager.TextWeight.LIGHT) {
      return RobotoTypefaceManager.TextWeight.NORMAL;
    } else if (fontFamily == RobotoTypefaceManager.FontFamily.ROBOTO) {
      return RobotoTypefaceManager.TextWeight.MEDIUM;
    } else {
      return RobotoTypefaceManager.TextWeight.BOLD;
    }
  }
Exemple #3
0
  public static int getTextSize(Context context, int type) {
    SharedPreferences prefs = MainActivity.getPrefs(context);
    int fontSize = Integer.parseInt(prefs.getString(SettingsFragment.FONT_SIZE, "1"));

    switch (type) {
      case TEXT_TYPE_TERTIARY:
        if (fontSize == TEXT_SIZE_SMALL) return 10;
        if (fontSize == TEXT_SIZE_NORMAL) return 12;
        if (fontSize == TEXT_SIZE_LARGE) return 14;
        if (fontSize == TEXT_SIZE_LARGEST) return 16;
        break; // All further cases do the same checks, so we might as will just break and return
        // the default value
      case TEXT_TYPE_SECONDARY:
      case TEXT_TYPE_DIALOG_BUTTON:
      case TEXT_TYPE_CATEGORY:
        if (fontSize == TEXT_SIZE_SMALL) return 12;
        if (fontSize == TEXT_SIZE_NORMAL) return 14;
        if (fontSize == TEXT_SIZE_LARGE) return 16;
        if (fontSize == TEXT_SIZE_LARGEST) return 18;
        break;
      case TEXT_TYPE_PRIMARY:
      case TEXT_TYPE_DIALOG_MESSAGE:
        if (fontSize == TEXT_SIZE_SMALL) return 14;
        if (fontSize == TEXT_SIZE_NORMAL) return 16;
        if (fontSize == TEXT_SIZE_LARGE) return 18;
        if (fontSize == TEXT_SIZE_LARGEST) return 22;
        break;
      case TEXT_TYPE_DIALOG_TITLE:
      case TEXT_TYPE_TOOLBAR:
        if (fontSize == TEXT_SIZE_SMALL) return 18;
        if (fontSize == TEXT_SIZE_NORMAL) return 20;
        if (fontSize == TEXT_SIZE_LARGE) return 22;
        if (fontSize == TEXT_SIZE_LARGEST) return 26;
        break;
    }

    return 14;
  }
 private void init(Context context) {
   mContext = context;
   mPrefs = MainActivity.getPrefs(mContext);
 }
Exemple #5
0
 public static int getFontFamily(Context context) {
   SharedPreferences prefs = MainActivity.getPrefs(context);
   return Integer.parseInt(prefs.getString(SettingsFragment.FONT_FAMILY, "0"));
 }
  @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");
  }