diff options
author | Camil Staps | 2015-06-10 20:19:25 +0200 |
---|---|---|
committer | Camil Staps | 2015-06-10 20:19:25 +0200 |
commit | e349f9010067d7cdc34fd050a39b30aa2e9bd838 (patch) | |
tree | 965066a333811714114d1bb311b06824f0409520 | |
parent | javadoc (diff) |
Cleanup; about dialogue
-rwxr-xr-x | app/src/main/AndroidManifest.xml | 4 | ||||
-rw-r--r-- | app/src/main/java/org/rssin/android/HomeScreenActivity.java | 4 | ||||
-rw-r--r-- | app/src/main/java/org/rssin/android/NavigationDrawerAdapter.java | 14 | ||||
-rw-r--r-- | app/src/main/java/org/rssin/android/NavigationDrawerFragment.java | 61 | ||||
-rw-r--r-- | app/src/main/java/org/rssin/android/SettingsActivity.java | 166 | ||||
-rw-r--r-- | app/src/main/res/menu/home_screen.xml | 6 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 8 | ||||
-rw-r--r-- | app/src/main/res/xml/pref_data_sync.xml | 39 | ||||
-rw-r--r-- | app/src/main/res/xml/pref_headers.xml | 24 | ||||
-rw-r--r-- | app/src/main/res/xml/pref_main.xml | 20 |
10 files changed, 61 insertions, 285 deletions
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 @@ -10,10 +10,6 @@ android:label="@string/app_name" android:theme="@style/AppTheme" > <activity - android:name="org.rssin.android.SettingsActivity" - android:label="@string/title_activity_settings" > - </activity> - <activity android:name="org.rssin.android.FilterSettingsActivity" android:label="@string/title_activity_filter_settings" > <meta-data 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());
@@ -208,12 +205,6 @@ class NavigationDrawerAdapter implements ListAdapter { }
@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"> <item - android:id="@+id/action_settings" - android:title="@string/action_settings" + android:id="@+id/action_info" + android:title="@string/action_info" android:orderInCategory="100" app:showAsAction="ifRoom" - android:icon="@drawable/ic_action_action_settings" /> + android:icon="@drawable/ic_action_action_info_outline" /> </menu> 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 @@ --> <resources> <string name="app_name">RSSin</string> + <string name="app_info"><![CDATA[ + <h1>RSSin</h1> + <em>Clever RSS reader for Android</em> + <p>Copyright © Randy Wanga, Jos Craaijo, Joep Bernards, Camil Staps</p> + <p>This project is free, open source software licensed under GPLv2. For more information and the full license text, visit <a href="https://github.com/camilstaps/RSSin">https://github.com/camilstaps/RSSin</a>.</p> + <p>Articles loaded from external sources remain under the original copyright.</p> + ]]></string> <string name="action_import_feed">Open in RRSin</string> <string name="action_settings">Settings</string> <string name="action_filters">Filters</string> <string name="action_feeds">Feeds</string> + <string name="action_info">About RSSin</string> <string name="button_ok">OK</string> <string name="button_apply">Apply</string> 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 @@ -<!-- - 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. ---> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - - <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to - dismiss it. --> - <!-- NOTE: ListPreference's summary should be set to its value by the activity code. --> - <ListPreference - android:key="sync_frequency" - android:title="@string/pref_title_sync_frequency" - android:entries="@array/pref_sync_frequency_titles" - android:entryValues="@array/pref_sync_frequency_values" - android:defaultValue="180" - android:negativeButtonText="@null" - android:positiveButtonText="@null" /> - - <!-- This preference simply launches an intent when selected. Use this UI sparingly, per - design guidelines. --> - <Preference android:title="@string/pref_title_system_sync_settings"> - <intent android:action="android.settings.SYNC_SETTINGS" /> - </Preference> - -</PreferenceScreen> 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 @@ -<!-- - 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. ---> -<preference-headers xmlns:android="http://schemas.android.com/apk/res/android"> - - <header android:fragment="org.rssin.android.SettingsActivity$DataSyncPreferenceFragment" - android:title="@string/pref_header_data_sync" /> - -</preference-headers> 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 @@ -<!-- - 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. ---> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> -</PreferenceScreen>
\ No newline at end of file |