mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +00:00
Got rid of status bar and made animation apply to the window instead of the layout.
This commit is contained in:
parent
6d3b451396
commit
d0112bbbe4
7 changed files with 29 additions and 58 deletions
|
|
@ -41,14 +41,11 @@ android {
|
|||
dependencies {
|
||||
|
||||
implementation("androidx.core:core-ktx:1.13.1")
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
implementation("androidx.appcompat:appcompat:1.7.0")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
|
||||
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
|
||||
implementation("com.google.code.gson:gson:2.10")
|
||||
implementation("androidx.recyclerview:recyclerview:1.3.2")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||
}
|
||||
|
|
@ -4,7 +4,9 @@ import android.animation.Animator
|
|||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.ValueAnimator
|
||||
import android.app.Activity
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
|
|
@ -34,56 +36,32 @@ class Animations () {
|
|||
val originalColor = ContextCompat.getColor(activity, R.color.original_color)
|
||||
val newColor = ContextCompat.getColor(activity, R.color.new_color)
|
||||
|
||||
val backgroundColorAnimator: ObjectAnimator = ObjectAnimator.ofObject(
|
||||
binding.root,
|
||||
"backgroundColor",
|
||||
ArgbEvaluator(),
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
val colorDrawable = ColorDrawable(originalColor)
|
||||
activity.window.setBackgroundDrawable(colorDrawable)
|
||||
|
||||
backgroundColorAnimator.setDuration(duration)
|
||||
val backgroundColorAnimator = ValueAnimator.ofObject(ArgbEvaluator(), originalColor, newColor)
|
||||
backgroundColorAnimator.addUpdateListener { animator ->
|
||||
colorDrawable.color = animator.animatedValue as Int
|
||||
}
|
||||
backgroundColorAnimator.duration = duration
|
||||
|
||||
val window = activity.window
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
|
||||
val statusBarColorAnimator = ObjectAnimator.ofArgb(
|
||||
window,
|
||||
"statusBarColor",
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
statusBarColorAnimator.setDuration(duration)
|
||||
backgroundColorAnimator.start()
|
||||
statusBarColorAnimator.start()
|
||||
}
|
||||
|
||||
fun backgroundOut(activity: Activity, binding: ActivityMainBinding, duration: Long = 100) {
|
||||
val originalColor = ContextCompat.getColor(activity, R.color.new_color)
|
||||
val newColor = ContextCompat.getColor(activity, R.color.original_color)
|
||||
|
||||
val backgroundColorAnimator: ObjectAnimator = ObjectAnimator.ofObject(
|
||||
binding.root,
|
||||
"backgroundColor",
|
||||
ArgbEvaluator(),
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
val colorDrawable = ColorDrawable(originalColor)
|
||||
activity.window.setBackgroundDrawable(colorDrawable)
|
||||
|
||||
backgroundColorAnimator.setDuration(duration)
|
||||
val backgroundColorAnimator = ValueAnimator.ofObject(ArgbEvaluator(), originalColor, newColor)
|
||||
backgroundColorAnimator.addUpdateListener { animator ->
|
||||
colorDrawable.color = animator.animatedValue as Int
|
||||
}
|
||||
backgroundColorAnimator.duration = duration
|
||||
|
||||
val window = activity.window
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
|
||||
val statusBarColorAnimator = ObjectAnimator.ofArgb(
|
||||
window,
|
||||
"statusBarColor",
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
statusBarColorAnimator.setDuration(duration)
|
||||
backgroundColorAnimator.start()
|
||||
statusBarColorAnimator.start()
|
||||
}
|
||||
private fun View.slideInFromBottom(duration: Long = 100) {
|
||||
if (visibility != View.VISIBLE) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import android.text.TextWatcher
|
|||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
|
|
@ -71,7 +72,6 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
setContentView(binding.root)
|
||||
setSupportActionBar(null)
|
||||
|
||||
|
||||
launcherApps = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||
|
||||
gestureDetector = GestureDetector(this, GestureListener())
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="fill_vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
|
|
@ -77,7 +76,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="fill_vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
android:gravity="fill_vertical"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.YamLauncher" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<style name="Base.Theme.YamLauncher" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
<item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
|
||||
<item name="android:windowShowWallpaper">true</item>
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<style name="Theme.YamLauncher" parent="Base.Theme.YamLauncher">
|
||||
<!-- Transparent system bars for edge-to-edge. -->
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.YamLauncher" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<style name="Base.Theme.YamLauncher" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
<item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
|
||||
<item name="android:windowShowWallpaper">true</item>
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppSearchView" parent="Widget.AppCompat.SearchView" >
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue