From 3f4f83fdbb4010a28643fa4dcd0bab0fda055792 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 22 Jun 2022 22:00:24 +0200 Subject: [PATCH] moving the bottom tab item layout file to commons --- app/build.gradle | 2 +- .../voicerecorder/activities/MainActivity.kt | 25 +++++++++-------- .../main/res/layout/bottom_tablayout_item.xml | 28 ------------------- 3 files changed, 14 insertions(+), 41 deletions(-) delete mode 100644 app/src/main/res/layout/bottom_tablayout_item.xml diff --git a/app/build.gradle b/app/build.gradle index 2ea5479..b214f09 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,7 +62,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:0834a977e4' + implementation 'com.github.SimpleMobileTools:Simple-Commons:b2167e4b2a' implementation 'org.greenrobot:eventbus:3.3.1' implementation 'com.github.Armen101:AudioRecordView:1.0.4' implementation 'androidx.documentfile:documentfile:1.0.1' diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt index 8d008a9..c5f8877 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt @@ -103,26 +103,26 @@ class MainActivity : SimpleActivity() { private fun setupViewPager() { main_tabs_holder.removeAllTabs() main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { - customView?.findViewById(R.id.tab_icon)?.setImageDrawable(getDrawable(R.drawable.ic_microphone_vector)) - customView?.findViewById(R.id.tab_label)?.setText(R.string.recorder) + customView?.findViewById(R.id.tab_item_icon)?.setImageDrawable(getDrawable(R.drawable.ic_microphone_vector)) + customView?.findViewById(R.id.tab_item_label)?.setText(R.string.recorder) main_tabs_holder.addTab(this) } main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { - customView?.findViewById(R.id.tab_icon)?.setImageDrawable(getDrawable(R.drawable.ic_headset_vector)) - customView?.findViewById(R.id.tab_label)?.setText(R.string.player) + customView?.findViewById(R.id.tab_item_icon)?.setImageDrawable(getDrawable(R.drawable.ic_headset_vector)) + customView?.findViewById(R.id.tab_item_label)?.setText(R.string.player) main_tabs_holder.addTab(this) } main_tabs_holder.onTabSelectionChanged( tabUnselectedAction = { - it.customView?.findViewById(R.id.tab_icon)?.applyColorFilter(getProperTextColor()) - it.customView?.findViewById(R.id.tab_label)?.setTextColor(getProperTextColor()) + it.customView?.findViewById(R.id.tab_item_icon)?.applyColorFilter(getProperTextColor()) + it.customView?.findViewById(R.id.tab_item_label)?.setTextColor(getProperTextColor()) }, tabSelectedAction = { view_pager.currentItem = it.position - it.customView?.findViewById(R.id.tab_icon)?.applyColorFilter(getProperPrimaryColor()) - it.customView?.findViewById(R.id.tab_label)?.setTextColor(getProperPrimaryColor()) + it.customView?.findViewById(R.id.tab_item_icon)?.applyColorFilter(getProperPrimaryColor()) + it.customView?.findViewById(R.id.tab_item_label)?.setTextColor(getProperPrimaryColor()) } ) @@ -131,6 +131,7 @@ class MainActivity : SimpleActivity() { main_tabs_holder.getTabAt(it)?.select() (view_pager.adapter as ViewPagerAdapter).finishActMode() } + view_pager.currentItem = config.lastUsedViewPagerPage main_tabs_holder.getTabAt(config.lastUsedViewPagerPage)?.select() } @@ -139,13 +140,13 @@ class MainActivity : SimpleActivity() { private fun setupTabColors() { main_tabs_holder.getTabAt(getInactiveTabIndex())?.customView?.apply { - findViewById(R.id.tab_icon)?.applyColorFilter(getProperTextColor()) - findViewById(R.id.tab_label)?.setTextColor(getProperTextColor()) + findViewById(R.id.tab_item_icon)?.applyColorFilter(getProperTextColor()) + findViewById(R.id.tab_item_label)?.setTextColor(getProperTextColor()) } main_tabs_holder.getTabAt(view_pager.currentItem)?.customView?.apply { - findViewById(R.id.tab_icon)?.applyColorFilter(getProperPrimaryColor()) - findViewById(R.id.tab_label)?.setTextColor(getProperPrimaryColor()) + findViewById(R.id.tab_item_icon)?.applyColorFilter(getProperPrimaryColor()) + findViewById(R.id.tab_item_label)?.setTextColor(getProperPrimaryColor()) } } diff --git a/app/src/main/res/layout/bottom_tablayout_item.xml b/app/src/main/res/layout/bottom_tablayout_item.xml deleted file mode 100644 index 049e2cf..0000000 --- a/app/src/main/res/layout/bottom_tablayout_item.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - -