From 2cd48e3a656789370cd753e7d0f6549b8081587d Mon Sep 17 00:00:00 2001 From: davidoskky Date: Thu, 26 Jan 2023 15:13:49 +0100 Subject: [PATCH] Handle public access in the home screen In public access mode we can only read articles. Disable swiping articles in the listing to read them and remove the menu items to read all articles and to access sources settings. --- .../apps/readerforselfossv2/android/HomeActivity.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index 64f9428..3b1ed43 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -114,10 +114,16 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar } } + val swipeDirs = if (appSettingsService.getPublicAccess()) { + 0 + } else { + ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT + } + val simpleItemTouchCallback = object : ItemTouchHelper.SimpleCallback( 0, - ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT + swipeDirs ) { override fun getSwipeDirs( recyclerView: RecyclerView, @@ -510,6 +516,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar override fun onCreateOptionsMenu(menu: Menu): Boolean { val inflater = menuInflater inflater.inflate(R.menu.home_menu, menu) + if (appSettingsService.getPublicAccess()) { + menu.removeItem(R.id.readAll) + menu.removeItem(R.id.action_sources) + } val searchItem = menu.findItem(R.id.action_search) val searchView = searchItem.getActionView() as SearchView