Do not show a dialog more than once.
Implement "Do not show again"
This commit is contained in:
parent
b4fe2a4c0b
commit
6cb55ae2b1
28
mobile/res/layout/dialog_notice.xml
Normal file
28
mobile/res/layout/dialog_notice.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_notice"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/cb_do_not_show_again"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/notice_do_not_show_again"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -148,6 +148,7 @@
|
|||||||
<string name="search_hint">Search Locations</string>
|
<string name="search_hint">Search Locations</string>
|
||||||
<string name="intent_error">Address could not be opened</string>
|
<string name="intent_error">Address could not be opened</string>
|
||||||
<string name="msg_copied">Copied to clipboard…</string>
|
<string name="msg_copied">Copied to clipboard…</string>
|
||||||
|
<string name="notice_do_not_show_again">Do not show again</string>
|
||||||
|
|
||||||
<string name="tab_map">Map</string>
|
<string name="tab_map">Map</string>
|
||||||
<string name="tab_share">Share</string>
|
<string name="tab_share">Share</string>
|
||||||
|
@ -19,6 +19,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
|||||||
private boolean mIsLoading;
|
private boolean mIsLoading;
|
||||||
private Pane mPane = Pane.MAP;
|
private Pane mPane = Pane.MAP;
|
||||||
private String mHighlighter = null;
|
private String mHighlighter = null;
|
||||||
|
private int mDialogs = 0;
|
||||||
|
|
||||||
public IITC_NavigationHelper(IITC_Mobile activity, ActionBar bar) {
|
public IITC_NavigationHelper(IITC_Mobile activity, ActionBar bar) {
|
||||||
super(activity, (DrawerLayout) activity.findViewById(R.id.drawer_layout),
|
super(activity, (DrawerLayout) activity.findViewById(R.id.drawer_layout),
|
||||||
@ -79,30 +81,30 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showNotice(final int which) {
|
private void showNotice(final int which) {
|
||||||
if ((mPrefs.getInt("pref_messages", 0) & which) != 0) return;
|
if ((mPrefs.getInt("pref_messages", 0) & which) != 0 || (mDialogs & which) != 0) return;
|
||||||
|
|
||||||
String text;
|
int text;
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case NOTICE_DRAWERS:
|
case NOTICE_DRAWERS:
|
||||||
text = mIitc.getText(R.string.notice_how_to).toString();
|
text = R.string.notice_how_to;
|
||||||
break;
|
break;
|
||||||
case NOTICE_INFO:
|
case NOTICE_INFO:
|
||||||
text = mIitc.getText(R.string.notice_info).toString();
|
text = R.string.notice_info;
|
||||||
break;
|
break;
|
||||||
case NOTICE_PANES:
|
case NOTICE_PANES:
|
||||||
text = mIitc.getText(R.string.notice_panes).toString();
|
text = R.string.notice_panes;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView message = new TextView(mIitc);
|
final View content = mIitc.getLayoutInflater().inflate(R.layout.dialog_notice, null);
|
||||||
message.setPadding(20, 20, 20, 20);
|
TextView message = (TextView) content.findViewById(R.id.tv_notice);
|
||||||
message.setText(Html.fromHtml(text));
|
message.setText(Html.fromHtml(mIitc.getString(text)));
|
||||||
message.setMovementMethod(LinkMovementMethod.getInstance());
|
message.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
AlertDialog dialog = new AlertDialog.Builder(mIitc)
|
AlertDialog dialog = new AlertDialog.Builder(mIitc)
|
||||||
.setView(message)
|
.setView(content)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(android.R.string.ok, new OnClickListener() {
|
.setPositiveButton(android.R.string.ok, new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -114,15 +116,20 @@ 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);
|
mDialogs &= ~which;
|
||||||
value |= which;
|
if (((CheckBox) content.findViewById(R.id.cb_do_not_show_again)).isChecked()) {
|
||||||
|
int value = mPrefs.getInt("pref_messages", 0);
|
||||||
|
value |= which;
|
||||||
|
|
||||||
mPrefs
|
mPrefs
|
||||||
.edit()
|
.edit()
|
||||||
.putInt("pref_messages", value)
|
.putInt("pref_messages", value)
|
||||||
.commit();
|
.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mDialogs |= which;
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user