Added option to enable/disable Color Mode
This commit is contained in:
parent
c2b436ecfe
commit
8314676918
@ -187,6 +187,41 @@
|
||||
android:layout_centerVertical="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layoutColorMode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="60dp"
|
||||
android:text="@string/color_mode"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbColorMode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -197,4 +197,5 @@
|
||||
<string name="close_all_tabs">Close all tabs</string>
|
||||
<string name="third_party">Block 3rd Party Cookies</string>
|
||||
<string name="available_lollipop">This feature is only available on Android 5.0+</string>
|
||||
<string name="color_mode">Enable Color Mode</string>
|
||||
</resources>
|
||||
|
@ -102,6 +102,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
private int mActionBarSize;
|
||||
private ActionBar mActionBar;
|
||||
private boolean mFullScreen;
|
||||
private boolean mColorMode;
|
||||
private FrameLayout mBrowserFrame;
|
||||
private LinearLayout mPageLayout;
|
||||
private LinearLayout mUiLayout;
|
||||
@ -494,7 +495,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
initializePreferences();
|
||||
initializeTabs();
|
||||
|
||||
if (API < 19) {
|
||||
if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
|
||||
}
|
||||
|
||||
@ -720,17 +721,20 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
}
|
||||
mFullScreen = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false);
|
||||
if (mFullScreen) {
|
||||
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
|
||||
mUiLayout.removeView(mToolbarLayout);
|
||||
mBrowserFrame.addView(mToolbarLayout);
|
||||
mToolbarLayout.bringToFront();
|
||||
}
|
||||
} else {
|
||||
if (mBrowserFrame.findViewById(R.id.toolbar_layout) != null) {
|
||||
mBrowserFrame.removeView(mToolbarLayout);
|
||||
mUiLayout.addView(mToolbarLayout, 0);
|
||||
}
|
||||
mColorMode = mPreferences.getBoolean(PreferenceConstants.ENABLE_COLOR_MODE, true);
|
||||
|
||||
if (!isIncognito() && !mColorMode && mWebpageBitmap != null)
|
||||
changeToolbarBackground(mWebpageBitmap);
|
||||
else if (!isIncognito() && mCurrentView != null && mCurrentView.getFavicon() != null)
|
||||
changeToolbarBackground(mCurrentView.getFavicon());
|
||||
|
||||
if (mFullScreen && mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
|
||||
mUiLayout.removeView(mToolbarLayout);
|
||||
mBrowserFrame.addView(mToolbarLayout);
|
||||
mToolbarLayout.bringToFront();
|
||||
} else if (mBrowserFrame.findViewById(R.id.toolbar_layout) != null) {
|
||||
mBrowserFrame.removeView(mToolbarLayout);
|
||||
mUiLayout.addView(mToolbarLayout, 0);
|
||||
}
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
@ -1180,9 +1184,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
}
|
||||
|
||||
public void handleNewIntent(Intent intent) {
|
||||
if (mCurrentView == null) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
String url = null;
|
||||
if (intent != null) {
|
||||
@ -1534,8 +1535,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
}
|
||||
mBookmarkList = mBookmarkManager.getBookmarks(true);
|
||||
notifyBookmarkDataSetChanged();
|
||||
} else {
|
||||
initialize();
|
||||
}
|
||||
initializePreferences();
|
||||
if (mWebViews != null) {
|
||||
@ -1546,8 +1545,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
mWebViews.remove(n);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1696,7 +1693,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
if (web.isForegroundTab()) {
|
||||
|
||||
holder.favicon.setImageBitmap(favicon);
|
||||
if (!isIncognito())
|
||||
if (!isIncognito() && mColorMode)
|
||||
changeToolbarBackground(favicon);
|
||||
} else {
|
||||
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(),
|
||||
|
@ -41,6 +41,7 @@ public final class PreferenceConstants {
|
||||
public static final String RENDERING_MODE = "renderMode";
|
||||
public static final String SYNC_HISTORY = "syncHistory";
|
||||
public static final String BLOCK_THIRD_PARTY = "thirdParty";
|
||||
public static final String ENABLE_COLOR_MODE = "colorMode";
|
||||
|
||||
public static final String USE_PROXY = "useProxy";
|
||||
public static final String USE_PROXY_HOST = "useProxyHost";
|
||||
|
@ -74,6 +74,7 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
RelativeLayout layoutImages = (RelativeLayout) findViewById(R.id.layoutImages);
|
||||
RelativeLayout layoutEnableJS = (RelativeLayout) findViewById(R.id.layoutEnableJS);
|
||||
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(){
|
||||
@ -98,6 +99,7 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
CheckBox images = (CheckBox) findViewById(R.id.cbImageBlock);
|
||||
CheckBox enablejs = (CheckBox) findViewById(R.id.cbJavascript);
|
||||
CheckBox orbot = (CheckBox) findViewById(R.id.cbOrbot);
|
||||
CheckBox color = (CheckBox) findViewById(R.id.cbColorMode);
|
||||
|
||||
images.setChecked(imagesBool);
|
||||
enablejs.setChecked(enableJSBool);
|
||||
@ -108,10 +110,11 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
}
|
||||
adblock.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false));
|
||||
orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false));
|
||||
color.setChecked(mPreferences.getBoolean(PreferenceConstants.ENABLE_COLOR_MODE, true));
|
||||
|
||||
initCheckBox(flash, adblock, images, enablejs, orbot);
|
||||
initCheckBox(flash, adblock, images, enablejs, orbot, color);
|
||||
clickListenerForCheckBoxes(layoutFlash, layoutBlockAds, layoutImages, layoutEnableJS,
|
||||
layoutOrbot, flash, adblock, images, enablejs, orbot);
|
||||
layoutOrbot, layoutColor, flash, adblock, images, enablejs, orbot, color);
|
||||
|
||||
RelativeLayout general = (RelativeLayout) findViewById(R.id.layoutGeneral);
|
||||
RelativeLayout display = (RelativeLayout) findViewById(R.id.layoutDisplay);
|
||||
@ -127,9 +130,9 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
public void clickListenerForCheckBoxes(RelativeLayout layoutFlash, RelativeLayout layoutBlockAds,
|
||||
RelativeLayout layoutImages, RelativeLayout layoutEnableJS, RelativeLayout layoutOrbot,
|
||||
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 orbot, final CheckBox color) {
|
||||
layoutFlash.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
@ -180,10 +183,18 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
});
|
||||
layoutColor.setOnClickListener(new OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
color.setChecked(!color.isChecked());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void initCheckBox(CheckBox flash, CheckBox adblock, CheckBox images, CheckBox enablejs,
|
||||
CheckBox orbot) {
|
||||
CheckBox orbot, CheckBox color) {
|
||||
flash.setEnabled(API < 19);
|
||||
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@ -266,6 +277,16 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
});
|
||||
color.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mEditPrefs.putBoolean(PreferenceConstants.ENABLE_COLOR_MODE, isChecked);
|
||||
mEditPrefs.commit();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void getFlashChoice() {
|
||||
|
Loading…
Reference in New Issue
Block a user