moving the bottom tab item layout file to commons

This commit is contained in:
tibbi
2022-06-22 22:00:24 +02:00
parent fbc2a529ac
commit 3f4f83fdbb
3 changed files with 14 additions and 41 deletions

View File

@@ -62,7 +62,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:0834a977e4' implementation 'com.github.SimpleMobileTools:Simple-Commons:b2167e4b2a'
implementation 'org.greenrobot:eventbus:3.3.1' implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.github.Armen101:AudioRecordView:1.0.4' implementation 'com.github.Armen101:AudioRecordView:1.0.4'
implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'androidx.documentfile:documentfile:1.0.1'

View File

@@ -103,26 +103,26 @@ class MainActivity : SimpleActivity() {
private fun setupViewPager() { private fun setupViewPager() {
main_tabs_holder.removeAllTabs() main_tabs_holder.removeAllTabs()
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
customView?.findViewById<ImageView>(R.id.tab_icon)?.setImageDrawable(getDrawable(R.drawable.ic_microphone_vector)) customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(R.drawable.ic_microphone_vector))
customView?.findViewById<TextView>(R.id.tab_label)?.setText(R.string.recorder) customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(R.string.recorder)
main_tabs_holder.addTab(this) main_tabs_holder.addTab(this)
} }
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
customView?.findViewById<ImageView>(R.id.tab_icon)?.setImageDrawable(getDrawable(R.drawable.ic_headset_vector)) customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(R.drawable.ic_headset_vector))
customView?.findViewById<TextView>(R.id.tab_label)?.setText(R.string.player) customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(R.string.player)
main_tabs_holder.addTab(this) main_tabs_holder.addTab(this)
} }
main_tabs_holder.onTabSelectionChanged( main_tabs_holder.onTabSelectionChanged(
tabUnselectedAction = { tabUnselectedAction = {
it.customView?.findViewById<ImageView>(R.id.tab_icon)?.applyColorFilter(getProperTextColor()) it.customView?.findViewById<ImageView>(R.id.tab_item_icon)?.applyColorFilter(getProperTextColor())
it.customView?.findViewById<TextView>(R.id.tab_label)?.setTextColor(getProperTextColor()) it.customView?.findViewById<TextView>(R.id.tab_item_label)?.setTextColor(getProperTextColor())
}, },
tabSelectedAction = { tabSelectedAction = {
view_pager.currentItem = it.position view_pager.currentItem = it.position
it.customView?.findViewById<ImageView>(R.id.tab_icon)?.applyColorFilter(getProperPrimaryColor()) it.customView?.findViewById<ImageView>(R.id.tab_item_icon)?.applyColorFilter(getProperPrimaryColor())
it.customView?.findViewById<TextView>(R.id.tab_label)?.setTextColor(getProperPrimaryColor()) it.customView?.findViewById<TextView>(R.id.tab_item_label)?.setTextColor(getProperPrimaryColor())
} }
) )
@@ -131,6 +131,7 @@ class MainActivity : SimpleActivity() {
main_tabs_holder.getTabAt(it)?.select() main_tabs_holder.getTabAt(it)?.select()
(view_pager.adapter as ViewPagerAdapter).finishActMode() (view_pager.adapter as ViewPagerAdapter).finishActMode()
} }
view_pager.currentItem = config.lastUsedViewPagerPage view_pager.currentItem = config.lastUsedViewPagerPage
main_tabs_holder.getTabAt(config.lastUsedViewPagerPage)?.select() main_tabs_holder.getTabAt(config.lastUsedViewPagerPage)?.select()
} }
@@ -139,13 +140,13 @@ class MainActivity : SimpleActivity() {
private fun setupTabColors() { private fun setupTabColors() {
main_tabs_holder.getTabAt(getInactiveTabIndex())?.customView?.apply { main_tabs_holder.getTabAt(getInactiveTabIndex())?.customView?.apply {
findViewById<ImageView>(R.id.tab_icon)?.applyColorFilter(getProperTextColor()) findViewById<ImageView>(R.id.tab_item_icon)?.applyColorFilter(getProperTextColor())
findViewById<TextView>(R.id.tab_label)?.setTextColor(getProperTextColor()) findViewById<TextView>(R.id.tab_item_label)?.setTextColor(getProperTextColor())
} }
main_tabs_holder.getTabAt(view_pager.currentItem)?.customView?.apply { main_tabs_holder.getTabAt(view_pager.currentItem)?.customView?.apply {
findViewById<ImageView>(R.id.tab_icon)?.applyColorFilter(getProperPrimaryColor()) findViewById<ImageView>(R.id.tab_item_icon)?.applyColorFilter(getProperPrimaryColor())
findViewById<TextView>(R.id.tab_label)?.setTextColor(getProperPrimaryColor()) findViewById<TextView>(R.id.tab_item_label)?.setTextColor(getProperPrimaryColor())
} }
} }

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:orientation="vertical">
<ImageView
android:id="@+id/tab_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_horizontal"
android:scaleType="fitCenter"
tools:src="@drawable/ic_headset_vector" />
<TextView
android:id="@+id/tab_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:includeFontPadding="false"
android:paddingTop="@dimen/small_margin"
android:paddingBottom="@dimen/medium_margin"
android:textSize="@dimen/smaller_text_size"
tools:text="@string/player" />
</LinearLayout>