diff --git a/res/drawable-hdpi/ic_action_delete_dark.png b/res/drawable-hdpi/ic_action_delete_dark.png
new file mode 100644
index 0000000..c6f7100
Binary files /dev/null and b/res/drawable-hdpi/ic_action_delete_dark.png differ
diff --git a/res/drawable-hdpi/ic_action_invert_dark.png b/res/drawable-hdpi/ic_action_invert_dark.png
new file mode 100644
index 0000000..bd6cd0d
Binary files /dev/null and b/res/drawable-hdpi/ic_action_invert_dark.png differ
diff --git a/res/drawable-hdpi/ic_action_invert_light.png b/res/drawable-hdpi/ic_action_invert_light.png
new file mode 100644
index 0000000..d35a668
Binary files /dev/null and b/res/drawable-hdpi/ic_action_invert_light.png differ
diff --git a/res/drawable-hdpi/ic_action_plus_dark.png b/res/drawable-hdpi/ic_action_plus_dark.png
new file mode 100644
index 0000000..6b859ad
Binary files /dev/null and b/res/drawable-hdpi/ic_action_plus_dark.png differ
diff --git a/res/drawable-hdpi/ic_action_star_dark.png b/res/drawable-hdpi/ic_action_star_dark.png
new file mode 100644
index 0000000..a04d62f
Binary files /dev/null and b/res/drawable-hdpi/ic_action_star_dark.png differ
diff --git a/res/drawable-hdpi/ic_action_text_size_dark.png b/res/drawable-hdpi/ic_action_text_size_dark.png
new file mode 100644
index 0000000..a77414d
Binary files /dev/null and b/res/drawable-hdpi/ic_action_text_size_dark.png differ
diff --git a/res/drawable-hdpi/ic_action_text_size_light.png b/res/drawable-hdpi/ic_action_text_size_light.png
new file mode 100644
index 0000000..3069b3c
Binary files /dev/null and b/res/drawable-hdpi/ic_action_text_size_light.png differ
diff --git a/res/drawable-hdpi/ic_webpage_dark.png b/res/drawable-hdpi/ic_webpage_dark.png
new file mode 100644
index 0000000..e2c2dd9
Binary files /dev/null and b/res/drawable-hdpi/ic_webpage_dark.png differ
diff --git a/res/drawable-xhdpi/ic_action_delete_dark.png b/res/drawable-xhdpi/ic_action_delete_dark.png
new file mode 100644
index 0000000..456573f
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_delete_dark.png differ
diff --git a/res/drawable-xhdpi/ic_action_invert_dark.png b/res/drawable-xhdpi/ic_action_invert_dark.png
new file mode 100644
index 0000000..937dbe9
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_invert_dark.png differ
diff --git a/res/drawable-xhdpi/ic_action_invert_light.png b/res/drawable-xhdpi/ic_action_invert_light.png
new file mode 100644
index 0000000..48149db
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_invert_light.png differ
diff --git a/res/drawable-xhdpi/ic_action_plus_dark.png b/res/drawable-xhdpi/ic_action_plus_dark.png
new file mode 100644
index 0000000..849ed06
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_plus_dark.png differ
diff --git a/res/drawable-xhdpi/ic_action_star_dark.png b/res/drawable-xhdpi/ic_action_star_dark.png
new file mode 100644
index 0000000..b7c2ba9
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_star_dark.png differ
diff --git a/res/drawable-xhdpi/ic_action_text_size_dark.png b/res/drawable-xhdpi/ic_action_text_size_dark.png
new file mode 100644
index 0000000..de5ed93
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_text_size_dark.png differ
diff --git a/res/drawable-xhdpi/ic_action_text_size_light.png b/res/drawable-xhdpi/ic_action_text_size_light.png
new file mode 100644
index 0000000..d325391
Binary files /dev/null and b/res/drawable-xhdpi/ic_action_text_size_light.png differ
diff --git a/res/drawable-xhdpi/ic_webpage_dark.png b/res/drawable-xhdpi/ic_webpage_dark.png
new file mode 100644
index 0000000..7524ab5
Binary files /dev/null and b/res/drawable-xhdpi/ic_webpage_dark.png differ
diff --git a/res/drawable-xxhdpi/ic_action_delete_dark.png b/res/drawable-xxhdpi/ic_action_delete_dark.png
new file mode 100644
index 0000000..37a738d
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_delete_dark.png differ
diff --git a/res/drawable-xxhdpi/ic_action_invert_dark.png b/res/drawable-xxhdpi/ic_action_invert_dark.png
new file mode 100644
index 0000000..c82ea79
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_invert_dark.png differ
diff --git a/res/drawable-xxhdpi/ic_action_invert_light.png b/res/drawable-xxhdpi/ic_action_invert_light.png
new file mode 100644
index 0000000..9e6844f
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_invert_light.png differ
diff --git a/res/drawable-xxhdpi/ic_action_plus_dark.png b/res/drawable-xxhdpi/ic_action_plus_dark.png
new file mode 100644
index 0000000..7927662
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_plus_dark.png differ
diff --git a/res/drawable-xxhdpi/ic_action_star_dark.png b/res/drawable-xxhdpi/ic_action_star_dark.png
new file mode 100644
index 0000000..44d9afd
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_star_dark.png differ
diff --git a/res/drawable-xxhdpi/ic_action_text_size_dark.png b/res/drawable-xxhdpi/ic_action_text_size_dark.png
new file mode 100644
index 0000000..29682af
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_text_size_dark.png differ
diff --git a/res/drawable-xxhdpi/ic_action_text_size_light.png b/res/drawable-xxhdpi/ic_action_text_size_light.png
new file mode 100644
index 0000000..d76000f
Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_text_size_light.png differ
diff --git a/res/drawable-xxhdpi/ic_webpage_dark.png b/res/drawable-xxhdpi/ic_webpage_dark.png
new file mode 100644
index 0000000..9f6504e
Binary files /dev/null and b/res/drawable-xxhdpi/ic_webpage_dark.png differ
diff --git a/res/drawable/toolbar_elevate_dark.xml b/res/drawable/toolbar_elevate_dark.xml
new file mode 100644
index 0000000..3fbd3ed
--- /dev/null
+++ b/res/drawable/toolbar_elevate_dark.xml
@@ -0,0 +1,19 @@
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/about_settings.xml b/res/layout/about_settings.xml
index 243beac..4a1da29 100644
--- a/res/layout/about_settings.xml
+++ b/res/layout/about_settings.xml
@@ -56,7 +56,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
diff --git a/res/layout/advanced_settings.xml b/res/layout/advanced_settings.xml
index 042baeb..7a5ad24 100644
--- a/res/layout/advanced_settings.xml
+++ b/res/layout/advanced_settings.xml
@@ -65,7 +65,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
diff --git a/res/layout/bookmark_drawer.xml b/res/layout/bookmark_drawer.xml
index 13b8e29..9348d60 100644
--- a/res/layout/bookmark_drawer.xml
+++ b/res/layout/bookmark_drawer.xml
@@ -4,7 +4,7 @@
android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent"
android:layout_gravity="end"
- android:background="@color/drawer_background"
+ android:background="?attr/drawerBackground"
android:clickable="true"
android:fitsSystemWindows="true"
android:orientation="vertical" >
@@ -28,7 +28,7 @@
android:layout_marginRight="16dp"
android:contentDescription="Favicon"
android:gravity="center_vertical"
- android:src="@drawable/ic_action_star" >
+ android:src="?attr/starDrawable" >
+ android:textAppearance="?android:attr/textAppearanceListItemSmall" />
+ android:background="?attr/dividerColor" />
+ android:textAppearance="?android:attr/textAppearanceListItemSmall" />
\ No newline at end of file
diff --git a/res/layout/bookmark_settings.xml b/res/layout/bookmark_settings.xml
index c722801..f172e82 100644
--- a/res/layout/bookmark_settings.xml
+++ b/res/layout/bookmark_settings.xml
@@ -30,7 +30,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
\ No newline at end of file
diff --git a/res/layout/display_settings.xml b/res/layout/display_settings.xml
index 68c6659..6816c7e 100644
--- a/res/layout/display_settings.xml
+++ b/res/layout/display_settings.xml
@@ -49,7 +49,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+
+
+
+
+
+
+
+
+
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
diff --git a/res/layout/general_settings.xml b/res/layout/general_settings.xml
index 53ac6c7..ce1eea4 100644
--- a/res/layout/general_settings.xml
+++ b/res/layout/general_settings.xml
@@ -56,7 +56,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
diff --git a/res/layout/license_activity.xml b/res/layout/license_activity.xml
index e557432..030a624 100644
--- a/res/layout/license_activity.xml
+++ b/res/layout/license_activity.xml
@@ -35,7 +35,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
\ No newline at end of file
diff --git a/res/layout/privacy_settings.xml b/res/layout/privacy_settings.xml
index c498791..3a22150 100644
--- a/res/layout/privacy_settings.xml
+++ b/res/layout/privacy_settings.xml
@@ -50,7 +50,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
diff --git a/res/layout/seek_layout.xml b/res/layout/seek_layout.xml
new file mode 100644
index 0000000..0616d8d
--- /dev/null
+++ b/res/layout/seek_layout.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/settings.xml b/res/layout/settings.xml
index 8469644..3a04e18 100644
--- a/res/layout/settings.xml
+++ b/res/layout/settings.xml
@@ -50,7 +50,7 @@
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
- android:background="#cdcdcd" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
diff --git a/res/layout/tab_drawer.xml b/res/layout/tab_drawer.xml
index a308f6d..eb4b497 100644
--- a/res/layout/tab_drawer.xml
+++ b/res/layout/tab_drawer.xml
@@ -4,7 +4,7 @@
android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent"
android:layout_gravity="start"
- android:background="@color/drawer_background"
+ android:background="?drawerBackground"
android:clickable="true"
android:fitsSystemWindows="true"
android:orientation="vertical" >
@@ -27,7 +27,7 @@
android:layout_marginRight="16dp"
android:contentDescription="@string/action_new_tab"
android:gravity="center_vertical"
- android:src="@drawable/ic_action_plus" >
+ android:src="?attr/plusDrawable" >
+ android:textAppearance="?android:attr/textAppearanceListItemSmall" />
+ android:background="?attr/dividerColor" />
+ android:background="?attr/dividerColor" />
@@ -90,7 +89,7 @@
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
- android:src="@drawable/ic_action_back" />
+ android:src="?attr/arrowBackDrawable" />
+ android:src="?attr/arrowForwardDrawable" />
diff --git a/res/layout/tab_list_item.xml b/res/layout/tab_list_item.xml
index 03af796..cb54e17 100644
--- a/res/layout/tab_list_item.xml
+++ b/res/layout/tab_list_item.xml
@@ -31,8 +31,7 @@
android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceListItemSmall"
- android:textColor="@color/dark_text" />
+ android:textAppearance="?android:attr/textAppearanceListItemSmall" />
+ android:src="?attr/deleteDrawable" >
\ No newline at end of file
diff --git a/res/menu/reading.xml b/res/menu/reading.xml
new file mode 100644
index 0000000..57c9dd1
--- /dev/null
+++ b/res/menu/reading.xml
@@ -0,0 +1,18 @@
+
+
\ No newline at end of file
diff --git a/res/mipmap-mdpi/ic_launcher.png b/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..601a9d6
Binary files /dev/null and b/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/res/values-v21/styles.xml b/res/values-v21/styles.xml
index 5c568df..8f20406 100644
--- a/res/values-v21/styles.xml
+++ b/res/values-v21/styles.xml
@@ -12,6 +12,25 @@
- true
- false
- @null
+ - @drawable/ic_action_invert_light
+ - @drawable/ic_action_text_size_light
+ - @color/divider_light
+
+
+
\ No newline at end of file
diff --git a/res/values/attr.xml b/res/values/attr.xml
index a794e07..c575601 100644
--- a/res/values/attr.xml
+++ b/res/values/attr.xml
@@ -10,6 +10,13 @@
+
+
+
+
+
+
+
diff --git a/res/values/colors.xml b/res/values/colors.xml
index dc6489c..0a874bd 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -1,7 +1,6 @@
- #ffffff
#ff000000
#ffa0a0a0
#222222
@@ -16,9 +15,17 @@
#4D000000
#0073EF
+ #ffffff
+ #424242
+
#9C9C9C
+ #2E2E2E
#BDBDBD
#424242
+
+ #1EFFFFFF
+ #1E000000
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e64a5fd..89c1746 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -210,4 +210,7 @@
- URL
- Title
+ Invert color
+ Use Dark Theme
+ The theme change will take effect after you restart the browser.
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 780ccab..a75ae83 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -12,6 +12,25 @@
- true
- false
- @null
+ - @drawable/ic_action_invert_light
+ - @drawable/ic_action_text_size_light
+ - @color/divider_light
+
+
+
-
\ No newline at end of file
diff --git a/src/acr/browser/lightning/AboutSettingsActivity.java b/src/acr/browser/lightning/AboutSettingsActivity.java
index 2099b12..0f77f15 100644
--- a/src/acr/browser/lightning/AboutSettingsActivity.java
+++ b/src/acr/browser/lightning/AboutSettingsActivity.java
@@ -28,6 +28,10 @@ public class AboutSettingsActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.about_settings);
@@ -37,7 +41,6 @@ public class AboutSettingsActivity extends ActionBarActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
diff --git a/src/acr/browser/lightning/AdvancedSettingsActivity.java b/src/acr/browser/lightning/AdvancedSettingsActivity.java
index 42e32df..7eb24d4 100644
--- a/src/acr/browser/lightning/AdvancedSettingsActivity.java
+++ b/src/acr/browser/lightning/AdvancedSettingsActivity.java
@@ -34,6 +34,10 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.advanced_settings);
@@ -43,7 +47,6 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
diff --git a/src/acr/browser/lightning/BookmarkActivity.java b/src/acr/browser/lightning/BookmarkActivity.java
index e4d99f4..94e6f9e 100644
--- a/src/acr/browser/lightning/BookmarkActivity.java
+++ b/src/acr/browser/lightning/BookmarkActivity.java
@@ -31,6 +31,10 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
@Override
public void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.bookmark_settings);
@@ -48,8 +52,6 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
mBookmarkManager = new BookmarkManager(this);
- mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
-
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
exportBackup.setOnClickListener(this);
diff --git a/src/acr/browser/lightning/BrowserActivity.java b/src/acr/browser/lightning/BrowserActivity.java
index 7fe8d34..99975ab 100644
--- a/src/acr/browser/lightning/BrowserActivity.java
+++ b/src/acr/browser/lightning/BrowserActivity.java
@@ -129,6 +129,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
private static LayoutParams mMatchParent = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
private BookmarkManager mBookmarkManager;
+ private boolean mDarkTheme;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -145,6 +146,8 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
setSupportActionBar(mToolbar);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ mDarkTheme = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)
+ || isIncognito();
mContext = this;
if (mWebViews != null) {
mWebViews.clear();
@@ -184,7 +187,12 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
setNavigationDrawerWidth();
mDrawerLayout.setDrawerListener(new DrawerLocker());
- mWebpageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_webpage);
+ if (mDarkTheme) {
+ mWebpageBitmap = BitmapFactory.decodeResource(getResources(),
+ R.drawable.ic_webpage_dark);
+ } else {
+ mWebpageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_webpage);
+ }
mActionBar = getSupportActionBar();
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
@@ -218,15 +226,10 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
lp.width = LayoutParams.MATCH_PARENT;
v.setLayoutParams(lp);
- // TODO
-
mArrowDrawable = new DrawerArrowDrawable(this);
mArrowImage = (ImageView) mActionBar.getCustomView().findViewById(R.id.arrow);
- mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null); // Use a
- // hardware
- // layer for
- // the
- // animation
+ // Use hardware acceleration for the animation
+ mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mArrowImage.setImageDrawable(mArrowDrawable);
LinearLayout arrowButton = (LinearLayout) mActionBar.getCustomView().findViewById(
R.id.arrow_button);
@@ -771,11 +774,14 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
}
mFullScreen = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false);
mColorMode = mPreferences.getBoolean(PreferenceConstants.ENABLE_COLOR_MODE, true);
+ mColorMode &= !mDarkTheme;
- if (!isIncognito() && !mColorMode && mWebpageBitmap != null)
+ if (!isIncognito() && !mColorMode && !mDarkTheme && mWebpageBitmap != null) {
changeToolbarBackground(mWebpageBitmap);
- else if (!isIncognito() && mCurrentView != null && mCurrentView.getFavicon() != null)
+ } else if (!isIncognito() && mCurrentView != null && !mDarkTheme
+ && mCurrentView.getFavicon() != null) {
changeToolbarBackground(mCurrentView.getFavicon());
+ }
if (mFullScreen && mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
mUiLayout.removeView(mToolbarLayout);
@@ -1287,7 +1293,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
protected synchronized boolean newTab(String url, boolean show) {
mIsNewIntent = false;
- LightningView startingTab = new LightningView(mActivity, url);
+ LightningView startingTab = new LightningView(mActivity, url, mDarkTheme);
if (mIdGenerator == 0) {
startingTab.resumeTimers();
}
@@ -2064,7 +2070,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
});
getUrl.setSelectAllOnFocus(true);
- mSearchAdapter = new SearchAdapter(mContext, isIncognito());
+ mSearchAdapter = new SearchAdapter(mContext, isIncognito() || mDarkTheme);
getUrl.setAdapter(mSearchAdapter);
}
diff --git a/src/acr/browser/lightning/DisplaySettingsActivity.java b/src/acr/browser/lightning/DisplaySettingsActivity.java
index ed0f32a..b21b035 100644
--- a/src/acr/browser/lightning/DisplaySettingsActivity.java
+++ b/src/acr/browser/lightning/DisplaySettingsActivity.java
@@ -3,6 +3,7 @@
*/
package acr.browser.lightning;
+import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
@@ -22,30 +23,31 @@ public class DisplaySettingsActivity extends ActionBarActivity {
// mPreferences variables
private SharedPreferences mPreferences;
- private SharedPreferences.Editor mEditPrefs;
- private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow;
+ private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow,
+ cbDarkTheme;
+ private Activity mActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.display_settings);
+ mActivity = this;
+
// set up ActionBar
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
-
- // TODO WARNING: SharedPreferences.edit() without a corresponding
- // commit() or apply() call
- mEditPrefs = mPreferences.edit();
-
initialize();
}
@@ -57,7 +59,7 @@ public class DisplaySettingsActivity extends ActionBarActivity {
private void initialize() {
- RelativeLayout rHideStatusBar, rFullScreen, rWideViewPort, rOverView, rTextReflow, rTextSize;
+ RelativeLayout rHideStatusBar, rFullScreen, rWideViewPort, rOverView, rTextReflow, rTextSize, rDarkTheme;
rHideStatusBar = (RelativeLayout) findViewById(R.id.rHideStatusBar);
rFullScreen = (RelativeLayout) findViewById(R.id.rFullScreen);
@@ -65,18 +67,23 @@ public class DisplaySettingsActivity extends ActionBarActivity {
rOverView = (RelativeLayout) findViewById(R.id.rOverView);
rTextReflow = (RelativeLayout) findViewById(R.id.rTextReflow);
rTextSize = (RelativeLayout) findViewById(R.id.rTextSize);
+ rDarkTheme = (RelativeLayout) findViewById(R.id.rDarkTheme);
cbHideStatusBar = (CheckBox) findViewById(R.id.cbHideStatusBar);
cbFullScreen = (CheckBox) findViewById(R.id.cbFullScreen);
cbWideViewPort = (CheckBox) findViewById(R.id.cbWideViewPort);
cbOverView = (CheckBox) findViewById(R.id.cbOverView);
cbTextReflow = (CheckBox) findViewById(R.id.cbTextReflow);
+ cbDarkTheme = (CheckBox) findViewById(R.id.cbDarkTheme);
- cbHideStatusBar.setChecked(mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false));
+ cbHideStatusBar.setChecked(mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR,
+ false));
cbFullScreen.setChecked(mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false));
- cbWideViewPort.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, true));
+ cbWideViewPort.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT,
+ true));
cbOverView.setChecked(mPreferences.getBoolean(PreferenceConstants.OVERVIEW_MODE, true));
cbTextReflow.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, false));
+ cbDarkTheme.setChecked(mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false));
rHideStatusBar(rHideStatusBar);
rFullScreen(rFullScreen);
@@ -84,11 +91,13 @@ public class DisplaySettingsActivity extends ActionBarActivity {
rOverView(rOverView);
rTextReflow(rTextReflow);
rTextSize(rTextSize);
+ rDarkTheme(rDarkTheme);
cbHideStatusBar(cbHideStatusBar);
cbFullScreen(cbFullScreen);
cbWideViewPort(cbWideViewPort);
cbOverView(cbOverView);
cbTextReflow(cbTextReflow);
+ cbDarkTheme(cbDarkTheme);
}
private void cbHideStatusBar(CheckBox view) {
@@ -96,8 +105,8 @@ public class DisplaySettingsActivity extends ActionBarActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.HIDE_STATUS_BAR, isChecked);
- mEditPrefs.apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.HIDE_STATUS_BAR, isChecked)
+ .apply();
}
});
@@ -108,21 +117,31 @@ public class DisplaySettingsActivity extends ActionBarActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, isChecked);
- mEditPrefs.apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.FULL_SCREEN, isChecked).apply();
}
});
}
+ private void cbDarkTheme(CheckBox view) {
+ view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mPreferences.edit().putBoolean(PreferenceConstants.DARK_THEME, isChecked).apply();
+ mActivity.recreate();
+ }
+
+ });
+ }
private void cbWideViewPort(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, isChecked);
- mEditPrefs.apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, isChecked)
+ .apply();
}
});
@@ -133,8 +152,8 @@ public class DisplaySettingsActivity extends ActionBarActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.OVERVIEW_MODE, isChecked);
- mEditPrefs.apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.OVERVIEW_MODE, isChecked)
+ .apply();
}
});
@@ -145,8 +164,7 @@ public class DisplaySettingsActivity extends ActionBarActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, isChecked);
- mEditPrefs.apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.TEXT_REFLOW, isChecked).apply();
}
});
}
@@ -173,6 +191,17 @@ public class DisplaySettingsActivity extends ActionBarActivity {
});
}
+ private void rDarkTheme(RelativeLayout view) {
+ view.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ cbDarkTheme.setChecked(!cbDarkTheme.isChecked());
+ }
+
+ });
+ }
+
private void rWideViewPort(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() {
@@ -224,8 +253,8 @@ public class DisplaySettingsActivity extends ActionBarActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
- mEditPrefs.putInt(PreferenceConstants.TEXT_SIZE, which + 1);
- mEditPrefs.apply();
+ mPreferences.edit()
+ .putInt(PreferenceConstants.TEXT_SIZE, which + 1).apply();
}
});
diff --git a/src/acr/browser/lightning/GeneralSettingsActivity.java b/src/acr/browser/lightning/GeneralSettingsActivity.java
index fb2c98c..935ad05 100644
--- a/src/acr/browser/lightning/GeneralSettingsActivity.java
+++ b/src/acr/browser/lightning/GeneralSettingsActivity.java
@@ -44,6 +44,10 @@ public class GeneralSettingsActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.general_settings);
@@ -53,7 +57,6 @@ public class GeneralSettingsActivity extends ActionBarActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
diff --git a/src/acr/browser/lightning/LicenseActivity.java b/src/acr/browser/lightning/LicenseActivity.java
index e442f88..2cf3f17 100644
--- a/src/acr/browser/lightning/LicenseActivity.java
+++ b/src/acr/browser/lightning/LicenseActivity.java
@@ -4,6 +4,7 @@
package acr.browser.lightning;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
@@ -20,6 +21,10 @@ public class LicenseActivity extends ActionBarActivity implements View.OnClickLi
@Override
protected void onCreate(Bundle savedInstanceState) {
+ SharedPreferences preferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (preferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.license_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
diff --git a/src/acr/browser/lightning/LightningView.java b/src/acr/browser/lightning/LightningView.java
index 3814972..f0cadae 100644
--- a/src/acr/browser/lightning/LightningView.java
+++ b/src/acr/browser/lightning/LightningView.java
@@ -81,15 +81,20 @@ public class LightningView {
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
- public LightningView(Activity activity, String url) {
+ public LightningView(Activity activity, String url, boolean darkTheme) {
mActivity = activity;
mWebView = new WebView(activity);
- mTitle = new Title(activity);
+ mTitle = new Title(activity, darkTheme);
mAdBlock = new AdBlock(activity);
- mWebpageBitmap = BitmapFactory.decodeResource(activity.getResources(),
- R.drawable.ic_webpage);
+ if (darkTheme) {
+ mWebpageBitmap = BitmapFactory.decodeResource(activity.getResources(),
+ R.drawable.ic_webpage_dark);
+ } else {
+ mWebpageBitmap = BitmapFactory.decodeResource(activity.getResources(),
+ R.drawable.ic_webpage);
+ }
try {
mBrowserController = (BrowserController) activity;
@@ -1007,14 +1012,17 @@ public class LightningView {
public class Title {
private Bitmap mFavicon;
-
private String mTitle;
-
private Bitmap mDefaultIcon;
- public Title(Context context) {
- mDefaultIcon = BitmapFactory.decodeResource(context.getResources(),
- R.drawable.ic_webpage);
+ public Title(Context context, boolean darkTheme) {
+ if (darkTheme) {
+ mDefaultIcon = BitmapFactory.decodeResource(context.getResources(),
+ R.drawable.ic_webpage_dark);
+ } else {
+ mDefaultIcon = BitmapFactory.decodeResource(context.getResources(),
+ R.drawable.ic_webpage);
+ }
mFavicon = mDefaultIcon;
mTitle = mActivity.getString(R.string.action_new_tab);
}
diff --git a/src/acr/browser/lightning/MainActivity.java b/src/acr/browser/lightning/MainActivity.java
index a391219..8a4403e 100644
--- a/src/acr/browser/lightning/MainActivity.java
+++ b/src/acr/browser/lightning/MainActivity.java
@@ -12,13 +12,17 @@ import android.webkit.CookieSyncManager;
public class MainActivity extends BrowserActivity {
SharedPreferences mPreferences;
-
CookieManager mCookieManager;
+ private boolean mDark;
@Override
protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
+ if (mDark) {
+ this.setTheme(R.style.Theme_DarkTheme);
+ }
+ super.onCreate(savedInstanceState);
}
@Override
@@ -58,6 +62,15 @@ public class MainActivity extends BrowserActivity {
saveOpenTabs();
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (mPreferences != null
+ && mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false) != mDark) {
+ this.recreate();
+ }
+ }
+
@Override
public void updateHistory(String title, String url) {
super.updateHistory(title, url);
diff --git a/src/acr/browser/lightning/PrivacySettingsActivity.java b/src/acr/browser/lightning/PrivacySettingsActivity.java
index 00afa57..d8e55f3 100644
--- a/src/acr/browser/lightning/PrivacySettingsActivity.java
+++ b/src/acr/browser/lightning/PrivacySettingsActivity.java
@@ -39,6 +39,10 @@ public class PrivacySettingsActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.privacy_settings);
@@ -48,7 +52,6 @@ public class PrivacySettingsActivity extends ActionBarActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
diff --git a/src/acr/browser/lightning/ReadingActivity.java b/src/acr/browser/lightning/ReadingActivity.java
index 0ac5340..c1d8ef8 100644
--- a/src/acr/browser/lightning/ReadingActivity.java
+++ b/src/acr/browser/lightning/ReadingActivity.java
@@ -6,27 +6,50 @@ import java.util.List;
import acr.browser.lightning.reading.HtmlFetcher;
import acr.browser.lightning.reading.JResult;
import android.animation.ObjectAnimator;
+import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
+import android.view.LayoutInflater;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
public class ReadingActivity extends ActionBarActivity {
private TextView mTitle;
private TextView mBody;
+ private boolean mInvert;
+ private String mUrl = null;
+ private SharedPreferences mPreferences;
+ private int mTextSize;
+ private static final float XXLARGE = 30.0f;
+ private static final float XLARGE = 26.0f;
+ private static final float LARGE = 22.0f;
+ private static final float MEDIUM = 18.0f;
+ private static final float SMALL = 14.0f;
+ private static final float XSMALL = 10.0f;
@Override
protected void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ boolean initInvert = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
+ mInvert = mPreferences.getBoolean(PreferenceConstants.INVERT_COLORS, initInvert);
+ if (mInvert) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.reading_view);
-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@@ -35,6 +58,8 @@ public class ReadingActivity extends ActionBarActivity {
mTitle = (TextView) findViewById(R.id.textViewTitle);
mBody = (TextView) findViewById(R.id.textViewBody);
+ mTextSize = mPreferences.getInt(PreferenceConstants.READING_TEXT_SIZE, 2);
+ mBody.setTextSize(getTextSize(mTextSize));
mTitle.setText(getString(R.string.untitled));
mBody.setText(getString(R.string.loading));
@@ -47,16 +72,41 @@ public class ReadingActivity extends ActionBarActivity {
}
}
+ private float getTextSize(int size) {
+ switch (size) {
+ case 0:
+ return XSMALL;
+ case 1:
+ return SMALL;
+ case 2:
+ return MEDIUM;
+ case 3:
+ return LARGE;
+ case 4:
+ return XLARGE;
+ case 5:
+ return XXLARGE;
+ default:
+ return MEDIUM;
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.reading, menu);
+ return super.onCreateOptionsMenu(menu);
+ }
+
protected boolean loadPage(Intent intent) {
if (intent == null) {
return false;
}
- String url = intent.getStringExtra(Constants.LOAD_READING_URL);
- if (url == null) {
+ mUrl = intent.getStringExtra(Constants.LOAD_READING_URL);
+ if (mUrl == null) {
return false;
}
- getSupportActionBar().setTitle(Utils.getDomainName(url));
- new PageLoader(this).execute(url);
+ getSupportActionBar().setTitle(Utils.getDomainName(mUrl));
+ new PageLoader(this).execute(mUrl);
return true;
}
@@ -146,8 +196,57 @@ public class ReadingActivity extends ActionBarActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- finish();
+ switch (item.getItemId()) {
+ case R.id.invert_item:
+ mPreferences.edit().putBoolean(PreferenceConstants.INVERT_COLORS, !mInvert).apply();
+ Intent read = new Intent(this, ReadingActivity.class);
+ read.putExtra(Constants.LOAD_READING_URL, mUrl);
+ startActivity(read);
+ finish();
+ break;
+ case R.id.text_size_item:
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ LayoutInflater inflater = this.getLayoutInflater();
+ View view = inflater.inflate(R.layout.seek_layout, null);
+ final SeekBar bar = (SeekBar) view.findViewById(R.id.text_size_seekbar);
+ bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
+
+ @Override
+ public void onProgressChanged(SeekBar view, int size, boolean user) {
+ mBody.setTextSize(getTextSize(size));
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar arg0) {
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar arg0) {
+ }
+
+ });
+ bar.setMax(5);
+ bar.setProgress(mTextSize);
+ builder.setView(view);
+ builder.setTitle(R.string.size);
+ builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface arg0, int arg1) {
+ mTextSize = bar.getProgress();
+ mBody.setTextSize(getTextSize(mTextSize));
+ mPreferences.edit()
+ .putInt(PreferenceConstants.READING_TEXT_SIZE, bar.getProgress())
+ .apply();
+ }
+
+ });
+ builder.show();
+ break;
+ default:
+ finish();
+ break;
+ }
return super.onOptionsItemSelected(item);
}
-
}
diff --git a/src/acr/browser/lightning/SearchAdapter.java b/src/acr/browser/lightning/SearchAdapter.java
index d8f9334..5eb3612 100644
--- a/src/acr/browser/lightning/SearchAdapter.java
+++ b/src/acr/browser/lightning/SearchAdapter.java
@@ -49,7 +49,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
private Context mContext;
private boolean mUseGoogle = true;
private boolean mIsExecuting = false;
- private boolean mIncognito;
+ private boolean mDarkTheme;
private BookmarkManager mBookmarkManager;
private static final String ENCODING = "ISO-8859-1";
private static final long INTERVAL_DAY = 86400000;
@@ -59,7 +59,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
private static final int API = Build.VERSION.SDK_INT;
private Theme mTheme;
- public SearchAdapter(Context context, boolean incognito) {
+ public SearchAdapter(Context context, boolean dark) {
mDatabaseHandler = HistoryDatabase.getInstance(context);
mTheme = context.getTheme();
mFilteredList = new ArrayList();
@@ -72,7 +72,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
mContext = context;
mSearchSubtitle = mContext.getString(R.string.suggestion);
- mIncognito = incognito;
+ mDarkTheme = dark;
Thread delete = new Thread(new Runnable() {
@Override
@@ -164,7 +164,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
int imageId = R.drawable.ic_bookmark;
switch (web.getImageId()) {
case R.drawable.ic_bookmark: {
- if (!mIncognito) {
+ if (!mDarkTheme) {
imageId = R.drawable.ic_bookmark;
} else {
holder.mTitle.setTextColor(Color.WHITE);
@@ -173,7 +173,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
break;
}
case R.drawable.ic_search: {
- if (!mIncognito) {
+ if (!mDarkTheme) {
imageId = R.drawable.ic_search;
} else {
holder.mTitle.setTextColor(Color.WHITE);
@@ -182,7 +182,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
break;
}
case R.drawable.ic_history: {
- if (!mIncognito) {
+ if (!mDarkTheme) {
imageId = R.drawable.ic_history;
} else {
holder.mTitle.setTextColor(Color.WHITE);
@@ -225,7 +225,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
return results;
}
String query = constraint.toString().toLowerCase(Locale.getDefault());
- if (mUseGoogle && !mIncognito && !mIsExecuting) {
+ if (mUseGoogle && !mDarkTheme && !mIsExecuting) {
new RetrieveSearchSuggestions().execute(query);
}
@@ -403,7 +403,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
int maxBookmarks = (suggestionsSize + historySize < 3) ? (5 - suggestionsSize - historySize)
: 2;
- if (!mUseGoogle || mIncognito) {
+ if (!mUseGoogle || mDarkTheme) {
maxHistory++;
maxBookmarks++;
}
diff --git a/src/acr/browser/lightning/SettingsActivity.java b/src/acr/browser/lightning/SettingsActivity.java
index 7e03894..524b5e3 100644
--- a/src/acr/browser/lightning/SettingsActivity.java
+++ b/src/acr/browser/lightning/SettingsActivity.java
@@ -35,32 +35,46 @@ public class SettingsActivity extends ActionBarActivity {
private SharedPreferences mPreferences;
private Context mContext;
private Activity mActivity;
+ private boolean mDark;
@Override
protected void onCreate(Bundle savedInstanceState) {
+ mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
+ if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
+ this.setTheme(R.style.Theme_SettingsTheme_Dark);
+ }
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
+ mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
mContext = this;
mActivity = this;
init();
}
-
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (mPreferences != null
+ && mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false) != mDark) {
+ this.recreate();
+ }
+ }
+
@SuppressLint("NewApi")
public void init() {
// set up ActionBar
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// mPreferences storage
- mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
@@ -76,14 +90,14 @@ public class SettingsActivity extends ActionBarActivity {
RelativeLayout layoutOrbot = (RelativeLayout) findViewById(R.id.layoutUseOrbot);
RelativeLayout layoutColor = (RelativeLayout) findViewById(R.id.layoutColorMode);
RelativeLayout layoutBookmarks = (RelativeLayout) findViewById(R.id.layoutBookmarks);
-
- layoutBookmarks.setOnClickListener(new OnClickListener(){
+
+ layoutBookmarks.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(mContext, BookmarkActivity.class));
}
-
+
});
if (API >= 19) {
@@ -113,7 +127,7 @@ public class SettingsActivity extends ActionBarActivity {
color.setChecked(mPreferences.getBoolean(PreferenceConstants.ENABLE_COLOR_MODE, true));
initCheckBox(flash, adblock, images, enablejs, orbot, color);
- clickListenerForCheckBoxes(layoutFlash, layoutBlockAds, layoutImages, layoutEnableJS,
+ clickListenerForCheckBoxes(layoutFlash, layoutBlockAds, layoutImages, layoutEnableJS,
layoutOrbot, layoutColor, flash, adblock, images, enablejs, orbot, color);
RelativeLayout general = (RelativeLayout) findViewById(R.id.layoutGeneral);
@@ -129,10 +143,11 @@ public class SettingsActivity extends ActionBarActivity {
about(about);
}
- public void clickListenerForCheckBoxes(RelativeLayout layoutFlash, RelativeLayout layoutBlockAds,
- RelativeLayout layoutImages, RelativeLayout layoutEnableJS, RelativeLayout layoutOrbot, RelativeLayout layoutColor,
- final CheckBox flash, final CheckBox adblock, final CheckBox images, final CheckBox enablejs,
- final CheckBox orbot, final CheckBox color) {
+ public void clickListenerForCheckBoxes(RelativeLayout layoutFlash,
+ RelativeLayout layoutBlockAds, RelativeLayout layoutImages,
+ RelativeLayout layoutEnableJS, RelativeLayout layoutOrbot, RelativeLayout layoutColor,
+ final CheckBox flash, final CheckBox adblock, final CheckBox images,
+ final CheckBox enablejs, final CheckBox orbot, final CheckBox color) {
layoutFlash.setOnClickListener(new OnClickListener() {
@Override
@@ -183,13 +198,13 @@ public class SettingsActivity extends ActionBarActivity {
}
});
- layoutColor.setOnClickListener(new OnClickListener(){
+ layoutColor.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
color.setChecked(!color.isChecked());
}
-
+
});
}