Skip to content

Commit

Permalink
more fixes for experiments and animations 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
queuejw committed Jun 24, 2024
1 parent 781c62f commit e17c198
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 57 deletions.
36 changes: 27 additions & 9 deletions app/src/main/java/ru/dimon6018/metrolauncher/content/NewAllApps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import kotlin.random.Random
class NewAllApps: Fragment() {

private var recyclerView: RecyclerView? = null
private var recyclerViewLM: LinearLayoutManager? = null

private var recyclerViewAlphabet: RecyclerView? = null
private var alphabetLayout: LinearLayout? = null
Expand Down Expand Up @@ -172,7 +173,7 @@ class NewAllApps: Fragment() {
}
}
appAdapter = AppAdapter(appList!!, dbCall)
val lm = LinearLayoutManager(contextFragment)
recyclerViewLM = LinearLayoutManager(contextFragment)
setAlphabetRecyclerView()
shouldShowTip = PREFS!!.pref.getBoolean("tip2Enabled", true)
withContext(mainDispatcher) {
Expand All @@ -182,7 +183,7 @@ class NewAllApps: Fragment() {
}
}
recyclerView?.apply {
layoutManager = lm
layoutManager = recyclerViewLM
adapter = appAdapter
OverScrollDecoratorHelper.setUpOverScroll(this, OverScrollDecoratorHelper.ORIENTATION_VERTICAL)
visibility = View.VISIBLE
Expand Down Expand Up @@ -238,9 +239,7 @@ class NewAllApps: Fragment() {
val packageName = intent.getStringExtra("package")
// End early if it has anything to do with us.
if (packageName.isNullOrEmpty()) return
val action = intent.getIntExtra("action", 42)
packageName.apply {
Log.d("AllApps Broadcaster", "$action , app: $this")
broadcastListUpdater()
}
}
Expand All @@ -260,8 +259,6 @@ class NewAllApps: Fragment() {
requireActivity().registerReceiver(packageBroadcastReceiver, it)
}
}
} else {
Log.d("AllApps", "register canceled because it already registered")
}
}
private fun broadcastListUpdater() {
Expand Down Expand Up @@ -614,8 +611,7 @@ class NewAllApps: Fragment() {
anim2.start()
}
anim.start()
ObjectAnimator.ofFloat(recyclerView!!, "alpha", 1f, 0.5f).setDuration(500).start()
ObjectAnimator.ofFloat(view, "alpha", 1f, 1f).setDuration(500).start()
fadeList(appPackage, label, false)
PopupWindowCompat.showAsDropDown(popupWindow!!, view, 0, 0, Gravity.NO_GRAVITY)
isWindowVisible = true
val pin = popupView.findViewById<MaterialCardView>(R.id.pinApp)
Expand Down Expand Up @@ -654,11 +650,33 @@ class NewAllApps: Fragment() {
startActivity(Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:$appPackage")))
}
popupWindow?.setOnDismissListener {
ObjectAnimator.ofFloat(recyclerView!!, "alpha", 0.5f, 1f).setDuration(500).start()
fadeList(appPackage, label, true)
isWindowVisible = false
popupWindow = null
}
}
private fun fadeList(app: String, label: String, restoreAll: Boolean) {
val first = recyclerViewLM!!.findFirstVisibleItemPosition()
val last = recyclerViewLM!!.findLastVisibleItemPosition()
if (restoreAll) {
for (i in first..last) {
val itemView = recyclerView!!.findViewHolderForAdapterPosition(i)?.itemView
if (itemView != null) {
ObjectAnimator.ofFloat(itemView, "alpha", 0.5f, 1f).setDuration(500).start()
}
}
} else {
for (i in first..last) {
if (list[i].appPackage == app && list[i].appLabel == label) {
continue
}
val itemView = recyclerView!!.findViewHolderForAdapterPosition(i)?.itemView
if (itemView != null) {
ObjectAnimator.ofFloat(itemView, "alpha", 1f, 0.5f).setDuration(500).start()
}
}
}
}
private fun startDismissAnim(item: App) {
if (recyclerView == null || appAdapter == null || !PREFS!!.isAAllAppsAnimEnabled) {
startAppDelay(item)
Expand Down
72 changes: 24 additions & 48 deletions app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1084,24 +1084,17 @@ class NewStart: Fragment(), OnStartDragListener {
val mContainer: FrameLayout = v.findViewById(R.id.container)
val mTextView: TextView = v.findViewById(android.R.id.text1)
val mAppIcon: ImageView = v.findViewById(android.R.id.icon1)

private val gestureDetector: GestureDetector =
GestureDetector(context, object : SimpleOnGestureListener() {
override fun onLongPress(e: MotionEvent) {
// Обработка долгого нажатия здесь
// Например, вызов метода или выполнение действия
handleLongClick()
}

override fun onSingleTapUp(e: MotionEvent): Boolean {
// Обработка обычного нажатия здесь
// Например, вызов метода или выполнение действия
visualFeedback(v)
handleClick()
return true
}
})

init {
mContainer.alpha = PREFS!!.getTilesTransparency
mCardContainer.apply {
Expand Down Expand Up @@ -1259,165 +1252,148 @@ class NewStart: Fragment(), OnStartDragListener {
back.setOnClickListener { dismiss() }
lime.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 0
dbCall.updateApp(item)
updateTileColor(0)
}
dismiss()
}
val green = view.findViewById<ImageView>(R.id.choose_color_green)
green.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 1
dbCall.updateApp(item)
updateTileColor(1)
}
dismiss()
}
val emerald = view.findViewById<ImageView>(R.id.choose_color_emerald)
emerald.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 2
dbCall.updateApp(item)
updateTileColor(2)
}
dismiss()
}
val cyan = view.findViewById<ImageView>(R.id.choose_color_cyan)
cyan.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 3
dbCall.updateApp(item)
updateTileColor(3)
}
dismiss()
}
val teal = view.findViewById<ImageView>(R.id.choose_color_teal)
teal.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 4
dbCall.updateApp(item)
updateTileColor(4)
}
dismiss()
}
val cobalt = view.findViewById<ImageView>(R.id.choose_color_cobalt)
cobalt.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 5
dbCall.updateApp(item)
updateTileColor(5)
}
dismiss()
}
val indigo = view.findViewById<ImageView>(R.id.choose_color_indigo)
indigo.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 6
dbCall.updateApp(item)
updateTileColor(6)
}
dismiss()
}
val violet = view.findViewById<ImageView>(R.id.choose_color_violet)
violet.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 7
dbCall.updateApp(item)
updateTileColor(7)
}
dismiss()
}
val pink = view.findViewById<ImageView>(R.id.choose_color_pink)
pink.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 8
dbCall.updateApp(item)
updateTileColor(8)
}
dismiss()
}
val magenta = view.findViewById<ImageView>(R.id.choose_color_magenta)
magenta.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 9
dbCall.updateApp(item)
updateTileColor(9)
}
dismiss()
}
val crimson = view.findViewById<ImageView>(R.id.choose_color_crimson)
crimson.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 10
dbCall.updateApp(item)
updateTileColor(10)
}
dismiss()
}
val red = view.findViewById<ImageView>(R.id.choose_color_red)
red.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 11
dbCall.updateApp(item)
updateTileColor(11)
}
dismiss()
}
val orange = view.findViewById<ImageView>(R.id.choose_color_orange)
orange.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 12
dbCall.updateApp(item)
updateTileColor(12)
}
dismiss()
}
val amber = view.findViewById<ImageView>(R.id.choose_color_amber)
amber.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 13
dbCall.updateApp(item)
updateTileColor(13)
}
dismiss()
}
val yellow = view.findViewById<ImageView>(R.id.choose_color_yellow)
yellow.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 14
dbCall.updateApp(item)
updateTileColor(14)
}
dismiss()
}
val brown = view.findViewById<ImageView>(R.id.choose_color_brown)
brown.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 15
dbCall.updateApp(item)
updateTileColor(15)
}
dismiss()
}
val olive = view.findViewById<ImageView>(R.id.choose_color_olive)
olive.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 16
dbCall.updateApp(item)
updateTileColor(16)
}
dismiss()
}
val steel = view.findViewById<ImageView>(R.id.choose_color_steel)
steel.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 17
dbCall.updateApp(item)
updateTileColor(17)
}
dismiss()
}
val mauve = view.findViewById<ImageView>(R.id.choose_color_mauve)
mauve.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 18
dbCall.updateApp(item)
updateTileColor(18)
}
dismiss()
}
val taupe = view.findViewById<ImageView>(R.id.choose_color_taupe)
taupe.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = 19
dbCall.updateApp(item)
updateTileColor(19)
}
dismiss()
}
}

private suspend fun updateTileColor(color: Int) {
item.tileColor = color
dbCall.updateApp(item)
}
override fun dismiss() {
adapter.notifyItemChanged(item.appPos!!)
adapter.showSettingsBottomSheet(item, item.appPos!!)
Expand Down

0 comments on commit e17c198

Please sign in to comment.