Add notice about long tapping

This commit is contained in:
fkloft 2013-09-24 14:17:55 +02:00
parent 845efddecd
commit 3172fc4e69
3 changed files with 33 additions and 7 deletions

View File

@ -62,6 +62,9 @@
• Layers/Highlights: swipe from the right edge of your screen (or click the layer-chooser icon in the ActionBar) • Layers/Highlights: swipe from the right edge of your screen (or click the layer-chooser icon in the ActionBar)
to evoke the Layer Drawer]]> to evoke the Layer Drawer]]>
</string> </string>
<string name="notice_info">
<![CDATA[Hint: The info screen will open if you tap and hold a portal for a second.]]>
</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>

View File

@ -106,7 +106,7 @@ public class IITC_Mobile extends Activity {
if (key.equals("pref_press_twice_to_exit") if (key.equals("pref_press_twice_to_exit")
|| key.equals("pref_share_selected_tab") || key.equals("pref_share_selected_tab")
|| key.equals("pref_drawers_seen")) || key.equals("pref_messages"))
// no reload needed // no reload needed
return; return;

View File

@ -94,6 +94,10 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
COMPACT, DEBUG, FACTION, FULL, INFO, MAP, PUBLIC COMPACT, DEBUG, FACTION, FULL, INFO, MAP, PUBLIC
} }
public static final int NOTICE_DRAWERS = 1 << 0;
public static final int NOTICE_INFO = 1 << 1;
// next one would be 1<<2; (this results in 1,2,4,8,...)
private IITC_Mobile mIitc; private IITC_Mobile mIitc;
private ActionBar mActionBar; private ActionBar mActionBar;
private SharedPreferences mPrefs; private SharedPreferences mPrefs;
@ -130,16 +134,28 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
onPrefChanged(); // also calls updateActionBar() onPrefChanged(); // also calls updateActionBar()
showNotice(); showNotice(NOTICE_DRAWERS);
} }
private void showNotice() { private void showNotice(final int which) {
if (mPrefs.getBoolean("pref_drawers_seen", false)) if ((mPrefs.getInt("pref_messages", 0) & which) != 0)
return; return;
String text;
switch (which) {
case NOTICE_DRAWERS:
text = mIitc.getText(R.string.notice_drawers).toString();
break;
case NOTICE_INFO:
text = mIitc.getText(R.string.notice_info).toString();
break;
default:
return;
}
TextView message = new TextView(mIitc); TextView message = new TextView(mIitc);
message.setPadding(20, 20, 20, 20); message.setPadding(20, 20, 20, 20);
message.setText(Html.fromHtml(mIitc.getText(R.string.notice_drawers).toString())); message.setText(Html.fromHtml(text));
AlertDialog dialog = new AlertDialog.Builder(mIitc) AlertDialog dialog = new AlertDialog.Builder(mIitc)
.setView(message) .setView(message)
@ -154,9 +170,12 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
dialog.setOnDismissListener(new OnDismissListener() { dialog.setOnDismissListener(new OnDismissListener() {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
int value = mPrefs.getInt("pref_messages", 0);
value |= which;
mPrefs mPrefs
.edit() .edit()
.putBoolean("pref_drawers_seen", true) .putInt("pref_messages", value)
.commit(); .commit();
} }
}); });
@ -255,6 +274,10 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Pane item = mNavigationAdapter.getItem(position); Pane item = mNavigationAdapter.getItem(position);
mIitc.switchToPane(item); mIitc.switchToPane(item);
if (item == Pane.INFO)
showNotice(NOTICE_INFO);
mDrawerLayout.closeDrawer(mDrawerLeft); mDrawerLayout.closeDrawer(mDrawerLeft);
} }