mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Moved animations to a new class and added the settings activity
This commit is contained in:
parent
87b4fc3612
commit
709692482a
14 changed files with 342 additions and 258 deletions
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
|
||||
|
||||
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
|
@ -21,27 +22,25 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.YamLauncher"
|
||||
tools:targetApi="34">
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.YamLauncher"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:launchMode="singleTask">
|
||||
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
143
app/src/main/java/eu/ottop/yamlauncher/Animations.kt
Normal file
143
app/src/main/java/eu/ottop/yamlauncher/Animations.kt
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
package eu.ottop.yamlauncher
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ObjectAnimator
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import eu.ottop.yamlauncher.databinding.ActivityMainBinding
|
||||
|
||||
class Animations () {
|
||||
|
||||
fun fadeViewIn(view: View, duration: Long = 100) {
|
||||
view.fadeIn(duration)
|
||||
}
|
||||
|
||||
fun fadeViewOut(view: View, duration: Long = 100) {
|
||||
view.fadeOut(duration)
|
||||
}
|
||||
fun showHome(binding: ActivityMainBinding) {
|
||||
binding.appView.slideOutToBottom()
|
||||
binding.homeView.fadeIn()
|
||||
binding.menutitle.visibility = View.GONE
|
||||
}
|
||||
|
||||
fun showApps(binding: ActivityMainBinding) {
|
||||
binding.homeView.fadeOut()
|
||||
binding.appView.slideInFromBottom()
|
||||
}
|
||||
|
||||
fun backgroundIn(activity: Activity, binding: ActivityMainBinding, duration: Long = 100) {
|
||||
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
|
||||
)
|
||||
|
||||
backgroundColorAnimator.setDuration(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
|
||||
)
|
||||
|
||||
backgroundColorAnimator.setDuration(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) {
|
||||
translationY = height.toFloat()/5
|
||||
scaleY = 1.2f
|
||||
alpha = 0f
|
||||
visibility = View.VISIBLE
|
||||
animate()
|
||||
.translationY(0f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f)
|
||||
.setDuration(duration)
|
||||
.setListener(null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun View.slideOutToBottom(duration: Long = 50) {
|
||||
if (visibility == View.VISIBLE) {
|
||||
animate()
|
||||
.translationY(height.toFloat() / 5)
|
||||
.scaleY(1.2f)
|
||||
.alpha(0f)
|
||||
.setDuration(duration)
|
||||
.setListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun View.fadeIn(duration: Long = 100) {
|
||||
if (visibility != View.VISIBLE) {
|
||||
alpha = 0f
|
||||
translationY = -height.toFloat()/100
|
||||
visibility = View.VISIBLE
|
||||
animate()
|
||||
.alpha(1f)
|
||||
.translationY(0f)
|
||||
.setDuration(duration)
|
||||
.setListener(null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun View.fadeOut(duration: Long = 50) {
|
||||
if (visibility == View.VISIBLE) {
|
||||
animate()
|
||||
.alpha(0f)
|
||||
.translationY(-height.toFloat()/100)
|
||||
.setDuration(duration)
|
||||
.setListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
})}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ class AppActionMenu {
|
|||
|
||||
private val sharedPreferenceManager = SharedPreferenceManager()
|
||||
private val appUtils = AppUtils()
|
||||
private val animations = Animations()
|
||||
|
||||
fun setActionListeners(
|
||||
activity: MainActivity,
|
||||
|
|
@ -52,7 +53,7 @@ class AppActionMenu {
|
|||
)
|
||||
}
|
||||
|
||||
actionMenu.visibility = View.INVISIBLE
|
||||
animations.fadeViewOut(actionMenu, 100)
|
||||
textView.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
|
|
@ -62,14 +63,14 @@ class AppActionMenu {
|
|||
intent.putExtra(Intent.EXTRA_USER, userHandle)
|
||||
activity.startActivity(intent)
|
||||
|
||||
actionMenu.visibility = View.INVISIBLE
|
||||
animations.fadeViewOut(actionMenu, 100)
|
||||
textView.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
actionMenu.findViewById<TextView>(R.id.rename).setOnClickListener {
|
||||
textView.visibility = View.INVISIBLE
|
||||
editLayout.visibility = View.VISIBLE
|
||||
actionMenu.visibility = View.INVISIBLE
|
||||
animations.fadeViewIn(editLayout)
|
||||
animations.fadeViewOut(actionMenu, 100)
|
||||
val editText = editLayout.findViewById<EditText>(R.id.app_name_edit)
|
||||
val resetButton = editLayout.findViewById<AppCompatButton>(R.id.reset)
|
||||
|
||||
|
|
@ -89,7 +90,7 @@ class AppActionMenu {
|
|||
if (bottom - top > oldBottom - oldTop) {
|
||||
editLayout.clearFocus()
|
||||
|
||||
editLayout.visibility = View.INVISIBLE
|
||||
animations.fadeViewOut(editLayout, 100)
|
||||
textView.visibility = View.VISIBLE
|
||||
searchView.visibility = View.VISIBLE
|
||||
}
|
||||
|
|
@ -153,7 +154,7 @@ class AppActionMenu {
|
|||
}
|
||||
|
||||
actionMenu.findViewById<TextView>(R.id.close).setOnClickListener {
|
||||
actionMenu.visibility = View.INVISIBLE
|
||||
animations.fadeViewOut(actionMenu, 100)
|
||||
textView.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class AppMenuAdapter(
|
|||
holder.textView.compoundDrawablePadding = 0
|
||||
|
||||
val appInfo = app.first.activityInfo.applicationInfo
|
||||
holder.textView.text = sharedPreferenceManager.getAppName(activity, app.first.applicationInfo.packageName,app.second.second, appInfo.loadLabel(holder.itemView.context.packageManager))
|
||||
holder.textView.text = sharedPreferenceManager.getAppName(activity, app.first.applicationInfo.packageName,app.second.second, holder.itemView.context.packageManager.getApplicationLabel(appInfo))
|
||||
holder.editView.findViewById<EditText>(R.id.app_name_edit).setText(holder.textView.text)
|
||||
holder.textView.visibility = View.VISIBLE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class AppMenuLinearLayoutManager(private val activity: MainActivity) : LinearLay
|
|||
val overscroll: Int = dy - scrollRange
|
||||
|
||||
if (overscroll < 0 && firstVisibleItemPosition == 0 && scrollStarted) {
|
||||
activity.showHome()
|
||||
activity.backToHome()
|
||||
}
|
||||
|
||||
if (scrollStarted) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class AppUtils {
|
|||
}
|
||||
}
|
||||
return allApps.sortedBy {
|
||||
sharedPreferenceManager.getAppName(activity, it.first.applicationInfo.packageName,it.second.second, it.first.applicationInfo.loadLabel(activity.packageManager)).toString().lowercase()
|
||||
sharedPreferenceManager.getAppName(activity, it.first.applicationInfo.packageName,it.second.second, activity.packageManager.getApplicationLabel(it.first.applicationInfo)).toString().lowercase()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
29
app/src/main/java/eu/ottop/yamlauncher/BatteryReceiver.kt
Normal file
29
app/src/main/java/eu/ottop/yamlauncher/BatteryReceiver.kt
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package eu.ottop.yamlauncher
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.BatteryManager
|
||||
import android.widget.TextView
|
||||
|
||||
class BatteryReceiver(private val textView: TextView) : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
intent?.let {
|
||||
val level = it.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
|
||||
val scale = it.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
|
||||
val batteryPct = level * 100 / scale.toFloat()
|
||||
textView.text = "${batteryPct.toInt()}%"
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun register(context: Context, textView: TextView): BatteryReceiver {
|
||||
val receiver = BatteryReceiver(textView)
|
||||
val filter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||
context.registerReceiver(receiver, filter)
|
||||
return receiver
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
package eu.ottop.yamlauncher
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.LauncherActivityInfo
|
||||
import android.content.pm.LauncherApps
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
|
|
@ -19,17 +16,15 @@ 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
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import eu.ottop.yamlauncher.databinding.ActivityMainBinding
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
|
@ -39,6 +34,8 @@ import kotlinx.coroutines.delay
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.math.abs
|
||||
import java.lang.reflect.Method
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, AppMenuAdapter.OnShortcutListener, AppMenuAdapter.OnItemLongClickListener {
|
||||
|
||||
|
|
@ -53,37 +50,53 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
private var job: Job? = null
|
||||
val cameraIntent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE)
|
||||
val phoneIntent = Intent(Intent.ACTION_DIAL)
|
||||
private lateinit var batteryReceiver: BatteryReceiver
|
||||
private lateinit var batteryTextView: TextView
|
||||
|
||||
private var appActionMenu = AppActionMenu()
|
||||
private val sharedPreferenceManager = SharedPreferenceManager()
|
||||
private val appUtils = AppUtils()
|
||||
private val appMenuLinearLayoutManager = AppMenuLinearLayoutManager(this@MainActivity)
|
||||
private val appMenuEdgeFactory = AppMenuEdgeFactory(this@MainActivity)
|
||||
private val animations = Animations()
|
||||
|
||||
private val swipeThreshold = 100
|
||||
private val swipeVelocityThreshold = 100
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(null)
|
||||
|
||||
|
||||
launcherApps = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||
|
||||
gestureDetector = GestureDetector(this, GestureListener())
|
||||
|
||||
setupApps()
|
||||
|
||||
|
||||
batteryTextView = findViewById(R.id.battery_charge)
|
||||
|
||||
batteryReceiver = BatteryReceiver.register(this, batteryTextView)
|
||||
|
||||
binding.homeView.setOnTouchListener { _, event ->
|
||||
gestureDetector.onTouchEvent(event)
|
||||
super.onTouchEvent(event)
|
||||
true // Return true if the touch event is handled
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
showHome()
|
||||
backToHome()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
showHome()
|
||||
backToHome()
|
||||
super.onNewIntent(intent)
|
||||
|
||||
}
|
||||
|
|
@ -96,6 +109,7 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
job?.cancel()
|
||||
unregisterReceiver(batteryReceiver)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
|
@ -109,12 +123,10 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
imm.hideSoftInputFromWindow(binding.root.windowToken, 0)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
gestureDetector.onTouchEvent(event)
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
@SuppressLint("WrongConstant")
|
||||
override fun onFling(
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
|
|
@ -128,12 +140,16 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
// Detect swipe up
|
||||
if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
||||
openAppMenuActivity()
|
||||
return true
|
||||
}
|
||||
|
||||
// Detect swipe down
|
||||
else if (deltaY > swipeThreshold && abs(velocityY) > swipeVelocityThreshold) {
|
||||
return true
|
||||
|
||||
val statusBarService = getSystemService(Context.STATUS_BAR_SERVICE)
|
||||
val statusBarManager: Class<*> = Class.forName("android.app.StatusBarManager")
|
||||
val expandMethod: Method = statusBarManager.getMethod("expandNotificationsPanel")
|
||||
expandMethod.invoke(statusBarService)
|
||||
|
||||
}
|
||||
|
||||
// Detect swipe left
|
||||
|
|
@ -149,6 +165,11 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
return false
|
||||
}
|
||||
|
||||
override fun onLongPress(e: MotionEvent) {
|
||||
super.onLongPress(e)
|
||||
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setupApps() {
|
||||
|
|
@ -211,7 +232,8 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
textView.setOnLongClickListener {
|
||||
adapter.menuMode = "shortcut"
|
||||
adapter.shortcutTextView = textView
|
||||
showApps()
|
||||
binding.menutitle.visibility = View.VISIBLE
|
||||
toAppMenu()
|
||||
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
|
@ -304,7 +326,7 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
newFilteredApps.addAll(installedApps)
|
||||
} else {
|
||||
updatedApps.forEach {
|
||||
val cleanItemText = sharedPreferenceManager.getAppName(this@MainActivity, it.first.applicationInfo.packageName, it.second.second, it.first.applicationInfo.loadLabel(packageManager)).toString().clean()
|
||||
val cleanItemText = sharedPreferenceManager.getAppName(this@MainActivity, it.first.applicationInfo.packageName, it.second.second, packageManager.getApplicationLabel(it.first.applicationInfo)).toString().clean()
|
||||
if (cleanItemText.contains(cleanQuery, ignoreCase = true)) {
|
||||
newFilteredApps.add(it)
|
||||
}
|
||||
|
|
@ -333,133 +355,25 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
}
|
||||
}
|
||||
|
||||
private fun View.slideInFromBottom(duration: Long = 100) {
|
||||
if (visibility != View.VISIBLE) {
|
||||
translationY = height.toFloat()/5
|
||||
scaleY = 1.2f
|
||||
alpha = 0f
|
||||
visibility = View.VISIBLE
|
||||
animate()
|
||||
.translationY(0f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f)
|
||||
.setDuration(duration)
|
||||
.setListener(null)
|
||||
val originalColor = ContextCompat.getColor(this@MainActivity, R.color.original_color)
|
||||
val newColor = ContextCompat.getColor(this@MainActivity, R.color.new_color)
|
||||
|
||||
val backgroundColorAnimator: ObjectAnimator = ObjectAnimator.ofObject(
|
||||
binding.root,
|
||||
"backgroundColor",
|
||||
ArgbEvaluator(),
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
|
||||
backgroundColorAnimator.setDuration(100)
|
||||
|
||||
val window = window
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
|
||||
val statusBarColorAnimator = ObjectAnimator.ofArgb(
|
||||
window,
|
||||
"statusBarColor",
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
statusBarColorAnimator.setDuration(100)
|
||||
backgroundColorAnimator.start()
|
||||
statusBarColorAnimator.start()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun View.slideOutToBottom(duration: Long = 50) {
|
||||
if (visibility == View.VISIBLE) {
|
||||
animate()
|
||||
.translationY(height.toFloat() / 5)
|
||||
.scaleY(1.2f)
|
||||
.alpha(0f)
|
||||
.setDuration(duration)
|
||||
.setListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
})
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
handler.postDelayed({
|
||||
recyclerView.scrollToPosition(0)
|
||||
}, 150)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun View.fadeIn(duration: Long = 100) {
|
||||
if (visibility != View.VISIBLE) {
|
||||
alpha = 0f
|
||||
translationY = -height.toFloat()/100
|
||||
visibility = View.VISIBLE
|
||||
animate()
|
||||
.alpha(1f)
|
||||
.translationY(0f)
|
||||
.setDuration(duration)
|
||||
.setListener(null)
|
||||
val originalColor = ContextCompat.getColor(this@MainActivity, R.color.new_color)
|
||||
val newColor = ContextCompat.getColor(this@MainActivity, R.color.original_color)
|
||||
|
||||
val backgroundColorAnimator: ObjectAnimator = ObjectAnimator.ofObject(
|
||||
binding.root,
|
||||
"backgroundColor",
|
||||
ArgbEvaluator(),
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
|
||||
backgroundColorAnimator.setDuration(100)
|
||||
|
||||
val window = window
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
|
||||
val statusBarColorAnimator = ObjectAnimator.ofArgb(
|
||||
window,
|
||||
"statusBarColor",
|
||||
originalColor,
|
||||
newColor
|
||||
)
|
||||
statusBarColorAnimator.setDuration(100)
|
||||
backgroundColorAnimator.start()
|
||||
statusBarColorAnimator.start()
|
||||
}
|
||||
}
|
||||
|
||||
private fun View.fadeOut(duration: Long = 50) {
|
||||
if (visibility == View.VISIBLE) {
|
||||
animate()
|
||||
.alpha(0f)
|
||||
.translationY(-height.toFloat()/100)
|
||||
.setDuration(duration)
|
||||
.setListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
})}
|
||||
}
|
||||
|
||||
fun showHome() {
|
||||
binding.appView.slideOutToBottom()
|
||||
binding.homeView.fadeIn()
|
||||
}
|
||||
|
||||
private fun showApps() {
|
||||
binding.homeView.fadeOut()
|
||||
binding.appView.slideInFromBottom()
|
||||
}
|
||||
fun openAppMenuActivity() {
|
||||
//AppMenuActivity.start(this, installedApps) {
|
||||
//}
|
||||
adapter.menuMode = "app"
|
||||
showApps()
|
||||
toAppMenu()
|
||||
}
|
||||
|
||||
fun backToHome() {
|
||||
animations.showHome(binding)
|
||||
animations.backgroundOut(this@MainActivity, binding)
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
handler.postDelayed({
|
||||
recyclerView.scrollToPosition(0)
|
||||
}, 150)
|
||||
}
|
||||
|
||||
private fun toAppMenu() {
|
||||
animations.showApps(binding)
|
||||
animations.backgroundIn(this@MainActivity, binding)
|
||||
}
|
||||
|
||||
override fun onItemClick(appInfo: LauncherActivityInfo, userHandle: UserHandle) {
|
||||
|
|
@ -494,7 +408,7 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
}
|
||||
}
|
||||
sharedPreferenceManager.setShortcut(this, shortcutView, appInfo.applicationInfo.packageName, userProfile)
|
||||
showHome()
|
||||
backToHome()
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -508,7 +422,7 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
|
|||
position: Int
|
||||
) {
|
||||
textView.visibility = View.INVISIBLE
|
||||
actionMenuLayout.visibility = View.VISIBLE
|
||||
animations.fadeViewIn(actionMenuLayout)
|
||||
val mainActivity =
|
||||
launcherApps.getActivityList(appInfo.applicationInfo.packageName, userHandle)
|
||||
.firstOrNull()
|
||||
|
|
|
|||
17
app/src/main/java/eu/ottop/yamlauncher/SettingsActivity.kt
Normal file
17
app/src/main/java/eu/ottop/yamlauncher/SettingsActivity.kt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package eu.ottop.yamlauncher
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import eu.ottop.yamlauncher.databinding.ActivityMainBinding
|
||||
import eu.ottop.yamlauncher.databinding.ActivitySettingsBinding
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivitySettingsBinding
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
window.statusBarColor = getColor(R.color.settings_bg)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/menutitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingRight="40dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:text="Select an app"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#C1F3F3F3"
|
||||
android:textSize="36sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:clipToPadding="false"
|
||||
android:fadingEdgeLength="20dp"
|
||||
android:padding="0dp"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:stackFromEnd="true">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/searchView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginHorizontal="40dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:layout_weight="0.1"
|
||||
android:background="@android:color/transparent"
|
||||
android:cursorVisible="true"
|
||||
android:drawableLeft="@android:drawable/ic_menu_search"
|
||||
android:drawablePadding="8dp"
|
||||
android:editTextColor="#f3f3f3"
|
||||
android:hint="Search..."
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textSize="25sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginHorizontal="40dp"
|
||||
android:layout_marginHorizontal="32dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:layout_weight="0.1"
|
||||
|
|
@ -79,18 +79,49 @@
|
|||
android:layout_gravity="fill_vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
android:gravity="fill_vertical"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextClock
|
||||
android:id="@+id/text_clock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:layout_marginHorizontal="32dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:fontFamily="@null"
|
||||
android:textAlignment="center"
|
||||
android:format12Hour="hh:mm a"
|
||||
android:format24Hour="HH:mm"
|
||||
android:textAlignment="textStart"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
android:textSize="70sp" />
|
||||
android:textSize="68sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="37dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextClock
|
||||
android:id="@+id/text_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@null"
|
||||
android:format12Hour="dd MMM yyyy | "
|
||||
android:format24Hour="dd MMM yyyy | "
|
||||
android:textAlignment="textStart"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/battery_charge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -105,9 +136,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
@ -126,9 +157,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
@ -148,9 +179,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
@ -170,9 +201,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
@ -193,9 +224,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
@ -216,9 +247,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
@ -239,9 +270,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
@ -262,9 +293,9 @@
|
|||
android:autoSizeMaxTextSize="28sp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/shortcut_default"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
|
|||
12
app/src/main/res/layout/activity_settings.xml
Normal file
12
app/src/main/res/layout/activity_settings.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/settings_bg"
|
||||
android:orientation="vertical"
|
||||
tools:context=".SettingsActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
android:elegantTextHeight="false"
|
||||
android:imeOptions="actionDone"
|
||||
android:includeFontPadding="true"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingRight="40dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
|
|
@ -55,9 +55,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingRight="40dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||
android:textColor="#F3F3F3"
|
||||
|
|
|
|||
|
|
@ -6,4 +6,6 @@
|
|||
<color name="original_color">#00000000</color>
|
||||
<color name="new_color">#3F000000</color>
|
||||
|
||||
<color name="settings_bg">#88000000</color>
|
||||
|
||||
</resources>
|
||||
Loading…
Add table
Add a link
Reference in a new issue