mirror of
https://github.com/SimpleMobileTools/Simple-Voice-Recorder.git
synced 2025-01-25 13:38:48 +01:00
setting up the top tabs
This commit is contained in:
parent
656e887a1b
commit
d8dea46228
@ -1,16 +1,17 @@
|
||||
package com.simplemobiletools.voicerecorder.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.extensions.appLaunched
|
||||
import com.simplemobiletools.commons.extensions.checkAppSideloading
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.FAQItem
|
||||
import com.simplemobiletools.voicerecorder.BuildConfig
|
||||
import com.simplemobiletools.voicerecorder.R
|
||||
import com.simplemobiletools.voicerecorder.adapters.ViewPagerAdapter
|
||||
import com.simplemobiletools.voicerecorder.extensions.config
|
||||
import com.simplemobiletools.voicerecorder.helpers.STOP_AMPLITUDE_UPDATE
|
||||
import com.simplemobiletools.voicerecorder.services.RecorderService
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
@ -33,6 +34,8 @@ class MainActivity : SimpleActivity() {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
setupTabColors(config.lastUsedViewPagerPage)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -43,6 +46,7 @@ class MainActivity : SimpleActivity() {
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
getPagerAdapter()?.onDestroy()
|
||||
config.lastUsedViewPagerPage = view_pager.currentItem
|
||||
|
||||
Intent(this@MainActivity, RecorderService::class.java).apply {
|
||||
action = STOP_AMPLITUDE_UPDATE
|
||||
@ -79,10 +83,31 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun setupViewPager() {
|
||||
viewpager.adapter = ViewPagerAdapter(this)
|
||||
view_pager.adapter = ViewPagerAdapter(this)
|
||||
}
|
||||
|
||||
private fun getPagerAdapter() = (viewpager.adapter as? ViewPagerAdapter)
|
||||
private fun getPagerAdapter() = (view_pager.adapter as? ViewPagerAdapter)
|
||||
|
||||
private fun setupTabColors(lastUsedTab: Int) {
|
||||
main_tabs_holder.apply {
|
||||
background = ColorDrawable(config.backgroundColor)
|
||||
setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
|
||||
getTabAt(lastUsedTab)?.apply {
|
||||
select()
|
||||
icon?.applyColorFilter(getAdjustedPrimaryColor())
|
||||
}
|
||||
}
|
||||
|
||||
main_tabs_holder.onTabSelectionChanged(
|
||||
tabUnselectedAction = {
|
||||
it.icon?.applyColorFilter(config.textColor)
|
||||
},
|
||||
tabSelectedAction = {
|
||||
view_pager.currentItem = it.position
|
||||
it.icon?.applyColorFilter(getAdjustedPrimaryColor())
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun launchSettings() {
|
||||
startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
|
9
app/src/main/res/drawable/ic_headset_vector.xml
Normal file
9
app/src/main/res/drawable/ic_headset_vector.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="64dp"
|
||||
android:height="64dp"
|
||||
android:viewportWidth="108.6"
|
||||
android:viewportHeight="108.6">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M97.787,27.431C92.028,16.553 83.283,8.875 71.766,4.183 62.942,1.061 53.981,-0.372 45.105,1.197 36.787,2.263 29.535,5.462 22.923,10.368 12.472,18.259 6.074,28.71 3.514,41.294 2.839,44.555 2.875,47.506 2.875,50.892l0,23.888c-0.044,3.559 -0.177,8.108 0.427,11.091 2.346,8.958 7.678,14.93 16.636,17.276l0.213,0 0,0.427 0,0.213c0.213,1.066 0.64,2.559 2.559,3.626l0.427,0.213 8.105,0 0.427,-0.213c2.773,-1.066 2.773,-3.839 2.773,-5.119l0,-0.213 0,-15.996 0,-28.794c0,-2.986 -1.493,-4.479 -4.479,-4.479l-4.906,0c-1.066,0 -4.266,0 -4.692,3.626l-0.213,0.853c-4.266,1.066 -7.892,2.986 -11.091,6.185 -0.213,-4.052 0,-8.105 0,-12.157l0.427,0c1.706,0 1.706,0 1.706,-1.706 0,-1.706 0,-3.199 0.213,-4.692 0.853,-5.332 2.559,-10.238 5.119,-14.717l1.28,0.853c1.066,0.64 2.346,1.493 3.413,2.346 0.853,0.64 2.346,1.28 4.052,0 1.28,-0.853 2.133,-1.92 2.986,-2.986 0.213,-0.427 0.64,-0.64 0.853,-1.066 7.892,-8.531 17.916,-11.944 29.433,-10.024 7.465,1.066 13.864,4.906 19.196,11.091 0.853,1.066 1.92,2.133 2.986,2.773 0.64,0.427 1.28,0.853 2.133,0.853 0.64,0 1.28,-0.213 1.92,-0.64 1.28,-0.853 2.346,-1.493 3.626,-2.346l1.493,-0.853c1.493,2.559 2.559,5.332 3.626,8.105 1.28,3.839 1.92,7.892 1.92,12.157 0,0.853 0.427,1.066 1.066,1.066 0.427,0 0.64,-0.213 1.066,-0.213l0,12.371c-1.493,-1.493 -2.986,-2.773 -4.906,-3.839 -1.92,-1.066 -4.052,-2.133 -6.185,-2.346l0,-0.427C86.269,54.731 84.563,53.238 82.217,53.238l-1.28,0 -4.479,0C73.685,53.452 72.406,54.731 72.406,57.504l0,14.077 0,31.566c0.766,2.651 0.618,3.515 2.559,4.906l7.892,0 0.64,0 0.427,-0.213c0.853,-0.427 2.559,-1.493 2.346,-3.839l0,-0.213c5.332,-1.28 9.598,-4.052 12.797,-8.531 3.944,-6.929 4.435,-13.876 4.266,-20.689l0,-22.822c0.266,-7.952 -2.018,-17.44 -5.545,-24.315zM24.203,79.472 L24.203,65.822 24.203,57.931 24.203,57.077 24.63,57.077 29.322,57.077 29.535,57.077 29.535,57.504c0.213,9.598 0,19.409 0,28.794l0,15.996 0,0.427 0,0.853 -5.545,0 0,0 0,-7.252C24.203,90.563 24.203,85.018 24.203,79.472ZM82.857,29.35C82.217,28.924 81.577,28.284 81.15,27.431 75.178,20.392 67.927,16.127 59.395,14.847 46.385,12.714 35.081,16.553 26.123,26.151c-0.427,0.427 -0.64,0.64 -0.853,1.066 -0.64,0.853 -1.28,1.493 -1.92,2.133 -0.853,-0.64 -1.92,-1.28 -2.986,-1.92 0.853,-1.28 1.92,-2.346 2.773,-3.413 6.185,-6.612 13.65,-10.878 22.182,-12.584 6.948,-0.799 12.987,-0.551 19.409,1.066 8.531,2.773 15.57,7.892 20.902,14.93 -0.64,0.64 -1.706,1.28 -2.773,1.92zM81.79,82.672 L81.79,102.294 81.79,103.36 76.458,103.36 76.458,102.721 76.458,71.154 76.458,57.077 76.458,57.077 76.458,57.077 80.724,57.077 82.004,57.291 82.004,58.144c-0.213,7.892 -0.213,16.21 -0.213,24.528z" />
|
||||
</vector>
|
@ -1,12 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyViewPager
|
||||
android:id="@+id/viewpager"
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/main_tabs_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="48dp"
|
||||
app:elevation="6dp"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabIndicatorHeight="2dp"
|
||||
app:tabMinWidth="150dp"
|
||||
app:tabSelectedTextColor="@android:color/white">
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:id="@+id/tab_recorder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:icon="@drawable/ic_microphone_small" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:id="@+id/tab_player"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:icon="@drawable/ic_headset_vector" />
|
||||
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/main_tabs_holder" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user