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