diff options
author | Andrew Dolgov <[email protected]> | 2015-06-04 20:57:32 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-06-04 20:57:32 +0300 |
commit | 8c6d767190071487df97b47ef552669df36f1256 (patch) | |
tree | da871c6a5a69aeba33d8cf569db5bbf7aba137d3 /org.fox.ttrss/src/main/java | |
parent | c9398d0fe13fbce4deafb57c910d4edf97e97723 (diff) |
move offline/online prompts to the sidebar
Diffstat (limited to 'org.fox.ttrss/src/main/java')
7 files changed, 80 insertions, 43 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/BaseFeedlistFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/BaseFeedlistFragment.java index 9f9afe73..1dc880be 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/BaseFeedlistFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/BaseFeedlistFragment.java @@ -20,7 +20,8 @@ import java.net.URL; public abstract class BaseFeedlistFragment extends Fragment { abstract public void refresh(boolean background); - public void initDrawerHeader(LayoutInflater inflater, View view, ListView list, final CommonActivity activity, final SharedPreferences prefs) { + public void initDrawerHeader(LayoutInflater inflater, View view, ListView list, final CommonActivity activity, final SharedPreferences prefs, + boolean rootView, boolean isOffline) { if (true /*m_activity.findViewById(R.id.headlines_drawer) != null*/) { try { @@ -87,6 +88,22 @@ public abstract class BaseFeedlistFragment extends Fragment { } }); + if (rootView) { + // offline + footer = inflater.inflate(R.layout.feeds_row, list, false); + list.addFooterView(footer); + text = (TextView) footer.findViewById(R.id.title); + text.setText(isOffline ? R.string.go_online : R.string.go_offline); + + icon = (ImageView) footer.findViewById(R.id.icon); + tv = new TypedValue(); + getActivity().getTheme().resolveAttribute(isOffline ? R.attr.ic_cloud_upload : R.attr.ic_cloud_download, tv, true); + icon.setImageResource(tv.resourceId); + + TextView counter = (TextView) footer.findViewById(R.id.unread_counter); + counter.setText(R.string.blank); + } + // settings footer = inflater.inflate(R.layout.feeds_row, list, false); list.addFooterView(footer); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java index db748846..4f2f72ee 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java @@ -217,7 +217,7 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt m_list = (ListView)view.findViewById(R.id.feeds); m_adapter = new FeedCategoryListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<FeedCategory>)m_cats); - initDrawerHeader(inflater, view, m_list, m_activity, m_prefs); + initDrawerHeader(inflater, view, m_list, m_activity, m_prefs, true, false); m_list.setAdapter(m_adapter); m_list.setOnItemClickListener(this); @@ -511,14 +511,6 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt if (list != null) { - if (position == list.getCount() - 1) { - Intent intent = new Intent(m_activity, - PreferencesActivity.class); - startActivityForResult(intent, 0); - - return; - } - FeedCategory cat = (FeedCategory)list.getItemAtPosition(position); if (cat != null) { @@ -531,6 +523,19 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt m_selectedCat = cat; m_adapter.notifyDataSetChanged(); + } else { + if (position == list.getCount() - 1) { + Intent intent = new Intent(m_activity, + PreferencesActivity.class); + startActivityForResult(intent, 0); + + return; + } + + if (position == list.getCount() - 2) { + m_activity.switchOffline(); + return; + } } } } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java index a3a6222d..97a96490 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java @@ -283,7 +283,7 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi m_list = (ListView)view.findViewById(R.id.feeds); - initDrawerHeader(inflater, view, m_list, m_activity, m_prefs); + initDrawerHeader(inflater, view, m_list, m_activity, m_prefs, !m_enableParentBtn, false); if (m_enableParentBtn) { View layout = inflater.inflate(R.layout.feeds_goback, m_list, false); @@ -358,14 +358,6 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi ListView list = (ListView)av; if (list != null) { - if (position == list.getCount() - 1) { - Intent intent = new Intent(m_activity, - PreferencesActivity.class); - startActivityForResult(intent, 0); - - return; - } - Feed feed = (Feed)list.getItemAtPosition(position); if (feed != null) { @@ -378,6 +370,19 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi } else { m_activity.onFeedSelected(feed); } + } else { + if (position == list.getCount() - 1) { + Intent intent = new Intent(m_activity, + PreferencesActivity.class); + startActivityForResult(intent, 0); + + return; + } + + if (position == list.getCount() - 2) { + m_activity.switchOffline(); + return; + } } m_selectedFeed = feed; diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java index ab7c95e8..8766d3cd 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java @@ -200,7 +200,7 @@ public class OnlineActivity extends CommonActivity { return GlobalState.getInstance().m_canUseProgress; } - private void switchOffline() { + protected void switchOffline() { if (m_offlineModeStatus == 2) { AlertDialog.Builder builder = new AlertDialog.Builder( @@ -729,9 +729,9 @@ public class OnlineActivity extends CommonActivity { case R.id.login: login(); return true; - case R.id.go_offline: + /*case R.id.go_offline: switchOffline(); - return true; + return true;*/ case R.id.article_set_note: if (ap != null && ap.getSelectedArticle() != null) { editArticleNote(ap.getSelectedArticle()); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java index 1bd2342c..5041fd3a 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineActivity.java @@ -271,9 +271,9 @@ public class OfflineActivity extends CommonActivity { } } return true; */ - case R.id.go_online: + /*case R.id.go_online: switchOnline(); - return true; + return true;*/ case R.id.search: if (ohf != null) { Dialog dialog = new Dialog(this); @@ -602,7 +602,7 @@ public class OfflineActivity extends CommonActivity { } } - private void switchOnline() { + protected void switchOnline() { SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE); SharedPreferences.Editor editor = localPrefs.edit(); editor.putBoolean("offline_mode_active", false); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java index 0c48df4e..88abf0f5 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java @@ -148,7 +148,7 @@ public class OfflineFeedCategoriesFragment extends BaseFeedlistFragment implemen m_adapter = new FeedCategoryListAdapter(getActivity(), R.layout.feeds_row, m_cursor, new String[] { "title", "unread" }, new int[] { R.id.title, R.id.unread_counter }, 0); - initDrawerHeader(inflater, view, m_list, m_activity, m_prefs); + initDrawerHeader(inflater, view, m_list, m_activity, m_prefs, true, true); m_list.setAdapter(m_adapter); m_list.setOnItemClickListener(this); @@ -188,14 +188,6 @@ public class OfflineFeedCategoriesFragment extends BaseFeedlistFragment implemen ListView list = (ListView)getActivity().findViewById(R.id.feeds); if (list != null) { - if (position == list.getCount() - 1) { - Intent intent = new Intent(m_activity, - PreferencesActivity.class); - startActivityForResult(intent, 0); - - return; - } - Cursor cursor = (Cursor) list.getItemAtPosition(position); if (cursor != null) { @@ -207,6 +199,19 @@ public class OfflineFeedCategoriesFragment extends BaseFeedlistFragment implemen m_selectedCatId = feedId; m_adapter.notifyDataSetChanged(); + } else { + if (position == list.getCount() - 1) { + Intent intent = new Intent(m_activity, + PreferencesActivity.class); + startActivityForResult(intent, 0); + + return; + } + + if (position == list.getCount() - 2) { + m_activity.switchOnline(); + return; + } } } } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java index 13d57dea..1504a734 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineFeedsFragment.java @@ -150,7 +150,7 @@ public class OfflineFeedsFragment extends BaseFeedlistFragment implements OnItem m_list = (ListView)view.findViewById(R.id.feeds); - initDrawerHeader(inflater, view, m_list, m_activity, m_prefs); + initDrawerHeader(inflater, view, m_list, m_activity, m_prefs, !m_enableParentBtn, true); if (m_enableParentBtn) { View layout = inflater.inflate(R.layout.feeds_goback, container, false); @@ -215,14 +215,6 @@ public class OfflineFeedsFragment extends BaseFeedlistFragment implements OnItem ListView list = (ListView)getActivity().findViewById(R.id.feeds); if (list != null) { - if (position == list.getCount() - 1) { - Intent intent = new Intent(m_activity, - PreferencesActivity.class); - startActivityForResult(intent, 0); - - return; - } - Cursor cursor = (Cursor) list.getItemAtPosition(position); if (cursor != null) { @@ -234,6 +226,19 @@ public class OfflineFeedsFragment extends BaseFeedlistFragment implements OnItem m_selectedFeedId = feedId; m_adapter.notifyDataSetChanged(); + } else { + if (position == list.getCount() - 1) { + Intent intent = new Intent(m_activity, + PreferencesActivity.class); + startActivityForResult(intent, 0); + + return; + } + + if (position == list.getCount() - 2) { + m_activity.switchOnline(); + return; + } } } } |