add show unread/show all menu item
This commit is contained in:
parent
c18ed97aa4
commit
d5f17058c4
@ -1,17 +1,16 @@
|
||||
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:id="@+id/main_flipper">
|
||||
<FrameLayout android:id="@+id/sync_splash" android:layout_height="match_parent" android:layout_gravity="center_vertical" android:layout_width="match_parent">
|
||||
<LinearLayout android:gravity="center" android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:layout_height="wrap_content" android:id="@+id/loading_progress"></ProgressBar>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:text="@string/loading_message"></TextView>
|
||||
<FrameLayout android:layout_height="match_parent" android:id="@+id/sync_splash" android:layout_gravity="center_vertical" android:layout_width="match_parent">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/linearLayout1" android:gravity="center">
|
||||
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar>
|
||||
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/loading_message" android:layout_height="wrap_content" android:id="@+id/loading_message"></TextView>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
<LinearLayout android:layout_height="fill_parent" android:id="@+id/main" android:layout_width="fill_parent" android:orientation="horizontal">
|
||||
<LinearLayout android:id="@+id/feeds_fragment" android:layout_weight="0.6" android:layout_height="match_parent" android:orientation="vertical" android:layout_width="match_parent"></LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_height="match_parent" android:layout_weight="0.5" android:id="@+id/headlines_fragment" android:orientation="vertical" android:layout_width="match_parent"></LinearLayout>
|
||||
<LinearLayout android:id="@+id/article_fragment" android:layout_weight="0.5" android:layout_height="match_parent" android:orientation="vertical" android:layout_width="match_parent"></LinearLayout>
|
||||
<LinearLayout android:orientation="horizontal" android:layout_height="fill_parent" android:id="@+id/main" android:layout_width="fill_parent">
|
||||
<LinearLayout android:orientation="vertical" android:id="@+id/feeds_fragment" android:layout_height="match_parent" android:layout_width="300px"></LinearLayout>
|
||||
<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_weight="0.5" android:id="@+id/headlines_fragment" android:layout_height="match_parent"></LinearLayout>
|
||||
<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_weight="0.5" android:id="@+id/article_fragment" android:layout_height="match_parent"></LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/show_feeds"
|
||||
android:icon="@android:drawable/ic_menu_rotate"
|
||||
android:title="@string/menu_unread_feeds"
|
||||
android:showAsAction="ifRoom|withText"/>
|
||||
|
||||
<item android:id="@+id/preferences"
|
||||
android:icon="@android:drawable/ic_menu_preferences"
|
||||
android:title="@string/preferences"
|
||||
|
@ -26,4 +26,7 @@
|
||||
<string name="no_unread_feeds">No unread feeds.</string>
|
||||
<string name="no_unread_headlines">No unread headlines.</string>
|
||||
<string name="loading_message">Loading, please wait...</string>
|
||||
<string name="menu_unread_feeds">Unread feeds</string>
|
||||
<string name="menu_all_feeds">All feeds</string>
|
||||
|
||||
</resources>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<item name="unreadCounterColor">#0000ff</item>
|
||||
<item name="headlinesBackground">#ffffff</item>
|
||||
<item name="articleDivider">#f0f0f0</item>
|
||||
<item name="articleHeader">#ffffff</item>
|
||||
<item name="articleHeader">#E8F2FF</item>
|
||||
</style>
|
||||
|
||||
<style name="DarkTheme" parent="android:Theme.Holo">
|
||||
|
@ -47,7 +47,9 @@ public class ArticleFragment extends Fragment {
|
||||
if (web != null) {
|
||||
|
||||
// this is ridiculous
|
||||
String content = "<html><body>" + URLEncoder.encode(m_article.content).replace('+', ' ') + "</body></html>";
|
||||
String content = URLEncoder.encode("<html>" +
|
||||
"<head><style type=\"text/css\">img { max-width : 90%; }</style></head>" +
|
||||
"<body>" + m_article.content + "</body></html>").replace('+', ' ');
|
||||
|
||||
web.loadData(content, "text/html", "utf-8");
|
||||
}
|
||||
|
@ -32,8 +32,6 @@ import com.google.gson.reflect.TypeToken;
|
||||
public class FeedsFragment extends Fragment implements OnItemClickListener {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
private SharedPreferences m_prefs;
|
||||
//private String m_sessionId;
|
||||
//private int m_activeFeedId;
|
||||
private FeedListAdapter m_adapter;
|
||||
private List<Feed> m_feeds = new ArrayList<Feed>();
|
||||
private OnFeedSelectedListener m_feedSelectedListener;
|
||||
@ -41,7 +39,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
||||
public interface OnFeedSelectedListener {
|
||||
public void onFeedSelected(Feed feed);
|
||||
}
|
||||
|
||||
|
||||
public void showLoading(boolean show) {
|
||||
View v = getView();
|
||||
|
||||
@ -115,6 +113,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
||||
fr.setApi(m_prefs.getString("ttrss_url", null));
|
||||
|
||||
final String sessionId = ((MainActivity)getActivity()).getSessionId();
|
||||
final boolean unreadOnly = ((MainActivity)getActivity()).getUnreadOnly();
|
||||
|
||||
if (sessionId != null) {
|
||||
|
||||
@ -123,7 +122,9 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
||||
put("op", "getFeeds");
|
||||
put("sid", sessionId);
|
||||
put("cat_id", "-3");
|
||||
put("unread_only", "true");
|
||||
if (unreadOnly) {
|
||||
put("unread_only", String.valueOf(unreadOnly));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -32,8 +32,8 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
|
||||
private Feed m_activeFeed;
|
||||
private Timer m_refreshTimer;
|
||||
private RefreshTask m_refreshTask;
|
||||
|
||||
protected MenuItem m_syncStatus;
|
||||
private Menu m_menu;
|
||||
private boolean m_unreadOnly = true;
|
||||
|
||||
private class RefreshTask extends TimerTask {
|
||||
|
||||
@ -53,6 +53,17 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setUnreadOnly(boolean unread) {
|
||||
m_unreadOnly = unread;
|
||||
refreshFeeds();
|
||||
}
|
||||
|
||||
public boolean getUnreadOnly() {
|
||||
return m_unreadOnly;
|
||||
}
|
||||
|
||||
|
||||
public String getSessionId() {
|
||||
return m_sessionId;
|
||||
}
|
||||
@ -97,7 +108,7 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
|
||||
ft.commit();
|
||||
|
||||
findViewById(R.id.article_fragment).setVisibility(View.GONE);
|
||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||
//findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||
|
||||
LoginRequest ar = new LoginRequest();
|
||||
ar.setApi(m_prefs.getString("ttrss_url", null));
|
||||
@ -167,10 +178,20 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.main_menu, menu);
|
||||
|
||||
m_menu = menu;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setMenuLabel(int id, int labelId) {
|
||||
MenuItem mi = m_menu.findItem(id);
|
||||
|
||||
if (mi != null) {
|
||||
mi.setTitle(labelId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
@ -178,6 +199,15 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
|
||||
Intent intent = new Intent(this, PreferencesActivity.class);
|
||||
startActivityForResult(intent, 0);
|
||||
return true;
|
||||
case R.id.show_feeds:
|
||||
if (getUnreadOnly()) {
|
||||
item.setTitle(R.string.menu_all_feeds);
|
||||
} else {
|
||||
item.setTitle(R.string.menu_unread_feeds);
|
||||
}
|
||||
|
||||
setUnreadOnly(!getUnreadOnly());
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user