From a8e27a424cc70faf86e599f09ea99ac408c19a2b Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Fri, 6 Sep 2019 18:28:56 +0200 Subject: [PATCH 1/5] Added configurable swipe actions and open browser as a swipe action. Signed-off-by: Carlos Galindo --- .../NewsReaderDetailFragment.java | 79 ++++++++++++++++--- .../owncloudnewsreader/SettingsActivity.java | 9 ++- .../owncloudnewsreader/SettingsFragment.java | 11 ++- .../main/res/drawable/swipe_markasread.xml | 4 +- .../main/res/drawable/swipe_openinbrowser.xml | 12 +++ .../main/res/drawable/swipe_setstarred.xml | 4 +- .../src/main/res/values/attrs.xml | 2 +- .../src/main/res/values/strings.xml | 12 +++ .../src/main/res/values/themes.xml | 1 + .../src/main/res/xml/pref_general.xml | 16 +++- 10 files changed, 127 insertions(+), 23 deletions(-) create mode 100644 News-Android-App/src/main/res/drawable/swipe_openinbrowser.xml diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java index 79aefd3e..4cfb4b89 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java @@ -22,11 +22,13 @@ package de.luhmer.owncloudnewsreader; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; @@ -70,6 +72,10 @@ import io.reactivex.observers.DisposableObserver; import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_STARRED_ITEMS; import static de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS; +import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SWIPE_LEFT_ACTION; +import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SWIPE_LEFT_ACTION_DEFAULT; +import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SWIPE_RIGHT_ACTION; +import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SWIPE_RIGHT_ACTION_DEFAULT; /** * A fragment representing a single NewsReader detail screen. This fragment is @@ -92,8 +98,8 @@ public class NewsReaderDetailFragment extends Fragment { SwipeRefreshLayout swipeRefresh; private Long idFeed; - private Drawable markAsReadDrawable; - private Drawable starredDrawable; + private Drawable leftSwipeDrawable; + private Drawable rightSwipeDrawable; private int accentColor; private Parcelable layoutManagerSavedState; @@ -201,6 +207,8 @@ public class NewsReaderDetailFragment extends Fragment { } onResumeCount++; + updateSwipeDrawables(false); + super.onResume(); } @@ -413,18 +421,47 @@ public class NewsReaderDetailFragment extends Fragment { ((NewsReaderApplication) getActivity().getApplication()).getAppComponent().injectFragment(this); - TypedArray a = context.obtainStyledAttributes(attrs, new int[]{R.attr.markasreadDrawable, R.attr.starredDrawable, R.attr.colorAccent}); - markAsReadDrawable = a.getDrawable(0); - starredDrawable = a.getDrawable(1); + TypedArray a = context.obtainStyledAttributes(attrs, new int[]{R.attr.colorAccent}); + updateSwipeDrawables(true); int color = Constants.isNextCloud(mPrefs) ? R.color.nextcloudBlue : R.color.owncloudBlue; accentColor = a.getColor(2, ContextCompat.getColor(context, color)); a.recycle(); } + private String prevLeftAction = ""; + private String prevRightAction = ""; + private void updateSwipeDrawables(boolean always) { + String leftAction = mPrefs.getString(SP_SWIPE_LEFT_ACTION, SP_SWIPE_LEFT_ACTION_DEFAULT); + String rightAction = mPrefs.getString(SP_SWIPE_RIGHT_ACTION, SP_SWIPE_RIGHT_ACTION_DEFAULT); + if (!always && leftAction.equals(prevLeftAction) && rightAction.equals(prevRightAction)) + return; + prevLeftAction = leftAction; + prevRightAction = rightAction; + int leftId = getLayoutId(leftAction); + int rightId = getLayoutId(rightAction); + TypedArray a = getContext().obtainStyledAttributes(new int[]{leftId, rightId}); + leftSwipeDrawable = a.getDrawable(0); + rightSwipeDrawable = a.getDrawable(1); + } + + private int getLayoutId(String action) { + switch (action) { + case "0": return R.attr.openinbrowserDrawable; + case "1": return R.attr.starredDrawable; + case "2": return R.attr.markasreadDrawable; + default: + Log.e(TAG, "Invalid option saved to prefs. This should not happen"); + return Integer.MAX_VALUE; + } + } + @Override public void onViewStateRestored(Bundle savedInstanceState) { - if (savedInstanceState != null) + if (savedInstanceState != null) { layoutManagerSavedState = savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE); + prevLeftAction = savedInstanceState.getString("prevLeftAction", ""); + prevRightAction = savedInstanceState.getString("prevRightAction", ""); + } super.onViewStateRestored(savedInstanceState); } @@ -433,6 +470,8 @@ public class NewsReaderDetailFragment extends Fragment { super.onSaveInstanceState(outState); outState.putParcelable(LAYOUT_MANAGER_STATE, getLayoutManager().onSaveInstanceState()); + outState.putString("prevLeftAction", prevLeftAction); + outState.putString("prevRightAction", prevRightAction); } public int getFirstVisibleScrollPosition() { @@ -551,11 +590,27 @@ public class NewsReaderDetailFragment extends Fragment { public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int direction) { final NewsListRecyclerAdapter adapter = (NewsListRecyclerAdapter) recyclerView.getAdapter(); + String prefName, defValue; if (direction == ItemTouchHelper.LEFT) { - adapter.toggleReadStateOfItem((ViewHolder) viewHolder); - } else if (direction == ItemTouchHelper.RIGHT) { - adapter.toggleStarredStateOfItem((ViewHolder) viewHolder); - //adapter.toggleReadStateOfItem((ViewHolder) viewHolder); + prefName = SP_SWIPE_LEFT_ACTION; + defValue = SP_SWIPE_LEFT_ACTION_DEFAULT; + } else { + prefName = SettingsActivity.SP_SWIPE_RIGHT_ACTION; + defValue = SP_SWIPE_RIGHT_ACTION_DEFAULT; + } + switch (mPrefs.getString(prefName, defValue)) { + case "0": // Open link in browser and mark as read + String currentUrl = ((ViewHolder) viewHolder).getRssItem().getLink(); + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentUrl)); + startActivity(browserIntent); + adapter.changeReadStateOfItem((ViewHolder) viewHolder, true); + break; + case "1": // Star + adapter.toggleStarredStateOfItem((ViewHolder) viewHolder); + break; + case "2": // Read + adapter.toggleReadStateOfItem((ViewHolder) viewHolder); + break; } // Hack to reset view, see https://code.google.com/p/android/issues/detail?id=175798 recyclerView.removeView(viewHolder.itemView); @@ -572,10 +627,10 @@ public class NewsReaderDetailFragment extends Fragment { float fractionMoved = Math.abs(dX / viewHolder.itemView.getMeasuredWidth()); Drawable drawable; if (dX < 0) { - drawable = markAsReadDrawable; + drawable = leftSwipeDrawable; viewRect.left = (int) dX + viewRect.right; } else { - drawable = starredDrawable; + drawable = rightSwipeDrawable; viewRect.right = (int) dX - viewRect.left; } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java index 371d2b0c..e114f44a 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java @@ -27,10 +27,11 @@ import android.os.Bundle; import android.preference.PreferenceActivity; import android.view.MenuItem; -import javax.inject.Inject; - import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; + +import javax.inject.Inject; + import de.luhmer.owncloudnewsreader.helper.ThemeChooser; /** @@ -87,6 +88,10 @@ public class SettingsActivity extends AppCompatActivity { public static final String SP_SORT_ORDER = "sp_sort_order"; public static final String SP_DISPLAY_BROWSER = "sp_display_browser"; public static final String SP_SEARCH_IN = "sp_search_in"; + public static final String SP_SWIPE_RIGHT_ACTION = "sp_swipe_right_action"; + public static final String SP_SWIPE_LEFT_ACTION = "sp_swipe_left_action"; + public static final String SP_SWIPE_RIGHT_ACTION_DEFAULT = "1"; + public static final String SP_SWIPE_LEFT_ACTION_DEFAULT = "2"; public static final String CB_VERSION = "cb_version"; diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java index 58267c8f..521633af 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java @@ -12,9 +12,6 @@ import android.os.Bundle; import android.provider.Settings; import android.widget.Toast; -import javax.inject.Inject; -import javax.inject.Named; - import androidx.appcompat.app.AlertDialog; import androidx.preference.CheckBoxPreference; import androidx.preference.DialogPreference; @@ -22,6 +19,10 @@ import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.TwoStatePreference; + +import javax.inject.Inject; +import javax.inject.Named; + import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm; import de.luhmer.owncloudnewsreader.helper.ImageHandler; import de.luhmer.owncloudnewsreader.helper.NewsFileUtils; @@ -47,6 +48,8 @@ import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_FONT_SIZE; import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_MAX_CACHE_SIZE; import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SEARCH_IN; import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SORT_ORDER; +import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SWIPE_LEFT_ACTION; +import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SWIPE_RIGHT_ACTION; public class SettingsFragment extends PreferenceFragmentCompat { @@ -240,6 +243,8 @@ public class SettingsFragment extends PreferenceFragmentCompat { bindPreferenceBooleanToValue(prefFrag.findPreference(CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING)); bindPreferenceSummaryToValue(prefFrag.findPreference(SP_SORT_ORDER)); bindPreferenceSummaryToValue(prefFrag.findPreference(SP_SEARCH_IN)); + bindPreferenceSummaryToValue(prefFrag.findPreference(SP_SWIPE_RIGHT_ACTION)); + bindPreferenceSummaryToValue(prefFrag.findPreference(SP_SWIPE_LEFT_ACTION)); } private void bindDataSyncPreferences(final PreferenceFragmentCompat prefFrag) diff --git a/News-Android-App/src/main/res/drawable/swipe_markasread.xml b/News-Android-App/src/main/res/drawable/swipe_markasread.xml index 0725d443..616e094f 100644 --- a/News-Android-App/src/main/res/drawable/swipe_markasread.xml +++ b/News-Android-App/src/main/res/drawable/swipe_markasread.xml @@ -6,7 +6,7 @@ - - + + \ No newline at end of file diff --git a/News-Android-App/src/main/res/drawable/swipe_openinbrowser.xml b/News-Android-App/src/main/res/drawable/swipe_openinbrowser.xml new file mode 100644 index 00000000..5fa6456f --- /dev/null +++ b/News-Android-App/src/main/res/drawable/swipe_openinbrowser.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/News-Android-App/src/main/res/drawable/swipe_setstarred.xml b/News-Android-App/src/main/res/drawable/swipe_setstarred.xml index 43eb94bd..5f6a16b4 100644 --- a/News-Android-App/src/main/res/drawable/swipe_setstarred.xml +++ b/News-Android-App/src/main/res/drawable/swipe_setstarred.xml @@ -6,7 +6,7 @@ - - + + diff --git a/News-Android-App/src/main/res/values/attrs.xml b/News-Android-App/src/main/res/values/attrs.xml index cb1e6fbf..b9235c08 100644 --- a/News-Android-App/src/main/res/values/attrs.xml +++ b/News-Android-App/src/main/res/values/attrs.xml @@ -6,7 +6,7 @@ - + diff --git a/News-Android-App/src/main/res/values/strings.xml b/News-Android-App/src/main/res/values/strings.xml index a29f957f..c84c8f88 100644 --- a/News-Android-App/src/main/res/values/strings.xml +++ b/News-Android-App/src/main/res/values/strings.xml @@ -133,6 +133,18 @@ New -> Old Old -> New + + @string/action_openInBrowser + @string/action_starred + @string/action_read + + + 0 + 1 + 2 + + + @string/pref_general_sort_order_new_old @string/pref_general_sort_order_old_new diff --git a/News-Android-App/src/main/res/values/themes.xml b/News-Android-App/src/main/res/values/themes.xml index 23c2ad9c..98fccea0 100644 --- a/News-Android-App/src/main/res/values/themes.xml +++ b/News-Android-App/src/main/res/values/themes.xml @@ -39,6 +39,7 @@ @color/starredColor @color/unstarredColor @drawable/swipe_markasread + @drawable/swipe_openinbrowser @drawable/swipe_setstarred @color/news_detail_background_color diff --git a/News-Android-App/src/main/res/xml/pref_general.xml b/News-Android-App/src/main/res/xml/pref_general.xml index 99a96527..41a24fc4 100644 --- a/News-Android-App/src/main/res/xml/pref_general.xml +++ b/News-Android-App/src/main/res/xml/pref_general.xml @@ -58,7 +58,6 @@ android:title="@string/pref_title_AllowAllSSLCertificates" /> --> - + + + Date: Fri, 13 Sep 2019 18:42:35 +0200 Subject: [PATCH 2/5] move variables up / recycle typed array / rename variable --- .../NewsReaderDetailFragment.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java index 4cfb4b89..9531a4dd 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java @@ -43,6 +43,7 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.Toast; +import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.core.view.GestureDetectorCompat; import androidx.fragment.app.Fragment; @@ -100,6 +101,8 @@ public class NewsReaderDetailFragment extends Fragment { private Long idFeed; private Drawable leftSwipeDrawable; private Drawable rightSwipeDrawable; + private String prevLeftAction = ""; + private String prevRightAction = ""; private int accentColor; private Parcelable layoutManagerSavedState; @@ -421,27 +424,34 @@ public class NewsReaderDetailFragment extends Fragment { ((NewsReaderApplication) getActivity().getApplication()).getAppComponent().injectFragment(this); - TypedArray a = context.obtainStyledAttributes(attrs, new int[]{R.attr.colorAccent}); + TypedArray styledAttributes = context.obtainStyledAttributes(attrs, new int[]{R.attr.colorAccent}); updateSwipeDrawables(true); int color = Constants.isNextCloud(mPrefs) ? R.color.nextcloudBlue : R.color.owncloudBlue; - accentColor = a.getColor(2, ContextCompat.getColor(context, color)); - a.recycle(); + accentColor = styledAttributes.getColor(2, ContextCompat.getColor(context, color)); + styledAttributes.recycle(); } - private String prevLeftAction = ""; - private String prevRightAction = ""; - private void updateSwipeDrawables(boolean always) { + /** + * + * @param forceUpdate force swipe drawables to be reloaded + */ + private void updateSwipeDrawables(boolean forceUpdate) { String leftAction = mPrefs.getString(SP_SWIPE_LEFT_ACTION, SP_SWIPE_LEFT_ACTION_DEFAULT); String rightAction = mPrefs.getString(SP_SWIPE_RIGHT_ACTION, SP_SWIPE_RIGHT_ACTION_DEFAULT); - if (!always && leftAction.equals(prevLeftAction) && rightAction.equals(prevRightAction)) + + if (!forceUpdate && leftAction.equals(prevLeftAction) && rightAction.equals(prevRightAction)) { return; + } + prevLeftAction = leftAction; prevRightAction = rightAction; int leftId = getLayoutId(leftAction); int rightId = getLayoutId(rightAction); - TypedArray a = getContext().obtainStyledAttributes(new int[]{leftId, rightId}); - leftSwipeDrawable = a.getDrawable(0); - rightSwipeDrawable = a.getDrawable(1); + + TypedArray styledAttributes = getContext().obtainStyledAttributes(new int[]{leftId, rightId}); + leftSwipeDrawable = styledAttributes.getDrawable(0); + rightSwipeDrawable = styledAttributes.getDrawable(1); + styledAttributes.recycle(); } private int getLayoutId(String action) { From 0ec0d406f29cad2cb7b8e1e73b328d8f22054d90 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Fri, 13 Sep 2019 20:08:28 +0200 Subject: [PATCH 3/5] Removed swipe action save/restore. Signed-off-by: Carlos Galindo --- .../owncloudnewsreader/NewsReaderDetailFragment.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java index 9531a4dd..c96aa52c 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java @@ -43,7 +43,6 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.Toast; -import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.core.view.GestureDetectorCompat; import androidx.fragment.app.Fragment; @@ -467,11 +466,8 @@ public class NewsReaderDetailFragment extends Fragment { @Override public void onViewStateRestored(Bundle savedInstanceState) { - if (savedInstanceState != null) { + if (savedInstanceState != null) layoutManagerSavedState = savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE); - prevLeftAction = savedInstanceState.getString("prevLeftAction", ""); - prevRightAction = savedInstanceState.getString("prevRightAction", ""); - } super.onViewStateRestored(savedInstanceState); } @@ -480,8 +476,6 @@ public class NewsReaderDetailFragment extends Fragment { super.onSaveInstanceState(outState); outState.putParcelable(LAYOUT_MANAGER_STATE, getLayoutManager().onSaveInstanceState()); - outState.putString("prevLeftAction", prevLeftAction); - outState.putString("prevRightAction", prevRightAction); } public int getFirstVisibleScrollPosition() { From 46cecc50dcc9c0a622dcebad6fc783050c8ffd83 Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Sat, 14 Sep 2019 10:44:31 +0200 Subject: [PATCH 4/5] extract text for translation --- News-Android-App/src/main/res/values/strings.xml | 4 +++- News-Android-App/src/main/res/xml/pref_general.xml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/News-Android-App/src/main/res/values/strings.xml b/News-Android-App/src/main/res/values/strings.xml index c84c8f88..59f6599a 100644 --- a/News-Android-App/src/main/res/values/strings.xml +++ b/News-Android-App/src/main/res/values/strings.xml @@ -143,7 +143,9 @@ 1 2 - + + Action when swiping right + Action when swiping left @string/pref_general_sort_order_new_old diff --git a/News-Android-App/src/main/res/xml/pref_general.xml b/News-Android-App/src/main/res/xml/pref_general.xml index 41a24fc4..0ee9f9a5 100644 --- a/News-Android-App/src/main/res/xml/pref_general.xml +++ b/News-Android-App/src/main/res/xml/pref_general.xml @@ -88,7 +88,7 @@ android:entries="@array/pref_general_swipe_action" android:entryValues="@array/pref_general_swipe_action_values" android:key="sp_swipe_right_action" - android:title="Action when swiping right" + android:title="@string/pref_rename_action_swipe_right" app:iconSpaceReserved="false"/> Date: Sat, 14 Sep 2019 13:44:44 +0200 Subject: [PATCH 5/5] Fixed codacy-bot warnings Signed-off-by: Carlos Galindo --- .../NewsReaderDetailFragment.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java index c96aa52c..d15380bb 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java @@ -594,15 +594,12 @@ public class NewsReaderDetailFragment extends Fragment { public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int direction) { final NewsListRecyclerAdapter adapter = (NewsListRecyclerAdapter) recyclerView.getAdapter(); - String prefName, defValue; - if (direction == ItemTouchHelper.LEFT) { - prefName = SP_SWIPE_LEFT_ACTION; - defValue = SP_SWIPE_LEFT_ACTION_DEFAULT; - } else { - prefName = SettingsActivity.SP_SWIPE_RIGHT_ACTION; - defValue = SP_SWIPE_RIGHT_ACTION_DEFAULT; - } - switch (mPrefs.getString(prefName, defValue)) { + String swipeAction; + if (direction == ItemTouchHelper.LEFT) + swipeAction = mPrefs.getString(SP_SWIPE_LEFT_ACTION, SP_SWIPE_LEFT_ACTION_DEFAULT); + else + swipeAction = mPrefs.getString(SP_SWIPE_RIGHT_ACTION, SP_SWIPE_RIGHT_ACTION_DEFAULT); + switch (swipeAction) { case "0": // Open link in browser and mark as read String currentUrl = ((ViewHolder) viewHolder).getRssItem().getLink(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentUrl)); @@ -615,6 +612,8 @@ public class NewsReaderDetailFragment extends Fragment { case "2": // Read adapter.toggleReadStateOfItem((ViewHolder) viewHolder); break; + default: + Log.e(TAG, "Swipe preferences has an invalid value"); } // Hack to reset view, see https://code.google.com/p/android/issues/detail?id=175798 recyclerView.removeView(viewHolder.itemView);