Browse Source

Added text encoding setting, updated support libraries

master
Anthony Restaino 9 years ago
parent
commit
3b13999b03
  1. 18
      app/app.iml
  2. 16
      app/build.gradle
  3. 6
      app/src/main/java/acr/browser/lightning/constant/Constants.java
  4. 38
      app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java
  5. 15
      app/src/main/java/acr/browser/lightning/preference/PreferenceManager.java
  6. 7
      app/src/main/java/acr/browser/lightning/view/LightningView.java
  7. 1
      app/src/main/res/values/strings.xml
  8. 11
      app/src/main/res/xml/preference_advanced.xml

18
app/app.iml

@ -92,10 +92,10 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
@ -114,13 +114,13 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 22 Platform (1)" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 22 Platform (1)" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="palette-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="client-0.7" level="project" /> <orderEntry type="library" exported="" name="client-0.7" level="project" />
<orderEntry type="library" exported="" name="palette-v7-22.2.0" level="project" /> <orderEntry type="library" exported="" name="design-22.2.1" level="project" />
<orderEntry type="library" exported="" name="design-22.2.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" /> <orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" /> <orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
<orderEntry type="module" module-name="libnetcipher" exported="" /> <orderEntry type="module" module-name="libnetcipher" exported="" />
</component> </component>
</module> </module>

16
app/build.gradle

@ -3,13 +3,11 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 22 compileSdkVersion 22
buildToolsVersion "22.0.1" buildToolsVersion "22.0.1"
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 22 targetSdkVersion 22
versionName "4.0.10a" versionName "4.1.0a"
} }
buildTypes { buildTypes {
debug { debug {
minifyEnabled false minifyEnabled false
@ -23,32 +21,28 @@ android {
proguardFiles 'proguard-project.txt' proguardFiles 'proguard-project.txt'
} }
} }
productFlavors { productFlavors {
lightningPlus { lightningPlus {
buildConfigField "boolean", "FULL_VERSION", "true" buildConfigField "boolean", "FULL_VERSION", "true"
applicationId "acr.browser.lightning" applicationId "acr.browser.lightning"
versionCode 78 versionCode 79
} }
lightningLite { lightningLite {
buildConfigField "boolean", "FULL_VERSION", "false" buildConfigField "boolean", "FULL_VERSION", "false"
applicationId "acr.browser.barebones" applicationId "acr.browser.barebones"
versionCode 81 versionCode 81
} }
} }
lintOptions { lintOptions {
abortOnError false abortOnError false
} }
} }
dependencies { dependencies {
compile 'com.android.support:palette-v7:22.2.0' compile 'com.android.support:palette-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.0' compile 'com.android.support:design:22.2.1'
compile 'org.jsoup:jsoup:1.8.1' compile 'org.jsoup:jsoup:1.8.1'
// Only Lightning Plus needs the proxy libraries // Only Lightning Plus needs the proxy libraries
lightningPlusCompile 'net.i2p.android:client:0.7' lightningPlusCompile 'net.i2p.android:client:0.7'
lightningPlusCompile(project(':libnetcipher')) lightningPlusCompile(project(':libnetcipher'))

6
app/src/main/java/acr/browser/lightning/constant/Constants.java

@ -13,7 +13,7 @@ public final class Constants {
} }
public static final boolean FULL_VERSION = BuildConfig.FULL_VERSION; public static final boolean FULL_VERSION = BuildConfig.FULL_VERSION;
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"; public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36";
public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.4; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"; public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.4; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30";
public static final String YAHOO_SEARCH = "https://search.yahoo.com/search?p="; public static final String YAHOO_SEARCH = "https://search.yahoo.com/search?p=";
@ -46,4 +46,8 @@ public final class Constants {
public static final int PROXY_ORBOT = 1; public static final int PROXY_ORBOT = 1;
public static final int PROXY_I2P = 2; public static final int PROXY_I2P = 2;
public static final int PROXY_MANUAL = 3; public static final int PROXY_MANUAL = 3;
public static final String DEFAULT_ENCODING = "UTF-8";
public static final String[] TEXT_ENCODINGS = {"ISO-8859-1", "UTF-8", "GBK", "Big5", "ISO-2022-JP", "SHIFT_JS", "EUC-JP", "EUC-KR"};
} }

38
app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java

@ -11,7 +11,12 @@ import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import acr.browser.lightning.R; import acr.browser.lightning.R;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
public class AdvancedSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { public class AdvancedSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
@ -22,11 +27,12 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
private static final String SETTINGS_RESTORETABS = "restore_tabs"; private static final String SETTINGS_RESTORETABS = "restore_tabs";
private static final String SETTINGS_RENDERINGMODE = "rendering_mode"; private static final String SETTINGS_RENDERINGMODE = "rendering_mode";
private static final String SETTINGS_URLCONTENT = "url_contents"; private static final String SETTINGS_URLCONTENT = "url_contents";
private static final String SETTINGS_TEXTENCODING = "text_encoding";
private Activity mActivity; private Activity mActivity;
private PreferenceManager mPreferences; private PreferenceManager mPreferences;
private CheckBoxPreference cbAllowPopups, cbenablecookies, cbcookiesInkognito, cbrestoreTabs; private CheckBoxPreference cbAllowPopups, cbenablecookies, cbcookiesInkognito, cbrestoreTabs;
private Preference renderingmode, urlcontent; private Preference renderingmode, urlcontent, textEncoding;
private CharSequence[] mUrlOptions; private CharSequence[] mUrlOptions;
@Override @Override
@ -45,6 +51,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
mPreferences = PreferenceManager.getInstance(); mPreferences = PreferenceManager.getInstance();
renderingmode = findPreference(SETTINGS_RENDERINGMODE); renderingmode = findPreference(SETTINGS_RENDERINGMODE);
textEncoding = findPreference(SETTINGS_TEXTENCODING);
urlcontent = findPreference(SETTINGS_URLCONTENT); urlcontent = findPreference(SETTINGS_URLCONTENT);
cbAllowPopups = (CheckBoxPreference) findPreference(SETTINGS_NEWWINDOW); cbAllowPopups = (CheckBoxPreference) findPreference(SETTINGS_NEWWINDOW);
cbenablecookies = (CheckBoxPreference) findPreference(SETTINGS_ENABLECOOKIES); cbenablecookies = (CheckBoxPreference) findPreference(SETTINGS_ENABLECOOKIES);
@ -52,6 +59,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
cbrestoreTabs = (CheckBoxPreference) findPreference(SETTINGS_RESTORETABS); cbrestoreTabs = (CheckBoxPreference) findPreference(SETTINGS_RESTORETABS);
renderingmode.setOnPreferenceClickListener(this); renderingmode.setOnPreferenceClickListener(this);
textEncoding.setOnPreferenceClickListener(this);
urlcontent.setOnPreferenceClickListener(this); urlcontent.setOnPreferenceClickListener(this);
cbAllowPopups.setOnPreferenceChangeListener(this); cbAllowPopups.setOnPreferenceChangeListener(this);
cbenablecookies.setOnPreferenceChangeListener(this); cbenablecookies.setOnPreferenceChangeListener(this);
@ -73,6 +81,8 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
break; break;
} }
textEncoding.setSummary(mPreferences.getTextEncoding());
mUrlOptions = getResources().getStringArray(R.array.url_content_array); mUrlOptions = getResources().getStringArray(R.array.url_content_array);
int option = mPreferences.getUrlBoxContentChoice(); int option = mPreferences.getUrlBoxContentChoice();
urlcontent.setSummary(mUrlOptions[option]); urlcontent.setSummary(mUrlOptions[option]);
@ -92,6 +102,9 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
case SETTINGS_URLCONTENT: case SETTINGS_URLCONTENT:
urlBoxPicker(); urlBoxPicker();
return true; return true;
case SETTINGS_TEXTENCODING:
textEncodingPicker();
return true;
default: default:
return false; return false;
} }
@ -162,6 +175,29 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
picker.show(); picker.show();
} }
private void textEncodingPicker() {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.text_encoding));
final List<String> textEncodingList = Arrays.asList(Constants.TEXT_ENCODINGS);
int n = textEncodingList.indexOf(mPreferences.getTextEncoding());
picker.setSingleChoiceItems(Constants.TEXT_ENCODINGS, n, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferences.setTextEncoding(Constants.TEXT_ENCODINGS[which]);
textEncoding.setSummary(Constants.TEXT_ENCODINGS[which]);
}
});
picker.setNeutralButton(getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
picker.show();
}
private void urlBoxPicker() { private void urlBoxPicker() {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.url_contents)); picker.setTitle(getResources().getString(R.string.url_contents));

15
app/src/main/java/acr/browser/lightning/preference/PreferenceManager.java

@ -47,6 +47,7 @@ public class PreferenceManager {
public static final String READING_TEXT_SIZE = "readingTextSize"; public static final String READING_TEXT_SIZE = "readingTextSize";
public static final String THEME = "Theme"; public static final String THEME = "Theme";
public static final String DEFAULT_BOOKMARKS = "defaultBookmarks"; public static final String DEFAULT_BOOKMARKS = "defaultBookmarks";
public static final String TEXT_ENCODING = "textEncoding";
public static final String USE_PROXY = "useProxy"; public static final String USE_PROXY = "useProxy";
public static final String PROXY_CHOICE = "proxyChoice"; public static final String PROXY_CHOICE = "proxyChoice";
@ -248,6 +249,10 @@ public class PreferenceManager {
return mPrefs.getBoolean(Name.USE_WIDE_VIEWPORT, true); return mPrefs.getBoolean(Name.USE_WIDE_VIEWPORT, true);
} }
public String getTextEncoding() {
return mPrefs.getString(Name.TEXT_ENCODING, Constants.DEFAULT_ENCODING);
}
private void putBoolean(String name, boolean value) { private void putBoolean(String name, boolean value) {
mPrefs.edit().putBoolean(name, value).apply(); mPrefs.edit().putBoolean(name, value).apply();
} }
@ -260,6 +265,10 @@ public class PreferenceManager {
mPrefs.edit().putString(name, value).apply(); mPrefs.edit().putString(name, value).apply();
} }
public void setTextEncoding(String encoding) {
putString(Name.TEXT_ENCODING, encoding);
}
public void setAdBlockEnabled(boolean enable) { public void setAdBlockEnabled(boolean enable) {
putBoolean(Name.BLOCK_ADS, enable); putBoolean(Name.BLOCK_ADS, enable);
} }
@ -411,9 +420,9 @@ public class PreferenceManager {
/** /**
* Valid choices: * Valid choices:
* <ul> * <ul>
* <li>{@link Constants#NO_PROXY}</li> * <li>{@link Constants#NO_PROXY}</li>
* <li>{@link Constants#PROXY_ORBOT}</li> * <li>{@link Constants#PROXY_ORBOT}</li>
* <li>{@link Constants#PROXY_I2P}</li> * <li>{@link Constants#PROXY_I2P}</li>
* </ul> * </ul>
* *
* @param choice the proxy to use. * @param choice the proxy to use.

7
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -252,10 +252,10 @@ public class LightningView {
return Constants.FILE + homepage; return Constants.FILE + homepage;
} }
@SuppressWarnings("deprecation")
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
public synchronized void initializePreferences(Context context) { public synchronized void initializePreferences(Context context) {
mPreferences = PreferenceManager.getInstance(); mPreferences = PreferenceManager.getInstance();
mSettings.setDefaultTextEncodingName(mPreferences.getTextEncoding());
mHomepage = mPreferences.getHomepage(); mHomepage = mPreferences.getHomepage();
mAdBlock.updatePreference(); mAdBlock.updatePreference();
if (mSettings == null && mWebView != null) { if (mSettings == null && mWebView != null) {
@ -353,8 +353,6 @@ public class LightningView {
} }
} }
@SuppressWarnings("deprecation")
@SuppressLint({"SetJavaScriptEnabled", "NewApi"})
private void initializeSettings(WebSettings settings, Context context) { private void initializeSettings(WebSettings settings, Context context) {
if (API < Build.VERSION_CODES.JELLY_BEAN_MR2) { if (API < Build.VERSION_CODES.JELLY_BEAN_MR2) {
settings.setAppCacheMaxSize(Long.MAX_VALUE); settings.setAppCacheMaxSize(Long.MAX_VALUE);
@ -380,7 +378,6 @@ public class LightningView {
settings.setDisplayZoomControls(false); settings.setDisplayZoomControls(false);
settings.setAllowContentAccess(true); settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true); settings.setAllowFileAccess(true);
settings.setDefaultTextEncodingName("utf-8");
if (API >= Build.VERSION_CODES.JELLY_BEAN) { if (API >= Build.VERSION_CODES.JELLY_BEAN) {
settings.setAllowFileAccessFromFileURLs(false); settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false); settings.setAllowUniversalAccessFromFileURLs(false);

1
app/src/main/res/values/strings.xml

@ -193,6 +193,7 @@
<string name="jsoup">jsoup: Java HTML Parser</string> <string name="jsoup">jsoup: Java HTML Parser</string>
<string name="mit_license">MIT License</string> <string name="mit_license">MIT License</string>
<string name="url_contents">URL Box Contents</string> <string name="url_contents">URL Box Contents</string>
<string name="text_encoding">Text Encoding</string>
<string-array name="url_content_array"> <string-array name="url_content_array">
<item >Domain (default)</item> <item >Domain (default)</item>
<item >URL</item> <item >URL</item>

11
app/src/main/res/xml/preference_advanced.xml

@ -5,13 +5,13 @@
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="allow_new_window" android:key="allow_new_window"
android:title="@string/window" android:summary="@string/recommended"
android:summary="@string/recommended" /> android:title="@string/window" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="allow_cookies" android:key="allow_cookies"
android:title="@string/cookies" android:summary="@string/recommended"
android:summary="@string/recommended" /> android:title="@string/cookies" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="incognito_cookies" android:key="incognito_cookies"
@ -20,6 +20,9 @@
android:defaultValue="true" android:defaultValue="true"
android:key="restore_tabs" android:key="restore_tabs"
android:title="@string/restore" /> android:title="@string/restore" />
<Preference
android:key="text_encoding"
android:title="@string/text_encoding" />
<Preference <Preference
android:key="rendering_mode" android:key="rendering_mode"
android:title="@string/rendering_mode" /> android:title="@string/rendering_mode" />

Loading…
Cancel
Save