Added an AMOLED Black theme, changed from tabs to spaces for some files

This commit is contained in:
Anthony Restaino 2015-05-13 10:35:32 -04:00
parent b400ef0647
commit 9f8dff8c5d
15 changed files with 394 additions and 216 deletions

View File

@ -162,7 +162,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
ActionBar actionBar = getSupportActionBar();
mPreferences = PreferenceManager.getInstance();
mDarkTheme = mPreferences.getUseDarkTheme() || isIncognito();
//TODO make sure dark theme flag gets set correctly
mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito();
mActivity = this;
mWebViews.clear();

View File

@ -14,6 +14,7 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.R;
@ -22,8 +23,10 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
// mPreferences variables
private PreferenceManager mPreferences;
private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow,
cbDarkTheme;
private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow;
private String[] mThemeOptions;
private TextView mThemeText;
private int mCurrentTheme;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -35,6 +38,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mPreferences = PreferenceManager.getInstance();
mThemeOptions = this.getResources().getStringArray(R.array.themes);
initialize();
}
@ -56,7 +60,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
rOverView = (RelativeLayout) findViewById(R.id.rOverView);
rTextReflow = (RelativeLayout) findViewById(R.id.rTextReflow);
rTextSize = (RelativeLayout) findViewById(R.id.rTextSize);
rDarkTheme = (RelativeLayout) findViewById(R.id.rDarkTheme);
rDarkTheme = (RelativeLayout) findViewById(R.id.rTheme);
rHideStatusBar.setOnClickListener(clickListener);
rFullScreen.setOnClickListener(clickListener);
@ -66,26 +70,28 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
rTextSize.setOnClickListener(clickListener);
rDarkTheme.setOnClickListener(clickListener);
mThemeText = (TextView) findViewById(R.id.textViewTheme);
mCurrentTheme = mPreferences.getUseTheme();
mThemeText.setText(mThemeOptions[mPreferences.getUseTheme()]);
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.getHideStatusBarEnabled());
cbFullScreen.setChecked(mPreferences.getFullScreenEnabled());
cbWideViewPort.setChecked(mPreferences.getUseWideViewportEnabled());
cbOverView.setChecked(mPreferences.getOverviewModeEnabled());
cbTextReflow.setChecked(mPreferences.getTextReflowEnabled());
cbDarkTheme.setChecked(mPreferences.getUseDarkTheme());
cbHideStatusBar.setOnCheckedChangeListener(toggleListener);
cbFullScreen.setOnCheckedChangeListener(toggleListener);
cbWideViewPort.setOnCheckedChangeListener(toggleListener);
cbOverView.setOnCheckedChangeListener(toggleListener);
cbTextReflow.setOnCheckedChangeListener(toggleListener);
cbDarkTheme.setOnCheckedChangeListener(toggleListener);
}
private class LayoutClickListener implements OnClickListener {
@ -111,8 +117,8 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
case R.id.rTextSize:
textSizePicker();
break;
case R.id.rDarkTheme:
cbDarkTheme.setChecked(!cbDarkTheme.isChecked());
case R.id.rTheme:
themePicker();
break;
}
}
@ -139,10 +145,6 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
case R.id.cbTextReflow:
mPreferences.setTextReflowEnabled(isChecked);
break;
case R.id.cbDarkTheme:
mPreferences.setUseDarkTheme(isChecked);
restart();
break;
}
}
@ -172,4 +174,41 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
});
picker.show();
}
private void themePicker() {
AlertDialog.Builder picker = new AlertDialog.Builder(DisplaySettingsActivity.this);
picker.setTitle(getResources().getString(R.string.url_contents));
int n = mPreferences.getUseTheme();
picker.setSingleChoiceItems(mThemeOptions, n, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferences.setUseTheme(which);
if (which < mThemeOptions.length) {
mThemeText.setText(mThemeOptions[which]);
}
}
});
picker.setNeutralButton(getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mCurrentTheme != mPreferences.getUseTheme()) {
restart();
}
}
});
picker.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (mCurrentTheme != mPreferences.getUseTheme()) {
restart();
}
}
});
picker.show();
}
}

View File

@ -9,15 +9,17 @@ import acr.browser.lightning.preference.PreferenceManager;
public abstract class ThemableActivity extends AppCompatActivity {
private boolean mDark;
private int mTheme;
@Override
protected void onCreate(Bundle savedInstanceState) {
mDark = PreferenceManager.getInstance().getUseDarkTheme();
mTheme = PreferenceManager.getInstance().getUseTheme();
// set the theme
if (mDark) {
if (mTheme == 1) {
setTheme(R.style.Theme_DarkTheme);
} else if (mTheme == 2) {
setTheme(R.style.Theme_BlackTheme);
}
super.onCreate(savedInstanceState);
}
@ -25,7 +27,7 @@ public abstract class ThemableActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
if (PreferenceManager.getInstance().getUseDarkTheme() != mDark) {
if (PreferenceManager.getInstance().getUseTheme() != mTheme) {
restart();
}
}

View File

@ -1,6 +1,7 @@
package acr.browser.lightning.activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
@ -9,15 +10,18 @@ import acr.browser.lightning.preference.PreferenceManager;
public abstract class ThemableSettingsActivity extends AppCompatActivity {
private boolean mDark;
private int mTheme;
@Override
protected void onCreate(Bundle savedInstanceState) {
mDark = PreferenceManager.getInstance().getUseDarkTheme();
mTheme = PreferenceManager.getInstance().getUseTheme();
// set the theme
if (mDark) {
if (mTheme == 1) {
setTheme(R.style.Theme_SettingsTheme_Dark);
} else if (mTheme == 2) {
setTheme(R.style.Theme_SettingsTheme_Black);
this.getWindow().setBackgroundDrawable(new ColorDrawable(this.getResources().getColor(R.color.black)));
}
super.onCreate(savedInstanceState);
}
@ -25,7 +29,7 @@ public abstract class ThemableSettingsActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
if (PreferenceManager.getInstance().getUseDarkTheme() != mDark) {
if (PreferenceManager.getInstance().getUseTheme() != mTheme) {
restart();
}
}

View File

@ -116,6 +116,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
if (!mUseGoogle && mSuggestions != null) {
mSuggestions.clear();
}
mDatabaseHandler = HistoryDatabase.getInstance(mContext.getApplicationContext());
}
public void refreshBookmarks() {

View File

@ -45,7 +45,7 @@ public class PreferenceManager {
public static final String URL_BOX_CONTENTS = "urlContent";
public static final String INVERT_COLORS = "invertColors";
public static final String READING_TEXT_SIZE = "readingTextSize";
public static final String DARK_THEME = "darkTheme";
public static final String THEME = "Theme";
public static final String DEFAULT_BOOKMARKS = "defaultBookmarks";
public static final String USE_PROXY = "useProxy";
@ -218,8 +218,8 @@ public class PreferenceManager {
return mPrefs.getInt(Name.URL_BOX_CONTENTS, 0);
}
public boolean getUseDarkTheme() {
return mPrefs.getBoolean(Name.DARK_THEME, false);
public int getUseTheme() {
return mPrefs.getInt(Name.THEME, 0);
}
public boolean getUseProxy() {
@ -390,8 +390,8 @@ public class PreferenceManager {
putInt(Name.URL_BOX_CONTENTS, choice);
}
public void setUseDarkTheme(boolean use) {
putBoolean(Name.DARK_THEME, use);
public void setUseTheme(int theme) {
putInt(Name.THEME, theme);
}
public void setUseProxy(boolean enable) {

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle" >
<solid android:color="@color/black" />
</shape>
</item>
<item android:bottom="1dp">
<shape
android:shape="rectangle" >
<solid android:color="@color/black" />
</shape>
</item>
</layer-list>

View File

@ -87,7 +87,7 @@
android:background="?attr/dividerColor" />
<RelativeLayout
android:id="@+id/rDarkTheme"
android:id="@+id/rTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/listChoiceBackgroundIndicator"
@ -96,6 +96,13 @@
android:paddingRight="10dp"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -103,15 +110,20 @@
android:layout_centerVertical="true"
android:paddingLeft="16dp"
android:paddingRight="30dp"
android:text="@string/dark_theme"
android:text="@string/theme"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/cbDarkTheme"
<TextView
android:id="@+id/textViewTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
android:paddingLeft="16dp"
android:paddingRight="30dp"
android:text="CURRENT THEME"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light" />
</LinearLayout>
</RelativeLayout>
<LinearLayout

View File

@ -211,7 +211,7 @@
<item >Cím</item>
</string-array>
<string name="invert_color">Negatív szín</string>
<string name="dark_theme">Sötét téma használata</string>
<string name="dark_theme">Sötét téma </string>
<string name="change_after_restart">A téma megváltoztatásának érvénybelépéséhez indítsa újra a böngészőt.</string>
<string name="tabs">Lapok</string>
</resources>

View File

@ -211,7 +211,7 @@
<item >Título</item>
</string-array>
<string name="invert_color">Inverter cores</string>
<string name="dark_theme">Utilizar tema escuro</string>
<string name="dark_theme">Tema escuro</string>
<string name="change_after_restart">Esta opção será aplicada depois de reiniciar a aplicação.</string>
<string name="tabs">Separadores</string>
</resources>

View File

@ -208,7 +208,7 @@
<item >Наслов</item>
</string-array>
<string name="invert_color">Обрнута боја</string>
<string name="dark_theme">Тамна тема</string>
<string name="change_after_restart">Промена теме ће бити извршена по поновном покретању прегледача.</string>
<string name="tabs">Језичци</string>
<string name="dark_theme">Тамна тема</string>
</resources>

View File

@ -33,6 +33,22 @@
<item name="dividerColor">@color/divider_dark</item>
</style>
<style name="Theme.SettingsTheme.Black" parent="Theme.AppCompat">
<!-- customize the color palette -->
<item name="toolbarSettingsBackground">@color/black</item>
<item name="listBackground">?attr/listChoiceBackgroundIndicator</item>
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/accent_color</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="invertColorDrawable">@drawable/ic_action_invert_dark</item>
<item name="textSizeDrawable">@drawable/ic_action_text_size_dark</item>
<item name="dividerColor">@color/divider_dark</item>
</style>
<style name="Theme.LightTheme" parent="Theme.AppCompat.Light">
<!-- customize the color palette -->
@ -101,4 +117,35 @@
<item name="android:windowTranslucentStatus">false</item>
</style>
<style name="Theme.BlackTheme" parent="Theme.AppCompat">
<!-- customize the color palette -->
<item name="searchBackground">@drawable/card_bg_elevate</item>
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/accent_color</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="progressBackgroundColor">#00000000</item>
<item name="listBackground">?attr/listChoiceBackgroundIndicator</item>
<item name="android:windowContentOverlay">@null</item>
<item name="progressColor">@color/gray_medium</item>
<item name="numberColor">@color/gray_dark</item>
<item name="autoCompleteTitleColor">@color/black</item>
<item name="autoCompleteUrlColor">@color/gray_medium</item>
<item name="arrowBackDrawable">@drawable/ic_action_back_dark</item>
<item name="arrowForwardDrawable">@drawable/ic_action_forward_dark</item>
<item name="actionOverflowButtonStyle">@style/overFlowButtonStyle</item>
<item name="drawerBackground">@color/black</item>
<item name="plusDrawable">@drawable/ic_action_plus_dark</item>
<item name="deleteDrawable">@drawable/ic_action_delete_dark</item>
<item name="starDrawable">@drawable/ic_action_star_dark</item>
<item name="tabDrawable">@drawable/ic_action_tabs_dark</item>
<item name="dividerColor">@color/black</item>
<item name="selectedBackground">@drawable/list_bg_dark</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/black</item>
<item name="android:windowTranslucentStatus">false</item>
</style>
</resources>

View File

@ -26,4 +26,10 @@
<item>@string/size_small</item>
<item>@string/size_smallest</item>
</string-array>
<string-array name="themes">
<item>@string/light_theme</item>
<item>@string/dark_theme</item>
<item>@string/black_theme</item>
</string-array>
</resources>

View File

@ -211,7 +211,10 @@
<item >Title</item>
</string-array>
<string name="invert_color">Invert color</string>
<string name="dark_theme">Use Dark Theme</string>
<string name="dark_theme">Dark Theme</string>
<string name="change_after_restart">The theme change will take effect after you restart the browser.</string>
<string name="tabs">Tabs</string>
<string name="theme">App Theme</string>
<string name="light_theme">Light Theme</string>
<string name="black_theme">Black Theme (AMOLED)</string>
</resources>

View File

@ -33,6 +33,22 @@
<item name="dividerColor">@color/divider_dark</item>
</style>
<style name="Theme.SettingsTheme.Black" parent="Theme.AppCompat">
<!-- customize the color palette -->
<item name="toolbarSettingsBackground">@drawable/toolbar_elevate_black</item>
<item name="listBackground">@drawable/list_bg</item>
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/accent_color</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="invertColorDrawable">@drawable/ic_action_invert_dark</item>
<item name="textSizeDrawable">@drawable/ic_action_text_size_dark</item>
<item name="dividerColor">@color/divider_dark</item>
</style>
<style name="Theme.LightTheme" parent="Theme.AppCompat.Light">
<!-- customize the color palette -->
@ -89,6 +105,34 @@
<item name="selectedBackground">@drawable/list_bg_dark</item>
</style>
<style name="Theme.BlackTheme" parent="Theme.AppCompat">
<!-- customize the color palette -->
<item name="searchBackground">@drawable/card_bg_elevate</item>
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/accent_color</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="progressBackgroundColor">@color/black</item>
<item name="listBackground">@drawable/list_bg</item>
<item name="android:windowContentOverlay">@null</item>
<item name="progressColor">@color/gray_medium</item>
<item name="numberColor">@color/gray_dark</item>
<item name="autoCompleteTitleColor">@color/black</item>
<item name="autoCompleteUrlColor">@color/gray_medium</item>
<item name="arrowBackDrawable">@drawable/ic_action_back_dark</item>
<item name="arrowForwardDrawable">@drawable/ic_action_forward_dark</item>
<item name="actionOverflowButtonStyle">@style/overFlowButtonStyle</item>
<item name="drawerBackground">@color/black</item>
<item name="plusDrawable">@drawable/ic_action_plus_dark</item>
<item name="deleteDrawable">@drawable/ic_action_delete_dark</item>
<item name="starDrawable">@drawable/ic_action_star_dark</item>
<item name="tabDrawable">@drawable/ic_action_tabs_dark</item>
<item name="dividerColor">@color/black</item>
<item name="selectedBackground">@drawable/list_bg_dark</item>
</style>
<style name="overFlowButtonStyle" parent="@style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:minWidth">48dp</item>
<item name="android:padding">0dp</item>