From 2287b09f17a930233aeffce6affd58883d3dba3a Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 9 Apr 2013 21:31:48 +0200 Subject: [PATCH] mobile: added first version of 'about' view --- mobile/AndroidManifest.xml | 4 +- mobile/res/menu/main.xml | 5 ++ mobile/res/values/strings.xml | 20 ++++++ .../com/cradle/iitc_mobile/IITC_Mobile.java | 66 +++++++++++++++---- 4 files changed, 81 insertions(+), 14 deletions(-) diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index 7bfd23d2..c2cc350f 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="7" + android:versionName="0.2.6" > + + Clear Cache Get Location local + close Build Version IITC Version + About + About + + + Ingress Intel Total Conversion Mobile

+ by cradle

+ Icon by machtwerk

+ 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.

+ Website:
+ http://iitc.jonatkins.com/

+ Fork github:
+ https://github.com/jonatkins/ingress-intel-total-conversion

+ Old github:
+ https://github.com/breunigs/ingress-intel-total-conversion]]> +
+ Force desktop mode Nice for tablets, looks awful on smartphones Developer options diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 8dc50b01..999b53c0 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -13,14 +13,20 @@ import android.os.Handler; import android.os.StrictMode; import android.preference.PreferenceManager; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Configuration; +import android.text.Html; +import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import android.widget.TextView; import android.widget.Toast; public class IITC_Mobile extends Activity { @@ -29,6 +35,7 @@ public class IITC_Mobile extends Activity { private boolean back_button_pressed = false; private boolean desktop = false; private OnSharedPreferenceChangeListener listener; + private String intel_url = "https://www.ingress.com/intel"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -45,9 +52,7 @@ public class IITC_Mobile extends Activity { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("pref_force_desktop")) desktop = sharedPreferences.getBoolean("pref_force_desktop", false); - // reload intel map - iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel")); - injectJS(); + IITC_Mobile.this.loadUrl(intel_url); } }; sharedPref.registerOnSharedPreferenceChangeListener(listener); @@ -60,24 +65,26 @@ public class IITC_Mobile extends Activity { String url = uri.toString(); if (intent.getScheme().equals("http://")) url = url.replace("http://", "https://"); - Log.d("Intent received", "url: " + url); + Log.d("iitcm", "intent received url: " + url); if (url.contains("ingress.com")) { - Log.d("Intent received", "loading url..."); - iitc_view.loadUrl(addUrlParam(url)); + Log.d("iitcm", "loading url..."); + this.loadUrl(url); } } else { - Log.d("No Intent call", "loading https://www.ingress.com/intel"); - iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel")); + Log.d("iitcm", "no intent...loading " + intel_url); + this.loadUrl(intel_url); } } @Override protected void onResume() { + super.onResume(); + // enough idle...let's do some work + Log.d("iitcm", "resuming...setting reset idleTimer"); iitc_view.loadUrl("javascript: window.idleTime = 0"); iitc_view.loadUrl("javascript: window.renderUpdateStatus()"); - super.onResume(); } @Override @@ -100,8 +107,11 @@ public class IITC_Mobile extends Activity { @Override public void onConfigurationChanged(Configuration newConfig) { - Log.d("iitcm", "configuration changed...restoring..."); super.onConfigurationChanged(newConfig); + + Log.d("iitcm", "configuration changed...restoring...reset idleTimer"); + iitc_view.loadUrl("javascript: window.idleTime = 0"); + iitc_view.loadUrl("javascript: window.renderUpdateStatus()"); } // we want a self defined behavior for the back button @@ -137,8 +147,7 @@ public class IITC_Mobile extends Activity { // Handle item selection switch (item.getItemId()) { case R.id.reload_button: - iitc_view.loadUrl(addUrlParam("https://www.ingress.com/intel")); - injectJS(); + this.loadUrl(intel_url); return true; // clear cache case R.id.cache_clear: @@ -150,11 +159,36 @@ public class IITC_Mobile extends Activity { case R.id.locate: iitc_view.loadUrl("javascript: window.map.locate({setView : true, maxZoom: 13});"); return true; + // start settings activity case R.id.settings: Intent intent = new Intent(this, IITC_Settings.class); intent.putExtra("iitc_version", iitc_view.getWebViewClient().getIITCVersion()); startActivity(intent); return true; + /* + * start a little about-dialog + * srsly...I found no better way for clickable links in a TextView then + * using Html.fromHtml...Linkify ist 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. + */ + case R.id.about: + AlertDialog.Builder builder = new AlertDialog.Builder(this); + final TextView message = new TextView(this); + String about_msg = this.getText(R.string.about_msg).toString(); + message.setText(Html.fromHtml(about_msg)); + message.setMovementMethod(LinkMovementMethod.getInstance()); + builder.setView(message) + .setTitle(R.string.about_title) + .setIcon(R.drawable.ic_stat_about) + .setNeutralButton(R.string.close, new OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); + AlertDialog dialog = builder.create(); + dialog.show(); + return true; default: return super.onOptionsItemSelected(item); } @@ -179,4 +213,12 @@ public class IITC_Mobile extends Activity { else return (url + "?vp=m"); } + + public void loadUrl(String url) { + url = addUrlParam(url); + Log.d("iitcm", "injecting js..."); + injectJS(); + Log.d("iitcm", "loading url: " + url); + iitc_view.loadUrl(url); + } }