mobile: added first version of 'about' view
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user