Re-theme lock view to actually match current theme

This commit is contained in:
NerdNumber9 2018-03-14 13:13:57 -04:00
parent 09dbd723e4
commit d2a2e17e91
5 changed files with 32 additions and 20 deletions

View File

@ -7,7 +7,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.changehandler.AnimatorChangeHandler import com.bluelinelabs.conductor.changehandler.AnimatorChangeHandler
import java.util.ArrayList import java.util.*
class LockChangeHandler : AnimatorChangeHandler { class LockChangeHandler : AnimatorChangeHandler {
constructor(): super() constructor(): super()

View File

@ -1,29 +1,21 @@
package exh.ui.lock package exh.ui.lock
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.CardView
import android.util.TypedValue import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.andrognito.pinlockview.PinLockListener import com.andrognito.pinlockview.PinLockListener
import com.github.ajalt.reprint.core.AuthenticationResult import com.github.ajalt.reprint.core.AuthenticationResult
import com.github.ajalt.reprint.core.Reprint
import com.github.ajalt.reprint.rxjava.RxReprint import com.github.ajalt.reprint.rxjava.RxReprint
import com.mattprecious.swirl.SwirlView import com.mattprecious.swirl.SwirlView
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.main.MainActivity
import exh.util.dpToPx import exh.util.dpToPx
import kotlinx.android.synthetic.main.activity_lock.view.* import kotlinx.android.synthetic.main.activity_lock.view.*
import kotlinx.android.synthetic.main.main_activity.view.*
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
class LockController : NucleusController<LockPresenter>() { class LockController : NucleusController<LockPresenter>() {
@ -94,13 +86,13 @@ class LockController : NucleusController<LockPresenter>() {
val pSize = dpToPx(context, 8) val pSize = dpToPx(context, 8)
setPadding(pSize, pSize, pSize, pSize) setPadding(pSize, pSize, pSize, pSize)
} }
val typedVal = TypedValue() val lockColor = resolvColor(android.R.attr.windowBackground)
activity!!.theme!!.resolveAttribute(android.R.attr.windowBackground, typedVal, true) setBackgroundColor(lockColor)
setBackgroundColor(typedVal.data) val bgColor = resolvColor(android.R.attr.colorBackground)
//Disable elevation if dark theme is active //Disable elevation if lock color is same as background color
if (typedVal.data == resources.getColor(R.color.backgroundDark, activity!!.theme!!)) if (lockColor == bgColor)
this@with.swirl_container.cardElevation = 0f this@with.swirl_container.cardElevation = 0f
setState(SwirlView.State.OFF, false) setState(SwirlView.State.OFF, true)
} }
swirl_container.addView(icon) swirl_container.addView(icon)
icon.setState(SwirlView.State.ON) icon.setState(SwirlView.State.ON)
@ -126,6 +118,12 @@ class LockController : NucleusController<LockPresenter>() {
} }
} }
private fun resolvColor(color: Int): Int {
val typedVal = TypedValue()
activity!!.theme!!.resolveAttribute(android.R.attr.windowBackground, typedVal, true)
return typedVal.data
}
override fun onDetach(view: View) { override fun onDetach(view: View) {
super.onDetach(view) super.onDetach(view)
} }

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="?android:attr/textColorSecondary" />
</shape>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/blue_pressed" />
</shape>

View File

@ -1,17 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:card_view="http://schemas.android.com/apk/res-auto" android:background="?android:attr/colorBackground">
android:background="@color/backgroundDark">
<com.andrognito.pinlockview.PinLockView <com.andrognito.pinlockview.PinLockView
android:id="@+id/pin_lock_view" android:id="@+id/pin_lock_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
app:keypadDeleteButtonPressedColor="?android:attr/textColorPrimary"
app:keypadTextColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
@ -22,6 +24,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
app:dotEmptyBackground="@drawable/lock_dot_empty"
app:dotFilledBackground="@drawable/lock_dot_filled"
app:layout_constraintBottom_toTopOf="@+id/pin_lock_view" app:layout_constraintBottom_toTopOf="@+id/pin_lock_view"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
@ -35,11 +39,11 @@
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
card_view:cardCornerRadius="30dp"
card_view:cardElevation="4dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"> app:layout_constraintRight_toRightOf="parent"
card_view:cardCornerRadius="30dp"
card_view:cardElevation="4dp">
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>