* moved advanced settings to own preference screen
* added setting to fake user agent (see https://plus.google.com/u/0/104992284359985480029/posts/9mPFLPKjgvL) * bumped version number
This commit is contained in:
parent
7d60f93472
commit
56863aebac
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cradle.iitc_mobile"
|
||||
android:versionCode="53"
|
||||
android:versionName="0.7.3">
|
||||
android:versionCode="54"
|
||||
android:versionName="0.7.4">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
@ -84,7 +84,8 @@
|
||||
<string name="pref_force_https_sum">Disabling may improve performance</string>
|
||||
<string name="pref_press_twice_to_exit">Press back button twice to exit</string>
|
||||
<string name="pref_press_twice_to_exit_sum">Avoids accidental exits</string>
|
||||
<string name="pref_developer_options">Developer options</string>
|
||||
<string name="pref_developer_options_cat">Developer options</string>
|
||||
<string name="pref_advanced_options">Advanced settings</string>
|
||||
<string name="pref_enable_dev_mode">Enable developer mode</string>
|
||||
<string name="pref_enable_dev_mode_sum">If enabled, all IITC sources will be loaded from external storage of the Android device.
|
||||
Please copy all sources from $IITC_folder/build/mobile/ to /sdcard/IITC_Mobile/dev/.</string>
|
||||
@ -92,6 +93,9 @@
|
||||
<string name="pref_advanced_menu_sum">In addition to the default IITC buttons the advanced menu
|
||||
contains a debug pane plus an option to clear cookies</string>
|
||||
<string name="pref_disable_splash">Disable Splash Screen</string>
|
||||
<string name="pref_fake_user_agent">Fake User Agent</string>
|
||||
<string name="pref_fake_user_agent_sum">Let IITCm appear as a desktop browser for the intel site.
|
||||
Note: If just want to use the desktop mode use the \'force desktop mode\' setting</string>
|
||||
<string name="pref_select_iitc">IITC source</string>
|
||||
<string name="pref_select_iitc_sum">Load IITC main script from url or use local script. Currently used source:</string>
|
||||
|
||||
|
@ -45,7 +45,8 @@
|
||||
<PreferenceScreen
|
||||
android:fragment="com.cradle.iitc_mobile.fragments.PluginsFragment"
|
||||
android:key="pref_plugins"
|
||||
android:title="@string/pref_plugins" >
|
||||
android:title="@string/pref_plugins"
|
||||
android:persistent="false">
|
||||
<intent
|
||||
android:targetPackage="com.cradle.iitc_mobile"
|
||||
android:targetClass="com.cradle.iitc_mobile.IITC_PluginPreferenceActivity"/>
|
||||
@ -64,36 +65,52 @@
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pref_developer_options"
|
||||
android:title="@string/pref_developer_options">
|
||||
android:title="@string/pref_developer_options_cat">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="pref_dev_checkbox"
|
||||
android:title="@string/pref_enable_dev_mode"
|
||||
android:summary="@string/pref_enable_dev_mode_sum"
|
||||
android:defaultValue="false" />
|
||||
<PreferenceScreen
|
||||
android:key="pref_developer_screen"
|
||||
android:title="@string/pref_advanced_options"
|
||||
android:persistent="false">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="pref_advanced_menu"
|
||||
android:title="@string/pref_advanced_menu"
|
||||
android:summary="@string/pref_advanced_menu_sum"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference
|
||||
android:key="pref_advanced_menu"
|
||||
android:title="@string/pref_advanced_menu"
|
||||
android:summary="@string/pref_advanced_menu_sum"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
<CheckBoxPreference
|
||||
android:key="pref_disable_splash"
|
||||
android:title="@string/pref_disable_splash"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="pref_dev_checkbox"
|
||||
android:title="@string/pref_enable_dev_mode"
|
||||
android:summary="@string/pref_enable_dev_mode_sum"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="pref_fake_user_agent"
|
||||
android:title="@string/pref_fake_user_agent"
|
||||
android:summary="@string/pref_fake_user_agent_sum"
|
||||
android:defaultValue="false" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
<ListPreference
|
||||
android:key="pref_build_version"
|
||||
android:title="@string/build_version"
|
||||
android:enabled="false"
|
||||
android:selectable="false" />
|
||||
android:selectable="false"
|
||||
android:persistent="false" />
|
||||
|
||||
<ListPreference
|
||||
android:key="pref_iitc_version"
|
||||
android:title="@string/iitc_version"
|
||||
android:enabled="false"
|
||||
android:selectable="false" />
|
||||
android:selectable="false"
|
||||
android:persistent="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@ -112,23 +112,21 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
|
||||
if (key.equals("pref_force_desktop")) {
|
||||
mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
|
||||
mNavigationHelper.onPrefChanged();
|
||||
}
|
||||
if (key.equals("pref_user_loc"))
|
||||
} else if (key.equals("pref_user_loc")) {
|
||||
mIsLocEnabled = sharedPreferences.getBoolean("pref_user_loc",
|
||||
false);
|
||||
if (key.equals("pref_fullscreen_actionbar")) {
|
||||
} else if (key.equals("pref_fullscreen_actionbar")) {
|
||||
mNavigationHelper.onPrefChanged();
|
||||
return;
|
||||
}
|
||||
if (key.equals("pref_advanced_menu")) {
|
||||
} else if (key.equals("pref_advanced_menu")) {
|
||||
mAdvancedMenu = sharedPreferences.getBoolean("pref_advanced_menu", false);
|
||||
mNavigationHelper.setDebugMode(mAdvancedMenu);
|
||||
invalidateOptionsMenu();
|
||||
// no reload needed
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.equals("pref_press_twice_to_exit")
|
||||
} else if (key.equals("pref_fake_user_agent")) {
|
||||
mIitcWebView.setUserAgent();
|
||||
} else if (key.equals("pref_press_twice_to_exit")
|
||||
|| key.equals("pref_share_selected_tab")
|
||||
|| key.equals("pref_messages"))
|
||||
// no reload needed
|
||||
|
@ -15,6 +15,7 @@ public class IITC_PreferenceActivity extends Activity {
|
||||
MainSettings settings = new MainSettings();
|
||||
|
||||
getActionBar().setHomeButtonEnabled(true);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// iitc version
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
|
@ -27,25 +27,32 @@ public class IITC_WebView extends WebView {
|
||||
private IITC_JSInterface mJsInterface;
|
||||
private Context mContext;
|
||||
private boolean mDisableJs = false;
|
||||
private String mDefaultUserAgent;
|
||||
private final String mDesktopUserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:17.0)" +
|
||||
" Gecko/20130810 Firefox/17.0 Iceweasel/17.0.8";
|
||||
|
||||
|
||||
|
||||
// init web view
|
||||
private void iitc_init(Context c) {
|
||||
if (this.isInEditMode()) return;
|
||||
if (isInEditMode()) return;
|
||||
mContext = c;
|
||||
mSettings = this.getSettings();
|
||||
mSettings = getSettings();
|
||||
mSettings.setJavaScriptEnabled(true);
|
||||
mSettings.setDomStorageEnabled(true);
|
||||
mSettings.setAllowFileAccess(true);
|
||||
mSettings.setGeolocationEnabled(true);
|
||||
mSettings.setAppCacheEnabled(true);
|
||||
mSettings.setDatabasePath(this.getContext().getApplicationInfo().dataDir
|
||||
mSettings.setDatabasePath(getContext().getApplicationInfo().dataDir
|
||||
+ "/databases/");
|
||||
mSettings.setAppCachePath(this.getContext().getCacheDir()
|
||||
mSettings.setAppCachePath(getContext().getCacheDir()
|
||||
.getAbsolutePath());
|
||||
this.mJsInterface = new IITC_JSInterface((IITC_Mobile) mContext);
|
||||
this.addJavascriptInterface(mJsInterface, "android");
|
||||
mJsInterface = new IITC_JSInterface((IITC_Mobile) mContext);
|
||||
addJavascriptInterface(mJsInterface, "android");
|
||||
mDefaultUserAgent = mSettings.getUserAgentString();
|
||||
setUserAgent();
|
||||
|
||||
this.setWebChromeClient(new WebChromeClient() {
|
||||
setWebChromeClient(new WebChromeClient() {
|
||||
/**
|
||||
* our webchromeclient should share geolocation with the iitc script
|
||||
*
|
||||
@ -83,7 +90,7 @@ public class IITC_WebView extends WebView {
|
||||
});
|
||||
|
||||
mIitcWebViewClient = new IITC_WebViewClient(c);
|
||||
this.setWebViewClient(mIitcWebViewClient);
|
||||
setWebViewClient(mIitcWebViewClient);
|
||||
}
|
||||
|
||||
// constructors -------------------------------------------------
|
||||
@ -110,7 +117,7 @@ public class IITC_WebView extends WebView {
|
||||
@Override
|
||||
public void loadUrl(String url) {
|
||||
// if in edit text mode, don't load javascript otherwise the keyboard closes.
|
||||
HitTestResult testResult = this.getHitTestResult();
|
||||
HitTestResult testResult = getHitTestResult();
|
||||
if (url.startsWith("javascript:") && testResult != null &&
|
||||
testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) {
|
||||
// let window.show(...) interupt input
|
||||
@ -122,7 +129,7 @@ public class IITC_WebView extends WebView {
|
||||
}
|
||||
}
|
||||
// do nothing if script is enabled;
|
||||
if (this.mDisableJs) {
|
||||
if (mDisableJs) {
|
||||
Log.d("iitcm", "javascript injection disabled...return");
|
||||
return;
|
||||
}
|
||||
@ -143,11 +150,11 @@ public class IITC_WebView extends WebView {
|
||||
}
|
||||
|
||||
public IITC_WebViewClient getWebViewClient() {
|
||||
return this.mIitcWebViewClient;
|
||||
return mIitcWebViewClient;
|
||||
}
|
||||
|
||||
public IITC_JSInterface getJSInterface() {
|
||||
return this.mJsInterface;
|
||||
return mJsInterface;
|
||||
}
|
||||
|
||||
public void updateCaching() {
|
||||
@ -156,7 +163,7 @@ public class IITC_WebView extends WebView {
|
||||
login = getUrl().contains("accounts.google.com");
|
||||
}
|
||||
// use cache if on mobile network...saves traffic
|
||||
if (!this.isConnectedToWifi() && !login) {
|
||||
if (!isConnectedToWifi() && !login) {
|
||||
Log.d("iitcm", "not connected to wifi...load tiles from cache");
|
||||
mSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
||||
} else {
|
||||
@ -184,7 +191,14 @@ public class IITC_WebView extends WebView {
|
||||
}
|
||||
|
||||
public void disableJS(boolean val) {
|
||||
this.mDisableJs = val;
|
||||
mDisableJs = val;
|
||||
}
|
||||
|
||||
public void setUserAgent() {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
String ua = sharedPrefs.getBoolean("pref_fake_user_agent", false) ? mDesktopUserAgent : mDefaultUserAgent;
|
||||
Log.d("iitcm", "setting user agent to: " + ua);
|
||||
mSettings.setUserAgentString(ua);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.cradle.iitc_mobile.fragments;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
@ -9,6 +10,13 @@ import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.cradle.iitc_mobile.R;
|
||||
|
||||
@ -60,4 +68,55 @@ public class MainSettings extends PreferenceFragment {
|
||||
+ " " + pref_iitc_source.getText();
|
||||
pref_iitc_source.setSummary(pref_iitc_source_sum);
|
||||
}
|
||||
|
||||
// we want a home button + HomeAsUpEnabled in nested preferences
|
||||
// for some odd reasons android is not able to do this by default
|
||||
// so we need some additional hacks...
|
||||
// thx to http://stackoverflow.com/a/16800527/2638486 !!
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||
if (preference.getTitle().toString().equals(getString(R.string.pref_advanced_options)))
|
||||
initializeActionBar((PreferenceScreen) preference);
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
|
||||
// Apply custom home button area click listener to close the PreferenceScreen
|
||||
// because PreferenceScreens are dialogs which swallow
|
||||
// events instead of passing to the activity
|
||||
// Related Issue: https://code.google.com/p/android/issues/detail?id=4611
|
||||
public static void initializeActionBar(PreferenceScreen preferenceScreen) {
|
||||
final Dialog dialog = preferenceScreen.getDialog();
|
||||
|
||||
if (dialog != null) {
|
||||
dialog.getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
View homeBtn = dialog.findViewById(android.R.id.home);
|
||||
|
||||
if (homeBtn != null) {
|
||||
View.OnClickListener dismissDialogClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
ViewParent homeBtnContainer = homeBtn.getParent();
|
||||
|
||||
// The home button is an ImageView inside a FrameLayout
|
||||
if (homeBtnContainer instanceof FrameLayout) {
|
||||
ViewGroup containerParent = (ViewGroup) homeBtnContainer.getParent();
|
||||
|
||||
if (containerParent instanceof LinearLayout) {
|
||||
// This view also contains the title text, set the whole view as clickable
|
||||
((LinearLayout) containerParent).setOnClickListener(dismissDialogClickListener);
|
||||
} else {
|
||||
// Just set it on the home button
|
||||
((FrameLayout) homeBtnContainer).setOnClickListener(dismissDialogClickListener);
|
||||
}
|
||||
} else {
|
||||
homeBtn.setOnClickListener(dismissDialogClickListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user