diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt b/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt index 1ef5af2..823ae7c 100644 --- a/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt +++ b/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt @@ -8,6 +8,7 @@ import android.os.Build import android.os.Bundle import android.text.Editable import android.text.TextWatcher +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -217,9 +218,11 @@ class Main : AppCompatActivity() { override fun onResume() { if (PREFS!!.isPrefsChanged) { PREFS!!.isPrefsChanged = false + Log.d("Main", "Recreate") recreate() } super.onResume() + Log.d("Main", "RESUME") } override fun onDestroy() { @@ -233,7 +236,6 @@ class Main : AppCompatActivity() { "ru.dimon6018.metrolauncher" -> { startActivity(Intent(this@Main, SettingsActivity::class.java)) } - else -> { startActivity( Intent(this@Main.packageManager.getLaunchIntentForPackage(app)).addFlags( @@ -249,8 +251,11 @@ class Main : AppCompatActivity() { } private suspend fun setMainViewModel() { - val isCustomIconsInstalled = PREFS!!.iconPackPackage != "null" mainViewModel.setAppList(sortApps(setUpApps(this.packageManager, this))) + regenerateIcons() + } + private suspend fun regenerateIcons() { + val isCustomIconsInstalled = PREFS!!.iconPackPackage != "null" var diskCache = initDiskCache(this) if (PREFS!!.iconPackChanged) { PREFS!!.iconPackChanged = false @@ -290,7 +295,6 @@ class Main : AppCompatActivity() { } diskCache?.let { closeDiskCache(it) } } - fun generateIcon( appPackage: String, isCustomIconsInstalled: Boolean diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt index e193bc6..02f8a3c 100644 --- a/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt +++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt @@ -109,9 +109,9 @@ class NewStart: Fragment(), OnStartDragListener { val view = binding.root mainViewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java] binding.startFrame.setOnClickListener { - if(mAdapter != null) { - if (mAdapter!!.isEditMode) { - mAdapter!!.disableEditMode() + mAdapter?.apply { + if(isEditMode) { + disableEditMode() } } } @@ -141,8 +141,7 @@ class NewStart: Fragment(), OnStartDragListener { } private fun setupAdapter() { mAdapter = NewStartAdapter(requireContext(), tiles!!) - val callback: ItemTouchHelper.Callback = ItemTouchCallback(mAdapter!!) - mItemTouchHelper = ItemTouchHelper(callback) + mItemTouchHelper = ItemTouchHelper(ItemTouchCallback(mAdapter!!)) } private fun configureRecyclerView() { @@ -189,9 +188,9 @@ class NewStart: Fragment(), OnStartDragListener { ) } } - mSpannedLayoutManager!!.itemOrderIsStable = true - mSpannedLayoutManager!!.spanSizeLookup = - SpannedGridLayoutManager.SpanSizeLookup { position -> + mSpannedLayoutManager?.apply { + itemOrderIsStable = true + spanSizeLookup = SpannedGridLayoutManager.SpanSizeLookup { position -> when (tiles!![position].tileSize) { "small" -> { SpanSize(1, 1) @@ -210,8 +209,8 @@ class NewStart: Fragment(), OnStartDragListener { } } } + } } - override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) isLandscape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/SettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/SettingsActivity.kt index 858f42a..405d99f 100644 --- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/SettingsActivity.kt +++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/SettingsActivity.kt @@ -8,7 +8,6 @@ import android.os.Build import android.os.Bundle import android.provider.Settings import android.view.View -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.core.view.WindowCompat @@ -52,18 +51,20 @@ class SettingsActivity : AppCompatActivity() { private var job: Job? = null private val viewList: List> by lazy { listOf( - binding.settingsInclude.themeSetting to 200, - binding.settingsInclude.allAppsSetting to 210, - binding.settingsInclude.tilesSetting to 220, - binding.settingsInclude.iconsSetting to 225, - binding.settingsInclude.animSetting to 230, - binding.settingsInclude.feedbackSetting to 235, - binding.settingsInclude.weatherSetting to 240, - binding.settingsInclude.updatesSetting to 245, - binding.settingsInclude.navbarSetting to 250, - binding.settingsInclude.aboutSetting to 255, - binding.settingsInclude.leaks to 260, - binding.settingsInclude.expSetting to 265 + 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 ) } @@ -74,7 +75,7 @@ class SettingsActivity : AppCompatActivity() { binding = LauncherSettingsMainBinding.inflate(layoutInflater) setContentView(binding.root) WindowCompat.setDecorFitsSystemWindows(window, false) - confAnim() + confTouchAnim() setOnClickers() applyWindowInsets(binding.root) prepareMessage() @@ -173,7 +174,6 @@ class SettingsActivity : AppCompatActivity() { viewList.forEach { (view, duration) -> setupAnimForViews(view, duration) } - setupAnimForViews(binding.root, 180) } private fun setupAnimForViews(view: View, dur: Long) { if (!PREFS!!.isTransitionAnimEnabled) { @@ -182,14 +182,14 @@ 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 -500f, if (isEnter) -500f else 0f), + ObjectAnimator.ofFloat(view, "translationX", if (isEnter) 0f else -200f, if (isEnter) -200f else 0f), ObjectAnimator.ofFloat(view, "rotationY", if (isEnter) 0f else -90f, if (isEnter) -90f else 0f) ) duration = dur } animatorSet.start() } - private fun confAnim() { + private fun confTouchAnim() { setViewInteractAnimation(binding.settingsInclude.themeSetting) setViewInteractAnimation(binding.settingsInclude.allAppsSetting) setViewInteractAnimation(binding.settingsInclude.tilesSetting) @@ -208,14 +208,13 @@ class SettingsActivity : AppCompatActivity() { setupAnimations() isEnter = false CoroutineScope(Dispatchers.Main).launch { - delay(500) + delay(350) viewList.forEach { (view, _) -> view.alpha = 1f } - binding.root.alpha = 1f cancel() } - delay(150) + delay(350) } else { isEnter = false } @@ -225,7 +224,6 @@ class SettingsActivity : AppCompatActivity() { viewList.forEach { (view, _) -> hideAnim(view) } - hideAnim(binding.root) } } private fun hideAnim(view: View?) { @@ -273,15 +271,42 @@ class SettingsActivity : AppCompatActivity() { }.getOrElse { getString(R.string.iconPackNotSelectedSub) } if(PREFS!!.isPrefsChanged) { - PREFS!!.isPrefsChanged = false - Toast.makeText(this, getString(R.string.restart_required), Toast.LENGTH_SHORT).show() - exitProcess(0) + job?.cancel() + restartDialog() } else { - lifecycleScope.launch { - startAnim() + startAnimWithLifecycle() + } + } + + private fun restartDialog() { + WPDialog(this).apply { + setTopDialog(true) + setTitle(getString(R.string.settings_app_title)) + setMessage(getString(R.string.restart_required)) + setPositiveButton(getString(R.string.restart)) { + dismiss() + restartApp() + } + setNegativeButton(getString(R.string.later)) { + dismiss() + startAnimWithLifecycle() + } + setDismissListener { + startAnimWithLifecycle() } + show() } } + private fun startAnimWithLifecycle() { + lifecycleScope.launch { + startAnim() + } + } + private fun restartApp() { + PREFS!!.isPrefsChanged = false + exitProcess(0) + } + override fun onPause() { super.onPause() hideViews() diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/WPDialog.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/WPDialog.kt index f7f06be..7de56ee 100644 --- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/WPDialog.kt +++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/WPDialog.kt @@ -2,6 +2,7 @@ package ru.dimon6018.metrolauncher.helpers.ui import android.app.Dialog import android.content.Context +import android.content.DialogInterface import android.view.Gravity import android.view.View import android.view.WindowManager @@ -32,6 +33,7 @@ class WPDialog(private val mContext: Context) { private var okButtonListener: View.OnClickListener? = null private var cancelButtonListener: View.OnClickListener? = null private var neutralListener: View.OnClickListener? = null + private var dismissListener: DialogInterface.OnDismissListener? = null //Show方法 fun show(): WPDialog { if(PREFS!!.isLightThemeUsed) { @@ -157,6 +159,9 @@ class WPDialog(private val mContext: Context) { } else { wpNeutral.setOnClickListener(OnDialogButtonClickListener()) } + if(dismissListener != null) { + setOnDismissListener(dismissListener) + } } } } @@ -172,7 +177,10 @@ class WPDialog(private val mContext: Context) { mView = view return this } **/ - + fun setDismissListener(listener: DialogInterface.OnDismissListener?): WPDialog { + dismissListener = listener + return this + } fun setPositiveButton(text: String, listener: View.OnClickListener?): WPDialog { okText = text okButtonListener = listener diff --git a/app/src/main/res/layout/launcher_settings_main.xml b/app/src/main/res/layout/launcher_settings_main.xml index ddcdb0a..ab50daa 100644 --- a/app/src/main/res/layout/launcher_settings_main.xml +++ b/app/src/main/res/layout/launcher_settings_main.xml @@ -13,22 +13,24 @@ android:backgroundTint="?android:attr/colorBackground"> + app:fontFamily="@font/manrope_bold" /> diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 74b7b86..23baadf 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -21,8 +21,8 @@ тёмный Автоматическое восстановление Лаунчер запущен некорректно - Нажмите \'Перезагрузить\', чтобы перезапустить лаунчер. Иногда это решает проблему. Также можно нажать \'Дополнительные параметры\' и попробовать другие варианты восстановления лаунчера. - Перезагрузить + Нажмите \'Перезапустить\', чтобы перезапустить лаунчер. Иногда это решает проблему. Также можно нажать \'Дополнительные параметры\' и попробовать другие варианты восстановления лаунчера. + Перезапустить Дополнительные параметы только последнюю последние 5 @@ -231,4 +231,5 @@ Поддержать На этом экране вы можете проверить наличие обновлений для лаунчера, чтобы получить исправления и новые функции. Вы не выбрали никаких приложений. Хотите продолжить? + Позже \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 526017a..36ada90 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -230,4 +230,5 @@ Support From this screen, you can check for updates for MPL to get fixes and new features. You have not selected any applications. Do you want to continue? + Later \ No newline at end of file