Added option to change rendering mode
This commit is contained in:
parent
d191bf151e
commit
52fcf8fdc0
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/scrollView1"
|
||||
android:layout_width="match_parent"
|
||||
@ -14,11 +13,11 @@
|
||||
android:id="@+id/layoutLocation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:paddingRight="10dp" >
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
@ -51,11 +50,11 @@
|
||||
android:id="@+id/layoutFullScreen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:paddingRight="10dp" >
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
@ -88,11 +87,11 @@
|
||||
android:id="@+id/layoutFlash"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:paddingRight="10dp" >
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
@ -125,11 +124,11 @@
|
||||
android:id="@+id/layoutAdBlock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:paddingRight="10dp" >
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@ -161,11 +160,11 @@
|
||||
android:id="@+id/layoutUseOrbot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:paddingRight="10dp" >
|
||||
android:minHeight="60dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@ -197,10 +196,10 @@
|
||||
android:id="@+id/layoutUserAgent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -239,10 +238,10 @@
|
||||
android:id="@+id/layoutDownload"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -281,10 +280,10 @@
|
||||
android:id="@+id/layoutHomepage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -323,10 +322,10 @@
|
||||
android:id="@+id/layoutSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -353,6 +352,40 @@
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#cdcdcd" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutRendering"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/rendering_mode"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/renderText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="Small Text"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/light" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
@ -364,10 +397,10 @@
|
||||
android:id="@+id/layoutAdvanced"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView8"
|
||||
@ -391,10 +424,10 @@
|
||||
android:id="@+id/layoutSource"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -433,10 +466,10 @@
|
||||
android:id="@+id/layoutLicense"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -452,8 +485,6 @@
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/licenses"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
@ -468,10 +499,10 @@
|
||||
android:id="@+id/layoutVersion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator"
|
||||
android:minHeight="60dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="?android:attr/listChoiceBackgroundIndicator" >
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -505,4 +536,5 @@
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#cdcdcd" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -172,4 +172,10 @@
|
||||
<string name="freeware">Freeware</string>
|
||||
<string name="android_open_source_project">Android Open Source Project</string>
|
||||
<string name="hphosts_ad_server_list">hpHosts Ad Server List</string>
|
||||
<string name="deleted_tab">Reopened old tab</string>
|
||||
<string name="rendering_mode">Rendering Mode</string>
|
||||
<string name="name_inverted">Inverted</string>
|
||||
<string name="name_grayscale">Grayscale</string>
|
||||
<string name="name_inverted_grayscale">Inverted Grayscale</string>
|
||||
<string name="name_normal">Normal</string>
|
||||
</resources>
|
||||
|
@ -266,6 +266,9 @@ public class LightningView {
|
||||
} else if (mSettings == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setColorMode(mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0));
|
||||
|
||||
mSettings.setGeolocationEnabled(mPreferences
|
||||
.getBoolean(PreferenceConstants.LOCATION, false));
|
||||
if (API < 19) {
|
||||
@ -355,7 +358,6 @@ public class LightningView {
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
|
||||
public void initializeSettings(WebSettings settings, Context context) {
|
||||
this.setNormalRendering();
|
||||
if (API < 18) {
|
||||
settings.setAppCacheMaxSize(Long.MAX_VALUE);
|
||||
}
|
||||
@ -441,18 +443,33 @@ public class LightningView {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
mPaint.setColorFilter(null);
|
||||
setNormalRendering();
|
||||
break;
|
||||
case 1:
|
||||
ColorMatrixColorFilter filterInvert = new ColorMatrixColorFilter(
|
||||
mNegativeColorArray);
|
||||
mPaint.setColorFilter(filterInvert);
|
||||
setHardwareRendering();
|
||||
break;
|
||||
case 2:
|
||||
ColorMatrix cm = new ColorMatrix();
|
||||
cm.setSaturation(0);
|
||||
ColorMatrixColorFilter filterGray = new ColorMatrixColorFilter(cm);
|
||||
mPaint.setColorFilter(filterGray);
|
||||
setHardwareRendering();
|
||||
break;
|
||||
case 3:
|
||||
ColorMatrix matrix = new ColorMatrix();
|
||||
matrix.set(mNegativeColorArray);
|
||||
ColorMatrix matrixGray = new ColorMatrix();
|
||||
matrixGray.setSaturation(0);
|
||||
ColorMatrix concat = new ColorMatrix();
|
||||
concat.setConcat(matrix, matrixGray);
|
||||
ColorMatrixColorFilter filterInvertGray = new ColorMatrixColorFilter(concat);
|
||||
mPaint.setColorFilter(filterInvertGray);
|
||||
setHardwareRendering();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,29 +33,18 @@ import info.guardianproject.onionkit.ui.OrbotHelper;
|
||||
public class SettingsActivity extends Activity {
|
||||
|
||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
private SharedPreferences.Editor mEditPrefs;
|
||||
|
||||
private int mAgentChoice;
|
||||
|
||||
private String mHomepage;
|
||||
|
||||
private TextView mAgentTextView;
|
||||
|
||||
private TextView mDownloadTextView;
|
||||
|
||||
private int mEasterEggCounter;
|
||||
|
||||
private String mDownloadLocation;
|
||||
|
||||
private TextView mHomepageText;
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
|
||||
private TextView mSearchText;
|
||||
|
||||
private TextView mRenderText;
|
||||
private Context mContext;
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
@Override
|
||||
@ -98,6 +87,7 @@ public class SettingsActivity extends Activity {
|
||||
RelativeLayout layoutOrbot = (RelativeLayout) findViewById(R.id.layoutUseOrbot);
|
||||
|
||||
mSearchText = (TextView) findViewById(R.id.searchText);
|
||||
mRenderText = (TextView) findViewById(R.id.renderText);
|
||||
|
||||
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
|
||||
case 0:
|
||||
@ -134,6 +124,21 @@ public class SettingsActivity extends Activity {
|
||||
mSearchText.setText("Yandex");
|
||||
}
|
||||
|
||||
switch (mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0)) {
|
||||
case 0:
|
||||
mRenderText.setText(mContext.getString(R.string.name_normal));
|
||||
break;
|
||||
case 1:
|
||||
mRenderText.setText(mContext.getString(R.string.name_inverted));
|
||||
break;
|
||||
case 2:
|
||||
mRenderText.setText(mContext.getString(R.string.name_grayscale));
|
||||
break;
|
||||
case 3:
|
||||
mRenderText.setText(mContext.getString(R.string.name_inverted_grayscale));
|
||||
break;
|
||||
}
|
||||
|
||||
mAgentTextView = (TextView) findViewById(R.id.agentText);
|
||||
mHomepageText = (TextView) findViewById(R.id.homepageText);
|
||||
mDownloadTextView = (TextView) findViewById(R.id.downloadText);
|
||||
@ -244,6 +249,7 @@ public class SettingsActivity extends Activity {
|
||||
advanced(advanced);
|
||||
source(source);
|
||||
search();
|
||||
renderPicker();
|
||||
easterEgg();
|
||||
}
|
||||
|
||||
@ -318,6 +324,57 @@ public class SettingsActivity extends Activity {
|
||||
});
|
||||
}
|
||||
|
||||
public void renderPicker() {
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.layoutRendering);
|
||||
layout.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
|
||||
picker.setTitle(getResources().getString(R.string.rendering_mode));
|
||||
CharSequence[] chars = { mContext.getString(R.string.name_normal),
|
||||
mContext.getString(R.string.name_inverted),
|
||||
mContext.getString(R.string.name_grayscale),
|
||||
mContext.getString(R.string.name_inverted_grayscale) };
|
||||
|
||||
int n = mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0);
|
||||
|
||||
picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mEditPrefs.putInt(PreferenceConstants.RENDERING_MODE, which).apply();
|
||||
switch (which) {
|
||||
case 0:
|
||||
mRenderText.setText(mContext.getString(R.string.name_normal));
|
||||
break;
|
||||
case 1:
|
||||
mRenderText.setText(mContext.getString(R.string.name_inverted));
|
||||
break;
|
||||
case 2:
|
||||
mRenderText.setText(mContext.getString(R.string.name_grayscale));
|
||||
break;
|
||||
case 3:
|
||||
mRenderText.setText(mContext
|
||||
.getString(R.string.name_inverted_grayscale));
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
picker.setNeutralButton(getResources().getString(R.string.action_ok),
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
picker.show();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void searchUrlPicker() {
|
||||
final AlertDialog.Builder urlPicker = new AlertDialog.Builder(this);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user