mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Re-theme lock view to actually match current theme
This commit is contained in:
		| @@ -7,7 +7,7 @@ import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import com.bluelinelabs.conductor.ControllerChangeHandler | ||||
| import com.bluelinelabs.conductor.changehandler.AnimatorChangeHandler | ||||
| import java.util.ArrayList | ||||
| import java.util.* | ||||
|  | ||||
| class LockChangeHandler : AnimatorChangeHandler { | ||||
|     constructor(): super() | ||||
|   | ||||
| @@ -1,29 +1,21 @@ | ||||
| package exh.ui.lock | ||||
|  | ||||
| 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.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import android.widget.FrameLayout | ||||
| import com.afollestad.materialdialogs.MaterialDialog | ||||
| import com.andrognito.pinlockview.PinLockListener | ||||
| import com.github.ajalt.reprint.core.AuthenticationResult | ||||
| import com.github.ajalt.reprint.core.Reprint | ||||
| import com.github.ajalt.reprint.rxjava.RxReprint | ||||
| import com.mattprecious.swirl.SwirlView | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.data.preference.getOrDefault | ||||
| import eu.kanade.tachiyomi.ui.base.controller.NucleusController | ||||
| import eu.kanade.tachiyomi.ui.main.MainActivity | ||||
| import exh.util.dpToPx | ||||
| import kotlinx.android.synthetic.main.activity_lock.view.* | ||||
| import kotlinx.android.synthetic.main.main_activity.view.* | ||||
| import uy.kohesive.injekt.injectLazy | ||||
|  | ||||
| class LockController : NucleusController<LockPresenter>() { | ||||
| @@ -94,13 +86,13 @@ class LockController : NucleusController<LockPresenter>() { | ||||
|                         val pSize = dpToPx(context, 8) | ||||
|                         setPadding(pSize, pSize, pSize, pSize) | ||||
|                     } | ||||
|                     val typedVal = TypedValue() | ||||
|                     activity!!.theme!!.resolveAttribute(android.R.attr.windowBackground, typedVal, true) | ||||
|                     setBackgroundColor(typedVal.data) | ||||
|                     //Disable elevation if dark theme is active | ||||
|                     if (typedVal.data == resources.getColor(R.color.backgroundDark, activity!!.theme!!)) | ||||
|                     val lockColor = resolvColor(android.R.attr.windowBackground) | ||||
|                     setBackgroundColor(lockColor) | ||||
|                     val bgColor = resolvColor(android.R.attr.colorBackground) | ||||
|                     //Disable elevation if lock color is same as background color | ||||
|                     if (lockColor == bgColor) | ||||
|                         this@with.swirl_container.cardElevation = 0f | ||||
|                     setState(SwirlView.State.OFF, false) | ||||
|                     setState(SwirlView.State.OFF, true) | ||||
|                 } | ||||
|                 swirl_container.addView(icon) | ||||
|                 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) { | ||||
|         super.onDetach(view) | ||||
|     } | ||||
|   | ||||
							
								
								
									
										5
									
								
								app/src/main/res/drawable/lock_dot_empty.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/src/main/res/drawable/lock_dot_empty.xml
									
									
									
									
									
										Normal 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> | ||||
							
								
								
									
										5
									
								
								app/src/main/res/drawable/lock_dot_filled.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/src/main/res/drawable/lock_dot_filled.xml
									
									
									
									
									
										Normal 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> | ||||
| @@ -1,17 +1,19 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     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" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     xmlns:card_view="http://schemas.android.com/apk/res-auto" | ||||
|     android:background="@color/backgroundDark"> | ||||
|     android:background="?android:attr/colorBackground"> | ||||
|  | ||||
|     <com.andrognito.pinlockview.PinLockView | ||||
|         android:id="@+id/pin_lock_view" | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginTop="8dp" | ||||
|         app:keypadDeleteButtonPressedColor="?android:attr/textColorPrimary" | ||||
|         app:keypadTextColor="?android:attr/textColorSecondary" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintLeft_toLeftOf="parent" | ||||
|         app:layout_constraintRight_toRightOf="parent" | ||||
| @@ -22,6 +24,8 @@ | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         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_constraintLeft_toLeftOf="parent" | ||||
|         app:layout_constraintRight_toRightOf="parent" | ||||
| @@ -35,11 +39,11 @@ | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:layout_marginLeft="8dp" | ||||
|         android:layout_marginRight="8dp" | ||||
|         card_view:cardCornerRadius="30dp" | ||||
|         card_view:cardElevation="4dp" | ||||
|         app:layout_constraintBottom_toBottomOf="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.constraint.ConstraintLayout> | ||||
		Reference in New Issue
	
	Block a user