Permalink
Browse files

Merge pull request #142 from yuri-danilchenko/master.

"Huge" Font Size Feature
  • Loading branch information...
2 parents ed0adb6 + 82e6620 commit 78dcd2a8725575c25f619dd22aa41722094caa07 @talklittle committed May 2, 2011
View
@@ -154,11 +154,13 @@
<item>Medium</item>
<item>Large</item>
<item>Larger</item>
+ <item>Huge</item>
</string-array>
<string-array name="pref_text_size_values" translatable="false">
<item>TEXT_SIZE_MEDIUM</item>
<item>TEXT_SIZE_LARGE</item>
<item>TEXT_SIZE_LARGER</item>
+ <item>TEXT_SIZE_HUGE</item>
</string-array>
<string name="pref_show_comment_guide_lines">Comment guide lines</string>
View
@@ -73,13 +73,28 @@
<item name="android:textAppearanceLarge">@style/TextAppearance_Larger.Large</item>
</style>
+ <style name="Reddit_Light_Huge" parent="@android:style/Theme.Light">
+ <item name="android:listSelector">@drawable/list_selector_blue</item>
+ <item name="android:cacheColorHint">@color/white</item>
+ <item name="android:textAppearanceSmall">@style/TextAppearance_Huge.Small</item>
+ <item name="android:textAppearanceMedium">@style/TextAppearance_Huge.Medium</item>
+ <item name="android:textAppearanceLarge">@style/TextAppearance_Huge.Large</item>
+ </style>
+
<style name="Reddit_Dark_Larger" parent="@android:style/Theme">
<item name="android:textAppearanceSmall">@style/TextAppearance_Larger.Small</item>
<item name="android:textAppearanceMedium">@style/TextAppearance_Larger.Medium</item>
<item name="android:textAppearanceLarge">@style/TextAppearance_Larger.Large</item>
<item name="android:windowBackground">@color/black</item>
</style>
+ <style name="Reddit_Dark_Huge" parent="@android:style/Theme">
+ <item name="android:textAppearanceSmall">@style/TextAppearance_Huge.Small</item>
+ <item name="android:textAppearanceMedium">@style/TextAppearance_Huge.Medium</item>
+ <item name="android:textAppearanceLarge">@style/TextAppearance_Huge.Large</item>
+ <item name="android:windowBackground">@color/black</item>
+ </style>
+
<!-- TextAppearance for different font size settings -->
<style name="TextAppearance_Medium.Small" parent="@android:style/TextAppearance.Small">
<item name="android:textSize">10sp</item>
@@ -90,6 +105,7 @@
<style name="TextAppearance_Medium.Large" parent="@android:style/TextAppearance.Large">
<item name="android:textSize">14sp</item>
</style>
+
<style name="TextAppearance_Large.Small" parent="@android:style/TextAppearance.Small">
<item name="android:textSize">12sp</item>
</style>
@@ -99,6 +115,7 @@
<style name="TextAppearance_Large.Large" parent="@android:style/TextAppearance.Large">
<item name="android:textSize">14sp</item>
</style>
+
<style name="TextAppearance_Larger.Small" parent="@android:style/TextAppearance.Small">
<item name="android:textSize">14sp</item>
</style>
@@ -109,5 +126,15 @@
<item name="android:textSize">16sp</item>
</style>
+ <style name="TextAppearance_Huge.Small" parent="@android:style/TextAppearance.Small">
+ <item name="android:textSize">18sp</item>
+ </style>
+ <style name="TextAppearance_Huge.Medium" parent="@android:style/TextAppearance.Medium">
+ <item name="android:textSize">20sp</item>
+ </style>
+ <style name="TextAppearance_Huge.Large" parent="@android:style/TextAppearance.Large">
+ <item name="android:textSize">22sp</item>
+ </style>
+
</resources>
@@ -282,12 +282,13 @@
static final String PREF_ALWAYS_SHOW_NEXT_PREVIOUS = "always_show_next_previous";
static final String PREF_COMMENTS_SORT_BY_URL = "sort_by_url";
static final String PREF_THEME = "theme";
- static final String PREF_THEME_LIGHT = "THEME_LIGHT";
- static final String PREF_THEME_DARK = "THEME_DARK";
+ public static final String PREF_THEME_LIGHT = "THEME_LIGHT";
+ public static final String PREF_THEME_DARK = "THEME_DARK";
static final String PREF_TEXT_SIZE = "text_size";
static final String PREF_TEXT_SIZE_MEDIUM = "TEXT_SIZE_MEDIUM";
static final String PREF_TEXT_SIZE_LARGE = "TEXT_SIZE_LARGE";
static final String PREF_TEXT_SIZE_LARGER = "TEXT_SIZE_LARGER";
+ public static final String PREF_TEXT_SIZE_HUGE = "TEXT_SIZE_HUGE";
static final String PREF_SHOW_COMMENT_GUIDE_LINES = "show_comment_guide_lines";
static final String PREF_ROTATION = "rotation";
static final String PREF_ROTATION_UNSPECIFIED = "ROTATION_UNSPECIFIED";
@@ -176,75 +176,87 @@ public static boolean isHttpStatusOK(HttpResponse response) {
// Theme
// ===============
- static boolean isLightTheme(int theme) {
- return theme == R.style.Reddit_Light_Medium || theme == R.style.Reddit_Light_Large || theme == R.style.Reddit_Light_Larger;
+ public static boolean isLightTheme(int theme) {
+ return theme == R.style.Reddit_Light_Medium || theme == R.style.Reddit_Light_Large || theme == R.style.Reddit_Light_Larger || theme == R.style.Reddit_Light_Huge;
}
- static boolean isDarkTheme(int theme) {
- return theme == R.style.Reddit_Dark_Medium || theme == R.style.Reddit_Dark_Large || theme == R.style.Reddit_Dark_Larger;
+ public static boolean isDarkTheme(int theme) {
+ return theme == R.style.Reddit_Dark_Medium || theme == R.style.Reddit_Dark_Large || theme == R.style.Reddit_Dark_Larger || theme == R.style.Reddit_Dark_Huge;
}
- static int getInvertedTheme(int theme) {
+ public static int getInvertedTheme(int theme) {
switch (theme) {
case R.style.Reddit_Light_Medium:
return R.style.Reddit_Dark_Medium;
case R.style.Reddit_Light_Large:
return R.style.Reddit_Dark_Large;
case R.style.Reddit_Light_Larger:
return R.style.Reddit_Dark_Larger;
+ case R.style.Reddit_Light_Huge:
+ return R.style.Reddit_Dark_Huge;
case R.style.Reddit_Dark_Medium:
return R.style.Reddit_Light_Medium;
case R.style.Reddit_Dark_Large:
return R.style.Reddit_Light_Large;
case R.style.Reddit_Dark_Larger:
return R.style.Reddit_Light_Larger;
+ case R.style.Reddit_Dark_Huge:
+ return R.style.Reddit_Light_Huge;
default:
return R.style.Reddit_Light_Medium;
}
}
- static int getThemeResourceFromPrefs(String themePref, String textSizePref) {
+ public static int getThemeResourceFromPrefs(String themePref, String textSizePref) {
if (Constants.PREF_THEME_LIGHT.equals(themePref)) {
if (Constants.PREF_TEXT_SIZE_MEDIUM.equals(textSizePref))
return R.style.Reddit_Light_Medium;
else if (Constants.PREF_TEXT_SIZE_LARGE.equals(textSizePref))
return R.style.Reddit_Light_Large;
else if (Constants.PREF_TEXT_SIZE_LARGER.equals(textSizePref))
return R.style.Reddit_Light_Larger;
+ else if (Constants.PREF_TEXT_SIZE_HUGE.equals(textSizePref))
+ return R.style.Reddit_Light_Huge;
} else /* if (Constants.PREF_THEME_DARK.equals(themePref)) */ {
if (Constants.PREF_TEXT_SIZE_MEDIUM.equals(textSizePref))
return R.style.Reddit_Dark_Medium;
else if (Constants.PREF_TEXT_SIZE_LARGE.equals(textSizePref))
return R.style.Reddit_Dark_Large;
else if (Constants.PREF_TEXT_SIZE_LARGER.equals(textSizePref))
return R.style.Reddit_Dark_Larger;
+ else if (Constants.PREF_TEXT_SIZE_HUGE.equals(textSizePref))
+ return R.style.Reddit_Dark_Huge;
}
return R.style.Reddit_Light_Medium;
}
/**
* Return the theme and textSize String prefs
*/
- static String[] getPrefsFromThemeResource(int theme) {
+ public static String[] getPrefsFromThemeResource(int theme) {
switch (theme) {
case R.style.Reddit_Light_Medium:
return new String[] { Constants.PREF_THEME_LIGHT, Constants.PREF_TEXT_SIZE_MEDIUM };
case R.style.Reddit_Light_Large:
return new String[] { Constants.PREF_THEME_LIGHT, Constants.PREF_TEXT_SIZE_LARGE };
case R.style.Reddit_Light_Larger:
return new String[] { Constants.PREF_THEME_LIGHT, Constants.PREF_TEXT_SIZE_LARGER };
+ case R.style.Reddit_Light_Huge:
+ return new String[] { Constants.PREF_THEME_LIGHT, Constants.PREF_TEXT_SIZE_HUGE };
case R.style.Reddit_Dark_Medium:
return new String[] { Constants.PREF_THEME_DARK, Constants.PREF_TEXT_SIZE_MEDIUM };
case R.style.Reddit_Dark_Large:
return new String[] { Constants.PREF_THEME_DARK, Constants.PREF_TEXT_SIZE_LARGE };
case R.style.Reddit_Dark_Larger:
return new String[] { Constants.PREF_THEME_DARK, Constants.PREF_TEXT_SIZE_LARGER };
+ case R.style.Reddit_Dark_Huge:
+ return new String[] { Constants.PREF_THEME_DARK, Constants.PREF_TEXT_SIZE_HUGE };
default:
return new String[] { Constants.PREF_THEME_LIGHT, Constants.PREF_TEXT_SIZE_MEDIUM };
}
}
- static int getTextAppearanceResource(int themeResource, int androidTextAppearanceStyle) {
+ public static int getTextAppearanceResource(int themeResource, int androidTextAppearanceStyle) {
switch (themeResource) {
case R.style.Reddit_Light_Medium:
case R.style.Reddit_Dark_Medium:
@@ -282,6 +294,18 @@ static int getTextAppearanceResource(int themeResource, int androidTextAppearanc
default:
return R.style.TextAppearance_Larger_Medium;
}
+ case R.style.Reddit_Light_Huge:
+ case R.style.Reddit_Dark_Huge:
+ switch (androidTextAppearanceStyle) {
+ case android.R.style.TextAppearance_Small:
+ return R.style.TextAppearance_Huge_Small;
+ case android.R.style.TextAppearance_Medium:
+ return R.style.TextAppearance_Huge_Medium;
+ case android.R.style.TextAppearance_Large:
+ return R.style.TextAppearance_Huge_Large;
+ default:
+ return R.style.TextAppearance_Huge_Medium;
+ }
default:
return R.style.TextAppearance_Medium_Medium;
}
View
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.andrewshu.android.reddit.test"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="4" />
+ <instrumentation android:targetPackage="com.andrewshu.android.reddit" android:name="android.test.InstrumentationTestRunner" />
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+
+ <uses-library android:name="android.test.runner" />
+ </application>
+</manifest>
View
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-7
View
@@ -0,0 +1,36 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+</LinearLayout>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World!</string>
+ <string name="app_name">reddit is funTest</string>
+</resources>
@@ -0,0 +1,90 @@
+package com.andrewshu.android.reddit.test;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
+
+import com.andrewshu.android.reddit.Constants;
+import com.andrewshu.android.reddit.Util;
+import com.andrewshu.android.reddit.R;
+
+import junit.framework.TestCase;
+
+public class RedditIsFunUtilTest extends TestCase {
+
+ public void testIsLightTheme()
+ {
+
+ boolean result = Util.isLightTheme(R.style.Reddit_Light_Medium) &&
+ Util.isLightTheme(R.style.Reddit_Light_Large) &&
+ Util.isLightTheme(R.style.Reddit_Light_Larger) &&
+ Util.isLightTheme(R.style.Reddit_Light_Huge);
+
+ assertTrue(result);
+
+ }
+
+ public void testIsDarkTheme()
+ {
+
+ boolean result = Util.isDarkTheme(R.style.Reddit_Dark_Medium) &&
+ Util.isDarkTheme(R.style.Reddit_Dark_Large) &&
+ Util.isDarkTheme(R.style.Reddit_Dark_Larger) &&
+ Util.isDarkTheme(R.style.Reddit_Dark_Huge);
+
+ assertTrue(result);
+
+ }
+
+ public void testGetInvertedTheme()
+ {
+
+ assertEquals("GetInvertedTheme From Dark to Light Failed", R.style.Reddit_Dark_Huge, Util.getInvertedTheme(R.style.Reddit_Light_Huge));
+
+ assertEquals("GetInvertedTheme From Light to Dark Failed", R.style.Reddit_Light_Huge, Util.getInvertedTheme(R.style.Reddit_Dark_Huge));
+
+ }
+
+ public void testGetThemeResourceFromPrefs()
+ {
+
+ assertEquals("GetThemeResourceFromPrefs for Dark Theme Failed", R.style.Reddit_Dark_Huge, Util.getThemeResourceFromPrefs(Constants.PREF_THEME_DARK, Constants.PREF_TEXT_SIZE_HUGE));
+
+ assertEquals("GetThemeResourceFromPrefs for Light Theme Failed", R.style.Reddit_Light_Huge, Util.getThemeResourceFromPrefs(Constants.PREF_THEME_LIGHT, Constants.PREF_TEXT_SIZE_HUGE));
+
+ }
+
+ public void testGetPrefsFromThemeResource()
+ {
+
+ boolean blnResultForDarkTheme;
+ boolean blnResultForLightTheme;
+
+ String [] astrDarkHugePrefs = new String[] { Constants.PREF_THEME_DARK, Constants.PREF_TEXT_SIZE_HUGE };
+ String [] astrLightHugePrefs = new String[] { Constants.PREF_THEME_LIGHT, Constants.PREF_TEXT_SIZE_HUGE };
+
+ blnResultForDarkTheme = Arrays.equals(astrDarkHugePrefs, Util.getPrefsFromThemeResource(R.style.Reddit_Dark_Huge));
+ blnResultForLightTheme = Arrays.equals(astrLightHugePrefs, Util.getPrefsFromThemeResource(R.style.Reddit_Light_Huge));
+
+ assertTrue(blnResultForDarkTheme && blnResultForLightTheme);
+
+ }
+
+ public void testGetTextAppearanceResource()
+ {
+
+ assertEquals("GetTextAppearanceResource for Dark Theme Small Text Failed", R.style.TextAppearance_Huge_Small, Util.getTextAppearanceResource(R.style.Reddit_Dark_Huge, android.R.style.TextAppearance_Small));
+
+ assertEquals("GetTextAppearanceResource for Dark Theme Medium Text Failed", R.style.TextAppearance_Huge_Medium, Util.getTextAppearanceResource(R.style.Reddit_Dark_Huge, android.R.style.TextAppearance_Medium));
+
+ assertEquals("GetTextAppearanceResource for Dark Theme Large Text Failed", R.style.TextAppearance_Huge_Large, Util.getTextAppearanceResource(R.style.Reddit_Dark_Huge, android.R.style.TextAppearance_Large));
+
+ assertEquals("GetTextAppearanceResource for Light Theme Small Text Failed", R.style.TextAppearance_Huge_Small, Util.getTextAppearanceResource(R.style.Reddit_Light_Huge, android.R.style.TextAppearance_Small));
+
+ assertEquals("GetTextAppearanceResource for Light Theme Medium Text Failed", R.style.TextAppearance_Huge_Medium, Util.getTextAppearanceResource(R.style.Reddit_Light_Huge, android.R.style.TextAppearance_Medium));
+
+ assertEquals("GetTextAppearanceResource for Light Theme Large Text Failed", R.style.TextAppearance_Huge_Large, Util.getTextAppearanceResource(R.style.Reddit_Light_Huge, android.R.style.TextAppearance_Large));
+
+
+ }
+
+}

0 comments on commit 78dcd2a

Please sign in to comment.