From c3305b7523c1416bb0f65d944614dd4788b8afaa Mon Sep 17 00:00:00 2001 From: Amine Date: Sun, 4 Jun 2017 16:44:31 +0200 Subject: [PATCH] Moved some menu items to the drawable. --- app/build.gradle | 4 +- .../bou/readerforselfoss/HomeActivity.kt | 85 ++++++++++++------- .../res/drawable-anydpi/ic_info_outline.xml | 9 ++ .../main/res/drawable-anydpi/ic_settings.xml | 9 ++ app/src/main/res/menu/home_menu.xml | 13 --- 5 files changed, 76 insertions(+), 44 deletions(-) create mode 100644 app/src/main/res/drawable-anydpi/ic_info_outline.xml create mode 100644 app/src/main/res/drawable-anydpi/ic_settings.xml diff --git a/app/build.gradle b/app/build.gradle index ff6975c..44b2cb3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,8 +25,8 @@ android { applicationId "apps.amine.bou.readerforselfoss" minSdkVersion 16 targetSdkVersion 25 - versionCode 1502 - versionName "1.5.0.2" + versionCode 1503 + versionName "1.5.0.3" // Enabling multidex support. multiDexEnabled true diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt index 0d8a349..a3d36d8 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -66,6 +66,7 @@ class HomeActivity : AppCompatActivity() { private val REQUEST_INVITE_BYMAIL = 13232 private val DRAWER_ID_TAGS = 100101L private val DRAWER_ID_SOURCES = 100110L + private val DRAWER_ID_FILTERS = 100111L private var mRecyclerView: RecyclerView? = null private var api: SelfossApi? = null private var items: ArrayList = ArrayList() @@ -159,7 +160,7 @@ class HomeActivity : AppCompatActivity() { gd.setSize(30, 30) gd.cornerRadius = 30F drawer!!.addItem( - PrimaryDrawerItem() + SecondaryDrawerItem() .withName(tag.tag) .withIdentifier(longHash(tag.tag)) .withIcon(gd) @@ -181,24 +182,68 @@ class HomeActivity : AppCompatActivity() { else for (tag in maybeSources) drawer!!.addItem( - PrimaryDrawerItem() - .withName(tag.title) - .withIdentifier(tag.id.toLong()) - .withOnDrawerItemClickListener { _, _, _ -> - getElementsAccordingToTab(maybeSourceFilter = tag) - true - } + SecondaryDrawerItem() + .withName(tag.title) + .withIdentifier(tag.id.toLong()) + .withOnDrawerItemClickListener { _, _, _ -> + getElementsAccordingToTab(maybeSourceFilter = tag) + true + } ) } drawer!!.removeAllItems() if (maybeDrawerData != null) { - drawer!!.addItem(SecondaryDrawerItem().withName("Tags").withIdentifier(DRAWER_ID_TAGS).withSelectable(false)) - handleTags(maybeDrawerData.tags) + drawer!!.addItem( + PrimaryDrawerItem() + .withName("Filtres") + .withIdentifier(DRAWER_ID_FILTERS) + .withBadge("clear") + .withOnDrawerItemClickListener { _, _, _ -> + getElementsAccordingToTab() + true + } + ) drawer!!.addItem(DividerDrawerItem()) - drawer!!.addItem(SecondaryDrawerItem().withName("Sources").withIdentifier(DRAWER_ID_TAGS).withSelectable(false)) + drawer!!.addItem(PrimaryDrawerItem().withName("Tags").withIdentifier(DRAWER_ID_TAGS).withSelectable(false)) + handleTags(maybeDrawerData.tags) + drawer!!.addItem( + PrimaryDrawerItem() + .withName("Sources") + .withIdentifier(DRAWER_ID_TAGS) + .withBadge("edit") + .withOnDrawerItemClickListener { _, _, _ -> + startActivity(Intent(this, SourcesActivity::class.java)) + true + } + ) handleSources(maybeDrawerData.sources) + + + drawer!!.addItem(DividerDrawerItem()) + drawer!!.addStickyFooterItem( + PrimaryDrawerItem() + .withName(R.string.action_about) + .withIcon(R.drawable.ic_info_outline) + .withOnDrawerItemClickListener { _, _, _ -> + LibsBuilder() + .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR) + .withAboutIconShown(true) + .withAboutVersionShown(true) + .start(this@HomeActivity) + true + }) + drawer!!.addStickyFooterItem( + PrimaryDrawerItem() + .withName(R.string.title_activity_settings) + .withIcon(R.drawable.ic_settings) + .withOnDrawerItemClickListener { _, _, _ -> + startActivityForResult(Intent(this@HomeActivity, SettingsActivity::class.java), MENU_PREFERENCES) + true + } + ) + if (!loadedFromCache) Reservoir.putAsync("drawerData", maybeDrawerData, object : ReservoirPutCallback { override fun onSuccess() {} @@ -544,24 +589,6 @@ class HomeActivity : AppCompatActivity() { finish() return true } - R.id.action_sources -> { - val intent2 = Intent(this, SourcesActivity::class.java) - startActivity(intent2) - return true - } - R.id.action_settings -> { - val intent3 = Intent(this, SettingsActivity::class.java) - startActivityForResult(intent3, MENU_PREFERENCES) - return true - } - R.id.about -> { - LibsBuilder() - .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR) - .withAboutIconShown(true) - .withAboutVersionShown(true) - .start(this) - return true - } R.id.action_share_the_app -> { if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS) { val share = AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title)) diff --git a/app/src/main/res/drawable-anydpi/ic_info_outline.xml b/app/src/main/res/drawable-anydpi/ic_info_outline.xml new file mode 100644 index 0000000..cf53e14 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_info_outline.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_settings.xml b/app/src/main/res/drawable-anydpi/ic_settings.xml new file mode 100644 index 0000000..ace746c --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_settings.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/home_menu.xml b/app/src/main/res/menu/home_menu.xml index 1aec784..f9d4199 100644 --- a/app/src/main/res/menu/home_menu.xml +++ b/app/src/main/res/menu/home_menu.xml @@ -14,24 +14,11 @@ android:orderInCategory="99" android:title="@string/menu_home_refresh" app:showAsAction="ifRoom" /> - - - -