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="local">local</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>
<!-- Use CDATA to prevent android from parsing html tags....we are doing this with Html.fromHtml() -->
<string name="pref_about_msg">
<![CDATA[<big><b>Ingress Intel Total Conversion Mobile</b></big><br><br>
<string name="pref_about_text">
<![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>Icon by <a href="http://www.ludolab.net">Giuseppe Lucido</a></b><br><br>
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>.
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>
<b>Community:</b><br>
is continued on a fork of <a href="https://github.com/jonatkins"><b>jonatkins</b></a>.
<h3>Community:</h3>
• 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>
for release announcements.<br>
• 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>
<b>Developers:</b><br>
<a href="https://github.com/jonatkins/ingress-intel-total-conversion">IITC on Github</a><br><br>
<b>IITC Licence:</b><br>
- a place to ask for help and discuss with other users.
<h3>Developers:</h3>
<a href="https://github.com/jonatkins/ingress-intel-total-conversion">IITC on Github</a>
<h3>IITC Licence:</h3>
Copyright © 2013 Stefan Breunig, Jon Atkins, Philipp Schäfer and others<br><br>
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.
]]>
</string>
<string name="notice_drawers">
<![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 on the left half of the status bar]]>
</string>
<string name="pref_ui_cat">UI</string>
<string name="pref_misc_cat">Misc</string>
<string name="pref_developer_options_cat">Developer options</string>

View File

@ -1,136 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<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"/>
<PreferenceScreen
android:key="pref_about_screen"
android:persistent="false"
android:title="@string/pref_about_title">
<com.cradle.iitc_mobile.IITC_AboutDialogPreference
android:dialogIcon="@android:drawable/ic_dialog_info"
android:key="pref_about"
android:title="@string/pref_about_title"/>
</PreferenceScreen>
<PreferenceCategory
android:key="pref_ui_cat"
android:title="@string/pref_ui_cat">
<CheckBoxPreference
android:key="pref_user_loc"
android:title="@string/pref_user_loc"
android:summary="@string/pref_user_loc_sum"
android:defaultValue="false" />
android:defaultValue="false"
android:key="pref_user_loc"
android:summary="@string/pref_user_loc_sum"
android:title="@string/pref_user_loc"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_user_zoom"
android:title="@string/pref_user_zoom"
android:summary="@string/pref_user_zoom_sum"
android:defaultValue="false" />
android:title="@string/pref_user_zoom"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_fullscreen_actionbar"
android:title="@string/pref_fullscreen_actionbar"
android:summary="@string/pref_fullscreen_actionbar_sum"
android:defaultValue="true" />
android:title="@string/pref_fullscreen_actionbar"/>
<CheckBoxPreference
android:key="pref_force_desktop"
android:title="@string/pref_force_desktop"
android:defaultValue="false"
android:key="pref_force_desktop"
android:summary="@string/pref_force_desktop_sum"
android:defaultValue="false" />
android:title="@string/pref_force_desktop"/>
</PreferenceCategory>
<PreferenceCategory
android:key="pref_mics"
android:title="@string/pref_misc_cat">
<!-- summary is set in settings fragment -->
<EditTextPreference
android:defaultValue="local"
android:key="pref_iitc_source"
android:title="@string/pref_select_iitc"
android:defaultValue="local"/>
android:title="@string/pref_select_iitc"/>
<PreferenceScreen
android:fragment="com.cradle.iitc_mobile.fragments.PluginsFragment"
android:key="pref_plugins"
android:title="@string/pref_plugins"
android:persistent="false">
android:persistent="false"
android:title="@string/pref_plugins">
<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>
<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
android:key="pref_developer_options"
android:title="@string/pref_developer_options_cat">
<PreferenceScreen
android:key="pref_developer_screen"
android:title="@string/pref_advanced_options"
android:persistent="false">
android:persistent="false"
android:title="@string/pref_advanced_options">
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_dev_checkbox"
android:title="@string/pref_enable_dev_mode"
android:summary="@string/pref_enable_dev_mode_sum"
android:defaultValue="false" />
android:title="@string/pref_enable_dev_mode"/>
<PreferenceCategory
android:key="pref_advanced_ui_cat"
android:title="@string/pref_ui_cat">
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_advanced_menu"
android:title="@string/pref_advanced_menu"
android:summary="@string/pref_advanced_menu_sum"
android:defaultValue="false" />
android:title="@string/pref_advanced_menu"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_disable_splash"
android:title="@string/pref_disable_splash"
android:defaultValue="false" />
android:title="@string/pref_disable_splash"/>
</PreferenceCategory>
<PreferenceCategory
android:key="pref_advanced_tweaks_cat"
android:title="@string/pref_tweaks_cat">
<ListPreference
android:key="pref_caching"
android:title="@string/pref_caching"
android:summary="@string/pref_caching_sum"
android:defaultValue="1"
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
android:defaultValue="false"
android:key="pref_fake_user_agent"
android:title="@string/pref_fake_user_agent"
android:summary="@string/pref_fake_user_agent_sum"
android:defaultValue="false" />
android:title="@string/pref_fake_user_agent"/>
</PreferenceCategory>
</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>
</PreferenceScreen>

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}