Skip to content

Commit

Permalink
pre-alpha 5.1.1 ?
Browse files Browse the repository at this point in the history
  • Loading branch information
queuejw committed Aug 12, 2024
1 parent 8402ac0 commit 278a1ec
Show file tree
Hide file tree
Showing 24 changed files with 224 additions and 344 deletions.
13 changes: 9 additions & 4 deletions app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,18 @@ class Main : AppCompatActivity() {
}

override fun onResume() {
super.onResume()
if (PREFS!!.isPrefsChanged) {
PREFS!!.isPrefsChanged = false
recreate()
restart()
}
super.onResume()
}
private fun restart() {
PREFS!!.isPrefsChanged = false
val componentName = Intent(this, this::class.java).component
val intent = Intent.makeRestartActivityTask(componentName)
startActivity(intent)
Runtime.getRuntime().exit(0)
}

override fun onDestroy() {
super.onDestroy()
unregisterPackageReceiver(this, packageReceiver)
Expand Down
23 changes: 10 additions & 13 deletions app/src/main/java/ru/dimon6018/metrolauncher/content/NewAllApps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import android.text.Spannable
import android.text.SpannableString
import android.text.TextWatcher
import android.text.style.ForegroundColorSpan
import android.util.Log
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -127,9 +126,13 @@ class NewAllApps: Fragment() {
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (context == null) {
requireActivity().recreate()
return
}
viewLifecycleOwner.lifecycleScope.launch(defaultDispatcher) {
appAdapter = AppAdapter(getHeaderListLatter(mainViewModel.getAppList()))
recyclerViewLM = LinearLayoutManager(requireContext())
recyclerViewLM = LinearLayoutManager(requireActivity())
setAlphabetRecyclerView(requireContext())
if (PREFS!!.prefs.getBoolean("tip2Enabled", true)) {
withContext(mainDispatcher) {
Expand Down Expand Up @@ -164,12 +167,10 @@ class NewAllApps: Fragment() {

@SuppressLint("UnspecifiedRegisterReceiverFlag", "InlinedApi")
private fun registerBroadcast() {
Log.d("AllApps", "register")
if(!isBroadcasterRegistered) {
isBroadcasterRegistered = true
packageBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Log.d("AllApps", "on receive")
val packageName = intent.getStringExtra("package")
// End early if it has anything to do with us.
if (packageName.isNullOrEmpty()) return
Expand Down Expand Up @@ -211,18 +212,14 @@ class NewAllApps: Fragment() {
}
}
private fun broadcastListUpdater(context: Context) {
Log.d("AllApps", "update list")
mainViewModel.setAppList(setUpApps(context.packageManager, context))
appAdapter?.setData(getHeaderListLatter(mainViewModel.getAppList()))
}
private fun unregisterBroadcast() {
Log.d("AllApps", "unreg broadcaster")
isBroadcasterRegistered = false
packageBroadcastReceiver?.apply {
requireActivity().unregisterReceiver(packageBroadcastReceiver)
packageBroadcastReceiver = null
} ?: run {
Log.d("AllApps", "unregisterBroadcast() was called to a null receiver.")
}
}
override fun onDestroy() {
Expand Down Expand Up @@ -361,11 +358,11 @@ class NewAllApps: Fragment() {
}
searchLayout.animate().translationY(-128f).setDuration(200).withEndAction {
searchLayout.visibility = View.GONE
searchBtn.apply {
visibility = View.VISIBLE
animate().alpha(1f).setDuration(200).start()
}
}.start()
searchBtn.apply {
visibility = View.VISIBLE
animate().alpha(1f).setDuration(100).start()
}
settingsBtn.visibility = if(!PREFS!!.isSettingsBtnEnabled) View.GONE else View.VISIBLE
appList.apply {
alpha = 0.5f
Expand Down Expand Up @@ -395,7 +392,7 @@ class NewAllApps: Fragment() {
}.start()
settingsBtn.visibility = View.GONE
appList.apply {
animate().translationX(-150f).setDuration(200).start()
animate().translationX(-requireContext().resources.getDimensionPixelSize(R.dimen.recyclerViewSearchPadding).toFloat()).setDuration(200).start()
isVerticalScrollBarEnabled = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInset
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.launcherAccentTheme
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.setViewInteractAnimation
import kotlin.random.Random
import kotlin.system.exitProcess

class SettingsActivity : AppCompatActivity() {

Expand All @@ -51,20 +50,20 @@ class SettingsActivity : AppCompatActivity() {
private var job: Job? = null
private val viewList: List<Pair<View, Long>> by lazy {
listOf(
binding.settings to 200,
binding.settingsLabel to 250,
binding.settingsInclude.themeSetting to 300,
binding.settingsInclude.allAppsSetting to 310,
binding.settingsInclude.tilesSetting to 320,
binding.settingsInclude.iconsSetting to 330,
binding.settingsInclude.animSetting to 340,
binding.settingsInclude.feedbackSetting to 350,
binding.settingsInclude.weatherSetting to 360,
binding.settingsInclude.updatesSetting to 370,
binding.settingsInclude.navbarSetting to 380,
binding.settingsInclude.aboutSetting to 390,
binding.settingsInclude.leaks to 400,
binding.settingsInclude.expSetting to 410
binding.settings to 100,
binding.settingsLabel to 150,
binding.settingsInclude.themeSetting to 200,
binding.settingsInclude.allAppsSetting to 205,
binding.settingsInclude.tilesSetting to 210,
binding.settingsInclude.iconsSetting to 215,
binding.settingsInclude.animSetting to 220,
binding.settingsInclude.feedbackSetting to 225,
binding.settingsInclude.weatherSetting to 225,
binding.settingsInclude.updatesSetting to 225,
binding.settingsInclude.navbarSetting to 225,
binding.settingsInclude.aboutSetting to 225,
binding.settingsInclude.leaks to 225,
binding.settingsInclude.expSetting to 225
)
}

Expand Down Expand Up @@ -179,7 +178,7 @@ class SettingsActivity : AppCompatActivity() {
val animatorSet = AnimatorSet().apply {
playTogether(
ObjectAnimator.ofFloat(view, "alpha", if (isEnter) 1f else 0f, if (isEnter) 0f else 1f),
ObjectAnimator.ofFloat(view, "translationX", if (isEnter) 0f else -200f, if (isEnter) -200f else 0f),
ObjectAnimator.ofFloat(view, "translationX", if (isEnter) 0f else -400f, if (isEnter) -400f else 0f),
ObjectAnimator.ofFloat(view, "rotationY", if (isEnter) 0f else -90f, if (isEnter) -90f else 0f)
)
duration = dur
Expand All @@ -204,14 +203,14 @@ class SettingsActivity : AppCompatActivity() {
if (PREFS!!.isTransitionAnimEnabled) {
setupAnimations()
CoroutineScope(Dispatchers.Main).launch {
delay(350)
delay(200)
isEnter = false
viewList.forEach { (view, _) ->
view.alpha = 1f
}
cancel()
}
delay(350)
delay(200)
} else {
isEnter = false
}
Expand Down Expand Up @@ -286,7 +285,6 @@ class SettingsActivity : AppCompatActivity() {
}
setNegativeButton(getString(R.string.later)) {
dismiss()
startAnimWithLifecycle()
}
setDismissListener {
startAnimWithLifecycle()
Expand All @@ -301,7 +299,11 @@ class SettingsActivity : AppCompatActivity() {
}
private fun restartApp() {
PREFS!!.isPrefsChanged = false
exitProcess(0)
finishAffinity()
val componentName = Intent(this, this::class.java).component
val intent = Intent.makeRestartActivityTask(componentName)
startActivity(intent)
Runtime.getRuntime().exit(0)
}

override fun onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,25 @@ class AboutSettingsActivity : AppCompatActivity() {
startActivity(intent)
}
private fun enterAnimation(exit: Boolean) {
if(!PREFS!!.isTransitionAnimEnabled) {
if (!PREFS!!.isTransitionAnimEnabled) {
return
}
val main = binding.root
val animatorSet = AnimatorSet()
if(exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, 300f),
ObjectAnimator.ofFloat(main, "rotationY", 0f, 90f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
ObjectAnimator.ofFloat(main, "scaleX", 1f, 0.5f),
ObjectAnimator.ofFloat(main, "scaleY", 1f, 0.5f),
)
} else {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 300f, 0f),
ObjectAnimator.ofFloat(main, "rotationY", 90f, 0f),
ObjectAnimator.ofFloat(main, "alpha", 0f, 1f),
ObjectAnimator.ofFloat(main, "scaleX", 0.5f, 1f),
ObjectAnimator.ofFloat(main, "scaleY", 0.5f, 1f)
val animatorSet = AnimatorSet().apply {
playTogether(
createObjectAnimator(main, "translationX", if (exit) 0f else -300f, if (exit) -300f else 0f),
createObjectAnimator(main, "rotationY", if (exit) 0f else 90f, if (exit) 90f else 0f),
createObjectAnimator(main, "alpha", if (exit) 1f else 0f, if (exit) 0f else 1f),
createObjectAnimator(main, "scaleX", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f),
createObjectAnimator(main, "scaleY", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f)
)
duration = 400
}
animatorSet.setDuration(400)
animatorSet.start()
}
private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}

override fun onResume() {
enterAnimation(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,25 @@ class AllAppsSettingsActivity: AppCompatActivity() {
applyWindowInsets(binding.root)
}
private fun enterAnimation(exit: Boolean) {
if(!PREFS!!.isTransitionAnimEnabled) {
if (!PREFS!!.isTransitionAnimEnabled) {
return
}
val main = binding.root
val animatorSet = AnimatorSet()
if(exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, 300f),
ObjectAnimator.ofFloat(main, "rotationY", 0f, 90f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
ObjectAnimator.ofFloat(main, "scaleX", 1f, 0.5f),
ObjectAnimator.ofFloat(main, "scaleY", 1f, 0.5f),
)
} else {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 300f, 0f),
ObjectAnimator.ofFloat(main, "rotationY", 90f, 0f),
ObjectAnimator.ofFloat(main, "alpha", 0f, 1f),
ObjectAnimator.ofFloat(main, "scaleX", 0.5f, 1f),
ObjectAnimator.ofFloat(main, "scaleY", 0.5f, 1f)
val animatorSet = AnimatorSet().apply {
playTogether(
createObjectAnimator(main, "translationX", if (exit) 0f else -300f, if (exit) -300f else 0f),
createObjectAnimator(main, "rotationY", if (exit) 0f else 90f, if (exit) 90f else 0f),
createObjectAnimator(main, "alpha", if (exit) 1f else 0f, if (exit) 0f else 1f),
createObjectAnimator(main, "scaleX", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f),
createObjectAnimator(main, "scaleY", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f)
)
duration = 400
}
animatorSet.setDuration(400)
animatorSet.start()
}

private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}
override fun onResume() {
enterAnimation(false)
super.onResume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,25 @@ class AnimationSettingsActivity: AppCompatActivity() {
}
}
private fun enterAnimation(exit: Boolean) {
if(!PREFS!!.isTransitionAnimEnabled) {
if (!PREFS!!.isTransitionAnimEnabled) {
return
}
val main = binding.root
val animatorSet = AnimatorSet()
if(exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, 300f),
ObjectAnimator.ofFloat(main, "rotationY", 0f, 90f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
ObjectAnimator.ofFloat(main, "scaleX", 1f, 0.5f),
ObjectAnimator.ofFloat(main, "scaleY", 1f, 0.5f),
)
} else {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 300f, 0f),
ObjectAnimator.ofFloat(main, "rotationY", 90f, 0f),
ObjectAnimator.ofFloat(main, "alpha", 0f, 1f),
ObjectAnimator.ofFloat(main, "scaleX", 0.5f, 1f),
ObjectAnimator.ofFloat(main, "scaleY", 0.5f, 1f)
val animatorSet = AnimatorSet().apply {
playTogether(
createObjectAnimator(main, "translationX", if (exit) 0f else -300f, if (exit) -300f else 0f),
createObjectAnimator(main, "rotationY", if (exit) 0f else 90f, if (exit) 90f else 0f),
createObjectAnimator(main, "alpha", if (exit) 1f else 0f, if (exit) 0f else 1f),
createObjectAnimator(main, "scaleX", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f),
createObjectAnimator(main, "scaleY", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f)
)
duration = 400
}
animatorSet.setDuration(400)
animatorSet.start()
}
private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}
override fun onResume() {
enterAnimation(false)
super.onResume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,25 @@ class ExperimentsSettingsActivity: AppCompatActivity() {
applyWindowInsets(binding.root)
}
private fun enterAnimation(exit: Boolean) {
if(!PREFS!!.isTransitionAnimEnabled) {
if (!PREFS!!.isTransitionAnimEnabled) {
return
}
val main = binding.root
val animatorSet = AnimatorSet()
if(exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, 300f),
ObjectAnimator.ofFloat(main, "rotationY", 0f, 90f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
ObjectAnimator.ofFloat(main, "scaleX", 1f, 0.5f),
ObjectAnimator.ofFloat(main, "scaleY", 1f, 0.5f),
)
} else {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 300f, 0f),
ObjectAnimator.ofFloat(main, "rotationY", 90f, 0f),
ObjectAnimator.ofFloat(main, "alpha", 0f, 1f),
ObjectAnimator.ofFloat(main, "scaleX", 0.5f, 1f),
ObjectAnimator.ofFloat(main, "scaleY", 0.5f, 1f)
val animatorSet = AnimatorSet().apply {
playTogether(
createObjectAnimator(main, "translationX", if (exit) 0f else -300f, if (exit) -300f else 0f),
createObjectAnimator(main, "rotationY", if (exit) 0f else 90f, if (exit) 90f else 0f),
createObjectAnimator(main, "alpha", if (exit) 1f else 0f, if (exit) 0f else 1f),
createObjectAnimator(main, "scaleX", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f),
createObjectAnimator(main, "scaleY", if (exit) 1f else 0.5f, if (exit) 0.5f else 1f)
)
duration = 400
}
animatorSet.setDuration(400)
animatorSet.start()
}

private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}
override fun onResume() {
enterAnimation(false)
super.onResume()
Expand Down
Loading

0 comments on commit 278a1ec

Please sign in to comment.