add menu item to set view mode, bump version

This commit is contained in:
Andrew Dolgov 2013-03-25 10:15:42 +04:00
parent 201dce1474
commit 48e5015353
6 changed files with 88 additions and 6 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss"
android:versionCode="147"
android:versionName="1.3" >
android:versionCode="148"
android:versionName="1.4" >
<uses-sdk
android:minSdkVersion="8"

View File

@ -61,6 +61,12 @@
android:showAsAction=""
android:title="@string/headlines_select"/>
<item
android:id="@+id/headlines_view_mode"
android:showAsAction=""
android:title="@string/headlines_view_mode"/>
<!--
<item
android:id="@+id/close_feed"

View File

@ -179,5 +179,11 @@
<string name="error_url_is_an_html_page_no_feeds_found">Error: URL is an HTML page, no feeds found.</string>
<string name="error_url_contains_multiple_feeds">Error: URL contains multiple feeds</string>
<string name="error_could_not_download_url">Error: Could not download URL</string>
<string name="headlines_view_mode">Set view mode</string>
<string name="headlines_set_view_mode">Set view mode</string>
<string name="headlines_adaptive">Adaptive</string>
<string name="headlines_all_articles">All articles</string>
<string name="headlines_starred">Starred</string>
<string name="headlines_published">Published</string>
<string name="headlines_unread">Unread</string>
</resources>

View File

@ -218,7 +218,7 @@ public class ArticlePager extends Fragment {
put("include_attachments", "true");
put("limit", String.valueOf(HeadlinesFragment.HEADLINES_REQUEST_SIZE));
put("offset", String.valueOf(0));
put("view_mode", showUnread ? "adaptive" : "all_articles");
put("view_mode", m_activity.getViewMode());
put("skip", String.valueOf(fskip));
put("include_nested", "true");

View File

@ -344,7 +344,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
final boolean fappend = append;
final String sessionId = m_activity.getSessionId();
final boolean showUnread = m_activity.getUnreadArticlesOnly();
final boolean isCat = m_feed.is_cat;
HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext(), m_activity) {
@ -410,9 +409,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
put("feed_id", String.valueOf(m_feed.id));
put("show_content", "true");
put("include_attachments", "true");
put("view_mode", m_activity.getViewMode());
put("limit", String.valueOf(HEADLINES_REQUEST_SIZE));
put("offset", String.valueOf(0));
put("view_mode", showUnread ? "adaptive" : "all_articles");
put("skip", String.valueOf(fskip));
put("include_nested", "true");

View File

@ -711,6 +711,67 @@ public class OnlineActivity extends CommonActivity {
req.execute(map);
}
return true;
case R.id.headlines_view_mode:
if (hf != null) {
Dialog dialog = new Dialog(this);
String viewMode = getViewMode();
//Log.d(TAG, "viewMode:" + getViewMode());
int selectedIndex = 0;
if (viewMode.equals("all_articles")) {
selectedIndex = 1;
} else if (viewMode.equals("marked")) {
selectedIndex = 2;
} else if (viewMode.equals("published")) {
selectedIndex = 3;
} else if (viewMode.equals("unread")) {
selectedIndex = 4;
}
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.headlines_set_view_mode)
.setSingleChoiceItems(
new String[] {
getString(R.string.headlines_adaptive),
getString(R.string.headlines_all_articles),
getString(R.string.headlines_starred),
getString(R.string.headlines_published),
getString(R.string.headlines_unread) },
selectedIndex, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
switch (which) {
case 0:
setViewMode("adaptive");
break;
case 1:
setViewMode("all_articles");
break;
case 2:
setViewMode("marked");
break;
case 3:
setViewMode("published");
break;
case 4:
setViewMode("unread");
break;
}
dialog.cancel();
refresh();
}
});
dialog = builder.create();
dialog.show();
}
return true;
case R.id.headlines_select:
if (hf != null) {
Dialog dialog = new Dialog(this);
@ -1499,4 +1560,14 @@ public class OnlineActivity extends CommonActivity {
}
}
public void setViewMode(String viewMode) {
SharedPreferences.Editor editor = m_prefs.edit();
editor.putString("view_mode", viewMode);
editor.commit();
}
public String getViewMode() {
return m_prefs.getString("view_mode", "adaptive");
}
}