New about dialog for IITCm

This commit is contained in:
fkloft 2013-10-22 20:12:59 +02:00
parent 9248fe6221
commit 5198858b6c
5 changed files with 110 additions and 147 deletions

View File

@ -16,29 +16,29 @@
<string name="locate">Get Location</string> <string name="locate">Get Location</string>
<string name="local">local</string> <string name="local">local</string>
<string name="close">Close</string> <string name="close">Close</string>
<string name="build_version">Build Version</string>
<string name="iitc_version">IITC Version</string>
<string name="about">About</string>
<string name="pref_about_title">About IITC Mobile</string> <string name="pref_about_title">About IITC Mobile</string>
<!-- Use CDATA to prevent android from parsing html tags....we are doing this with Html.fromHtml() --> <!-- Use CDATA to prevent android from parsing html tags....we are doing this with Html.fromHtml() -->
<string name="pref_about_msg"> <string name="pref_about_text">
<![CDATA[<big><b>Ingress Intel Total Conversion Mobile</b></big><br><br> <![CDATA[
<h1>Ingress Intel Total Conversion Mobile</h1>
<b>Build Version: %1$s</b><br>
<b>IITC Version: %2$s</b><br>
<br>
<b>by <a href="https://github.com/leCradle">cradle</a> and contributors</b><br><br> <b>by <a href="https://github.com/leCradle">cradle</a> and contributors</b><br><br>
<b>Icon by <a href="http://www.ludolab.net">Giuseppe Lucido</a></b><br><br> <b>Icon by <a href="http://www.ludolab.net">Giuseppe Lucido</a></b><br><br>
IITC Mobile is an optimized mobile browser for the IITC Mobile is an optimized mobile browser for the
Ingress Intel Total Conversion (IITC) userscript by <a href="https://github.com/breunigs"><b>breunigs</b></a>. Ingress Intel Total Conversion (IITC) userscript by <a href="https://github.com/breunigs"><b>breunigs</b></a>.
After Niantic asked the main developer to shut down his github project, development After Niantic asked the main developer to shut down his github project, development
is continued on a fork of <a href="https://github.com/jonatkins"><b>jonatkins</b></a>.<br><br> is continued on a fork of <a href="https://github.com/jonatkins"><b>jonatkins</b></a>.
<b>Community:</b><br> <h3>Community:</h3>
• Visit the <a href="http://iitc.jonatkins.com/">IITC website</a> for new releases and the desktop version.<br> • Visit the <a href="http://iitc.jonatkins.com/">IITC website</a> for new releases and the desktop version.<br>
• Follow the <a href="https://plus.google.com/105383756361375410867">IITC Google+ page</a> • Follow the <a href="https://plus.google.com/105383756361375410867">IITC Google+ page</a>
for release announcements.<br> for release announcements.<br>
• Join the <a href="https://plus.google.com/communities/105647403088015055797">IITC Google+ community</a> • Join the <a href="https://plus.google.com/communities/105647403088015055797">IITC Google+ community</a>
- a place to ask for help and discuss with other users.<br><br> - a place to ask for help and discuss with other users.
<b>Developers:</b><br> <h3>Developers:</h3>
<a href="https://github.com/jonatkins/ingress-intel-total-conversion">IITC on Github</a><br><br> <a href="https://github.com/jonatkins/ingress-intel-total-conversion">IITC on Github</a>
<b>IITC Licence:</b><br> <h3>IITC Licence:</h3>
Copyright © 2013 Stefan Breunig, Jon Atkins, Philipp Schäfer and others<br><br> Copyright © 2013 Stefan Breunig, Jon Atkins, Philipp Schäfer and others<br><br>
Permission to use, copy, modify, and/or distribute this software for 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 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.]]> PERFORMANCE OF THIS SOFTWARE.
]]>
</string> </string>
<string name="notice_drawers"> <string name="notice_drawers">
<![CDATA[IITCm recently changed its navigation structure. How to use it:<br><br> <![CDATA[IITCm recently changed its navigation structure. How to use it:<br><br>
@ -67,7 +68,7 @@
• tap and hold a portal for a second<br> • tap and hold a portal for a second<br>
• tap on the left half of the status bar]]> • tap on the left half of the status bar]]>
</string> </string>
<string name="pref_ui_cat">UI</string> <string name="pref_ui_cat">UI</string>
<string name="pref_misc_cat">Misc</string> <string name="pref_misc_cat">Misc</string>
<string name="pref_developer_options_cat">Developer options</string> <string name="pref_developer_options_cat">Developer options</string>

View File

@ -1,136 +1,115 @@
<?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 <PreferenceScreen
android:key="pref_about" android:key="pref_about_screen"
android:title="@string/pref_about_title" android:persistent="false"
android:dialogIcon="@android:drawable/ic_dialog_info" android:title="@string/pref_about_title">
android:negativeButtonText="" <com.cradle.iitc_mobile.IITC_AboutDialogPreference
android:positiveButtonText="" android:dialogIcon="@android:drawable/ic_dialog_info"
android:dialogTitle="@string/pref_about_title"/> android:key="pref_about"
android:title="@string/pref_about_title"/>
</PreferenceScreen>
<PreferenceCategory <PreferenceCategory
android:key="pref_ui_cat" android:key="pref_ui_cat"
android:title="@string/pref_ui_cat"> android:title="@string/pref_ui_cat">
<CheckBoxPreference <CheckBoxPreference
android:key="pref_user_loc" android:defaultValue="false"
android:title="@string/pref_user_loc" android:key="pref_user_loc"
android:summary="@string/pref_user_loc_sum" android:summary="@string/pref_user_loc_sum"
android:defaultValue="false" /> android:title="@string/pref_user_loc"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="pref_user_zoom" android:key="pref_user_zoom"
android:title="@string/pref_user_zoom"
android:summary="@string/pref_user_zoom_sum" android:summary="@string/pref_user_zoom_sum"
android:defaultValue="false" /> android:title="@string/pref_user_zoom"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true"
android:key="pref_fullscreen_actionbar" android:key="pref_fullscreen_actionbar"
android:title="@string/pref_fullscreen_actionbar"
android:summary="@string/pref_fullscreen_actionbar_sum" android:summary="@string/pref_fullscreen_actionbar_sum"
android:defaultValue="true" /> android:title="@string/pref_fullscreen_actionbar"/>
<CheckBoxPreference <CheckBoxPreference
android:key="pref_force_desktop" android:defaultValue="false"
android:title="@string/pref_force_desktop" android:key="pref_force_desktop"
android:summary="@string/pref_force_desktop_sum" android:summary="@string/pref_force_desktop_sum"
android:defaultValue="false" /> android:title="@string/pref_force_desktop"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="pref_mics" android:key="pref_mics"
android:title="@string/pref_misc_cat"> android:title="@string/pref_misc_cat">
<!-- summary is set in settings fragment --> <!-- summary is set in settings fragment -->
<EditTextPreference <EditTextPreference
android:defaultValue="local"
android:key="pref_iitc_source" android:key="pref_iitc_source"
android:title="@string/pref_select_iitc" android:title="@string/pref_select_iitc"/>
android:defaultValue="local"/>
<PreferenceScreen <PreferenceScreen
android:fragment="com.cradle.iitc_mobile.fragments.PluginsFragment" android:fragment="com.cradle.iitc_mobile.fragments.PluginsFragment"
android:key="pref_plugins" android:key="pref_plugins"
android:title="@string/pref_plugins" android:persistent="false"
android:persistent="false"> android:title="@string/pref_plugins">
<intent <intent
android:targetPackage="com.cradle.iitc_mobile" android:targetClass="com.cradle.iitc_mobile.IITC_PluginPreferenceActivity"
android:targetClass="com.cradle.iitc_mobile.IITC_PluginPreferenceActivity"/> android:targetPackage="com.cradle.iitc_mobile"/>
</PreferenceScreen> </PreferenceScreen>
<CheckBoxPreference
android:key="pref_force_https"
android:title="@string/pref_force_https"
android:summary="@string/pref_force_https_sum"
android:defaultValue="true" />
<CheckBoxPreference
android:key="pref_press_twice_to_exit"
android:title="@string/pref_press_twice_to_exit"
android:summary="@string/pref_press_twice_to_exit_sum"
android:defaultValue="false" />
</PreferenceCategory>
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_force_https"
android:summary="@string/pref_force_https_sum"
android:title="@string/pref_force_https"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_press_twice_to_exit"
android:summary="@string/pref_press_twice_to_exit_sum"
android:title="@string/pref_press_twice_to_exit"/>
</PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="pref_developer_options" android:key="pref_developer_options"
android:title="@string/pref_developer_options_cat"> android:title="@string/pref_developer_options_cat">
<PreferenceScreen <PreferenceScreen
android:key="pref_developer_screen" android:key="pref_developer_screen"
android:title="@string/pref_advanced_options" android:persistent="false"
android:persistent="false"> android:title="@string/pref_advanced_options">
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="pref_dev_checkbox" android:key="pref_dev_checkbox"
android:title="@string/pref_enable_dev_mode"
android:summary="@string/pref_enable_dev_mode_sum" android:summary="@string/pref_enable_dev_mode_sum"
android:defaultValue="false" /> android:title="@string/pref_enable_dev_mode"/>
<PreferenceCategory <PreferenceCategory
android:key="pref_advanced_ui_cat" android:key="pref_advanced_ui_cat"
android:title="@string/pref_ui_cat"> android:title="@string/pref_ui_cat">
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="pref_advanced_menu" android:key="pref_advanced_menu"
android:title="@string/pref_advanced_menu"
android:summary="@string/pref_advanced_menu_sum" android:summary="@string/pref_advanced_menu_sum"
android:defaultValue="false" /> android:title="@string/pref_advanced_menu"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="pref_disable_splash" android:key="pref_disable_splash"
android:title="@string/pref_disable_splash" android:title="@string/pref_disable_splash"/>
android:defaultValue="false" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="pref_advanced_tweaks_cat" android:key="pref_advanced_tweaks_cat"
android:title="@string/pref_tweaks_cat"> android:title="@string/pref_tweaks_cat">
<ListPreference <ListPreference
android:key="pref_caching"
android:title="@string/pref_caching"
android:summary="@string/pref_caching_sum"
android:defaultValue="1" android:defaultValue="1"
android:entries="@array/pref_caching_array" android:entries="@array/pref_caching_array"
android:entryValues="@array/pref_caching_array_vals" /> android:entryValues="@array/pref_caching_array_vals"
android:key="pref_caching"
android:summary="@string/pref_caching_sum"
android:title="@string/pref_caching"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="pref_fake_user_agent" android:key="pref_fake_user_agent"
android:title="@string/pref_fake_user_agent"
android:summary="@string/pref_fake_user_agent_sum" android:summary="@string/pref_fake_user_agent_sum"
android:defaultValue="false" /> android:title="@string/pref_fake_user_agent"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
<ListPreference
android:key="pref_build_version"
android:title="@string/build_version"
android:enabled="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:persistent="false" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -1,44 +1,41 @@
package com.cradle.iitc_mobile; package com.cradle.iitc_mobile;
import android.app.AlertDialog.Builder;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.preference.Preference;
import android.content.DialogInterface.OnClickListener;
import android.preference.DialogPreference;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
public class IITC_AboutDialogPreference extends DialogPreference { public class IITC_AboutDialogPreference extends Preference {
private String mBuildVersion = "";
private final Context mContext; private String mIitcVersion = "";
public IITC_AboutDialogPreference(Context context, AttributeSet attrs) { public IITC_AboutDialogPreference(Context context, AttributeSet attrs) {
super(context, 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 @Override
protected void onPrepareDialogBuilder(Builder builder) { public View getView(View convertView, ViewGroup parent) {
final TextView message = new TextView(mContext); /*
String about_msg = mContext.getText(R.string.pref_about_msg).toString(); * I found no better way for clickable links in a TextView then using Html.fromHtml(). Linkify
message.setText(Html.fromHtml(about_msg)); * is just broken and does not understand html href tags, so let's tag the @string/about_msg
message.setMovementMethod(LinkMovementMethod.getInstance()); * with CDATA and use Html.fromHtml() for clickable hrefs with tags.
builder.setView(message).setTitle(R.string.about) */
.setIcon(android.R.drawable.ic_dialog_info) final TextView tv = new TextView(getContext());
.setNeutralButton(R.string.close, new OnClickListener() { String text = getContext().getText(R.string.pref_about_text).toString();
public void onClick(DialogInterface dialog, int id) { text = String.format(text, mBuildVersion, mIitcVersion);
dialog.cancel();
} tv.setText(Html.fromHtml(text));
}); tv.setMovementMethod(LinkMovementMethod.getInstance());
super.onPrepareDialogBuilder(builder);
return tv;
} }
public void setVersions(String iitcVersion, String buildVersion) {
mIitcVersion = iitcVersion;
mBuildVersion = buildVersion;
}
} }

View File

@ -12,7 +12,6 @@ import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.webkit.SslErrorHandler; import android.webkit.SslErrorHandler;
import android.webkit.WebResourceResponse; import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.Toast; import android.widget.Toast;

View File

@ -6,66 +6,53 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle; import android.os.Bundle;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.cradle.iitc_mobile.IITC_AboutDialogPreference;
import com.cradle.iitc_mobile.R; import com.cradle.iitc_mobile.R;
public class MainSettings extends PreferenceFragment { public class MainSettings extends PreferenceFragment {
private String mIitcVersion;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mIitcVersion = getArguments().getString("iitc_version");
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
// set build version // set versions
ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version"); String iitcVersion = getArguments().getString("iitc_version");
String buildVersion = "unknown";
PackageManager pm = getActivity().getPackageManager(); PackageManager pm = getActivity().getPackageManager();
String version = "unknown";
try { try {
PackageInfo info = pm.getPackageInfo( PackageInfo info = pm.getPackageInfo(getActivity().getPackageName(), 0);
getActivity().getPackageName(), 0); buildVersion = info.versionName;
version = info.versionName;
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
pref_build_version.setSummary(version);
// set iitc version IITC_AboutDialogPreference pref_about = (IITC_AboutDialogPreference) findPreference("pref_about");
ListPreference pref_iitc_version = (ListPreference) findPreference("pref_iitc_version"); pref_about.setVersions(iitcVersion, buildVersion);
pref_iitc_version.setSummary(mIitcVersion);
// set iitc source // set iitc source
EditTextPreference pref_iitc_source = (EditTextPreference) findPreference("pref_iitc_source"); EditTextPreference pref_iitc_source = (EditTextPreference) findPreference("pref_iitc_source");
pref_iitc_source pref_iitc_source.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override
@Override public boolean onPreferenceChange(Preference preference, Object newValue) {
public boolean onPreferenceChange(Preference preference, preference.setSummary(getString(R.string.pref_select_iitc_sum) + " " + newValue);
Object newValue) { // TODO: update mIitcVersion when iitc source has changed
preference.setSummary(getString(R.string.pref_select_iitc_sum) + return true;
" " + newValue); }
// TODO: update mIitcVersion when iitc source has });
// changed
return true;
}
});
// first init of summary // first init of summary
String pref_iitc_source_sum = getString(R.string.pref_select_iitc_sum) String pref_iitc_source_sum = getString(R.string.pref_select_iitc_sum) + " " + pref_iitc_source.getText();
+ " " + pref_iitc_source.getText();
pref_iitc_source.setSummary(pref_iitc_source_sum); pref_iitc_source.setSummary(pref_iitc_source_sum);
} }