mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Hide the select button for the already selected theme
And reorder themes, Finn's theme on top, as it is the default ^^
This commit is contained in:
parent
442b7b8712
commit
1d540f7d37
3 changed files with 50 additions and 30 deletions
|
@ -128,7 +128,7 @@ class MainActivity : AppCompatActivity(),
|
|||
/** Touch- and Key-related functions to start activities */
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) if (settingsIconShown) hideSettingsIcon()
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) { if (settingsIconShown) hideSettingsIcon() }
|
||||
else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) launchApp(volumeUpApp, this)
|
||||
else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) launchApp(volumeDownApp, this)
|
||||
return true
|
||||
|
|
|
@ -22,6 +22,8 @@ import androidx.viewpager.widget.ViewPager
|
|||
import com.finnmglas.launcher.ui.main.SectionsPagerAdapter
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import kotlinx.android.synthetic.main.activity_settings.container
|
||||
import kotlinx.android.synthetic.main.fragment_settings_theme.*
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
|
||||
|
@ -52,6 +54,21 @@ class SettingsActivity : AppCompatActivity() {
|
|||
val tabs: TabLayout = findViewById(R.id.tabs)
|
||||
tabs.setupWithViewPager(viewPager)
|
||||
|
||||
// Hide 'select' button for the selected theme
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
if (tab == tabs.getTabAt(1 )) {
|
||||
when (getSavedTheme(container!!.context)) {
|
||||
"dark" -> select_theme_dark.visibility = View.INVISIBLE
|
||||
"finn" -> select_theme_finn.visibility = View.INVISIBLE
|
||||
"custom" -> select_theme_custom.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) {}
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {}
|
||||
})
|
||||
|
||||
// As older APIs somehow do not recognize the xml defined onClick
|
||||
close_settings.setOnClickListener() { finish() }
|
||||
}
|
||||
|
|
|
@ -22,35 +22,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10sp"
|
||||
app:cardCornerRadius="8dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitXY"
|
||||
app:srcCompat="@drawable/dark_theme" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseDarkTheme"
|
||||
android:text="@string/settings_select_theme"
|
||||
android:textAllCaps="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -70,6 +41,7 @@
|
|||
app:srcCompat="@drawable/finnmglas_theme" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_theme_finn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseFinnTheme"
|
||||
|
@ -82,6 +54,36 @@
|
|||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10sp"
|
||||
app:cardCornerRadius="8dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitXY"
|
||||
app:srcCompat="@drawable/dark_theme" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_theme_dark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseDarkTheme"
|
||||
android:text="@string/settings_select_theme"
|
||||
android:textAllCaps="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -100,6 +102,7 @@
|
|||
app:srcCompat="@drawable/custom_theme" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_theme_custom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseCustomTheme"
|
||||
|
|
Loading…
Add table
Reference in a new issue