From e349f9010067d7cdc34fd050a39b30aa2e9bd838 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 10 Jun 2015 20:19:25 +0200 Subject: Cleanup; about dialogue --- app/src/main/AndroidManifest.xml | 4 - .../java/org/rssin/android/HomeScreenActivity.java | 4 +- .../org/rssin/android/NavigationDrawerAdapter.java | 14 +- .../rssin/android/NavigationDrawerFragment.java | 61 +++++--- .../java/org/rssin/android/SettingsActivity.java | 166 --------------------- app/src/main/res/menu/home_screen.xml | 6 +- app/src/main/res/values/strings.xml | 8 + app/src/main/res/xml/pref_data_sync.xml | 39 ----- app/src/main/res/xml/pref_headers.xml | 24 --- app/src/main/res/xml/pref_main.xml | 20 --- 10 files changed, 61 insertions(+), 285 deletions(-) delete mode 100644 app/src/main/java/org/rssin/android/SettingsActivity.java delete mode 100644 app/src/main/res/xml/pref_data_sync.xml delete mode 100644 app/src/main/res/xml/pref_headers.xml delete mode 100644 app/src/main/res/xml/pref_main.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4f85b1a..3880595 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,10 +9,6 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > - - diff --git a/app/src/main/java/org/rssin/android/HomeScreenActivity.java b/app/src/main/java/org/rssin/android/HomeScreenActivity.java index a1ed705..6b1d78f 100644 --- a/app/src/main/java/org/rssin/android/HomeScreenActivity.java +++ b/app/src/main/java/org/rssin/android/HomeScreenActivity.java @@ -37,6 +37,8 @@ public class HomeScreenActivity extends ActionBarActivity implements NavigationD */ private NavigationDrawerFragment mNavigationDrawerFragment; + private Fragment currentFragment; + /** * Used to store the last screen title. For use in {@link #restoreActionBar()}. */ @@ -67,8 +69,6 @@ public class HomeScreenActivity extends ActionBarActivity implements NavigationD mTitle = getString(R.string.navigation_drawer_all_feeds); } - private Fragment currentFragment; - @Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments diff --git a/app/src/main/java/org/rssin/android/NavigationDrawerAdapter.java b/app/src/main/java/org/rssin/android/NavigationDrawerAdapter.java index 00e10be..eb1906f 100644 --- a/app/src/main/java/org/rssin/android/NavigationDrawerAdapter.java +++ b/app/src/main/java/org/rssin/android/NavigationDrawerAdapter.java @@ -124,14 +124,11 @@ class NavigationDrawerAdapter implements ListAdapter { public View getView(int position, View convertView, ViewGroup parent) { final int type = getItemViewType(position); - // First, let's create a new convertView if needed. You can also - // create a ViewHolder to speed up changes if you want ;) if (convertView == null) { convertView = LayoutInflater.from(parent.getContext()).inflate( type == ITEM_VIEW_TYPE_SEPARATOR ? R.layout.separator_navigation_drawer : R.layout.item_navigation_drawer, parent, false); } - // We can now fill the list item view with the appropriate data. if (type == ITEM_VIEW_TYPE_SEPARATOR) { final MenuSection section = (MenuSection) getItem(position); ((TextView) convertView.findViewById(R.id.separator_navigation_drawer_text)).setText(section.getText()); @@ -207,12 +204,6 @@ class NavigationDrawerAdapter implements ListAdapter { super(context.getString(R.string.navigation_drawer_all_feeds)); } - @Override - public void invokeActionSettings(Context context) { - Intent intent = new Intent(context, SettingsActivity.class); - context.startActivity(intent); - } - @Override public int getItemViewType() { return ITEM_VIEW_TYPE_NORMAL; @@ -222,6 +213,11 @@ class NavigationDrawerAdapter implements ListAdapter { public Fragment getFragment() { return NavigationDrawerAllFeedsFragment.newInstance(); } + + @Override + public int getPreferredMenuId() { + return R.menu.home_screen; + } } class MenuFeedItem extends MenuItem diff --git a/app/src/main/java/org/rssin/android/NavigationDrawerFragment.java b/app/src/main/java/org/rssin/android/NavigationDrawerFragment.java index 4fbbee5..5e6cccf 100644 --- a/app/src/main/java/org/rssin/android/NavigationDrawerFragment.java +++ b/app/src/main/java/org/rssin/android/NavigationDrawerFragment.java @@ -1,24 +1,25 @@ -/** - * RSSin - Clever RSS reader for Android - * Copyright (C) 2015 Randy Wanga, Jos Craaijo, Joep Bernards, Camil Staps - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ +/** + * RSSin - Clever RSS reader for Android + * Copyright (C) 2015 Randy Wanga, Jos Craaijo, Joep Bernards, Camil Staps + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ package org.rssin.android; import android.app.Activity; +import android.app.AlertDialog; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; @@ -29,6 +30,8 @@ import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; +import android.text.Html; +import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -37,8 +40,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; +import android.widget.TextView; import org.rssin.rssin.R; +import org.w3c.dom.Text; import java.io.IOException; @@ -278,6 +283,26 @@ public class NavigationDrawerFragment extends Fragment { return true; } + if (item.getItemId() == R.id.action_info) { + TextView message = new TextView(getActivity()); + message.setText(Html.fromHtml(getString(R.string.app_info))); + int padding = getResources().getDimensionPixelSize(R.dimen.listview_item_padding); + message.setPadding(padding, padding, padding, 0); + message.setMovementMethod(LinkMovementMethod.getInstance()); + + AlertDialog dialog = new AlertDialog.Builder(getActivity()) + .setTitle(getString(R.string.app_name)) + .setView(message) + .setPositiveButton(R.string.button_ok, null) + .setIcon(R.mipmap.ic_launcher) + .show(); + + View titleDivider = dialog.findViewById(getResources().getIdentifier("titleDivider", "id", "android")); + titleDivider.setBackgroundColor(getResources().getColor(R.color.abc_primary_text_material_light)); + TextView title = (TextView) dialog.findViewById(getResources().getIdentifier("alertTitle", "id", "android")); + title.setTextColor(getResources().getColor(R.color.abc_primary_text_material_light)); + } + return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/org/rssin/android/SettingsActivity.java b/app/src/main/java/org/rssin/android/SettingsActivity.java deleted file mode 100644 index 9bce8f6..0000000 --- a/app/src/main/java/org/rssin/android/SettingsActivity.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * RSSin - Clever RSS reader for Android - * Copyright (C) 2015 Randy Wanga, Jos Craaijo, Joep Bernards, Camil Staps - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.rssin.android; - -import android.annotation.TargetApi; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceCategory; -import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; - -import org.rssin.rssin.R; - -/** - * Global app settings - * - * @author Camil Staps - */ -public class SettingsActivity extends PreferenceActivity { - /** - * Determines whether to always show the simplified settings UI, where - * settings are presented in a single list. When false, settings are shown - * as a master/detail two-pane view on tablets. When true, a single pane is - * shown on tablets. - * - * For now, this is true, so that we don't have to think about tablets. - */ - private static final boolean ALWAYS_SIMPLE_PREFS = true; - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - setupSimplePreferencesScreen(); - } - - /** - * Shows the simplified settings UI if the device configuration if the - * device configuration dictates that a simplified, single-pane UI should be - * shown. - */ - private void setupSimplePreferencesScreen() { - if (!isSimplePreferences(this)) { - return; - } - - // Add 'general' preferences. - addPreferencesFromResource(R.xml.pref_main); - - // Add 'data and sync' preferences, and a corresponding header. - PreferenceCategory fakeHeader = new PreferenceCategory(this); - fakeHeader.setTitle(R.string.pref_header_data_sync); - getPreferenceScreen().addPreference(fakeHeader); - addPreferencesFromResource(R.xml.pref_data_sync); - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences to - // their values. When their values change, their summaries are updated - // to reflect the new value, per the Android Design guidelines. - bindPreferenceSummaryToValue(findPreference("sync_frequency")); - } - - @Override - public boolean onIsMultiPane() { - return isXLargeTablet(this) && !isSimplePreferences(this); - } - - /** - * Helper method to determine if the device has an extra-large screen. For - * example, 10" tablets are extra-large. - */ - private static boolean isXLargeTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; - } - - /** - * Determines whether the simplified settings UI should be shown. This is - * true if this is forced via {@link #ALWAYS_SIMPLE_PREFS}, or the device - * doesn't have newer APIs like {@link PreferenceFragment}, or the device - * doesn't have an extra-large screen. In these cases, a single-pane - * "simplified" settings UI should be shown. - */ - private static boolean isSimplePreferences(Context context) { - return ALWAYS_SIMPLE_PREFS - || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB - || !isXLargeTablet(context); - } - - /** - * A preference value change listener that updates the preference's summary - * to reflect its new value. - */ - private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - String stringValue = value.toString(); - - if (preference instanceof ListPreference) { - ListPreference listPreference = (ListPreference) preference; - int index = listPreference.findIndexOfValue(stringValue); - - preference.setSummary(index >= 0 - ? listPreference.getEntries()[index] - : null); - } else { - preference.setSummary(stringValue); - } - return true; - } - }; - - /** - * Binds a preference's summary to its value. More specifically, when the - * preference's value is changed, its summary (line of text below the - * preference title) is updated to reflect the value. The summary is also - * immediately updated upon calling this method. The exact display format is - * dependent on the type of preference. - * - * @see #sBindPreferenceSummaryToValueListener - */ - private static void bindPreferenceSummaryToValue(Preference preference) { - // Set the listener to watch for value changes. - preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); - - // Trigger the listener immediately with the preference's - // current value. - sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, - PreferenceManager - .getDefaultSharedPreferences(preference.getContext()) - .getString(preference.getKey(), "")); - } - - /** - * This fragment shows data and sync preferences only. It is used when the - * activity is showing a two-pane settings UI. - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static class DataSyncPreferenceFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_data_sync); - bindPreferenceSummaryToValue(findPreference("sync_frequency")); - } - } -} diff --git a/app/src/main/res/menu/home_screen.xml b/app/src/main/res/menu/home_screen.xml index 8ffd091..f28278e 100644 --- a/app/src/main/res/menu/home_screen.xml +++ b/app/src/main/res/menu/home_screen.xml @@ -23,10 +23,10 @@ tools:context="org.rssin.android.HomeScreenActivity"> + android:icon="@drawable/ic_action_action_info_outline" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index baaf0f2..b979926 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -18,12 +18,20 @@ --> RSSin + RSSin + Clever RSS reader for Android +

Copyright © Randy Wanga, Jos Craaijo, Joep Bernards, Camil Staps

+

This project is free, open source software licensed under GPLv2. For more information and the full license text, visit https://github.com/camilstaps/RSSin.

+

Articles loaded from external sources remain under the original copyright.

+ ]]>
Open in RRSin Settings Filters Feeds + About RSSin OK Apply diff --git a/app/src/main/res/xml/pref_data_sync.xml b/app/src/main/res/xml/pref_data_sync.xml deleted file mode 100644 index 3a53dc7..0000000 --- a/app/src/main/res/xml/pref_data_sync.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/xml/pref_headers.xml b/app/src/main/res/xml/pref_headers.xml deleted file mode 100644 index 96dc4bb..0000000 --- a/app/src/main/res/xml/pref_headers.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - -
- - diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml deleted file mode 100644 index efff7cd..0000000 --- a/app/src/main/res/xml/pref_main.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - \ No newline at end of file -- cgit v1.2.3