move offline/online prompts to the sidebar
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 976 B |
After Width: | Height: | Size: 971 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.6 KiB |
@ -14,12 +14,12 @@
|
||||
android:icon="@drawable/ic_filter_remove"
|
||||
app:showAsAction=""
|
||||
android:title="@string/menu_all_feeds"/> -->
|
||||
<item
|
||||
<!-- <item
|
||||
android:id="@+id/go_offline"
|
||||
android:icon="@drawable/ic_cloud_download"
|
||||
android:orderInCategory="800"
|
||||
app:showAsAction=""
|
||||
android:title="@string/go_offline"/> <!-- iRroom -->
|
||||
android:title="@string/go_offline"/> --><!-- iRroom -->
|
||||
<!-- <item
|
||||
android:id="@+id/update_feeds"
|
||||
android:icon="@drawable/ic_refresh"
|
||||
|
@ -1,12 +1,12 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<group android:id="@+id/menu_group_feeds" >
|
||||
<item
|
||||
<!-- <item
|
||||
android:id="@+id/go_online"
|
||||
android:icon="@drawable/ic_cloud_upload"
|
||||
app:showAsAction=""
|
||||
android:title="@string/go_online"
|
||||
android:visible="false"/> <!-- ifRoom|withText -->
|
||||
android:visible="false"/> --> <!-- ifRoom|withText -->
|
||||
<!-- <item
|
||||
android:id="@+id/show_feeds"
|
||||
android:icon="@drawable/ic_filter_remove"
|
||||
|
@ -38,6 +38,8 @@
|
||||
<attr name="ic_keyboard_backspace" format="reference" />
|
||||
<attr name="ic_settings" format="reference" />
|
||||
<attr name="ic_filter_variant" format="reference" />
|
||||
<attr name="ic_cloud_download" format="reference" />
|
||||
<attr name="ic_cloud_upload" format="reference" />
|
||||
<declare-styleable name="ScrimInsetsView">
|
||||
<attr format="reference|color" name="insetForeground">
|
||||
</attr></declare-styleable>
|
||||
|
@ -51,6 +51,8 @@
|
||||
<item name="ic_keyboard_backspace">@drawable/ic_keyboard_backspace_dark</item>
|
||||
<item name="ic_settings">@drawable/ic_settings_dark</item>
|
||||
<item name="ic_filter_variant">@drawable/ic_filter_variant_dark</item>
|
||||
<item name="ic_cloud_download">@drawable/ic_cloud_download_dark</item>
|
||||
<item name="ic_cloud_upload">@drawable/ic_cloud_upload_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="DarkTheme.Base" parent="Theme.AppCompat.NoActionBar">
|
||||
@ -103,6 +105,8 @@
|
||||
<item name="ic_keyboard_backspace">@drawable/ic_keyboard_backspace</item>
|
||||
<item name="ic_settings">@drawable/ic_settings</item>
|
||||
<item name="ic_filter_variant">@drawable/ic_filter_variant</item>
|
||||
<item name="ic_cloud_download">@drawable/ic_cloud_download</item>
|
||||
<item name="ic_cloud_upload">@drawable/ic_cloud_upload</item>
|
||||
</style>
|
||||
|
||||
<style name="DarkDialogTheme" parent="android:Theme"></style>
|
||||
|