From adfa14f606e2673c70aaf88c33cd1078f4aaadbd Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 29 Nov 2011 20:48:09 +0300 Subject: [PATCH] menu cleanup, use popup dialog for selecting articles --- res/menu/main_menu.xml | 41 +++++++++++---------------- res/values/strings.xml | 14 +++++---- src/org/fox/ttrss/MainActivity.java | 44 +++++++++++++++++++++++------ 3 files changed, 59 insertions(+), 40 deletions(-) diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml index 2d2e2998..584b896b 100644 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@ -49,51 +49,42 @@ android:showAsAction="" android:title="@string/show_all_articles"/> - - - - - + android:id="@+id/headlines_select" + android:title="@string/headlines_select"/> - - - - + + + android:title="@string/article_toggle_published"/> + android:title="@string/article_set_unread"/> + + Browse articles Log sent and received data - Toggle starred - Toggle published - Select all - Select none - Unread + Toggle starred + Toggle published + Select articles + Select articles + All articles + Unread articles + None Starred Published Unread - Mark unread + Mark unread Optional. Fill this if your tt-rss installation is protected by HTTP Basic authentication Your tt-rss login. Not needed for single user mode Enable ads diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index 7aba8cc7..50313072 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -5,7 +5,10 @@ import java.util.Timer; import java.util.TimerTask; import android.animation.LayoutTransition; +import android.app.AlertDialog; +import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; @@ -23,7 +26,9 @@ import android.view.MenuItem; import android.view.View; import android.view.animation.AnimationUtils; import android.widget.AdapterView.AdapterContextMenuInfo; +import android.widget.ArrayAdapter; import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.TextView; import com.google.gson.JsonElement; @@ -528,7 +533,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe @SuppressWarnings("unchecked") @Override public boolean onOptionsItemSelected(MenuItem item) { - HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment); + final HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment); switch (item.getItemId()) { case R.id.preferences: @@ -553,14 +558,35 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe case R.id.back_to_categories: closeCategory(); return true; - case R.id.headlines_select_all: - if (hf != null) hf.setSelection(HeadlinesFragment.ArticlesSelection.ALL); - return true; - case R.id.headlines_select_none: - if (hf != null) hf.setSelection(HeadlinesFragment.ArticlesSelection.NONE); - return true; - case R.id.headlines_select_unread: - if (hf != null) hf.setSelection(HeadlinesFragment.ArticlesSelection.UNREAD); + case R.id.headlines_select: + if (hf != null) { + Dialog dialog = new Dialog(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.headlines_select_dialog); + + builder.setSingleChoiceItems(new String[] { getString(R.string.headlines_select_all), + getString(R.string.headlines_select_unread), getString(R.string.headlines_select_none) }, 0, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case 0: + hf.setSelection(HeadlinesFragment.ArticlesSelection.ALL); + break; + case 1: + hf.setSelection(HeadlinesFragment.ArticlesSelection.UNREAD); + break; + case 2: + hf.setSelection(HeadlinesFragment.ArticlesSelection.NONE); + break; + } + dialog.cancel(); + } + }); + + dialog = builder.create(); + dialog.show(); + } + return true; case R.id.catchup_and_load: if (hf != null) {