From 5198858b6cc2b579f23bcab29ebacb21b77968b7 Mon Sep 17 00:00:00 2001 From: fkloft Date: Tue, 22 Oct 2013 20:12:59 +0200 Subject: [PATCH] New about dialog for IITCm --- mobile/res/values/strings.xml | 29 ++-- mobile/res/xml/preferences.xml | 127 ++++++++---------- .../IITC_AboutDialogPreference.java | 51 ++++--- .../iitc_mobile/IITC_WebViewClient.java | 1 - .../iitc_mobile/fragments/MainSettings.java | 49 +++---- 5 files changed, 110 insertions(+), 147 deletions(-) diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index b1565352..21e99338 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -16,29 +16,29 @@ Get Location local Close - Build Version - IITC Version - About - About IITC Mobile - - Ingress Intel Total Conversion Mobile

+ + Ingress Intel Total Conversion Mobile + Build Version: %1$s
+ IITC Version: %2$s
+
by cradle and contributors

Icon by Giuseppe Lucido

IITC Mobile is an optimized mobile browser for the Ingress Intel Total Conversion (IITC) userscript by breunigs. After Niantic asked the main developer to shut down his github project, development - is continued on a fork of jonatkins.

- Community:
+ is continued on a fork of jonatkins. +

Community:

• Visit the IITC website for new releases and the desktop version.
• Follow the IITC Google+ page for release announcements.
• Join the IITC Google+ community - - a place to ask for help and discuss with other users.

- Developers:
- IITC on Github

- IITC Licence:
+ - a place to ask for help and discuss with other users. +

Developers:

+ IITC on Github +

IITC Licence:

Copyright © 2013 Stefan Breunig, Jon Atkins, Philipp Schäfer and others

Permission to use, copy, modify, and/or distribute this software for @@ -53,7 +53,8 @@ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE.]]> + PERFORMANCE OF THIS SOFTWARE. + ]]>

@@ -67,7 +68,7 @@ • tap and hold a portal for a second
• tap on the left half of the status bar]]>
- + UI Misc Developer options diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index 4e743e35..289856d5 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -1,136 +1,115 @@ - + + + + android:defaultValue="false" + android:key="pref_user_loc" + android:summary="@string/pref_user_loc_sum" + android:title="@string/pref_user_loc"/> + android:title="@string/pref_user_zoom"/> + android:title="@string/pref_fullscreen_actionbar"/> + android:title="@string/pref_force_desktop"/> - + + android:title="@string/pref_select_iitc"/> + + android:persistent="false" + android:title="@string/pref_plugins"> + android:targetClass="com.cradle.iitc_mobile.IITC_PluginPreferenceActivity" + android:targetPackage="com.cradle.iitc_mobile"/> - - - + + + - - + android:persistent="false" + android:title="@string/pref_advanced_options"> + android:title="@string/pref_enable_dev_mode"/> - - + android:title="@string/pref_advanced_menu"/> - + android:title="@string/pref_disable_splash"/> - - + android:entryValues="@array/pref_caching_array_vals" + android:key="pref_caching" + android:summary="@string/pref_caching_sum" + android:title="@string/pref_caching"/> - + android:title="@string/pref_fake_user_agent"/> - - - - - - \ No newline at end of file diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java b/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java index 54600070..1bfd0fbe 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java @@ -1,44 +1,41 @@ package com.cradle.iitc_mobile; -import android.app.AlertDialog.Builder; import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.preference.DialogPreference; +import android.preference.Preference; import android.text.Html; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; import android.widget.TextView; -public class IITC_AboutDialogPreference extends DialogPreference { - - private final Context mContext; +public class IITC_AboutDialogPreference extends Preference { + private String mBuildVersion = ""; + private String mIitcVersion = ""; public IITC_AboutDialogPreference(Context context, AttributeSet attrs) { super(context, attrs); - this.mContext = context; } - /* - * start an about-dialog...I found no better way for clickable - * links in a TextView then using Html.fromHtml...Linkify is just broken and - * does not understand html href tags...so let's tag the @string/about_msg - * with CDATA and use Html.fromHtml(...) for clickable hrefs with tags. - */ @Override - protected void onPrepareDialogBuilder(Builder builder) { - final TextView message = new TextView(mContext); - String about_msg = mContext.getText(R.string.pref_about_msg).toString(); - message.setText(Html.fromHtml(about_msg)); - message.setMovementMethod(LinkMovementMethod.getInstance()); - builder.setView(message).setTitle(R.string.about) - .setIcon(android.R.drawable.ic_dialog_info) - .setNeutralButton(R.string.close, new OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }); - super.onPrepareDialogBuilder(builder); + public View getView(View convertView, ViewGroup parent) { + /* + * I found no better way for clickable links in a TextView then using Html.fromHtml(). Linkify + * is just broken and does not understand html href tags, so let's tag the @string/about_msg + * with CDATA and use Html.fromHtml() for clickable hrefs with tags. + */ + final TextView tv = new TextView(getContext()); + String text = getContext().getText(R.string.pref_about_text).toString(); + text = String.format(text, mBuildVersion, mIitcVersion); + + tv.setText(Html.fromHtml(text)); + tv.setMovementMethod(LinkMovementMethod.getInstance()); + + return tv; } + public void setVersions(String iitcVersion, String buildVersion) { + mIitcVersion = iitcVersion; + mBuildVersion = buildVersion; + } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index a41835ae..ef409706 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -12,7 +12,6 @@ import android.preference.PreferenceManager; import android.util.Log; import android.webkit.SslErrorHandler; import android.webkit.WebResourceResponse; -import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; diff --git a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java index 49af96ea..71d26ed4 100644 --- a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java +++ b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java @@ -6,66 +6,53 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.preference.EditTextPreference; -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.IITC_AboutDialogPreference; import com.cradle.iitc_mobile.R; public class MainSettings extends PreferenceFragment { - - private String mIitcVersion; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mIitcVersion = getArguments().getString("iitc_version"); - addPreferencesFromResource(R.xml.preferences); - // set build version - ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version"); + // set versions + String iitcVersion = getArguments().getString("iitc_version"); + String buildVersion = "unknown"; + PackageManager pm = getActivity().getPackageManager(); - String version = "unknown"; try { - PackageInfo info = pm.getPackageInfo( - getActivity().getPackageName(), 0); - version = info.versionName; + PackageInfo info = pm.getPackageInfo(getActivity().getPackageName(), 0); + buildVersion = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } - pref_build_version.setSummary(version); - // set iitc version - ListPreference pref_iitc_version = (ListPreference) findPreference("pref_iitc_version"); - pref_iitc_version.setSummary(mIitcVersion); + IITC_AboutDialogPreference pref_about = (IITC_AboutDialogPreference) findPreference("pref_about"); + pref_about.setVersions(iitcVersion, buildVersion); // set iitc source EditTextPreference pref_iitc_source = (EditTextPreference) findPreference("pref_iitc_source"); - pref_iitc_source - .setOnPreferenceChangeListener(new OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, - Object newValue) { - preference.setSummary(getString(R.string.pref_select_iitc_sum) + - " " + newValue); - // TODO: update mIitcVersion when iitc source has - // changed - return true; - } - }); + pref_iitc_source.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + preference.setSummary(getString(R.string.pref_select_iitc_sum) + " " + newValue); + // TODO: update mIitcVersion when iitc source has changed + return true; + } + }); // first init of summary - String pref_iitc_source_sum = getString(R.string.pref_select_iitc_sum) - + " " + pref_iitc_source.getText(); + String pref_iitc_source_sum = getString(R.string.pref_select_iitc_sum) + " " + pref_iitc_source.getText(); pref_iitc_source.setSummary(pref_iitc_source_sum); }