aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/org/rssin/android/HomeScreenActivity.java4
-rw-r--r--app/src/main/java/org/rssin/android/NavigationDrawerAdapter.java14
-rw-r--r--app/src/main/java/org/rssin/android/NavigationDrawerFragment.java61
-rw-r--r--app/src/main/java/org/rssin/android/SettingsActivity.java166
4 files changed, 50 insertions, 195 deletions
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"));
- }
- }
-}