Browse Source

Added text encoding setting, updated support libraries

master
Anthony Restaino 10 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 @@ @@ -92,10 +92,10 @@
<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-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/design/22.2.0/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/support-v4/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.1/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.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/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
@ -114,13 +114,13 @@ @@ -114,13 +114,13 @@
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform (1)" jdkType="Android SDK" />
<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="palette-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="design-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" 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="design-22.2.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.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="" />
</component>
</module>

16
app/build.gradle

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

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

@ -13,7 +13,7 @@ public final class Constants { @@ -13,7 +13,7 @@ public final class Constants {
}
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 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=";
@ -46,4 +46,8 @@ public final class Constants { @@ -46,4 +46,8 @@ public final class Constants {
public static final int PROXY_ORBOT = 1;
public static final int PROXY_I2P = 2;
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; @@ -11,7 +11,12 @@ import android.preference.Preference;
import android.preference.PreferenceFragment;
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.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager;
public class AdvancedSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
@ -22,11 +27,12 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref @@ -22,11 +27,12 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
private static final String SETTINGS_RESTORETABS = "restore_tabs";
private static final String SETTINGS_RENDERINGMODE = "rendering_mode";
private static final String SETTINGS_URLCONTENT = "url_contents";
private static final String SETTINGS_TEXTENCODING = "text_encoding";
private Activity mActivity;
private PreferenceManager mPreferences;
private CheckBoxPreference cbAllowPopups, cbenablecookies, cbcookiesInkognito, cbrestoreTabs;
private Preference renderingmode, urlcontent;
private Preference renderingmode, urlcontent, textEncoding;
private CharSequence[] mUrlOptions;
@Override
@ -45,6 +51,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref @@ -45,6 +51,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
mPreferences = PreferenceManager.getInstance();
renderingmode = findPreference(SETTINGS_RENDERINGMODE);
textEncoding = findPreference(SETTINGS_TEXTENCODING);
urlcontent = findPreference(SETTINGS_URLCONTENT);
cbAllowPopups = (CheckBoxPreference) findPreference(SETTINGS_NEWWINDOW);
cbenablecookies = (CheckBoxPreference) findPreference(SETTINGS_ENABLECOOKIES);
@ -52,6 +59,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref @@ -52,6 +59,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
cbrestoreTabs = (CheckBoxPreference) findPreference(SETTINGS_RESTORETABS);
renderingmode.setOnPreferenceClickListener(this);
textEncoding.setOnPreferenceClickListener(this);
urlcontent.setOnPreferenceClickListener(this);
cbAllowPopups.setOnPreferenceChangeListener(this);
cbenablecookies.setOnPreferenceChangeListener(this);
@ -73,6 +81,8 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref @@ -73,6 +81,8 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
break;
}
textEncoding.setSummary(mPreferences.getTextEncoding());
mUrlOptions = getResources().getStringArray(R.array.url_content_array);
int option = mPreferences.getUrlBoxContentChoice();
urlcontent.setSummary(mUrlOptions[option]);
@ -92,6 +102,9 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref @@ -92,6 +102,9 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
case SETTINGS_URLCONTENT:
urlBoxPicker();
return true;
case SETTINGS_TEXTENCODING:
textEncodingPicker();
return true;
default:
return false;
}
@ -162,6 +175,29 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref @@ -162,6 +175,29 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref
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() {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
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 { @@ -47,6 +47,7 @@ public class PreferenceManager {
public static final String READING_TEXT_SIZE = "readingTextSize";
public static final String THEME = "Theme";
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 PROXY_CHOICE = "proxyChoice";
@ -248,6 +249,10 @@ public class PreferenceManager { @@ -248,6 +249,10 @@ public class PreferenceManager {
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) {
mPrefs.edit().putBoolean(name, value).apply();
}
@ -260,6 +265,10 @@ public class PreferenceManager { @@ -260,6 +265,10 @@ public class PreferenceManager {
mPrefs.edit().putString(name, value).apply();
}
public void setTextEncoding(String encoding) {
putString(Name.TEXT_ENCODING, encoding);
}
public void setAdBlockEnabled(boolean enable) {
putBoolean(Name.BLOCK_ADS, enable);
}
@ -411,9 +420,9 @@ public class PreferenceManager { @@ -411,9 +420,9 @@ public class PreferenceManager {
/**
* Valid choices:
* <ul>
* <li>{@link Constants#NO_PROXY}</li>
* <li>{@link Constants#PROXY_ORBOT}</li>
* <li>{@link Constants#PROXY_I2P}</li>
* <li>{@link Constants#NO_PROXY}</li>
* <li>{@link Constants#PROXY_ORBOT}</li>
* <li>{@link Constants#PROXY_I2P}</li>
* </ul>
*
* @param choice the proxy to use.

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

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

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

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

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

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

Loading…
Cancel
Save