mobile: moved about to settings activity

This commit is contained in:
Philipp Schaefer
2013-04-09 22:03:33 +02:00
parent 2287b09f17
commit 81857a3812
5 changed files with 64 additions and 38 deletions

View File

@ -10,11 +10,6 @@
android:showAsAction="never" android:showAsAction="never"
android:title="@string/action_settings"></item> android:title="@string/action_settings"></item>
<item android:id="@+id/about"
android:orderInCategory="1200"
android:showAsAction="never"
android:title="@string/action_about"></item>
<item android:id="@+id/cache_clear" <item android:id="@+id/cache_clear"
android:orderInCategory="100" android:orderInCategory="100"
android:showAsAction="never" android:showAsAction="never"

View File

@ -11,11 +11,11 @@
<string name="close">close</string> <string name="close">close</string>
<string name="build_version">Build Version</string> <string name="build_version">Build Version</string>
<string name="iitc_version">IITC Version</string> <string name="iitc_version">IITC Version</string>
<string name="about">About</string>
<string name="action_about">About</string> <string name="pref_about_title">About IITC Mobile</string>
<string name="about_title">About</string>
<!-- Use CDATA to prevent android from parsin html tags....we are doing this with Html.fromHtml() --> <!-- Use CDATA to prevent android from parsin html tags....we are doing this with Html.fromHtml() -->
<string name="about_msg"> <string name="pref_about_msg">
<![CDATA[<big><b>Ingress Intel Total Conversion Mobile</b></big><br><br> <![CDATA[<big><b>Ingress Intel Total Conversion Mobile</b></big><br><br>
<b>by <a href="https://github.com/leCradle">cradle</a></b><br><br> <b>by <a href="https://github.com/leCradle">cradle</a></b><br><br>
<b>Icon by <a href="https://twitter.com/machtwerk">machtwerk</a></b><br><br> <b>Icon by <a href="https://twitter.com/machtwerk">machtwerk</a></b><br><br>
@ -31,6 +31,7 @@
<a href="https://github.com/breunigs/ingress-intel-total-conversion">https://github.com/breunigs/ingress-intel-total-conversion</a>]]> <a href="https://github.com/breunigs/ingress-intel-total-conversion">https://github.com/breunigs/ingress-intel-total-conversion</a>]]>
</string> </string>
<string name="pref_ui_cat">UI</string>
<string name="pref_force_desktop">Force desktop mode</string> <string name="pref_force_desktop">Force desktop mode</string>
<string name="pref_force_desktop_sum">Nice for tablets, looks awful on smartphones</string> <string name="pref_force_desktop_sum">Nice for tablets, looks awful on smartphones</string>
<string name="pref_developer_options">Developer options</string> <string name="pref_developer_options">Developer options</string>

View File

@ -1,10 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<com.cradle.iitc_mobile.IITC_AboutDialogPreference
android:key="pref_about"
android:title="@string/pref_about_title"
android:dialogIcon="@android:drawable/ic_dialog_info"
android:negativeButtonText=""
android:positiveButtonText=""
android:dialogTitle="@string/pref_about_title"/>
<PreferenceCategory
android:key="pref_about_cat"
android:title="@string/pref_ui_cat">
<CheckBoxPreference <CheckBoxPreference
android:key="pref_force_desktop" android:key="pref_force_desktop"
android:title="@string/pref_force_desktop" android:title="@string/pref_force_desktop"
android:summary="@string/pref_force_desktop_sum" android:summary="@string/pref_force_desktop_sum"
android:defaultValue="false" /> android:defaultValue="false" />
</PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="pref_developer_options" android:key="pref_developer_options"
@ -28,4 +41,5 @@
android:enabled="false" android:enabled="false"
android:selectable="false" /> android:selectable="false" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -0,0 +1,46 @@
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.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
public class IITC_AboutDialogPreference extends DialogPreference{
private Context context;
public IITC_AboutDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
/*
* 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.
*/
@Override
protected void onPrepareDialogBuilder(Builder builder) {
final TextView message = new TextView(context);
String about_msg = context.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(R.drawable.ic_stat_about)
.setNeutralButton(R.string.close, new OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
super.onPrepareDialogBuilder(builder);
}
}

View File

@ -13,20 +13,14 @@ import android.os.Handler;
import android.os.StrictMode; import android.os.StrictMode;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
public class IITC_Mobile extends Activity { public class IITC_Mobile extends Activity {
@ -165,30 +159,6 @@ public class IITC_Mobile extends Activity {
intent.putExtra("iitc_version", iitc_view.getWebViewClient().getIITCVersion()); intent.putExtra("iitc_version", iitc_view.getWebViewClient().getIITCVersion());
startActivity(intent); startActivity(intent);
return true; 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: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }