implement support for article sorting modes instead of previous preference options
This commit is contained in:
parent
7feb9203ab
commit
36c24e5846
@ -233,7 +233,7 @@ public class ArticlePager extends Fragment {
|
||||
put("view_mode", m_activity.getViewMode());
|
||||
put("skip", String.valueOf(fskip));
|
||||
put("include_nested", "true");
|
||||
put("order_by", m_prefs.getBoolean("oldest_first", false) ? "date_reverse" : "");
|
||||
put("order_by", m_activity.getSortMode());
|
||||
|
||||
if (feed.is_cat) put("is_cat", "true");
|
||||
|
||||
|
@ -2,6 +2,9 @@ package org.fox.ttrss;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
@ -297,10 +300,58 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
//getSupportFragmentManager().popBackStack();
|
||||
return true;
|
||||
case R.id.headlines_toggle_sort_order:
|
||||
SharedPreferences.Editor editor = m_prefs.edit();
|
||||
editor.putBoolean("oldest_first", !m_prefs.getBoolean("oldest_first", false));
|
||||
editor.commit();
|
||||
refresh();
|
||||
Dialog dialog = new Dialog(this);
|
||||
|
||||
String sortMode = getSortMode();
|
||||
|
||||
int selectedIndex = 0;
|
||||
|
||||
if (sortMode.equals("feed_dates")) {
|
||||
selectedIndex = 1;
|
||||
} else if (sortMode.equals("date_reverse")) {
|
||||
selectedIndex = 2;
|
||||
} else if (sortMode.equals("title")) {
|
||||
selectedIndex = 3;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||
.setTitle(getString(R.string.headlines_sort_articles_title))
|
||||
.setSingleChoiceItems(
|
||||
new String[] {
|
||||
getString(R.string.headlines_sort_default),
|
||||
getString(R.string.headlines_sort_newest_first),
|
||||
getString(R.string.headlines_sort_oldest_first),
|
||||
getString(R.string.headlines_sort_title)
|
||||
},
|
||||
selectedIndex, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
Log.d(TAG, "which:" + which);
|
||||
|
||||
switch (which) {
|
||||
case 0:
|
||||
setSortMode("default");
|
||||
break;
|
||||
case 1:
|
||||
setSortMode("feed_dates");
|
||||
break;
|
||||
case 2:
|
||||
setSortMode("date_reverse");
|
||||
break;
|
||||
case 3:
|
||||
setSortMode("title");
|
||||
break;
|
||||
}
|
||||
dialog.cancel();
|
||||
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
return true;
|
||||
case R.id.show_feeds:
|
||||
setUnreadOnly(!getUnreadOnly());
|
||||
|
@ -541,7 +541,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
put("offset", String.valueOf(0));
|
||||
put("skip", String.valueOf(fskip));
|
||||
put("include_nested", "true");
|
||||
put("order_by", m_prefs.getBoolean("oldest_first", false) ? "date_reverse" : "");
|
||||
put("order_by", m_activity.getSortMode());
|
||||
|
||||
if (isCat) put("is_cat", "true");
|
||||
|
||||
|
@ -1723,13 +1723,25 @@ public class OnlineActivity extends CommonActivity {
|
||||
|
||||
}
|
||||
|
||||
public void setViewMode(String viewMode) {
|
||||
public String getSortMode() {
|
||||
return m_prefs.getString("headlines_sort_mode", "default");
|
||||
}
|
||||
|
||||
public void setSortMode(String sortMode) {
|
||||
Log.d(TAG, "setSortMode:" + sortMode);
|
||||
|
||||
SharedPreferences.Editor editor = m_prefs.edit();
|
||||
editor.putString("headlines_sort_mode", sortMode);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public void setViewMode(String viewMode) {
|
||||
SharedPreferences.Editor editor = m_prefs.edit();
|
||||
editor.putString("view_mode", viewMode);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public String getViewMode() {
|
||||
|
||||
public String getViewMode() {
|
||||
return m_prefs.getString("view_mode", "adaptive");
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,17 @@ public class OfflineActivity extends CommonActivity {
|
||||
editor.putString("offline_view_mode", viewMode);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
|
||||
/* public String getSortMode() {
|
||||
return m_prefs.getString("headlines_sort_mode", "default");
|
||||
}
|
||||
|
||||
public void setSortMode(String sortMode) {
|
||||
SharedPreferences.Editor editor = m_prefs.edit();
|
||||
editor.putString("headlines_sort_mode", sortMode);
|
||||
editor.commit();
|
||||
} */
|
||||
|
||||
public String getViewMode() {
|
||||
return m_prefs.getString("offline_view_mode", "adaptive");
|
||||
}
|
||||
|
@ -244,5 +244,10 @@
|
||||
<string name="error_loading_image">Error loading image.</string>
|
||||
<string name="open_parent">Open parent</string>
|
||||
<string name="toggle_sort_order">Toggle oldest first</string>
|
||||
<string name="headlines_sort_default">Default</string>
|
||||
<string name="headlines_sort_newest_first">Newest first</string>
|
||||
<string name="headlines_sort_oldest_first">Oldest first</string>
|
||||
<string name="headlines_sort_title">Title</string>
|
||||
<string name="headlines_sort_articles_title">Sort articles</string>
|
||||
|
||||
</resources>
|
||||
|
@ -104,11 +104,6 @@
|
||||
android:summary="@string/pref_headlines_full_content_long"
|
||||
android:title="@string/pref_headlines_full_content" /> -->
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="oldest_first"
|
||||
android:summary="@string/requires_api5"
|
||||
android:title="@string/offline_oldest_first" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="headlines_mark_read_scroll"
|
||||
@ -171,10 +166,6 @@
|
||||
android:key="offline_image_cache_enabled"
|
||||
android:summary="@string/offline_image_cache_enabled_summary"
|
||||
android:title="@string/offline_image_cache_enabled" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="offline_oldest_first"
|
||||
android:title="@string/offline_oldest_first" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/debugging" >
|
||||
<CheckBoxPreference
|
||||
|
Loading…
Reference in New Issue
Block a user