diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index 38a9ab19..a70de469 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -81,6 +81,13 @@ They won\'t appear in the info pane any more.

Swipe from the left edge of your screen (or click the app icon) to seem them.]]> + +
+ IITC Mobile is able to load external plugins too!

+ • create %1$s
+ • move *.user.js files there
+ • plugins should be listed above the official plugins]]> +
UI Misc diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java index 5b68fb33..881c30a2 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java @@ -25,6 +25,7 @@ import android.widget.ListView; import android.widget.TextView; public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnItemClickListener { + // Show/hide the up arrow on the very left // getActionBar().setDisplayHomeAsUpEnabled(enabled); @@ -37,11 +38,6 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt // Makes the icon/title clickable // getActionBar().setHomeButtonEnabled(enabled); - public static final int NOTICE_HOWTO = 1 << 0; - public static final int NOTICE_INFO = 1 << 1; - public static final int NOTICE_PANES = 1 << 2; - // next one would be 1<<2; (this results in 1,2,4,8,...) - private final IITC_Mobile mIitc; private final ActionBar mActionBar; private final SharedPreferences mPrefs; @@ -49,11 +45,11 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt private final DrawerLayout mDrawerLayout; private final ListView mDrawerLeft; private final View mDrawerRight; + private final IITC_NotificationHelper mNotificationHelper; private boolean mDesktopMode = false; private Pane mPane = Pane.MAP; private String mHighlighter = null; - private int mDialogs = 0; public IITC_NavigationHelper(IITC_Mobile activity, ActionBar bar) { super(activity, (DrawerLayout) activity.findViewById(R.id.drawer_layout), @@ -74,63 +70,11 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt mDrawerLeft.setOnItemClickListener(this); mDrawerLeft.setItemChecked(0, true); mDrawerLayout.setDrawerListener(this); + mNotificationHelper = new IITC_NotificationHelper(mIitc); onPrefChanged(); // also calls updateActionBar() - showNotice(NOTICE_HOWTO); - } - - private void showNotice(final int which) { - if ((mPrefs.getInt("pref_messages", 0) & which) != 0 || (mDialogs & which) != 0) return; - - int text; - switch (which) { - case NOTICE_HOWTO: - text = R.string.notice_how_to; - break; - case NOTICE_INFO: - text = R.string.notice_info; - break; - case NOTICE_PANES: - text = R.string.notice_panes; - break; - default: - return; - } - - final View content = mIitc.getLayoutInflater().inflate(R.layout.dialog_notice, null); - TextView message = (TextView) content.findViewById(R.id.tv_notice); - message.setText(Html.fromHtml(mIitc.getString(text))); - message.setMovementMethod(LinkMovementMethod.getInstance()); - - AlertDialog dialog = new AlertDialog.Builder(mIitc) - .setView(content) - .setCancelable(true) - .setPositiveButton(android.R.string.ok, new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.cancel(); - } - }) - .create(); - dialog.setOnDismissListener(new OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - mDialogs &= ~which; - if (((CheckBox) content.findViewById(R.id.cb_do_not_show_again)).isChecked()) { - int value = mPrefs.getInt("pref_messages", 0); - value |= which; - - mPrefs - .edit() - .putInt("pref_messages", value) - .commit(); - } - } - }); - - mDialogs |= which; - dialog.show(); + mNotificationHelper.showNotice(IITC_NotificationHelper.NOTICE_HOWTO); } private void updateViews() { @@ -182,7 +126,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt } public void addPane(String name, String label, String icon) { - showNotice(NOTICE_PANES); + mNotificationHelper.showNotice(IITC_NotificationHelper.NOTICE_PANES); Resources res = mIitc.getResources(); String packageName = res.getResourcePackageName(R.string.app_name); @@ -248,7 +192,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt mIitc.switchToPane(item); if (item == Pane.INFO) { - showNotice(NOTICE_INFO); + mNotificationHelper.showNotice(IITC_NotificationHelper.NOTICE_INFO); } mDrawerLayout.closeDrawer(mDrawerLeft); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_NotificationHelper.java b/mobile/src/com/cradle/iitc_mobile/IITC_NotificationHelper.java new file mode 100644 index 00000000..64c49e76 --- /dev/null +++ b/mobile/src/com/cradle/iitc_mobile/IITC_NotificationHelper.java @@ -0,0 +1,90 @@ +package com.cradle.iitc_mobile; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.os.Environment; +import android.preference.PreferenceManager; +import android.text.Html; +import android.text.method.LinkMovementMethod; +import android.view.View; +import android.widget.CheckBox; +import android.widget.TextView; + +public class IITC_NotificationHelper { + + public static final int NOTICE_HOWTO = 1 << 0; + public static final int NOTICE_INFO = 1 << 1; + public static final int NOTICE_PANES = 1 << 2; + public static final int NOTICE_EXTPLUGINS = 1 << 3; + // next one would be 1<<4; (this results in 1,2,4,8,...) + + private final Activity mActivity; + private final SharedPreferences mPrefs; + private int mDialogs = 0; + + public IITC_NotificationHelper(Activity activity) { + mActivity = activity; + mPrefs = PreferenceManager.getDefaultSharedPreferences(mActivity); + } + + public void showNotice(final int which) { + if ((mPrefs.getInt("pref_messages", 0) & which) != 0 || (mDialogs & which) != 0) return; + + String text; + switch (which) { + case NOTICE_HOWTO: + text = mActivity.getString(R.string.notice_how_to); + break; + case NOTICE_INFO: + text = mActivity.getString(R.string.notice_info); + break; + case NOTICE_PANES: + text = mActivity.getString(R.string.notice_panes); + break; + case NOTICE_EXTPLUGINS: + text = mActivity.getString(R.string.notice_extplugins); + text = String.format(text, Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/plugins/"); + break; + default: + return; + } + + final View content = mActivity.getLayoutInflater().inflate(R.layout.dialog_notice, null); + TextView message = (TextView) content.findViewById(R.id.tv_notice); + message.setText(Html.fromHtml(text)); + message.setMovementMethod(LinkMovementMethod.getInstance()); + + AlertDialog dialog = new AlertDialog.Builder(mActivity) + .setView(content) + .setCancelable(true) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + } + }) + .create(); + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + mDialogs &= ~which; + if (((CheckBox) content.findViewById(R.id.cb_do_not_show_again)).isChecked()) { + int value = mPrefs.getInt("pref_messages", 0); + value |= which; + + mPrefs + .edit() + .putInt("pref_messages", value) + .commit(); + } + } + }); + + mDialogs |= which; + dialog.show(); + } + + +} diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java index fc667401..00510857 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java @@ -47,6 +47,10 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { public void onBuildHeaders(List
target) { getActionBar().setDisplayHomeAsUpEnabled(true); + // notify about external plugins + IITC_NotificationHelper nh = new IITC_NotificationHelper(this); + nh.showNotice(IITC_NotificationHelper.NOTICE_EXTPLUGINS); + mHeaders = target; // since the plugins container is static, // it is enough to parse the plugin only on first start. @@ -62,11 +66,12 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (onIsMultiPane()) { getIntent() .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, PluginsFragment.class.getName()); } - super.onCreate(savedInstanceState); } @Override diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 2c2591af..00244d2d 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -36,12 +36,6 @@ public class IITC_WebViewClient extends WebViewClient { this.mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/"; } - // TODO use somewhere else: - // Toast.makeText(mIitc, "File " + mIitcPath + - // "dev/total-conversion-build.user.js not found. " + - // "Disable developer mode or add iitc files to the dev folder.", - // Toast.LENGTH_LONG).show(); - // enable https @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {