diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 56d3ae3..182ee36 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -4,6 +4,6 @@
-
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 25eac43..670d4d1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,8 +17,8 @@ android {
applicationId "ru.dimon6018.metrolauncher"
minSdk 21
targetSdk 35
- versionCode 58
- versionName "1.0 Pre-Alpha 5.1.3"
+ versionCode 59
+ versionName "Exp. 7743"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled false
@@ -48,7 +48,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.annotation:annotation:1.9.1'
- implementation 'com.google.android.material:material:1.13.0-alpha07'
+ implementation 'com.google.android.material:material:1.13.0-alpha08'
implementation 'androidx.recyclerview:recyclerview:1.4.0-rc01'
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.fragment:fragment-ktx:1.8.5'
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/Application.kt b/app/src/main/java/ru/dimon6018/metrolauncher/Application.kt
index fdeb5d7..14c4e96 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/Application.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/Application.kt
@@ -18,7 +18,7 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.launcherAccentTh
class Application : Application() {
override fun onCreate() {
- if(applicationContext == null) {
+ if (applicationContext == null) {
super.onCreate()
return
}
@@ -26,7 +26,9 @@ class Application : Application() {
Thread.setDefaultUncaughtExceptionHandler(BsodDetector())
PREFS = Prefs(applicationContext)
//EXP_PREFS = ExperimentPrefs(applicationContext)
- if(PREFS.accentColor == 21 && DynamicColors.isDynamicColorAvailable()) DynamicColors.applyToActivitiesIfAvailable(this)
+ if (PREFS.accentColor == 21 && DynamicColors.isDynamicColorAvailable()) DynamicColors.applyToActivitiesIfAvailable(
+ this
+ )
setupCustomFont()
setupCustomLightFont()
setupCustomBoldFont()
@@ -35,12 +37,16 @@ class Application : Application() {
@SuppressLint("SourceLockedOrientationActivity")
override fun onActivityPreCreated(activity: Activity, savedInstanceState: Bundle?) {
activity.setTheme(launcherAccentTheme())
- when(PREFS.orientation) {
- "p" -> activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
- "l" -> activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
+ when (PREFS.orientation) {
+ "p" -> activity.requestedOrientation =
+ ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
+
+ "l" -> activity.requestedOrientation =
+ ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
}
super.onActivityPreCreated(activity, savedInstanceState)
}
+
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
override fun onActivityStarted(activity: Activity) {}
override fun onActivityResumed(activity: Activity) {}
@@ -50,9 +56,11 @@ class Application : Application() {
override fun onActivityDestroyed(activity: Activity) {}
})
}
+
companion object {
lateinit var PREFS: Prefs
- // var EXP_PREFS: ExperimentPrefs? = null
+
+ // var EXP_PREFS: ExperimentPrefs? = null
var isUpdateDownloading = false
var isAppOpened = false
var isStartMenuOpened = false
@@ -64,9 +72,11 @@ class Application : Application() {
fun setupCustomFont() {
customFont = getCustomFont()
}
+
fun setupCustomLightFont() {
customLightFont = getCustomLightFont()
}
+
fun setupCustomBoldFont() {
customBoldFont = getCustomBoldFont()
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt b/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
index 1f43e27..780a506 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
@@ -11,6 +11,7 @@ import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.WindowManager
import android.view.inputmethod.EditorInfo
import android.widget.AutoCompleteTextView
import android.widget.ImageView
@@ -66,6 +67,7 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.sendCrash
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.setUpApps
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.unregisterPackageReceiver
+// Main application screen (tiles, apps)
class Main : AppCompatActivity() {
private lateinit var pagerAdapter: FragmentStateAdapter
@@ -87,17 +89,20 @@ class Main : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
isDarkMode = resources.getBoolean(R.bool.isDark) && PREFS.appTheme != 2
- when(PREFS.appTheme) {
+ when (PREFS.appTheme) {
0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}
handleDevMode()
super.onCreate(savedInstanceState)
+
+ // If MPL has never run before, open OOBE
if (PREFS.launcherState == 0) {
runOOBE()
return
}
+
binding = LauncherMainScreenBinding.inflate(layoutInflater)
mainViewModel = ViewModelProvider(this)[MainViewModel::class.java]
setContentView(binding.root)
@@ -112,6 +117,7 @@ class Main : AppCompatActivity() {
}
}
+ // Turn off animations if developer mode is enabled to prevent some animation issues
private fun handleDevMode() {
if (isDevMode(this) && PREFS.isAutoShutdownAnimEnabled) {
disableAnims()
@@ -134,6 +140,13 @@ class Main : AppCompatActivity() {
private fun setupUI() {
WindowCompat.setDecorFitsSystemWindows(window, false)
+ if (PREFS.isWallpaperEnabled) {
+ window?.setFlags(
+ WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
+ WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
+ )
+ window?.setBackgroundDrawableResource(android.R.color.transparent)
+ }
ViewCompat.setOnApplyWindowInsetsListener(binding.mainBottomBar.navigationFrame) { view, insets ->
val systemBarInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
view.updatePadding(
@@ -143,15 +156,20 @@ class Main : AppCompatActivity() {
)
insets
}
- if(PREFS.isSearchBarEnabled) applyWindowInsets(binding.mainSearchResults.searchBarResultsLayout)
+ if (PREFS.isSearchBarEnabled) applyWindowInsets(binding.mainSearchResults.searchBarResultsLayout)
isLandscape = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
registerPackageReceiver(this, packageReceiver)
otherTasks()
}
private fun checkUpdate() {
- if (PREFS.prefs.getBoolean("updateInstalled", false) && PREFS.versionCode == VERSION_CODE) PREFS.updateState = 3
+ if (PREFS.prefs.getBoolean(
+ "updateInstalled",
+ false
+ ) && PREFS.versionCode == VERSION_CODE
+ ) PREFS.updateState = 3
}
+
private fun disableAnims() {
PREFS.apply {
isAAllAppsAnimEnabled = false
@@ -186,6 +204,7 @@ class Main : AppCompatActivity() {
super.onPageSelected(position)
updateNavigationBarColors(position)
}
+
private fun updateNavigationBarColors(position: Int) {
if (!PREFS.isSearchBarEnabled && PREFS.navBarColor != 2) {
val (startColor, searchColor) = when {
@@ -196,12 +215,23 @@ class Main : AppCompatActivity() {
binding.mainBottomBar.navigationSearchBtn.setColorFilter(searchColor)
}
}
+
+ override fun onPageScrollStateChanged(state: Int) {
+ when (state) {
+ ViewPager2.SCROLL_STATE_DRAGGING -> isViewPagerScrolling = true
+ ViewPager2.SCROLL_STATE_SETTLING -> isViewPagerScrolling = true
+ ViewPager2.SCROLL_STATE_IDLE -> isViewPagerScrolling = false
+ }
+ }
}
override fun onResume() {
+ // restart MPL if some settings have been changed
if (PREFS.isPrefsChanged) restart()
+
super.onResume()
}
+
private fun restart() {
PREFS.isPrefsChanged = false
val componentName = Intent(this, this::class.java).component
@@ -209,6 +239,7 @@ class Main : AppCompatActivity() {
startActivity(intent)
Runtime.getRuntime().exit(0)
}
+
override fun onDestroy() {
super.onDestroy()
unregisterPackageReceiver(this, packageReceiver)
@@ -237,7 +268,7 @@ class Main : AppCompatActivity() {
private suspend fun regenerateIcons() {
val isCustomIconsInstalled = PREFS.iconPackPackage != "null"
var diskCache = initDiskCache(this)
- if(isCustomIconsInstalled) {
+ if (isCustomIconsInstalled) {
checkIconPack(diskCache)
}
if (PREFS.iconPackChanged) {
@@ -282,6 +313,7 @@ class Main : AppCompatActivity() {
}
}
+ // Icon generation for cache
fun generateIcon(appPackage: String, isCustomIconsInstalled: Boolean) {
val icon = if (!isCustomIconsInstalled) {
packageManager.getApplicationIcon(appPackage)
@@ -316,6 +348,7 @@ class Main : AppCompatActivity() {
}
}
+ // If 5 seconds after the crash is successful, display an error message
private fun crashCheck() {
if (PREFS.prefs.getBoolean("app_crashed", false)) {
lifecycleScope.launch(Dispatchers.Default) {
@@ -367,6 +400,7 @@ class Main : AppCompatActivity() {
binding.mainBottomBar.navigationFrame.visibility = View.GONE
return ContextCompat.getColor(this, android.R.color.transparent)
}
+
else -> launcherSurfaceColor(theme)
}
}
@@ -418,6 +452,7 @@ class Main : AppCompatActivity() {
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
filterSearchText(s.toString(), mainViewModel.getAppList())
}
+
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun afterTextChanged(s: Editable) {}
})
@@ -436,6 +471,7 @@ class Main : AppCompatActivity() {
fun hideSearch() {
hideSearchResults()
}
+
private fun hideSearchResults() {
lifecycleScope.launch {
searching = false
@@ -464,16 +500,20 @@ class Main : AppCompatActivity() {
val defaultLocale = getDefaultLocale()
filteredList.clear()
- appList.filter { it.appLabel!!.lowercase(defaultLocale).contains(text.lowercase(defaultLocale)) }
+ appList.filter {
+ it.appLabel!!.lowercase(defaultLocale).contains(text.lowercase(defaultLocale))
+ }
.take(max)
.let { filteredList.addAll(it) }
filteredList.sortWith(compareBy { it.appLabel })
searchAdapter?.setData(filteredList)
}
+
companion object {
var isLandscape: Boolean = false
var isDarkMode: Boolean = false
+ var isViewPagerScrolling: Boolean = false
}
inner class WinAdapter(fragment: FragmentActivity) : FragmentStateAdapter(fragment) {
@@ -489,10 +529,13 @@ class Main : AppCompatActivity() {
}
}
- inner class SearchAdapter(private var dataList: MutableList) : RecyclerView.Adapter() {
+ inner class SearchAdapter(private var dataList: MutableList) :
+ RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
- return AppSearchHolder(LayoutInflater.from(parent.context).inflate(R.layout.app, parent, false))
+ return AppSearchHolder(
+ LayoutInflater.from(parent.context).inflate(R.layout.app, parent, false)
+ )
}
override fun getItemCount(): Int = dataList.size
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/MainViewModel.kt b/app/src/main/java/ru/dimon6018/metrolauncher/MainViewModel.kt
index 8ddd5d4..3c68ebb 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/MainViewModel.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/MainViewModel.kt
@@ -15,26 +15,33 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
private var appList: MutableList = ArrayList()
fun addIconToCache(appPackage: String, bitmap: Bitmap?) {
- if(icons[appPackage.hashCode()] == null) icons.append(appPackage.hashCode(), bitmap)
+ if (icons[appPackage.hashCode()] == null) icons.append(appPackage.hashCode(), bitmap)
}
+
fun removeIconFromCache(appPackage: String) {
icons.remove(appPackage.hashCode())
}
+
fun getIconFromCache(appPackage: String): Bitmap? {
return icons[appPackage.hashCode()]
}
+
fun addAppToList(app: App) {
- if(!appList.contains(app)) appList.add(app)
+ if (!appList.contains(app)) appList.add(app)
}
+
fun removeAppFromList(app: App) {
appList.remove(app)
}
+
fun getAppList(): MutableList {
return appList
}
+
fun setAppList(list: MutableList) {
appList = list
}
+
fun getTileDao(): TileDao {
return tileDao
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/AllApps.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/AllApps.kt
index bbbf3ed..7c9a721 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/AllApps.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/AllApps.kt
@@ -31,7 +31,6 @@ import android.widget.TextView
import androidx.core.animation.doOnEnd
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.toDrawable
-import androidx.core.widget.PopupWindowCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
@@ -81,7 +80,7 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.setUpApps
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.setViewInteractAnimation
import kotlin.random.Random
-class AllApps: Fragment() {
+class AllApps : Fragment() {
private lateinit var recyclerViewLM: LinearLayoutManager
private lateinit var decor: IOverScrollDecor
@@ -104,12 +103,16 @@ class AllApps: Fragment() {
private val binding get() = _binding!!
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
_binding = LauncherAllAppsScreenBinding.inflate(inflater, container, false)
Log.d("AllApps", "Init")
mainViewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
binding.settingsBtn.apply {
- visibility = if(!PREFS.isSettingsBtnEnabled) View.GONE else View.VISIBLE
+ visibility = if (!PREFS.isSettingsBtnEnabled) View.GONE else View.VISIBLE
setOnClickListener {
activity?.let { it.startActivity(Intent(it, SettingsActivity::class.java)) }
}
@@ -120,13 +123,14 @@ class AllApps: Fragment() {
binding.searchBackBtn.setOnClickListener {
disableSearch()
}
- if(PREFS.customFontInstalled) customFont?.let {
+ if (PREFS.customFontInstalled) customFont?.let {
binding.searchTextview.typeface = it
binding.noResults.typeface = it
}
applyWindowInsets(binding.root)
return binding.root
}
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (context == null) {
@@ -135,8 +139,13 @@ class AllApps: Fragment() {
}
viewLifecycleOwner.lifecycleScope.launch(defaultDispatcher) {
var data = getHeaderListLatter(mainViewModel.getAppList())
- if(data.isEmpty()) {
- data = getHeaderListLatter(setUpApps(requireActivity().packageManager, requireActivity()))
+ if (data.isEmpty()) {
+ data = getHeaderListLatter(
+ setUpApps(
+ requireActivity().packageManager,
+ requireActivity()
+ )
+ )
}
appAdapter = AppAdapter(data)
recyclerViewLM = LinearLayoutManager(requireActivity())
@@ -154,6 +163,7 @@ class AllApps: Fragment() {
}
registerBroadcast()
}
+
private fun tipDialog() {
WPDialog(requireContext()).setTopDialog(true)
.setTitle(getString(R.string.tip))
@@ -161,23 +171,34 @@ class AllApps: Fragment() {
.setPositiveButton(getString(android.R.string.ok), null)
.show()
}
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
+
private fun configureRecyclerView() {
binding.appList.apply {
layoutManager = recyclerViewLM
adapter = appAdapter
- addItemDecoration(Utils.BottomOffsetDecoration(requireContext().resources.getDimensionPixelSize(R.dimen.recyclerViewPadding)))
- decor = OverScrollDecoratorHelper.setUpOverScroll(this, OverScrollDecoratorHelper.ORIENTATION_VERTICAL)
+ addItemDecoration(
+ Utils.BottomOffsetDecoration(
+ requireContext().resources.getDimensionPixelSize(
+ R.dimen.recyclerViewPadding
+ )
+ )
+ )
+ decor = OverScrollDecoratorHelper.setUpOverScroll(
+ this,
+ OverScrollDecoratorHelper.ORIENTATION_VERTICAL
+ )
visibility = View.VISIBLE
}
}
@SuppressLint("UnspecifiedRegisterReceiverFlag", "InlinedApi")
private fun registerBroadcast() {
- if(!isBroadcasterRegistered) {
+ if (!isBroadcasterRegistered) {
isBroadcasterRegistered = true
packageBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
@@ -186,17 +207,19 @@ class AllApps: Fragment() {
if (packageName.isNullOrEmpty()) return
val action = intent.getIntExtra("action", 42)
packageName.apply {
- when(action) {
+ when (action) {
PackageChangesReceiver.PACKAGE_INSTALLED -> {
val bool = PREFS.iconPackPackage != "null"
(requireActivity() as Main).generateIcon(packageName, bool)
broadcastListUpdater(context)
}
+
PackageChangesReceiver.PACKAGE_REMOVED -> {
//I don't think that's gonna work.
mainViewModel.removeIconFromCache(packageName)
broadcastListUpdater(context)
}
+
else -> {
broadcastListUpdater(context)
}
@@ -221,10 +244,12 @@ class AllApps: Fragment() {
}
}
}
+
private fun broadcastListUpdater(context: Context) {
mainViewModel.setAppList(setUpApps(context.packageManager, context))
appAdapter?.setData(getHeaderListLatter(mainViewModel.getAppList()))
}
+
private fun unregisterBroadcast() {
isBroadcasterRegistered = false
packageBroadcastReceiver?.apply {
@@ -232,10 +257,12 @@ class AllApps: Fragment() {
packageBroadcastReceiver = null
}
}
+
override fun onDestroy() {
super.onDestroy()
unregisterBroadcast()
}
+
private suspend fun setAlphabetRecyclerView(context: Context) {
adapterAlphabet = AlphabetAdapter(getAlphabetList(), context)
val lm = GridLayoutManager(context, 4)
@@ -246,6 +273,7 @@ class AllApps: Fragment() {
}
}
}
+
private fun configureAlphabetRecyclerView(lm: GridLayoutManager) {
binding.alphabetList.apply {
layoutManager = lm
@@ -257,24 +285,26 @@ class AllApps: Fragment() {
}
}
}
+
private fun showAlphabet() {
adapterAlphabet!!.setNewData(getAlphabetList())
- if(PREFS.isAlphabetAnimEnabled) {
+ if (PREFS.isAlphabetAnimEnabled) {
ObjectAnimator.ofFloat(binding.appList, "alpha", 1f, 0.7f).setDuration(300).start()
}
isAlphabetVisible = true
- if(PREFS.isAlphabetAnimEnabled) {
+ if (PREFS.isAlphabetAnimEnabled) {
binding.alphabetLayout.visibility = View.VISIBLE
} else {
binding.alphabetLayout.visibility = View.VISIBLE
}
}
+
private fun hideAlphabet() {
- if(PREFS.isAlphabetAnimEnabled) {
+ if (PREFS.isAlphabetAnimEnabled) {
ObjectAnimator.ofFloat(binding.appList, "alpha", 0.7f, 1f).setDuration(300).start()
}
isAlphabetVisible = false
- if(PREFS.isAlphabetAnimEnabled) {
+ if (PREFS.isAlphabetAnimEnabled) {
binding.alphabetLayout.visibility = View.INVISIBLE
binding.alphabetList.scrollToPosition(0)
} else {
@@ -282,6 +312,7 @@ class AllApps: Fragment() {
binding.alphabetList.scrollToPosition(0)
}
}
+
private fun getAlphabetList(): MutableList {
val resultList: MutableList = ArrayList()
val alphabetList: MutableList = ArrayList()
@@ -297,7 +328,7 @@ class AllApps: Fragment() {
}
var pos = 0
alphabetList.forEach {
- if(it.length < 2) {
+ if (it.length < 2) {
val l = AlphabetLetter()
l.letter = it
l.isActive = false
@@ -314,14 +345,15 @@ class AllApps: Fragment() {
}
return resultList
}
+
override fun onPause() {
- if(isSearching && !PREFS.showKeyboardWhenOpeningAllApps) {
+ if (isSearching && !PREFS.showKeyboardWhenOpeningAllApps) {
disableSearch()
}
- if(isAlphabetVisible) {
+ if (isAlphabetVisible) {
hideAlphabet()
}
- if(appAdapter?.isWindowVisible == true) {
+ if (appAdapter?.isWindowVisible == true) {
appAdapter?.popupWindow?.dismiss()
appAdapter?.popupWindow = null
}
@@ -329,15 +361,15 @@ class AllApps: Fragment() {
}
override fun onResume() {
- if(isAppOpened && !isStartMenuOpened) {
+ if (isAppOpened && !isStartMenuOpened) {
activity?.onBackPressedDispatcher?.onBackPressed()
}
registerBroadcast()
super.onResume()
- if(binding.appList.visibility != View.VISIBLE) {
+ if (binding.appList.visibility != View.VISIBLE) {
binding.appList.visibility = View.VISIBLE
}
- if(binding.appList.alpha != 1f) {
+ if (binding.appList.alpha != 1f) {
if (PREFS.isAAllAppsAnimEnabled) {
binding.appList.apply {
val anim = ObjectAnimator.ofFloat(this, "alpha", 0f, 1f)
@@ -351,12 +383,13 @@ class AllApps: Fragment() {
binding.appList.alpha = 1f
}
}
- if(PREFS.showKeyboardWhenOpeningAllApps) {
+ if (PREFS.showKeyboardWhenOpeningAllApps) {
searchFunction()
}
}
+
private fun disableSearch() {
- if(!isSearching) return
+ if (!isSearching) return
isSearching = false
binding.noResults.visibility = View.GONE
decor.attach()
@@ -373,7 +406,7 @@ class AllApps: Fragment() {
animate().alpha(1f).setDuration(200).start()
}
}.start()
- settingsBtn.visibility = if(!PREFS.isSettingsBtnEnabled) View.GONE else View.VISIBLE
+ settingsBtn.visibility = if (!PREFS.isSettingsBtnEnabled) View.GONE else View.VISIBLE
appList.apply {
alpha = 0.5f
animate().translationX(0f).setDuration(200).start()
@@ -389,8 +422,9 @@ class AllApps: Fragment() {
}
}
}
+
private fun searchFunction() {
- if(isSearching) return
+ if (isSearching) return
appAdapter ?: return
isSearching = true
decor.detach()
@@ -404,16 +438,19 @@ class AllApps: Fragment() {
}.start()
settingsBtn.visibility = View.GONE
appList.apply {
- animate().translationX(-requireContext().resources.getDimensionPixelSize(R.dimen.recyclerViewSearchPadding).toFloat()).setDuration(200).start()
+ animate().translationX(
+ -requireContext().resources.getDimensionPixelSize(R.dimen.recyclerViewSearchPadding)
+ .toFloat()
+ ).setDuration(200).start()
isVerticalScrollBarEnabled = false
}
}
- if(PREFS.showKeyboardWhenSearching) {
+ if (PREFS.showKeyboardWhenSearching) {
showKeyboard(binding.search.editText as? AutoCompleteTextView)
}
viewLifecycleOwner.lifecycleScope.launch(defaultDispatcher) {
removeHeaders()
- if(PREFS.allAppsKeyboardActionEnabled) {
+ if (PREFS.allAppsKeyboardActionEnabled) {
(binding.search.editText as? AutoCompleteTextView)?.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_GO && appAdapter!!.list.isNotEmpty()) {
runApp(
@@ -433,7 +470,15 @@ class AllApps: Fragment() {
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
filterText(s.toString())
}
- override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
+
+ override fun beforeTextChanged(
+ s: CharSequence,
+ start: Int,
+ count: Int,
+ after: Int
+ ) {
+ }
+
override fun afterTextChanged(s: Editable) {}
})
withContext(mainDispatcher) {
@@ -441,6 +486,7 @@ class AllApps: Fragment() {
}
}
}
+
private fun showKeyboard(view: View?) {
if (view != null) {
if (view.requestFocus()) {
@@ -450,6 +496,7 @@ class AllApps: Fragment() {
}
}
}
+
private fun hideKeyboard(view: View?) {
if (view != null) {
if (view.requestFocus()) {
@@ -459,6 +506,7 @@ class AllApps: Fragment() {
}
}
}
+
private fun filterText(searchText: String) {
val filteredList: MutableList = ArrayList()
val locale = getDefaultLocale()
@@ -473,23 +521,31 @@ class AllApps: Fragment() {
visibility = View.VISIBLE
val string = context.getString(R.string.no_results_for) + " " + searchText
val spannable: Spannable = SpannableString(string)
- spannable.setSpan(ForegroundColorSpan(launcherAccentColor(requireActivity().theme)), string.indexOf(searchText),string.indexOf(searchText) + searchText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
+ spannable.setSpan(
+ ForegroundColorSpan(launcherAccentColor(requireActivity().theme)),
+ string.indexOf(searchText),
+ string.indexOf(searchText) + searchText.length,
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
+ )
setText(spannable, TextView.BufferType.SPANNABLE)
} else {
visibility = View.GONE
}
}
}
+
private suspend fun removeHeaders() {
val filteredList = mainViewModel.getAppList().filter { it.type != 1 }
withContext(mainDispatcher) {
appAdapter?.setData(filteredList.toMutableList())
}
}
+
private fun removeApps(currentApps: MutableList): List {
val filteredList: List = currentApps.filter { it.type != 0 }
return filteredList
}
+
private fun getHeaderListLatter(newApps: MutableList): MutableList {
val userLanguage = getDefaultLocale()
val userLanguageHeaders = mutableSetOf()
@@ -514,6 +570,7 @@ class AllApps: Fragment() {
}
userLanguageApps[header]?.add(app)
}
+
label.matches(Regex("^[a-zA-Z].*")) -> {
val header = label[0].lowercase(defaultLocale)
englishHeaders.add(header)
@@ -522,7 +579,10 @@ class AllApps: Fragment() {
}
englishApps[header]?.add(app)
}
- else -> { otherApps.add(app) }
+
+ else -> {
+ otherApps.add(app)
+ }
}
}
val list = mutableListOf()
@@ -551,14 +611,25 @@ class AllApps: Fragment() {
}
return list
}
+
private fun runApp(app: String, pm: PackageManager) {
isAppOpened = true
when (app) {
- "ru.dimon6018.metrolauncher" -> activity?.apply { startActivity(Intent(this, SettingsActivity::class.java)) }
+ "ru.dimon6018.metrolauncher" -> activity?.apply {
+ startActivity(
+ Intent(
+ this,
+ SettingsActivity::class.java
+ )
+ )
+ }
+
else -> startActivity(Intent(pm.getLaunchIntentForPackage(app)))
}
}
- open inner class AppAdapter(var list: MutableList) : RecyclerView.Adapter() {
+
+ open inner class AppAdapter(var list: MutableList) :
+ RecyclerView.Adapter() {
private val letterHolder = 1
private val appHolder = 0
@@ -574,19 +645,23 @@ class AllApps: Fragment() {
itemView.setOnClickListener {
showAlphabet()
}
- if(PREFS.customFontInstalled) customFont?.let { binding.abcLabel.typeface = it }
+ if (PREFS.customFontInstalled) customFont?.let { binding.abcLabel.typeface = it }
}
}
+
inner class AppHolder(val binding: AppBinding) : RecyclerView.ViewHolder(binding.root) {
init {
setViewInteractAnimation(itemView)
itemView.setOnClickListener {
visualFeedback(itemView)
- if(PREFS.isAAllAppsAnimEnabled) {
+ if (PREFS.isAAllAppsAnimEnabled) {
startDismissAnim(list[absoluteAdapterPosition])
} else {
- if(context != null) {
- runApp(list[absoluteAdapterPosition].appPackage!!, requireContext().packageManager)
+ if (context != null) {
+ runApp(
+ list[absoluteAdapterPosition].appPackage!!,
+ requireContext().packageManager
+ )
}
}
}
@@ -594,23 +669,27 @@ class AllApps: Fragment() {
showPopupWindow(itemView, list[absoluteAdapterPosition])
true
}
- if(PREFS.customFontInstalled) customFont?.let { binding.appLabel.typeface = it }
+ if (PREFS.customFontInstalled) customFont?.let { binding.appLabel.typeface = it }
}
+
private fun visualFeedback(view: View?) {
- if(view != null) {
+ if (view != null) {
val defaultAlpha = view.alpha
lifecycleScope.launch {
var newValue = defaultAlpha - 0.4f
- if(newValue <= 0.1f) {
+ if (newValue <= 0.1f) {
newValue = 0.2f
}
- ObjectAnimator.ofFloat(view, "alpha", defaultAlpha, newValue).setDuration(100).start()
+ ObjectAnimator.ofFloat(view, "alpha", defaultAlpha, newValue)
+ .setDuration(100).start()
delay(30)
- ObjectAnimator.ofFloat(view, "alpha", newValue, defaultAlpha).setDuration(100).start()
+ ObjectAnimator.ofFloat(view, "alpha", newValue, defaultAlpha)
+ .setDuration(100).start()
}
}
}
}
+
fun setData(new: MutableList) {
val diffCallback = AppDiffCallback(list, new)
val diffResult = DiffUtil.calculateDiff(diffCallback)
@@ -635,6 +714,7 @@ class AllApps: Fragment() {
letterHolder -> {
bindLetterHolder(holder as LetterHolder, app.appLabel!!)
}
+
appHolder -> {
bindAppHolder(holder as AppHolder, app)
}
@@ -649,6 +729,7 @@ class AllApps: Fragment() {
holder.binding.appIcon.load(mainViewModel.getIconFromCache(app.appPackage!!))
holder.binding.appLabel.text = app.appLabel
}
+
fun isPopupInTop(anchorView: View, popupHeight: Int): Boolean {
val location = IntArray(2)
anchorView.getLocationOnScreen(location)
@@ -658,25 +739,33 @@ class AllApps: Fragment() {
val popupY = anchorY - popupHeight
return popupY < screenHeight / 2
}
+
fun getPopupHeight(popupWindow: PopupWindow): Int {
val contentView = popupWindow.contentView
contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
return contentView.measuredHeight
}
+
private fun showPopupWindow(view: View, app: App) {
binding.appList.isScrollEnabled = false
(requireActivity() as Main).configureViewPagerScroll(false)
- val inflater = view.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+ val inflater =
+ view.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val popupView = inflater.inflate(R.layout.all_apps_window, binding.appList, false)
- popupWindow = PopupWindow(popupView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true)
+ popupWindow = PopupWindow(
+ popupView,
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ true
+ )
popupWindow!!.isFocusable = true
val popupHeight = getPopupHeight(popupWindow!!)
val top = isPopupInTop(view, popupHeight)
- popupView.pivotY = if(top) 0f else popupHeight.toFloat()
+ popupView.pivotY = if (top) 0f else popupHeight.toFloat()
val pinLabel = popupView.findViewById(R.id.pin_app_label)
val infoLabel = popupView.findViewById(R.id.app_info_label)
val uninstallLabel = popupView.findViewById(R.id.uninstall_label)
- (if(PREFS.customLightFontPath != null) customLightFont else customFont).let {
+ (if (PREFS.customLightFontPath != null) customLightFont else customFont)?.let {
pinLabel.typeface = it
infoLabel.typeface = it
uninstallLabel.typeface = it
@@ -692,7 +781,12 @@ class AllApps: Fragment() {
}
anim.start()
fadeList(app, false)
- PopupWindowCompat.showAsDropDown(popupWindow!!, view, 0, if(top) 0 else (-popupHeight + -view.height), Gravity.CENTER)
+ popupWindow!!.showAsDropDown(
+ view,
+ 0,
+ if (top) 0 else (-popupHeight + -view.height),
+ Gravity.CENTER
+ )
isWindowVisible = true
val pin = popupView.findViewById(R.id.pin_app)
@@ -750,16 +844,19 @@ class AllApps: Fragment() {
if (restoreAll) {
for (i in first..last) {
val itemView = binding.appList.findViewHolderForAdapterPosition(i)?.itemView
- itemView?.animate()?.alpha(1f)?.scaleY(1f)?.scaleX(1f)?.setDuration(500)?.start()
+ itemView?.animate()?.alpha(1f)?.scaleY(1f)?.scaleX(1f)?.setDuration(500)
+ ?.start()
}
} else {
for (i in first..last) {
val itemView = binding.appList.findViewHolderForAdapterPosition(i)?.itemView
if (list[i] == app) continue
- itemView?.animate()?.alpha(0.5f)?.scaleY(0.95f)?.scaleX(0.95f)?.setDuration(500)?.start()
+ itemView?.animate()?.alpha(0.5f)?.scaleY(0.95f)?.scaleX(0.95f)?.setDuration(500)
+ ?.start()
}
}
}
+
private fun startDismissAnim(item: App) {
if (appAdapter == null || !PREFS.isAAllAppsAnimEnabled) {
startAppDelay(item)
@@ -790,6 +887,7 @@ class AllApps: Fragment() {
}
startAppDelay(item)
}
+
private fun startAppDelay(item: App) {
CoroutineScope(mainDispatcher).launch {
delay(300)
@@ -812,6 +910,7 @@ class AllApps: Fragment() {
cancel()
}
}
+
private fun insertNewApp(app: App) {
lifecycleScope.launch(defaultDispatcher) {
val dataList = mainViewModel.getTileDao().getTilesList()
@@ -849,6 +948,7 @@ class AllApps: Fragment() {
else -> appHolder
}
}
+
inner class AppDiffCallback(
private val oldList: List,
private val newList: List
@@ -867,12 +967,16 @@ class AllApps: Fragment() {
}
}
}
- inner class AlphabetAdapter(private var alphabetList: MutableList,private val context: Context): RecyclerView.Adapter() {
+
+ inner class AlphabetAdapter(
+ private var alphabetList: MutableList,
+ private val context: Context
+ ) : RecyclerView.Adapter() {
private val activeLetter = 10
private val disabledLetter = 11
private val activeDrawable: ColorDrawable by lazy {
- if(activity != null) {
+ if (activity != null) {
launcherAccentColor(activity!!.theme).toDrawable()
} else {
ContextCompat.getColor(context, android.R.color.white).toDrawable()
@@ -881,6 +985,7 @@ class AllApps: Fragment() {
private val disabledDrawable: ColorDrawable by lazy {
ContextCompat.getColor(context, R.color.darkGray).toDrawable()
}
+
fun setNewData(new: MutableList) {
val diffCallback = LetterDiffCallback(alphabetList, new)
val diffResult = DiffUtil.calculateDiff(diffCallback)
@@ -888,8 +993,11 @@ class AllApps: Fragment() {
alphabetList.addAll(new)
diffResult.dispatchUpdatesTo(this)
}
+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
- return AlphabetLetterHolder(LayoutInflater.from(context).inflate(R.layout.abc_alphabet, parent, false), context)
+ return AlphabetLetterHolder(
+ LayoutInflater.from(context).inflate(R.layout.abc_alphabet, parent, false), context
+ )
}
override fun getItemCount(): Int {
@@ -903,17 +1011,19 @@ class AllApps: Fragment() {
setHolderView(holder, item.isActive)
setOnClick(holder, item)
}
+
private fun setHolderView(holder: AlphabetLetterHolder, isActive: Boolean) {
- if(isActive) {
+ if (isActive) {
holder.backgroundView.background = activeDrawable
} else {
holder.backgroundView.background = disabledDrawable
}
}
+
private fun setOnClick(holder: AlphabetLetterHolder, item: AlphabetLetter) {
- if(item.isActive) {
+ if (item.isActive) {
holder.itemView.setOnClickListener {
- if(item.posInList != null) {
+ if (item.posInList != null) {
hideAlphabet()
if (item.posInList!! > appAdapter?.itemCount!!) {
binding.appList.smoothScrollToPosition(appAdapter?.itemCount!!)
@@ -924,10 +1034,12 @@ class AllApps: Fragment() {
}
}
}
+
override fun getItemViewType(position: Int): Int {
- return if(alphabetList[position].isActive) activeLetter else disabledLetter
+ return if (alphabetList[position].isActive) activeLetter else disabledLetter
}
}
+
inner class LetterDiffCallback(
private val oldList: List,
private val newList: List
@@ -940,16 +1052,20 @@ class AllApps: Fragment() {
override fun areItemsTheSame(old: Int, new: Int): Boolean {
return oldList[old] == newList[new]
}
+
override fun areContentsTheSame(old: Int, new: Int): Boolean {
return oldList[old].posInList == newList[new].posInList
}
}
+
inner class AlphabetLetter {
var letter: String = ""
var isActive: Boolean = false
var posInList: Int? = null
}
- inner class AlphabetLetterHolder(itemView: View, context: Context) : RecyclerView.ViewHolder(itemView) {
+
+ inner class AlphabetLetterHolder(itemView: View, context: Context) :
+ RecyclerView.ViewHolder(itemView) {
var textView: MaterialTextView = itemView.findViewById(R.id.alphabetLetter)
var backgroundView: View = itemView.findViewById(R.id.alphabetBackground)
@@ -958,7 +1074,7 @@ class AllApps: Fragment() {
init {
itemView.layoutParams = params
- if(PREFS.customFontInstalled) customFont?.let { textView.typeface = it }
+ if (PREFS.customFontInstalled) customFont?.let { textView.typeface = it }
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt
index 6d1abd1..5fcb862 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt
@@ -20,6 +20,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateInterpolator
+import android.view.animation.LinearInterpolator
import android.widget.EditText
import android.widget.FrameLayout
import android.widget.ImageView
@@ -61,6 +62,7 @@ import ru.dimon6018.metrolauncher.Application.Companion.isAppOpened
import ru.dimon6018.metrolauncher.Application.Companion.isStartMenuOpened
import ru.dimon6018.metrolauncher.Main
import ru.dimon6018.metrolauncher.Main.Companion.isLandscape
+import ru.dimon6018.metrolauncher.Main.Companion.isViewPagerScrolling
import ru.dimon6018.metrolauncher.MainViewModel
import ru.dimon6018.metrolauncher.R
import ru.dimon6018.metrolauncher.content.data.app.App
@@ -75,6 +77,7 @@ import ru.dimon6018.metrolauncher.helpers.dragndrop.ItemTouchHelperAdapter
import ru.dimon6018.metrolauncher.helpers.dragndrop.ItemTouchHelperViewHolder
import ru.dimon6018.metrolauncher.helpers.dragndrop.OnStartDragListener
import ru.dimon6018.metrolauncher.helpers.receivers.PackageChangesReceiver
+import ru.dimon6018.metrolauncher.helpers.ui.StartRecyclerView
import ru.dimon6018.metrolauncher.helpers.utils.Utils
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.accentColorFromPrefs
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.getTileColorFromPrefs
@@ -83,7 +86,8 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.isScreenOn
import ru.dimon6018.metrolauncher.helpers.utils.Utils.MarginItemDecoration
import kotlin.random.Random
-class Start: Fragment(), OnStartDragListener {
+// Start screen
+class Start : Fragment(), OnStartDragListener {
private lateinit var mItemTouchHelper: ItemTouchHelper
@@ -99,7 +103,6 @@ class Start: Fragment(), OnStartDragListener {
private var isBroadcasterRegistered = false
private var screenIsOn = false
-
private var _binding: LauncherStartScreenBinding? = null
private val binding get() = _binding!!
private lateinit var mainViewModel: MainViewModel
@@ -108,14 +111,19 @@ class Start: Fragment(), OnStartDragListener {
private val backCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
- mAdapter?.let { if(it.isEditMode) it.disableEditMode() }
+ mAdapter?.let { if (it.isEditMode) it.disableEditMode() }
}
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
_binding = LauncherStartScreenBinding.inflate(inflater, container, false)
mainViewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
binding.startFrame.setOnClickListener {
- mAdapter?.let { if(it.isEditMode) it.disableEditMode() }
+ mAdapter?.let { if (it.isEditMode) it.disableEditMode() }
}
ViewCompat.setOnApplyWindowInsetsListener(binding.startTiles) { view, insets ->
val systemBarInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
@@ -127,11 +135,15 @@ class Start: Fragment(), OnStartDragListener {
)
insets
}
+ if (PREFS.isWallpaperEnabled) {
+ binding.startTiles.isUpdateEnabled = true
+ }
return binding.root
}
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- if(context != null) {
+ if (context != null) {
viewLifecycleOwner.lifecycleScope.launch(defaultDispatcher) {
tiles = mainViewModel.getTileDao().getTilesList()
setupRecyclerViewLayoutManager(requireContext())
@@ -146,34 +158,43 @@ class Start: Fragment(), OnStartDragListener {
}
}
}
+
private fun observe() {
- if(!screenLoaded || mainViewModel.getTileDao().getTilesLiveData().hasActiveObservers()) return
+ if (!screenLoaded || mainViewModel.getTileDao().getTilesLiveData()
+ .hasActiveObservers()
+ ) return
mainViewModel.getTileDao().getTilesLiveData().observe(viewLifecycleOwner) {
mAdapter ?: return@observe
- if(mAdapter!!.list != it) {
+ if (mAdapter!!.list != it) {
Log.w("obs", "set new data")
mAdapter!!.setData(it)
}
}
}
+
private fun stopObserver() {
mainViewModel.getTileDao().getTilesLiveData().removeObservers(viewLifecycleOwner)
}
+
override fun onDestroyView() {
stopObserver()
super.onDestroyView()
_binding = null
}
+
private fun setupAdapter() {
mAdapter = NewStartAdapter(requireContext(), tiles!!)
mItemTouchHelper = ItemTouchHelper(ItemTouchCallback(mAdapter!!))
}
+
private fun addCallback() {
activity?.onBackPressedDispatcher?.addCallback(viewLifecycleOwner, backCallback)
}
+
private fun removeCallback() {
backCallback.remove()
}
+
private fun configureRecyclerView() {
binding.startTiles.apply {
layoutManager = mSpannedLayoutManager
@@ -182,14 +203,15 @@ class Start: Fragment(), OnStartDragListener {
addItemDecoration(MarginItemDecoration(14))
}
}
+
private fun setupRecyclerViewLayoutManager(context: Context?) {
- if(mSpannedLayoutManager != null) mSpannedLayoutManager = null
+ if (mSpannedLayoutManager != null) mSpannedLayoutManager = null
if (!isLandscape) {
// phone
mSpannedLayoutManager = SpannedGridLayoutManager(
orientation = RecyclerView.VERTICAL,
- rowCount = if(!PREFS.isMoreTilesEnabled) 8 else 12,
- columnCount = if(!PREFS.isMoreTilesEnabled) 4 else 6
+ rowCount = if (!PREFS.isMoreTilesEnabled) 8 else 12,
+ columnCount = if (!PREFS.isMoreTilesEnabled) 4 else 6
)
} else {
// Landscape orientation
@@ -198,15 +220,15 @@ class Start: Fragment(), OnStartDragListener {
// tablet
SpannedGridLayoutManager(
orientation = RecyclerView.VERTICAL,
- rowCount = if(!PREFS.isMoreTilesEnabled) 2 else 3,
- columnCount = if(!PREFS.isMoreTilesEnabled) 4 else 6
+ rowCount = if (!PREFS.isMoreTilesEnabled) 2 else 3,
+ columnCount = if (!PREFS.isMoreTilesEnabled) 4 else 6
)
} else {
// phone but landscape
SpannedGridLayoutManager(
orientation = RecyclerView.VERTICAL,
rowCount = 3,
- columnCount = if(!PREFS.isMoreTilesEnabled) 4 else 6
+ columnCount = if (!PREFS.isMoreTilesEnabled) 4 else 6
)
}
}
@@ -222,6 +244,7 @@ class Start: Fragment(), OnStartDragListener {
}
}
}
+
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
isLandscape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE
@@ -230,12 +253,14 @@ class Start: Fragment(), OnStartDragListener {
layoutManager = mSpannedLayoutManager
}
}
+
override fun onResume() {
- if(screenLoaded) observe()
- if(!screenIsOn) {
- if(binding.startTiles.visibility == View.INVISIBLE) binding.startTiles.visibility = View.VISIBLE
+ if (screenLoaded) observe()
+ if (!screenIsOn) {
+ if (binding.startTiles.visibility == View.INVISIBLE) binding.startTiles.visibility =
+ View.VISIBLE
}
- if(isAppOpened) {
+ if (isAppOpened) {
viewLifecycleOwner.lifecycleScope.launch {
animateTiles(false, null, null)
}
@@ -251,33 +276,37 @@ class Start: Fragment(), OnStartDragListener {
isTopLeft = false
}
}
+
override fun onPause() {
super.onPause()
screenIsOn = isScreenOn(context)
- if(!screenIsOn) {
- if(binding.startTiles.visibility == View.VISIBLE) {
+ if (!screenIsOn) {
+ if (binding.startTiles.visibility == View.VISIBLE) {
binding.startTiles.visibility = View.INVISIBLE
}
}
mAdapter?.apply {
- if(isEditMode) disableEditMode()
+ if (isEditMode) disableEditMode()
}
isStartMenuOpened = false
}
+
override fun onStop() {
super.onStop()
isStartMenuOpened = false
}
+
override fun onStartDrag(viewHolder: RecyclerView.ViewHolder?) {
if (viewHolder != null && !PREFS.isStartBlocked && mAdapter != null) {
- if(!mAdapter!!.isEditMode) mAdapter!!.enableEditMode()
+ if (!mAdapter!!.isEditMode) mAdapter!!.enableEditMode()
mItemTouchHelper.startDrag(viewHolder)
}
}
+
@SuppressLint("InlinedApi", "UnspecifiedRegisterReceiverFlag")
private fun registerBroadcast() {
Log.d("Start", "reg broadcaster")
- if(!isBroadcasterRegistered) {
+ if (!isBroadcasterRegistered) {
isBroadcasterRegistered = true
packageBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
@@ -292,17 +321,23 @@ class Start: Fragment(), OnStartDragListener {
(requireActivity() as Main).generateIcon(packageName, bool)
mainViewModel.addAppToList(
App(
- appLabel = context.packageManager.getApplicationInfo(packageName, 0).name,
+ appLabel = context.packageManager.getApplicationInfo(
+ packageName,
+ 0
+ ).name,
appPackage = packageName,
id = Random.nextInt()
- ))
+ )
+ )
if (PREFS.pinNewApps) {
pinApp(packageName)
}
}
+
PackageChangesReceiver.PACKAGE_REMOVED -> {
packageName.apply { broadcastListUpdater(this, true) }
}
+
else -> {
packageName.apply { broadcastListUpdater(this, false) }
}
@@ -326,14 +361,15 @@ class Start: Fragment(), OnStartDragListener {
Log.d("Start", "broadcaster already registered")
}
}
+
private fun broadcastListUpdater(packageName: String, isDelete: Boolean) {
packageName.apply {
Log.d("Start", "update list by broadcaster")
CoroutineScope(ioDispatcher).launch {
var newList = mainViewModel.getTileDao().getTilesList()
- if(isDelete) {
+ if (isDelete) {
newList.forEach {
- if(it.tilePackage == packageName) {
+ if (it.tilePackage == packageName) {
Log.d("Start", "delete")
destroyTile(it)
}
@@ -346,9 +382,10 @@ class Start: Fragment(), OnStartDragListener {
}
}
}
+
private fun pinApp(packageName: String) {
lifecycleScope.launch(ioDispatcher) {
- if(mAdapter != null) {
+ if (mAdapter != null) {
var pos = 0
for (i in 0.. Intent(requireActivity(), SettingsActivity::class.java)
- else -> requireActivity().packageManager.getLaunchIntentForPackage(packageName)?.apply {
- addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- }
+ "ru.dimon6018.metrolauncher" -> Intent(
+ requireActivity(),
+ SettingsActivity::class.java
+ )
+
+ else -> requireActivity().packageManager.getLaunchIntentForPackage(packageName)
+ ?.apply {
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ }
}
intent?.let { startActivity(it) }
}
}
- inner class NewStartAdapter(val context: Context, var list: MutableList): RecyclerView.Adapter(), ItemTouchHelperAdapter {
+
+ inner class NewStartAdapter(val context: Context, var list: MutableList) :
+ RecyclerView.Adapter(), ItemTouchHelperAdapter {
val defaultTileType: Int = 0
val spaceType: Int = -1
+ var selectedItem: Tile? = null
+
private val accentColor: Int by lazy { Utils.launcherAccentColor(requireActivity().theme) }
var isEditMode = false
@@ -465,6 +522,7 @@ class Start: Fragment(), OnStartDragListener {
init {
setHasStableIds(true)
}
+
fun setData(newData: MutableList) {
val diffUtilCallback = DiffUtilCallback(list, newData)
val diffResult = DiffUtil.calculateDiff(diffUtilCallback, false)
@@ -477,24 +535,61 @@ class Start: Fragment(), OnStartDragListener {
Log.d("EditMode", "enter edit mode")
(requireActivity() as Main).configureViewPagerScroll(false)
addCallback()
- binding.startTiles.animate().scaleX(0.9f).scaleY(0.9f).setDuration(300).start()
isEditMode = true
+ for (i in 0..binding.startTiles.childCount) {
+ val holder = binding.startTiles.findViewHolderForAdapterPosition(i) ?: continue
+ if (holder.itemViewType == -1) continue
+ holder.itemView.animate().scaleX(0.9f).scaleY(0.9f).setDuration(300).start()
+ }
+ startEditModeAnim()
}
+
+ fun startEditModeAnim() {
+ for (i in 0..binding.startTiles.childCount) {
+ val holder = binding.startTiles.findViewHolderForAdapterPosition(i) ?: continue
+ if (holder.itemViewType == -1) continue
+ animateItemEditMode(holder.itemView, i)
+ }
+ }
+
fun disableEditMode() {
Log.d("EditMode", "exit edit mode")
removeCallback()
(requireActivity() as Main).configureViewPagerScroll(true)
- binding.startTiles.animate().scaleX(1f).scaleY(1f).setDuration(300).start()
isEditMode = false
+
+ for (i in 0..binding.startTiles.childCount) {
+ val holder = binding.startTiles.findViewHolderForAdapterPosition(i) ?: continue
+ if (holder.itemViewType == -1) continue
+ holder.itemView.clearAnimation()
+ holder.itemView.animate().scaleX(1f).scaleY(1f).setDuration(300).start()
+ holder.itemView.animate().setDuration(300).translationY(0f).translationX(0f).start()
+ }
}
+
+ // tile animation in edit mode
+ fun animateItemEditMode(view: View, position: Int) {
+ if (!isEditMode || list[position] == selectedItem) return
+ val rad = 5
+ val randomX = Random.nextFloat() * 2 * rad - rad
+ val randomY = Random.nextFloat() * 2 * rad - rad
+ view.animate().setDuration(1000).translationX(randomX).translationY(randomY)
+ .setInterpolator(
+ LinearInterpolator()
+ ).withEndAction {
+ animateItemEditMode(view, position)
+ }.start()
+ }
+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val inflater = LayoutInflater.from(parent.context)
- return when(viewType) {
+ return when (viewType) {
defaultTileType -> TileViewHolder(TileBinding.inflate(inflater, parent, false))
spaceType -> SpaceViewHolder(SpaceTileBinding.inflate(inflater, parent, false))
else -> SpaceViewHolder(SpaceTileBinding.inflate(inflater, parent, false))
}
}
+
override fun getItemCount(): Int {
return list.size
}
@@ -502,21 +597,34 @@ class Start: Fragment(), OnStartDragListener {
override fun getItemId(position: Int): Long {
return list[position].id!!
}
+
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
- when(holder.itemViewType) {
- defaultTileType -> bindDefaultTile(holder as TileViewHolder, list[position])
+ when (holder.itemViewType) {
+ defaultTileType -> bindDefaultTile(
+ holder as TileViewHolder,
+ list[position],
+ position
+ )
}
}
- private fun bindDefaultTile(holder: TileViewHolder, item: Tile) {
+
+ private fun bindDefaultTile(holder: TileViewHolder, item: Tile, position: Int) {
setTileSize(item, holder.binding.tileLabel)
setTileIconSize(holder.binding.tileIcon, item.tileSize, context.resources)
setTileColor(holder, item)
setTileIcon(holder.binding.tileIcon, item)
setTileText(holder.binding.tileLabel, item)
+ setTileAnimation(holder.itemView, position)
+ }
+
+ private fun setTileAnimation(view: View, pos: Int) {
+ animateItemEditMode(view, pos)
}
+
private fun setTileText(textView: MaterialTextView, item: Tile) {
textView.text = item.tileLabel
}
+
private fun setTileIcon(imageView: ImageView, item: Tile) {
imageView.load(mainViewModel.getIconFromCache(item.tilePackage)) {
listener(onError = { request: ImageRequest, error: ErrorResult ->
@@ -526,30 +634,37 @@ class Start: Fragment(), OnStartDragListener {
})
}
}
+
private fun setTileIconSize(imageView: ImageView, tileSize: String, res: Resources) {
imageView.layoutParams.apply {
when (tileSize) {
"small" -> {
- val size = if (PREFS.isMoreTilesEnabled) res.getDimensionPixelSize(R.dimen.tile_small_moreTiles_on) else res.getDimensionPixelSize(
- R.dimen.tile_small_moreTiles_off
- )
+ val size =
+ if (PREFS.isMoreTilesEnabled) res.getDimensionPixelSize(R.dimen.tile_small_moreTiles_on) else res.getDimensionPixelSize(
+ R.dimen.tile_small_moreTiles_off
+ )
width = size
height = size
}
+
"medium" -> {
- val size = if (PREFS.isMoreTilesEnabled) res.getDimensionPixelSize(R.dimen.tile_medium_moreTiles_on) else res.getDimensionPixelSize(
- R.dimen.tile_medium_moreTiles_off
- )
+ val size =
+ if (PREFS.isMoreTilesEnabled) res.getDimensionPixelSize(R.dimen.tile_medium_moreTiles_on) else res.getDimensionPixelSize(
+ R.dimen.tile_medium_moreTiles_off
+ )
width = size
height = size
}
+
"big" -> {
- val size = if (PREFS.isMoreTilesEnabled) res.getDimensionPixelSize(R.dimen.tile_big_moreTiles_on) else res.getDimensionPixelSize(
- R.dimen.tile_big_moreTiles_off
- )
+ val size =
+ if (PREFS.isMoreTilesEnabled) res.getDimensionPixelSize(R.dimen.tile_big_moreTiles_on) else res.getDimensionPixelSize(
+ R.dimen.tile_big_moreTiles_off
+ )
width = size
height = size
}
+
else -> {
width = res.getDimensionPixelSize(R.dimen.tile_medium_moreTiles_off)
height = res.getDimensionPixelSize(R.dimen.tile_medium_moreTiles_off)
@@ -557,36 +672,44 @@ class Start: Fragment(), OnStartDragListener {
}
}
}
+
private fun setTileColor(holder: TileViewHolder, item: Tile) {
- if (item.tileColor != -1) {
- holder.binding.container.setBackgroundColor(
- getTileColorFromPrefs(
- item.tileColor!!,
- context
+ if (!PREFS.isWallpaperEnabled) {
+ if (item.tileColor != -1) {
+ holder.binding.container.setBackgroundColor(
+ getTileColorFromPrefs(
+ item.tileColor!!,
+ context
+ )
)
- )
- } else {
- holder.binding.container.setBackgroundColor(accentColorFromPrefs(context))
+ } else {
+ holder.binding.container.setBackgroundColor(accentColorFromPrefs(context))
+ }
}
}
+
private fun setTileSize(item: Tile, mTextView: MaterialTextView) {
mTextView.apply {
when (item.tileSize) {
"small" -> visibility = View.GONE
- "medium" -> visibility = if (!PREFS.isMoreTilesEnabled) View.VISIBLE else View.GONE
+ "medium" -> visibility =
+ if (!PREFS.isMoreTilesEnabled) View.VISIBLE else View.GONE
+
"big" -> visibility = View.VISIBLE
}
}
}
+
override fun getItemViewType(position: Int): Int {
- return when(list[position].tileType) {
+ return when (list[position].tileType) {
-1 -> spaceType
0 -> defaultTileType
else -> spaceType
}
}
+
override fun onItemMove(fromPosition: Int, toPosition: Int) {
- if(!isEditMode) {
+ if (!isEditMode) {
enableEditMode()
return
}
@@ -596,8 +719,9 @@ class Start: Fragment(), OnStartDragListener {
list.add(toPosition, list.removeAt(fromPosition))
notifyItemMoved(fromPosition, toPosition)
}
+
override fun onItemDismiss(position: Int) {
- if(!isEditMode) return
+ if (!isEditMode) return
notifyItemChanged(position)
}
@@ -611,16 +735,27 @@ class Start: Fragment(), OnStartDragListener {
newData.add(item)
}
mainViewModel.getTileDao().updateAllTiles(newData)
+ withContext(mainDispatcher) {
+ startEditModeAnim()
+ }
}
}
+
+ // A popup window that shows the tile buttons (resize, unpin, customize)
private fun showTilePopupWindow(holder: TileViewHolder, item: Tile, position: Int) {
binding.startTiles.isScrollEnabled = false
- val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
- val popupView: View = inflater.inflate(if(item.tileSize == "small" && PREFS.isMoreTilesEnabled) R.layout.tile_window_small else R.layout.tile_window, holder.itemView as ViewGroup, false)
+ holder.itemView.clearAnimation()
+ val inflater =
+ context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+ val popupView: View = inflater.inflate(
+ if (item.tileSize == "small" && PREFS.isMoreTilesEnabled) R.layout.tile_window_small else R.layout.tile_window,
+ holder.itemView as ViewGroup,
+ false
+ )
var width = holder.itemView.width
var height = holder.itemView.height
- if(item.tileSize == "small") {
- width += if(PREFS.isMoreTilesEnabled) 75 else 50
+ if (item.tileSize == "small") {
+ width += if (PREFS.isMoreTilesEnabled) 75 else 50
height += 50
}
val popupWindow = PopupWindow(popupView, width, height, true)
@@ -630,23 +765,53 @@ class Start: Fragment(), OnStartDragListener {
val remove = popupView.findViewById(R.id.remove)
popupWindow.setOnDismissListener {
binding.startTiles.isScrollEnabled = true
+ selectedItem = null
+ animateItemEditMode(holder.itemView, position)
}
- popupWindow.showAsDropDown(holder.itemView, if(PREFS.isMoreTilesEnabled && item.tileSize == "small") -width / 5 else 0, -height, Gravity.CENTER)
+ popupWindow.showAsDropDown(
+ holder.itemView,
+ if (PREFS.isMoreTilesEnabled && item.tileSize == "small") -width / 5 else 0,
+ -height,
+ Gravity.CENTER
+ )
resizeIcon.apply {
- when(item.tileSize) {
+ when (item.tileSize) {
"small" -> {
rotation = 45f
- setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_arrow_right))
+ setImageDrawable(
+ ContextCompat.getDrawable(
+ requireContext(),
+ R.drawable.ic_arrow_right
+ )
+ )
}
+
"medium" -> {
rotation = 0f
- setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_arrow_right))
+ setImageDrawable(
+ ContextCompat.getDrawable(
+ requireContext(),
+ R.drawable.ic_arrow_right
+ )
+ )
}
+
"big" -> {
rotation = 45f
- setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_arrow_up))
+ setImageDrawable(
+ ContextCompat.getDrawable(
+ requireContext(),
+ R.drawable.ic_arrow_up
+ )
+ )
}
- else -> setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_arrow_right))
+
+ else -> setImageDrawable(
+ ContextCompat.getDrawable(
+ requireContext(),
+ R.drawable.ic_arrow_right
+ )
+ )
}
}
resize.setOnClickListener {
@@ -677,33 +842,49 @@ class Start: Fragment(), OnStartDragListener {
popupWindow.dismiss()
}
}
+
+ // The bottom panel with tile settings, which rises from the bottom
fun showSettingsBottomSheet(item: Tile) {
val bottomsheet = BottomSheetDialog(context)
bottomsheet.setContentView(R.layout.start_tile_settings_bottomsheet)
bottomsheet.dismissWithAnimation = true
- val bottomSheetInternal = bottomsheet.findViewById(com.google.android.material.R.id.design_bottom_sheet)
- BottomSheetBehavior.from(bottomSheetInternal!!).peekHeight = context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_size)
+ val bottomSheetInternal =
+ bottomsheet.findViewById(com.google.android.material.R.id.design_bottom_sheet)
+ BottomSheetBehavior.from(bottomSheetInternal!!).peekHeight =
+ context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_size)
configureTileBottomSheet(bottomSheetInternal, bottomsheet, item)
bottomsheet.show()
}
- private fun configureTileBottomSheet(bottomSheetInternal: View, bottomsheet: BottomSheetDialog, item: Tile) {
+
+ // creating the interface of the bottom panel is done here
+ private fun configureTileBottomSheet(
+ bottomSheetInternal: View,
+ bottomsheet: BottomSheetDialog,
+ item: Tile
+ ) {
val label = bottomSheetInternal.findViewById(R.id.appLabelSheet)
val colorSub = bottomSheetInternal.findViewById(R.id.chooseColorSub)
- val removeColor = bottomSheetInternal.findViewById(R.id.chooseColorRemove)
+ val removeColor =
+ bottomSheetInternal.findViewById(R.id.chooseColorRemove)
val uninstall = bottomSheetInternal.findViewById(R.id.uninstallApp)
- val uninstallLabel = bottomSheetInternal.findViewById(R.id.uninstall_label)
+ val uninstallLabel =
+ bottomSheetInternal.findViewById(R.id.uninstall_label)
val changeLabel = bottomSheetInternal.findViewById(R.id.editAppLabel)
val changeColor = bottomSheetInternal.findViewById(R.id.editTileColor)
val editor = bottomSheetInternal.findViewById(R.id.textEdit)
val textFiled = bottomSheetInternal.findViewById(R.id.textField)
val labelLayout = bottomSheetInternal.findViewById(R.id.changeLabelLayout)
- val labelChangeBtn = bottomSheetInternal.findViewById(R.id.labelChange)
- val editLabelText = bottomSheetInternal.findViewById(R.id.editAppLabelText)
+ val labelChangeBtn =
+ bottomSheetInternal.findViewById(R.id.labelChange)
+ val editLabelText =
+ bottomSheetInternal.findViewById(R.id.editAppLabelText)
val appInfo = bottomSheetInternal.findViewById(R.id.appInfo)
- val chooseTileColor = bottomSheetInternal.findViewById(R.id.choose_tile_color)
- val appInfoLabel = bottomSheetInternal.findViewById(R.id.app_info_label)
+ val chooseTileColor =
+ bottomSheetInternal.findViewById(R.id.choose_tile_color)
+ val appInfoLabel =
+ bottomSheetInternal.findViewById(R.id.app_info_label)
- (if(PREFS.customLightFontPath != null) customLightFont else customFont)?.let {
+ (if (PREFS.customLightFontPath != null) customLightFont else customFont)?.let {
label.typeface = it
colorSub.typeface = it
removeColor.typeface = it
@@ -717,23 +898,32 @@ class Start: Fragment(), OnStartDragListener {
editLabelText.setOnClickListener {
labelLayout.visibility = View.VISIBLE
}
- val originalLabel = context.packageManager.getApplicationLabel(context.packageManager.getApplicationInfo(item.tilePackage, 0)).toString()
+ val originalLabel = context.packageManager.getApplicationLabel(
+ context.packageManager.getApplicationInfo(
+ item.tilePackage,
+ 0
+ )
+ ).toString()
label.text = item.tileLabel
editor.setText(item.tileLabel)
editor.hint = originalLabel
- if(item.tileColor == -1) {
+ if (item.tileColor == -1) {
colorSub.visibility = View.GONE
removeColor.visibility = View.GONE
} else {
colorSub.setTextColor(getTileColorFromPrefs(item.tileColor!!, context))
- colorSub.text = getString(R.string.tileSettings_color_sub, getTileColorName(item.tileColor!!, context))
+ colorSub.text = getString(
+ R.string.tileSettings_color_sub,
+ getTileColorName(item.tileColor!!, context)
+ )
}
changeLabel.setOnClickListener {
labelLayout.visibility = View.VISIBLE
}
labelChangeBtn.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
- item.tileLabel =if(editor.text.toString() == "") originalLabel else editor.text.toString()
+ item.tileLabel =
+ if (editor.text.toString() == "") originalLabel else editor.text.toString()
mainViewModel.getTileDao().updateTile(item)
}
bottomsheet.dismiss()
@@ -756,24 +946,41 @@ class Start: Fragment(), OnStartDragListener {
bottomsheet.dismiss()
}
appInfo.setOnClickListener {
- startActivity(Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:" + item.tilePackage)))
+ startActivity(
+ Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(
+ Uri.parse(
+ "package:" + item.tilePackage
+ )
+ )
+ )
bottomsheet.dismiss()
}
}
+
+ // Default tile
@SuppressLint("ClickableViewAccessibility")
- inner class TileViewHolder(val binding: TileBinding) : RecyclerView.ViewHolder(binding.root), ItemTouchHelperViewHolder {
+ inner class TileViewHolder(val binding: TileBinding) :
+ RecyclerView.ViewHolder(binding.root), ItemTouchHelperViewHolder {
private val gestureDetector: GestureDetector =
GestureDetector(context, object : SimpleOnGestureListener() {
override fun onLongPress(e: MotionEvent) {
handleLongClick()
}
+
override fun onSingleTapUp(e: MotionEvent): Boolean {
handleClick()
return true
}
})
+
init {
+ if (PREFS.isWallpaperEnabled) {
+ itemView.viewTreeObserver.addOnPreDrawListener {
+ if (!isViewPagerScrolling) (itemView.parent as? StartRecyclerView)?.invalidate()
+ true
+ }
+ }
binding.cardContainer.apply {
if (PREFS.coloredStroke) strokeColor = accentColor
}
@@ -788,7 +995,7 @@ class Start: Fragment(), OnStartDragListener {
val bottom = view.bottom
isTopLeft =
- x >= left && x <= left + view.width / 2 && y >= top && y <= top + view.height/ 2
+ x >= left && x <= left + view.width / 2 && y >= top && y <= top + view.height / 2
isTopRight =
x >= (left + view.width / 2) && x <= right && y >= top && y <= top + view.height / 2
@@ -802,14 +1009,16 @@ class Start: Fragment(), OnStartDragListener {
return@setOnTouchListener gestureDetector.onTouchEvent(event)
}
}
- if(PREFS.customFontInstalled) customFont?.let { binding.tileLabel.typeface = it }
+ if (PREFS.customFontInstalled) customFont?.let { binding.tileLabel.typeface = it }
}
+
private fun handleClick() {
val item = list[absoluteAdapterPosition]
if (isEditMode) {
+ selectedItem = item
showTilePopupWindow(this@TileViewHolder, item, absoluteAdapterPosition)
} else {
- if(PREFS.isTilesAnimEnabled) {
+ if (PREFS.isTilesAnimEnabled) {
lifecycleScope.launch {
animateTiles(true, absoluteAdapterPosition, item.tilePackage)
}
@@ -818,12 +1027,15 @@ class Start: Fragment(), OnStartDragListener {
}
}
}
+
private fun handleLongClick() {
- if(!isEditMode && !PREFS.isStartBlocked) enableEditMode()
+ if (!isEditMode && !PREFS.isStartBlocked) enableEditMode()
}
+
override fun onItemSelected() {}
override fun onItemClear() {}
}
+
/**inner class WeatherTileViewHolder(v: View) : RecyclerView.ViewHolder(v), ItemTouchHelperViewHolder {
val mCardContainer: MaterialCardView = v.findViewById(R.id.cardContainer)
val mContainer: FrameLayout = v.findViewById(R.id.container)
@@ -835,7 +1047,8 @@ class Start: Fragment(), OnStartDragListener {
override fun onItemSelected() {}
override fun onItemClear() {}
}**/
- inner class SpaceViewHolder(binding: SpaceTileBinding) : RecyclerView.ViewHolder(binding.root) {
+ inner class SpaceViewHolder(binding: SpaceTileBinding) :
+ RecyclerView.ViewHolder(binding.root) {
init {
itemView.setOnClickListener {
if (isEditMode) disableEditMode()
@@ -843,26 +1056,34 @@ class Start: Fragment(), OnStartDragListener {
}
}
}
- class DiffUtilCallback(private val old: List, private val new: List) : DiffUtil.Callback() {
+
+ class DiffUtilCallback(private val old: List, private val new: List) :
+ DiffUtil.Callback() {
override fun getOldListSize(): Int {
return old.size
}
+
override fun getNewListSize(): Int {
return new.size
}
+
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return old[oldItemPosition] == new[newItemPosition]
}
+
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return old[oldItemPosition].tilePackage == new[newItemPosition].tilePackage
}
}
+
+ // Responsible for tile color selection
class AccentDialog : DialogFragment() {
private lateinit var item: Tile
private lateinit var dao: TileDao
private lateinit var mAdapter: NewStartAdapter
+ //available colors
private val viewIds = arrayOf(
R.id.choose_color_lime, R.id.choose_color_green, R.id.choose_color_emerald,
R.id.choose_color_cyan, R.id.choose_color_teal, R.id.choose_color_cobalt,
@@ -877,35 +1098,48 @@ class Start: Fragment(), OnStartDragListener {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.AppTheme_FullScreenDialog)
}
+
fun configure(i: Tile, a: NewStartAdapter, d: TileDao) {
item = i
dao = d
mAdapter = a
}
+
override fun onStart() {
super.onStart()
dialog?.apply {
- window!!.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
+ window!!.setLayout(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT
+ )
setTitle("TILE COLOR")
}
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
super.onCreateView(inflater, container, savedInstanceState)
return inflater.inflate(R.layout.accent_dialog, container, false)
}
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val back = view.findViewById(R.id.back_accent_menu)
back.setOnClickListener { dismiss() }
- for(i in 0..(viewIds[i]), i)
}
}
+
private fun setOnClick(colorView: View, value: Int) {
colorView.setOnClickListener {
updateTileColor(value)
}
}
+
private fun updateTileColor(color: Int) {
lifecycleScope.launch(Dispatchers.IO) {
item.tileColor = color
@@ -915,6 +1149,7 @@ class Start: Fragment(), OnStartDragListener {
}
}
}
+
override fun dismiss() {
mAdapter.notifyItemChanged(item.tilePosition!!)
mAdapter.showSettingsBottomSheet(item)
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodDetector.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodDetector.kt
index 52c7353..ff7000a 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodDetector.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodDetector.kt
@@ -11,15 +11,17 @@ class BsodDetector : Thread.UncaughtExceptionHandler {
Log.e("BSOD", "Detected critical error. See: ${e.stackTraceToString()}")
openErrorActivity(e)
}
+
private fun openErrorActivity(e: Throwable) {
val intent = Intent(cntxt, BsodScreen::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- intent.putExtra("stacktrace",e.stackTraceToString())
+ intent.putExtra("stacktrace", e.stackTraceToString())
intent.putExtra("errorCode", e.toString())
cntxt!!.startActivity(intent)
exitProcess(1)
}
+
companion object {
@SuppressLint("StaticFieldLeak")
var cntxt: Context? = null
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodScreen.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodScreen.kt
index 3618465..3c0c715 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodScreen.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/BsodScreen.kt
@@ -46,10 +46,13 @@ class BsodScreen : AppCompatActivity() {
val code = intent.extras?.getString("errorCode")
val errCode = "\nIf vou call a support person. aive them this info:\n" +
"Stop code: $code"
- val error = "Your launcher ran into a problem and needs to restart. We're just collecting some error info, and then we'll restart for you.\n " + model + brand + android + name + intent.extras?.getString("stacktrace") + errCode
+ val error =
+ "Your launcher ran into a problem and needs to restart. We're just collecting some error info, and then we'll restart for you.\n " + model + brand + android + name + intent.extras?.getString(
+ "stacktrace"
+ ) + errCode
Log.e("BSOD", error)
saveError(error, db!!)
- if(PREFS.bsodOutputEnabled) {
+ if (PREFS.bsodOutputEnabled) {
withContext(Dispatchers.Main) {
val errorTextView = findViewById(R.id.bsodDetailsText)
errorTextView.text = error
@@ -69,10 +72,12 @@ class BsodScreen : AppCompatActivity() {
applyWindowInsets(layout)
}
+
override fun onStart() {
super.onStart()
Handler(Looper.getMainLooper()).postDelayed({ restartApplication() }, 3000)
}
+
private fun restartApplication() {
val intent = Intent(this, Main::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/Recovery.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/Recovery.kt
index 7825032..d4f11c6 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/Recovery.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/Recovery.kt
@@ -7,7 +7,7 @@ import ru.dimon6018.metrolauncher.Main
import ru.dimon6018.metrolauncher.R
import ru.dimon6018.metrolauncher.databinding.RecoveryMainScreenBinding
-class Recovery: AppCompatActivity() {
+class Recovery : AppCompatActivity() {
private lateinit var binding: RecoveryMainScreenBinding
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/RecoveryOptions.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/RecoveryOptions.kt
index b9b7fea..027ca05 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/RecoveryOptions.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/bsod/recovery/RecoveryOptions.kt
@@ -20,7 +20,7 @@ import ru.dimon6018.metrolauncher.content.settings.SettingsActivity
import ru.dimon6018.metrolauncher.databinding.RecoveryOptionsScreenBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.downloadUpdate
-class RecoveryOptions: AppCompatActivity() {
+class RecoveryOptions : AppCompatActivity() {
private lateinit var binding: RecoveryOptionsScreenBinding
@@ -39,12 +39,16 @@ class RecoveryOptions: AppCompatActivity() {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://google.com/")))
}
binding.launcherRefreshCard.setOnClickListener {
- if(checkStoragePermissions()) {
- if(areNotificationsEnabled(NotificationManagerCompat.from(this))) {
+ if (checkStoragePermissions()) {
+ if (areNotificationsEnabled(NotificationManagerCompat.from(this))) {
PREFS.reset()
downloadUpdate(this)
} else {
- Toast.makeText(this, getString(R.string.allow_notifications_recovery_error), Toast.LENGTH_LONG).show()
+ Toast.makeText(
+ this,
+ getString(R.string.allow_notifications_recovery_error),
+ Toast.LENGTH_LONG
+ ).show()
openSettings()
}
} else {
@@ -52,12 +56,14 @@ class RecoveryOptions: AppCompatActivity() {
}
}
}
+
private fun openSettings() {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null)
intent.setData(uri)
startActivity(intent)
}
+
private fun areNotificationsEnabled(noman: NotificationManagerCompat) = when {
noman.areNotificationsEnabled().not() -> false
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> {
@@ -65,8 +71,10 @@ class RecoveryOptions: AppCompatActivity() {
channel.importance == NotificationManager.IMPORTANCE_NONE
} == null
}
+
else -> true
}
+
private fun checkStoragePermissions(): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Environment.isExternalStorageManager()
@@ -78,9 +86,12 @@ class RecoveryOptions: AppCompatActivity() {
read == PackageManager.PERMISSION_GRANTED && write == PackageManager.PERMISSION_GRANTED
}
}
+
private fun getPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).setData(Uri.parse(String.format("package:%s", packageName)))
+ val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).setData(
+ Uri.parse(String.format("package:%s", packageName))
+ )
startActivity(intent)
} else {
ActivityCompat.requestPermissions(
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/ExperimentPrefs.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/ExperimentPrefs.kt
index ce9a09c..9cc69ae 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/ExperimentPrefs.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/ExperimentPrefs.kt
@@ -7,6 +7,6 @@ class ExperimentPrefs(context: Context) {
//val expPrefs: SharedPreferences = context.getSharedPreferences(FILE_NAME_EXP, 0)
companion object {
- // const val FILE_NAME_EXP = "ExperimentPrefs"
+ // const val FILE_NAME_EXP = "ExperimentPrefs"
}
}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt
index 045c82f..220b963 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt
@@ -58,16 +58,17 @@ class Prefs(context: Context) {
init {
prefs = context.getSharedPreferences(fileName, 0)
}
+
fun reset() {
prefs.edit().clear().apply()
}
- var isWallpaperUsed: Boolean
+ var isWallpaperEnabled: Boolean
get() = prefs.getBoolean(wallpaperPref, false)
set(value) = prefs.edit().putBoolean(wallpaperPref, value).apply()
var isMoreTilesEnabled: Boolean
- get() = prefs.getBoolean(showMoreTilesPref, false)
+ get() = prefs.getBoolean(showMoreTilesPref, false)
set(value) = prefs.edit().putBoolean(showMoreTilesPref, value).apply()
var maxCrashLogs: Int
@@ -83,7 +84,7 @@ class Prefs(context: Context) {
set(value) = prefs.edit().putBoolean(feedbackPref, value).apply()
var updateState: Int
- get() = prefs.getInt(updateStatePref, 0)
+ get() = prefs.getInt(updateStatePref, 0)
// 0 - nothing
// 1 - checking
// 2 - downloading
@@ -95,7 +96,7 @@ class Prefs(context: Context) {
set(value) = prefs.edit().putInt(updateStatePref, value).apply()
var updateProgressLevel: Int
- get() = prefs.getInt(updatePercentagePref, 0)
+ get() = prefs.getInt(updatePercentagePref, 0)
set(value) = prefs.edit().putInt(updatePercentagePref, value).apply()
var isAutoUpdateEnabled: Boolean
@@ -103,7 +104,7 @@ class Prefs(context: Context) {
set(value) = prefs.edit().putBoolean(autoUpdatePref, value).apply()
var isUpdateNotificationEnabled: Boolean
- get() = prefs.getBoolean(updateNotificationPref, false)
+ get() = prefs.getBoolean(updateNotificationPref, false)
set(value) = prefs.edit().putBoolean(updateNotificationPref, value).apply()
// is only used to save update data
@@ -145,11 +146,11 @@ class Prefs(context: Context) {
.putInt("previous_accent_color", prefs.getInt(accentColorPref, 5))
.apply()
prefs.edit()
- .putInt(accentColorPref, color)
- .apply()
+ .putInt(accentColorPref, color)
+ .apply()
}
var launcherState: Int
- get() = prefs.getInt(launcherStatePref, 0)
+ get() = prefs.getInt(launcherStatePref, 0)
// 0 - OOBE
// 1 - nothing
// 2 - OOBE - selecting the type of settings (recommended or customize)
@@ -190,7 +191,7 @@ class Prefs(context: Context) {
// 0 - windows (default)
// 1 - windows old
// 2 - android
- set(value) = prefs.edit().putInt(bottomBarIconPref, value).apply()
+ set(value) = prefs.edit().putInt(bottomBarIconPref, value).apply()
var isSearchBarEnabled: Boolean
get() = prefs.getBoolean(searchBarPref, false)
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSOD.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSOD.kt
index 53f4580..ab78407 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSOD.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSOD.kt
@@ -9,11 +9,13 @@ import androidx.room.RoomDatabase
abstract class BSOD : RoomDatabase() {
abstract fun getDao(): BSODDao
+
companion object {
private const val DB_BSOD: String = "bsodList.db"
fun getData(context: Context): BSOD {
- return Room.databaseBuilder(context, BSOD::class.java, DB_BSOD).fallbackToDestructiveMigration().build()
+ return Room.databaseBuilder(context, BSOD::class.java, DB_BSOD)
+ .fallbackToDestructiveMigration().build()
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODDao.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODDao.kt
index a262389..89e6802 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODDao.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODDao.kt
@@ -9,10 +9,13 @@ import androidx.room.Query
interface BSODDao {
@Insert
fun insertLog(bsod: BSODEntity)
+
@Delete
fun removeLog(bsod: BSODEntity)
+
@Query("SELECT * FROM bsod_list")
fun getBsodList(): List
+
@Query("SELECT * FROM bsod_list WHERE pos = :pos")
fun getBSOD(pos: Int): BSODEntity
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODEntity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODEntity.kt
index ccbf9a8..67835b5 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODEntity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/bsod/BSODEntity.kt
@@ -4,8 +4,8 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
-@Entity( tableName = "bsod_list" )
-data class BSODEntity (
+@Entity(tableName = "bsod_list")
+data class BSODEntity(
@PrimaryKey(autoGenerate = true)
val id: Int? = null,
@ColumnInfo
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt
index 50fbc97..6dd5489 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt
@@ -4,8 +4,8 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
-@Entity( tableName = "tiles" )
-data class Tile (
+@Entity(tableName = "tiles")
+data class Tile(
@PrimaryKey
var tilePosition: Int? = null,
var id: Long? = null,
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt
index c4424ad..509c951 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileDao.kt
@@ -12,22 +12,31 @@ import androidx.room.Update
interface TileDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun addTile(app: Tile)
+
@Delete
suspend fun deleteTile(app: Tile)
+
@Update
suspend fun updateTile(app: Tile)
+
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun updateAllTiles(apps: MutableList)
+
@Query("SELECT * FROM tiles")
fun getTilesLiveData(): LiveData>
+
@Query("SELECT * FROM tiles")
suspend fun getTilesList(): MutableList
+
@Query("SELECT * FROM tiles WHERE tileType != -1") //-1
suspend fun getUserTiles(): MutableList
+
@Query("SELECT * FROM tiles WHERE tilePosition = :pos")
fun getTileFromPosition(pos: Int): Tile
+
@Query("SELECT * FROM tiles WHERE id = :id")
fun getTileByID(id: Int): Tile
+
@Query("DELETE FROM tiles")
fun deleteAllTiles()
}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileData.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileData.kt
index 6b270fa..b671553 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileData.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/TileData.kt
@@ -6,7 +6,7 @@ import androidx.room.Room
import androidx.room.RoomDatabase
@Database(entities = [Tile::class], version = 2)
-abstract class TileData: RoomDatabase() {
+abstract class TileData : RoomDatabase() {
abstract fun getTileDao(): TileDao
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/WelcomeActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/WelcomeActivity.kt
index 9191231..1858f32 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/WelcomeActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/WelcomeActivity.kt
@@ -13,12 +13,12 @@ import ru.dimon6018.metrolauncher.databinding.OobeMainScreenBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class WelcomeActivity: AppCompatActivity() {
+class WelcomeActivity : AppCompatActivity() {
private lateinit var binding: OobeMainScreenBinding
override fun onCreate(savedInstanceState: Bundle?) {
- when(PREFS.appTheme) {
+ when (PREFS.appTheme) {
0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
@@ -38,6 +38,7 @@ class WelcomeActivity: AppCompatActivity() {
}
WindowCompat.setDecorFitsSystemWindows(window, false)
}
+
fun setText(newText: String) {
binding.appbarTextView.text = newText
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AlmostDoneFragment.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AlmostDoneFragment.kt
index c8b7e0f..13d2446 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AlmostDoneFragment.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AlmostDoneFragment.kt
@@ -13,7 +13,7 @@ import ru.dimon6018.metrolauncher.content.oobe.WelcomeActivity
import ru.dimon6018.metrolauncher.databinding.OobeFragmentAlmostdoneBinding
import kotlin.system.exitProcess
-class AlmostDoneFragment: Fragment() {
+class AlmostDoneFragment : Fragment() {
private var _binding: OobeFragmentAlmostdoneBinding? = null
private val binding get() = _binding!!
@@ -23,8 +23,10 @@ class AlmostDoneFragment: Fragment() {
super.onCreate(savedInstanceState)
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View {
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
_binding = OobeFragmentAlmostdoneBinding.inflate(inflater, container, false)
(requireActivity() as WelcomeActivity).setText(getString(R.string.welcomeAlmostDone))
binding.next.setOnClickListener {
@@ -33,16 +35,18 @@ class AlmostDoneFragment: Fragment() {
}
return binding.root
}
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
+
private fun enterAnimation() {
val main = binding.root
val animatorSet = AnimatorSet()
animatorSet.playTogether(
- ObjectAnimator.ofFloat(main, "translationX", 1000f, 0f),
- ObjectAnimator.ofFloat(main, "alpha", 0f, 1f)
+ ObjectAnimator.ofFloat(main, "translationX", 1000f, 0f),
+ ObjectAnimator.ofFloat(main, "alpha", 0f, 1f)
)
animatorSet.setDuration(300)
animatorSet.start()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AppsFragment.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AppsFragment.kt
index 82dfa00..413c7f5 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AppsFragment.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/AppsFragment.kt
@@ -33,7 +33,7 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.generateRandomTi
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.setUpApps
import kotlin.random.Random
-class AppsFragment: Fragment() {
+class AppsFragment : Fragment() {
private val hashCache = SparseArrayCompat()
@@ -49,10 +49,12 @@ class AppsFragment: Fragment() {
binding.oobeAppsLoadingBar.showProgressBar()
return binding.root
}
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val call = TileData.getTileData(requireContext()).getTileDao()
@@ -74,8 +76,8 @@ class AppsFragment: Fragment() {
val bmp = if (!isCustomIconsInstalled)
pm.getApplicationIcon(it.appPackage!!)
else
- iconManager?.getIconPackWithName(PREFS.iconPackPackage)
- ?.getDrawableIconForPackage(it.appPackage!!, null)
+ iconManager?.getIconPackWithName(PREFS.iconPackPackage)
+ ?.getDrawableIconForPackage(it.appPackage!!, null)
hashCache.append(it.id, bmp)
}
}
@@ -94,7 +96,7 @@ class AppsFragment: Fragment() {
}
}
binding.next.setOnClickListener {
- if(selectedItems!!.isEmpty()) {
+ if (selectedItems!!.isEmpty()) {
WPDialog(requireContext()).apply {
setTopDialog(true)
setTitle(getString(R.string.reset_warning_title))
@@ -127,6 +129,7 @@ class AppsFragment: Fragment() {
}
}
}
+
private fun addApps(call: TileDao) {
lifecycleScope.launch(Dispatchers.Default) {
var pos = 0
@@ -149,10 +152,11 @@ class AppsFragment: Fragment() {
}
}
}
+
private fun enterAnimation(exit: Boolean) {
val main = binding.root
val animatorSet = AnimatorSet()
- if(exit) {
+ if (exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, -1000f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
@@ -171,6 +175,7 @@ class AppsFragment: Fragment() {
enterAnimation(false)
super.onResume()
}
+
companion object {
var selectedItems: MutableList? = null
var latestItem: Int? = null
@@ -180,12 +185,19 @@ class AppsFragment: Fragment() {
RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
- return OOBEAppHolder(OobeAppItemBinding.inflate(LayoutInflater.from(parent.context), parent, false))
+ return OOBEAppHolder(
+ OobeAppItemBinding.inflate(
+ LayoutInflater.from(parent.context),
+ parent,
+ false
+ )
+ )
}
override fun getItemCount(): Int {
return adapterApps.size
}
+
@SuppressLint("NotifyDataSetChanged")
fun selectAll() {
adapterApps.forEach {
@@ -196,6 +208,7 @@ class AppsFragment: Fragment() {
}
notifyDataSetChanged()
}
+
@SuppressLint("NotifyDataSetChanged")
fun removeAll() {
adapterApps.forEach {
@@ -206,6 +219,7 @@ class AppsFragment: Fragment() {
}
notifyDataSetChanged()
}
+
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val item = adapterApps[position]
holder as OOBEAppHolder
@@ -228,5 +242,7 @@ class AppsFragment: Fragment() {
holder.binding.appCheckbox.isChecked = adapterApps[position].selected
}
}
- inner class OOBEAppHolder(val binding: OobeAppItemBinding) : RecyclerView.ViewHolder(binding.root)
+
+ inner class OOBEAppHolder(val binding: OobeAppItemBinding) :
+ RecyclerView.ViewHolder(binding.root)
}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/ConfigureFragment.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/ConfigureFragment.kt
index 892f280..3f08b36 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/ConfigureFragment.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/ConfigureFragment.kt
@@ -15,13 +15,15 @@ import ru.dimon6018.metrolauncher.R
import ru.dimon6018.metrolauncher.content.oobe.WelcomeActivity
import ru.dimon6018.metrolauncher.databinding.OobeFragmentConfBinding
-class ConfigureFragment: Fragment() {
+class ConfigureFragment : Fragment() {
private var _binding: OobeFragmentConfBinding? = null
private val binding get() = _binding!!
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View {
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
_binding = OobeFragmentConfBinding.inflate(inflater, container, false)
(requireActivity() as WelcomeActivity).setText(getString(R.string.configurePhone))
binding.back.setOnClickListener {
@@ -53,14 +55,16 @@ class ConfigureFragment: Fragment() {
}
return binding.root
}
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
+
private fun enterAnimation(exit: Boolean) {
val main = binding.root
val animatorSet = AnimatorSet()
- if(exit) {
+ if (exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, -1000f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/CustomSettingsFragment.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/CustomSettingsFragment.kt
index d2be4cf..a0fea8d 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/CustomSettingsFragment.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/CustomSettingsFragment.kt
@@ -15,13 +15,15 @@ import ru.dimon6018.metrolauncher.R
import ru.dimon6018.metrolauncher.content.oobe.WelcomeActivity
import ru.dimon6018.metrolauncher.databinding.OobeFragmentCustomPrefsBinding
-class CustomSettingsFragment: Fragment() {
+class CustomSettingsFragment : Fragment() {
private var _binding: OobeFragmentCustomPrefsBinding? = null
private val binding get() = _binding!!
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View {
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
_binding = OobeFragmentCustomPrefsBinding.inflate(inflater, container, false)
(requireActivity() as WelcomeActivity).setText(getString(R.string.configureCustomPhone))
binding.back.setOnClickListener {
@@ -44,14 +46,16 @@ class CustomSettingsFragment: Fragment() {
}
return binding.root
}
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
+
private fun enterAnimation(exit: Boolean) {
val main = binding.root
val animatorSet = AnimatorSet()
- if(exit) {
+ if (exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, -1000f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/IconPackFragment.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/IconPackFragment.kt
index 10ba7e6..fb9db05 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/IconPackFragment.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/IconPackFragment.kt
@@ -2,5 +2,4 @@ package ru.dimon6018.metrolauncher.content.oobe.fragments
import androidx.fragment.app.Fragment
-class IconPackFragment: Fragment() {
-}
\ No newline at end of file
+class IconPackFragment : Fragment()
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/WelcomeFragment.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/WelcomeFragment.kt
index facbc94..5c18c2b 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/WelcomeFragment.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/oobe/fragments/WelcomeFragment.kt
@@ -29,8 +29,10 @@ class WelcomeFragment : Fragment() {
private var _binding: OobeFragmentWelcomeBinding? = null
private val binding get() = _binding!!
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View {
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
_binding = OobeFragmentWelcomeBinding.inflate(inflater, container, false)
(requireActivity() as WelcomeActivity).setText(getString(R.string.welcomePhone))
binding.next.setOnClickListener {
@@ -42,20 +44,23 @@ class WelcomeFragment : Fragment() {
}
}
}
- if(!Application.PREFS.prefs.getBoolean("channelConfigured", false)) {
+ if (!Application.PREFS.prefs.getBoolean("channelConfigured", false)) {
UpdateWorker.setupNotificationChannels(requireActivity())
Application.PREFS.prefs.edit().putBoolean("channelConfigured", true).apply()
}
return binding.root
}
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
generatePlaceholders()
}
+
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
+
private fun generatePlaceholders() {
placeholderCoroutine.launch {
Application.PREFS.prefs.edit().putBoolean("placeholdersGenerated", true).apply()
@@ -63,10 +68,11 @@ class WelcomeFragment : Fragment() {
cancel()
}
}
+
private fun enterAnimation(exit: Boolean) {
val animatorSet = AnimatorSet()
val main = binding.root
- if(exit) {
+ if (exit) {
animatorSet.playTogether(
ObjectAnimator.ofFloat(main, "translationX", 0f, -1000f),
ObjectAnimator.ofFloat(main, "alpha", 1f, 0f),
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/Reset.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/Reset.kt
index 1ad79de..1e4b24b 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/Reset.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/Reset.kt
@@ -31,6 +31,7 @@ class Reset : AppCompatActivity() {
intent = Intent(this, WelcomeActivity::class.java)
resetPart2()
}
+
private fun resetPart2() {
lifecycleScope.launch(Dispatchers.IO) {
dbApps!!.clearAllTables()
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 cbadcf8..589dfb9 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
@@ -108,7 +108,7 @@ class SettingsActivity : AppCompatActivity() {
private var dialogActivated = false
override fun onCreate(savedInstanceState: Bundle?) {
- when(PREFS.appTheme) {
+ when (PREFS.appTheme) {
0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
@@ -125,6 +125,7 @@ class SettingsActivity : AppCompatActivity() {
prepareTip()
setupFont()
}
+
private fun setupFont() {
regularTextViewList.forEach {
customFont?.let { font ->
@@ -132,7 +133,7 @@ class SettingsActivity : AppCompatActivity() {
}
}
lightTextViewList.forEach {
- if(PREFS.customLightFontPath != null) {
+ if (PREFS.customLightFontPath != null) {
customLightFont?.let { font ->
it.typeface = font
}
@@ -146,8 +147,9 @@ class SettingsActivity : AppCompatActivity() {
binding.settings.typeface = it
}
}
+
private fun checkHome() {
- if(!isHomeApp() && isDialogEnabled && Random.nextFloat() < 0.2 && !dialogActivated) {
+ if (!isHomeApp() && isDialogEnabled && Random.nextFloat() < 0.2 && !dialogActivated) {
isDialogEnabled = false
WPDialog(this).setTopDialog(false)
.setTitle(getString(R.string.tip))
@@ -158,8 +160,13 @@ class SettingsActivity : AppCompatActivity() {
}.show()
}
}
+
private fun prepareMessage() {
- if(!PREFS.prefs.getBoolean("tipSettingsEnabled", true) && Random.nextFloat() < 0.05 && PREFS.prefs.getBoolean("messageEnabled", true)) {
+ if (!PREFS.prefs.getBoolean(
+ "tipSettingsEnabled",
+ true
+ ) && Random.nextFloat() < 0.05 && PREFS.prefs.getBoolean("messageEnabled", true)
+ ) {
dialogActivated = true
WPDialog(this).apply {
setTopDialog(true)
@@ -181,6 +188,7 @@ class SettingsActivity : AppCompatActivity() {
}
}
}
+
private fun donateDialog() {
WPDialog(this).apply {
setTopDialog(true)
@@ -191,14 +199,20 @@ class SettingsActivity : AppCompatActivity() {
dismiss()
}
setNegativeButton(getString(R.string.support)) {
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://donationalerts.com/r/queuejw")))
+ startActivity(
+ Intent(
+ Intent.ACTION_VIEW,
+ Uri.parse("https://donationalerts.com/r/queuejw")
+ )
+ )
dismiss()
}
show()
}
}
+
private fun prepareTip() {
- if(PREFS.prefs.getBoolean("tipSettingsEnabled", true)) {
+ if (PREFS.prefs.getBoolean("tipSettingsEnabled", true)) {
WPDialog(this).setTopDialog(true)
.setTitle(getString(R.string.tip))
.setMessage(getString(R.string.tipSettings))
@@ -207,21 +221,59 @@ class SettingsActivity : AppCompatActivity() {
PREFS.prefs.edit().putBoolean("tipSettingsEnabled", false).apply()
}
}
+
private fun setOnClickers() {
- setClickListener(binding.settingsInclude.themeSetting, Intent(this@SettingsActivity, ThemeSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.allAppsSetting, Intent(this@SettingsActivity, AllAppsSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.tilesSetting, Intent(this@SettingsActivity, TileSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.aboutSetting, Intent(this@SettingsActivity, AboutSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.feedbackSetting, Intent(this@SettingsActivity, FeedbackSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.updatesSetting, Intent(this@SettingsActivity, UpdateActivity::class.java))
- setClickListener(binding.settingsInclude.navbarSetting, Intent(this@SettingsActivity, NavBarSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.weatherSetting, Intent(this@SettingsActivity, WeatherSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.iconsSetting, Intent(this@SettingsActivity, IconSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.expSetting, Intent(this@SettingsActivity, ExperimentsSettingsActivity::class.java))
+ setClickListener(
+ binding.settingsInclude.themeSetting,
+ Intent(this@SettingsActivity, ThemeSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.allAppsSetting,
+ Intent(this@SettingsActivity, AllAppsSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.tilesSetting,
+ Intent(this@SettingsActivity, TileSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.aboutSetting,
+ Intent(this@SettingsActivity, AboutSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.feedbackSetting,
+ Intent(this@SettingsActivity, FeedbackSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.updatesSetting,
+ Intent(this@SettingsActivity, UpdateActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.navbarSetting,
+ Intent(this@SettingsActivity, NavBarSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.weatherSetting,
+ Intent(this@SettingsActivity, WeatherSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.iconsSetting,
+ Intent(this@SettingsActivity, IconSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.expSetting,
+ Intent(this@SettingsActivity, ExperimentsSettingsActivity::class.java)
+ )
setClickListener(binding.settingsInclude.leaks, LeakCanary.newLeakDisplayActivityIntent())
- setClickListener(binding.settingsInclude.animSetting, Intent(this@SettingsActivity, AnimationSettingsActivity::class.java))
- setClickListener(binding.settingsInclude.fontSetting, Intent(this@SettingsActivity, FontsSettingsActivity::class.java))
+ setClickListener(
+ binding.settingsInclude.animSetting,
+ Intent(this@SettingsActivity, AnimationSettingsActivity::class.java)
+ )
+ setClickListener(
+ binding.settingsInclude.fontSetting,
+ Intent(this@SettingsActivity, FontsSettingsActivity::class.java)
+ )
}
+
private fun setClickListener(view: View, intent: Intent) {
view.setOnClickListener {
if (!isEnter) {
@@ -234,28 +286,47 @@ class SettingsActivity : AppCompatActivity() {
}
}
}
+
private fun setupAnimations() {
viewList.forEach { (view, duration) ->
setupAnimForViews(view, duration)
}
}
+
private fun setupAnimForViews(view: View, dur: Long) {
if (!PREFS.isTransitionAnimEnabled) return
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 -400f, if (isEnter) -500f else 0f),
- ObjectAnimator.ofFloat(view, "rotationY", if (isEnter) 0f else -90f, if (isEnter) -90f else 0f)
+ ObjectAnimator.ofFloat(
+ view,
+ "alpha",
+ if (isEnter) 1f else 0f,
+ if (isEnter) 0f else 1f
+ ),
+ ObjectAnimator.ofFloat(
+ view,
+ "translationX",
+ if (isEnter) 0f else -400f,
+ if (isEnter) -500f else 0f
+ ),
+ ObjectAnimator.ofFloat(
+ view,
+ "rotationY",
+ if (isEnter) 0f else -90f,
+ if (isEnter) -90f else 0f
+ )
)
duration = dur
}
animatorSet.start()
}
+
private fun confTouchAnim() {
viewList.forEach {
setViewInteractAnimation(it.first)
}
}
+
private suspend fun startAnim() {
if (PREFS.isTransitionAnimEnabled) {
setupAnimations()
@@ -272,6 +343,7 @@ class SettingsActivity : AppCompatActivity() {
isEnter = false
}
}
+
private fun hideViews() {
if (PREFS.isTransitionAnimEnabled) {
viewList.forEach { (view, _) ->
@@ -279,12 +351,14 @@ class SettingsActivity : AppCompatActivity() {
}
}
}
+
private fun hideAnim(view: View?) {
- if(view == null || !PREFS.isTransitionAnimEnabled) {
+ if (view == null || !PREFS.isTransitionAnimEnabled) {
return
}
ObjectAnimator.ofFloat(view, "alpha", 1f, 0f).start()
}
+
private fun isHomeApp(): Boolean {
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_HOME)
@@ -292,6 +366,7 @@ class SettingsActivity : AppCompatActivity() {
return res!!.activityInfo != null && (packageName
== res.activityInfo.packageName)
}
+
override fun onResume() {
super.onResume()
binding.settingsInclude.themeSub.text = accentName(this)
@@ -304,16 +379,21 @@ class SettingsActivity : AppCompatActivity() {
else -> getString(R.string.navigation_bar_2)
}
binding.settingsInclude.fontsSub.text = runCatching {
- if(!PREFS.customFontInstalled) getString(R.string.fonts_tip) else PREFS.customFontName
+ if (!PREFS.customFontInstalled) getString(R.string.fonts_tip) else PREFS.customFontName
}.getOrElse {
getString(R.string.fonts_tip)
}
binding.settingsInclude.iconsSub.text = runCatching {
if (PREFS.iconPackPackage == "null") getString(R.string.iconPackNotSelectedSub)
- else packageManager.getApplicationLabel(packageManager.getApplicationInfo(PREFS.iconPackPackage!!, 0))
+ else packageManager.getApplicationLabel(
+ packageManager.getApplicationInfo(
+ PREFS.iconPackPackage!!,
+ 0
+ )
+ )
}.getOrElse { getString(R.string.iconPackNotSelectedSub) }
- if(PREFS.isPrefsChanged) {
+ if (PREFS.isPrefsChanged) {
job?.cancel()
restartDialog()
} else {
@@ -339,11 +419,13 @@ class SettingsActivity : AppCompatActivity() {
show()
}
}
+
private fun startAnimWithLifecycle() {
lifecycleScope.launch {
startAnim()
}
}
+
private fun restartApp() {
finishAffinity()
val componentName = Intent(this, this::class.java).component
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AboutSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AboutSettingsActivity.kt
index d61e229..e5c8fab 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AboutSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AboutSettingsActivity.kt
@@ -31,7 +31,8 @@ import kotlin.system.exitProcess
class AboutSettingsActivity : AppCompatActivity() {
- private val caracalLink = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Caracl_%2801%29%2C_Paris%2C_d%C3%A9cembre_2013.jpg/1288px-Caracl_%2801%29%2C_Paris%2C_d%C3%A9cembre_2013.jpg"
+ private val caracalLink =
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Caracl_%2801%29%2C_Paris%2C_d%C3%A9cembre_2013.jpg/1288px-Caracl_%2801%29%2C_Paris%2C_d%C3%A9cembre_2013.jpg"
private lateinit var binding: LauncherSettingsAboutBinding
override fun onCreate(savedInstanceState: Bundle?) {
@@ -41,7 +42,7 @@ class AboutSettingsActivity : AppCompatActivity() {
WindowCompat.setDecorFitsSystemWindows(window, false)
applyWindowInsets(binding.root)
setupLayout()
- if(PREFS.customFontInstalled) {
+ if (PREFS.customFontInstalled) {
customFont?.let {
binding.settingsSectionLabel.typeface = it
binding.settingsInclude.phoneinfoLabel.typeface = it
@@ -67,9 +68,21 @@ class AboutSettingsActivity : AppCompatActivity() {
}
private fun setupLayout() {
- binding.settingsInclude.phoneinfo.text = getString(R.string.phone_info, "$MANUFACTURER $PRODUCT", MODEL, VERSION_NAME)
+ binding.settingsInclude.phoneinfo.text =
+ getString(R.string.phone_info, "$MANUFACTURER $PRODUCT", MODEL, VERSION_NAME)
binding.settingsInclude.moreInfobtn.setOnClickListener {
- binding.settingsInclude.phoneinfoMore.text = getString(R.string.phone_moreinfo, VERSION_NAME, VERSION_CODE, DEVICE, BRAND, MODEL, PRODUCT, HARDWARE, BUILD, TIME)
+ binding.settingsInclude.phoneinfoMore.text = getString(
+ R.string.phone_moreinfo,
+ VERSION_NAME,
+ VERSION_CODE,
+ DEVICE,
+ BRAND,
+ MODEL,
+ PRODUCT,
+ HARDWARE,
+ BUILD,
+ TIME
+ )
binding.settingsInclude.moreInfobtn.visibility = View.GONE
binding.settingsInclude.moreinfoLayout.visibility = View.VISIBLE
}
@@ -94,7 +107,8 @@ class AboutSettingsActivity : AppCompatActivity() {
return@setOnLongClickListener true
}
binding.settingsInclude.queuejwImg.setOnClickListener {
- WPDialog(this).setTopDialog(true).setTitle("Meow meow").setMessage("Meow meow, meow?").setPositiveButton("meow", null).show()
+ WPDialog(this).setTopDialog(true).setTitle("Meow meow").setMessage("Meow meow, meow?")
+ .setPositiveButton("meow", null).show()
}
}
@@ -104,22 +118,44 @@ class AboutSettingsActivity : AppCompatActivity() {
finishAffinity()
startActivity(intent)
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ private fun createObjectAnimator(
+ target: Any,
+ property: String,
+ startValue: Float,
+ endValue: Float
+ ): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AllAppsSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AllAppsSettingsActivity.kt
index 2a9dcb8..4724174 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AllAppsSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AllAppsSettingsActivity.kt
@@ -11,7 +11,7 @@ import ru.dimon6018.metrolauncher.R
import ru.dimon6018.metrolauncher.databinding.LauncherSettingsAllappsBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class AllAppsSettingsActivity: AppCompatActivity() {
+class AllAppsSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsAllappsBinding
@@ -21,58 +21,71 @@ class AllAppsSettingsActivity: AppCompatActivity() {
setContentView(binding.root)
binding.settingsInclude.settingsBtnSwitch.apply {
isChecked = PREFS.isSettingsBtnEnabled
- text = if(PREFS.isSettingsBtnEnabled) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.isSettingsBtnEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.isSettingsBtnEnabled = isChecked
PREFS.isPrefsChanged = true
- text = if(PREFS.isSettingsBtnEnabled) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.isSettingsBtnEnabled) getString(R.string.on) else getString(R.string.off)
}
}
binding.settingsInclude.alphabetSwitch.apply {
isChecked = PREFS.isAlphabetEnabled
- text = if(PREFS.isAlphabetEnabled) getString(R.string.on) else getString(R.string.off)
+ text = if (PREFS.isAlphabetEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.isAlphabetEnabled = isChecked
PREFS.isPrefsChanged = true
- text = if(PREFS.isAlphabetEnabled) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.isAlphabetEnabled) getString(R.string.on) else getString(R.string.off)
}
}
binding.settingsInclude.disableAllAppsSwitch.apply {
isChecked = PREFS.isAllAppsEnabled
- text = if(PREFS.isAllAppsEnabled) getString(R.string.on) else getString(R.string.off)
+ text = if (PREFS.isAllAppsEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.isAllAppsEnabled = isChecked
PREFS.isPrefsChanged = true
- text = if(PREFS.isAllAppsEnabled) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.isAllAppsEnabled) getString(R.string.on) else getString(R.string.off)
}
}
binding.settingsInclude.keyboardWhenSearchingSwitch.apply {
isChecked = PREFS.showKeyboardWhenSearching
- text = if(PREFS.showKeyboardWhenSearching) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.showKeyboardWhenSearching) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.showKeyboardWhenSearching = isChecked
- text = if(PREFS.showKeyboardWhenSearching) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.showKeyboardWhenSearching) getString(R.string.on) else getString(R.string.off)
}
}
binding.settingsInclude.keyboardWhenAllAppsOpened.apply {
isChecked = PREFS.showKeyboardWhenOpeningAllApps
- text = if(PREFS.showKeyboardWhenOpeningAllApps) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.showKeyboardWhenOpeningAllApps) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.showKeyboardWhenOpeningAllApps = isChecked
- text = if(PREFS.showKeyboardWhenOpeningAllApps) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.showKeyboardWhenOpeningAllApps) getString(R.string.on) else getString(
+ R.string.off
+ )
}
}
binding.settingsInclude.allAppsKeyboardActionSwitch.apply {
isChecked = PREFS.allAppsKeyboardActionEnabled
- text = if(PREFS.allAppsKeyboardActionEnabled) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.allAppsKeyboardActionEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.allAppsKeyboardActionEnabled = isChecked
- text = if(PREFS.allAppsKeyboardActionEnabled) getString(R.string.on) else getString(R.string.off)
+ text =
+ if (PREFS.allAppsKeyboardActionEnabled) getString(R.string.on) else getString(R.string.off)
}
}
applyWindowInsets(binding.root)
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsSectionLabel.typeface = it
@@ -97,24 +110,47 @@ class AllAppsSettingsActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AnimationSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AnimationSettingsActivity.kt
index 8ef05ac..58b12fa 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AnimationSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/AnimationSettingsActivity.kt
@@ -13,7 +13,7 @@ import ru.dimon6018.metrolauncher.helpers.ui.WPDialog
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.isDevMode
-class AnimationSettingsActivity: AppCompatActivity() {
+class AnimationSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsAnimationsBinding
@@ -23,8 +23,10 @@ class AnimationSettingsActivity: AppCompatActivity() {
setContentView(binding.root)
applyWindowInsets(binding.root)
setupLayout()
- if(isDevMode(this) && PREFS.isAutoShutdownAnimEnabled) {
- WPDialog(this).setTopDialog(true).setTitle(getString(R.string.tip)).setMessage(getString(R.string.animations_dev_mode)).setPositiveButton(getString(android.R.string.ok), null).show()
+ if (isDevMode(this) && PREFS.isAutoShutdownAnimEnabled) {
+ WPDialog(this).setTopDialog(true).setTitle(getString(R.string.tip))
+ .setMessage(getString(R.string.animations_dev_mode))
+ .setPositiveButton(getString(android.R.string.ok), null).show()
}
setupFont()
}
@@ -86,6 +88,7 @@ class AnimationSettingsActivity: AppCompatActivity() {
}
}
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) {
return
@@ -93,19 +96,41 @@ class AnimationSettingsActivity: AppCompatActivity() {
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ExperimentsSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ExperimentsSettingsActivity.kt
index 5373dfa..4794246 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ExperimentsSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ExperimentsSettingsActivity.kt
@@ -10,7 +10,7 @@ import ru.dimon6018.metrolauncher.Application.Companion.customFont
import ru.dimon6018.metrolauncher.databinding.LauncherSettingsExperimentsBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class ExperimentsSettingsActivity: AppCompatActivity() {
+class ExperimentsSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsExperimentsBinding
@@ -21,6 +21,7 @@ class ExperimentsSettingsActivity: AppCompatActivity() {
applyWindowInsets(binding.root)
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsInclude.expPlaceholder.typeface = it
@@ -31,24 +32,47 @@ class ExperimentsSettingsActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackBsodListActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackBsodListActivity.kt
index d983882..6035718 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackBsodListActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackBsodListActivity.kt
@@ -29,7 +29,7 @@ import ru.dimon6018.metrolauncher.databinding.LauncherSettingsFeedbackBsodsBindi
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.sendCrash
-class FeedbackBsodListActivity: AppCompatActivity() {
+class FeedbackBsodListActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsFeedbackBsodsBinding
@@ -55,6 +55,7 @@ class FeedbackBsodListActivity: AppCompatActivity() {
}
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsSectionLabel.typeface = it
@@ -64,25 +65,48 @@ class FeedbackBsodListActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
@@ -92,15 +116,17 @@ class FeedbackBsodListActivity: AppCompatActivity() {
enterAnimation(true)
super.onPause()
}
+
inner class BSODadapter(
private var data: List,
private val db: BSOD
) :
RecyclerView.Adapter() {
- inner class ViewHolder(val holderBinding: BsodItemBinding) : RecyclerView.ViewHolder(holderBinding.root) {
+ inner class ViewHolder(val holderBinding: BsodItemBinding) :
+ RecyclerView.ViewHolder(holderBinding.root) {
init {
- if(PREFS.customFontInstalled) {
+ if (PREFS.customFontInstalled) {
customFont?.let {
holderBinding.date.typeface = it
holderBinding.log.typeface = it
@@ -121,7 +147,13 @@ class FeedbackBsodListActivity: AppCompatActivity() {
}
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
- return ViewHolder(BsodItemBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false))
+ return ViewHolder(
+ BsodItemBinding.inflate(
+ LayoutInflater.from(viewGroup.context),
+ viewGroup,
+ false
+ )
+ )
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
@@ -143,6 +175,7 @@ class FeedbackBsodListActivity: AppCompatActivity() {
sendCrash(item.log, this@FeedbackBsodListActivity)
}
}
+
private fun showDialog(text: String) {
MaterialAlertDialogBuilder(this@FeedbackBsodListActivity)
.setMessage(text)
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackSettingsActivity.kt
index cc7e73e..e8e27fa 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FeedbackSettingsActivity.kt
@@ -20,7 +20,7 @@ import ru.dimon6018.metrolauncher.content.data.bsod.BSOD
import ru.dimon6018.metrolauncher.databinding.LauncherSettingsFeedbackBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class FeedbackSettingsActivity: AppCompatActivity() {
+class FeedbackSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsFeedbackBinding
@@ -30,13 +30,14 @@ class FeedbackSettingsActivity: AppCompatActivity() {
setContentView(binding.root)
WindowCompat.setDecorFitsSystemWindows(window, false)
initViews()
- updateMaxLogsSize(binding.settingsInclude.save1bsod,0)
- updateMaxLogsSize(binding.settingsInclude.save5bsod,1)
- updateMaxLogsSize(binding.settingsInclude.save10bsod,2)
- updateMaxLogsSize(binding.settingsInclude.saveallbsods,3)
+ updateMaxLogsSize(binding.settingsInclude.save1bsod, 0)
+ updateMaxLogsSize(binding.settingsInclude.save5bsod, 1)
+ updateMaxLogsSize(binding.settingsInclude.save10bsod, 2)
+ updateMaxLogsSize(binding.settingsInclude.saveallbsods, 3)
applyWindowInsets(binding.root)
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsSectionLabel.typeface = it
@@ -61,6 +62,7 @@ class FeedbackSettingsActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun initViews() {
binding.settingsInclude.showBsodInfo.setOnClickListener {
startActivity(Intent(this, FeedbackBsodListActivity::class.java))
@@ -72,10 +74,10 @@ class FeedbackSettingsActivity: AppCompatActivity() {
}
binding.settingsInclude.sendFeedbackSwitch.apply {
isChecked = PREFS.isFeedbackEnabled
- text = if(PREFS.isFeedbackEnabled) getString(R.string.on) else getString(R.string.off)
+ text = if (PREFS.isFeedbackEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.isFeedbackEnabled = isChecked
- text = if(isChecked) getString(R.string.on) else getString(R.string.off)
+ text = if (isChecked) getString(R.string.on) else getString(R.string.off)
}
}
binding.settingsInclude.setCrashLogLimitBtn.apply {
@@ -87,10 +89,10 @@ class FeedbackSettingsActivity: AppCompatActivity() {
}
binding.settingsInclude.showErrorDetailsOnBsodSwitch.apply {
isChecked = PREFS.bsodOutputEnabled
- text = if(PREFS.bsodOutputEnabled) getString(R.string.on) else getString(R.string.off)
+ text = if (PREFS.bsodOutputEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.bsodOutputEnabled = isChecked
- text = if(isChecked) getString(R.string.on) else getString(R.string.off)
+ text = if (isChecked) getString(R.string.on) else getString(R.string.off)
}
}
}
@@ -103,8 +105,9 @@ class FeedbackSettingsActivity: AppCompatActivity() {
setButtonText(PREFS, binding.settingsInclude.setCrashLogLimitBtn)
}
}
+
private fun setButtonText(prefs: Prefs, button: MaterialButton) {
- button.text = when(prefs.maxCrashLogs) {
+ button.text = when (prefs.maxCrashLogs) {
0 -> getString(R.string.feedback_limit_0)
1 -> getString(R.string.feedback_limit_1)
2 -> getString(R.string.feedback_limit_2)
@@ -112,23 +115,45 @@ class FeedbackSettingsActivity: AppCompatActivity() {
else -> getString(R.string.feedback_limit_0)
}
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ private fun createObjectAnimator(
+ target: Any,
+ property: String,
+ startValue: Float,
+ endValue: Float
+ ): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FontsSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FontsSettingsActivity.kt
index 66b6053..6da59c9 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FontsSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/FontsSettingsActivity.kt
@@ -22,7 +22,7 @@ import ru.dimon6018.metrolauncher.databinding.LauncherSettingsFontsBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
import java.io.File
-class FontsSettingsActivity: AppCompatActivity() {
+class FontsSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsFontsBinding
@@ -35,59 +35,66 @@ class FontsSettingsActivity: AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(binding.root)
applyWindowInsets(binding.root)
- regularFontPickerLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
- if (result.resultCode == RESULT_OK) {
- PREFS.customFontInstalled = true
- result.data?.data?.let { uri ->
- applyFontFromUri(uri, "regular")
+ regularFontPickerLauncher =
+ registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
+ if (result.resultCode == RESULT_OK) {
+ PREFS.customFontInstalled = true
+ result.data?.data?.let { uri ->
+ applyFontFromUri(uri, "regular")
+ }
}
}
- }
- lightFontPickerLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
- if (result.resultCode == RESULT_OK) {
- result.data?.data?.let { uri ->
- applyFontFromUri(uri, "light")
+ lightFontPickerLauncher =
+ registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
+ if (result.resultCode == RESULT_OK) {
+ result.data?.data?.let { uri ->
+ applyFontFromUri(uri, "light")
+ }
}
}
- }
- boldFontPickerLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
- if (result.resultCode == RESULT_OK) {
- result.data?.data?.let { uri ->
- applyFontFromUri(uri, "bold")
+ boldFontPickerLauncher =
+ registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
+ if (result.resultCode == RESULT_OK) {
+ result.data?.data?.let { uri ->
+ applyFontFromUri(uri, "bold")
+ }
}
}
- }
binding.settingsInclude.chooseFont.setOnClickListener {
- if(!PREFS.customFontInstalled) selectCustomFont("regular") else removeCustomFont("regular")
+ if (!PREFS.customFontInstalled) selectCustomFont("regular") else removeCustomFont("regular")
PREFS.isPrefsChanged = true
}
binding.settingsInclude.chooseLightFont.setOnClickListener {
- if(PREFS.customLightFontPath == null) selectCustomFont("light") else removeCustomFont("light")
+ if (PREFS.customLightFontPath == null) selectCustomFont("light") else removeCustomFont("light")
PREFS.isPrefsChanged = true
}
binding.settingsInclude.chooseBoldFont.setOnClickListener {
- if(PREFS.customBoldFontPath == null) selectCustomFont("bold") else removeCustomFont("bold")
+ if (PREFS.customBoldFontPath == null) selectCustomFont("bold") else removeCustomFont("bold")
PREFS.isPrefsChanged = true
}
setupUi()
}
+
private fun applyFontFromUri(uri: Uri, fontType: String) {
runCatching {
val file = File(uri.path!!)
val fileName: String
- when(fontType) {
+ when (fontType) {
"regular" -> {
PREFS.customFontName = file.name
fileName = "custom_regular." + file.extension
}
+
"light" -> {
PREFS.customLightFontName = file.name
fileName = "custom_light." + file.extension
}
+
"bold" -> {
PREFS.customBoldFontName = file.name
fileName = "custom_bold." + file.extension
}
+
else -> {
PREFS.customFontName = file.name
fileName = "custom_regular." + file.extension
@@ -105,32 +112,45 @@ class FontsSettingsActivity: AppCompatActivity() {
it.printStackTrace()
}
}
+
private fun activateNewFont() {
setupCustomFont()
setupCustomLightFont()
setupCustomBoldFont()
setupUi()
}
+
private fun saveFontPath(path: String, fontType: String) {
- when(fontType) {
+ when (fontType) {
"regular" -> PREFS.customFontPath = path
"light" -> PREFS.customLightFontPath = path
"bold" -> PREFS.customBoldFontPath = path
else -> PREFS.customFontPath = path
}
}
+
private fun setupUi() {
- binding.settingsInclude.chooseFont.text = getString(if(!PREFS.customFontInstalled) R.string.choose_font else R.string.remove_font)
- binding.settingsInclude.chooseLightFont.text = getString(if(PREFS.customLightFontPath == null) R.string.choose_light_font else R.string.remove_light_font)
- binding.settingsInclude.chooseBoldFont.text = getString(if(PREFS.customBoldFontPath == null) R.string.choose_bold_font else R.string.remove_bold_font)
- binding.settingsInclude.currentFont.visibility = if(!PREFS.customFontInstalled) View.GONE else View.VISIBLE
- binding.settingsInclude.currentLightFont.visibility = if(PREFS.customLightFontPath == null) View.GONE else View.VISIBLE
- binding.settingsInclude.currentBoldFont.visibility = if(PREFS.customBoldFontPath == null) View.GONE else View.VISIBLE
- if(PREFS.customFontInstalled) binding.settingsInclude.currentFont.text = getString(R.string.current_font, PREFS.customFontName)
- if(PREFS.customLightFontPath != null) binding.settingsInclude.currentLightFont.text = getString(R.string.current_light_font, PREFS.customLightFontName)
- if(PREFS.customBoldFontPath != null) binding.settingsInclude.currentBoldFont.text = getString(R.string.current_bold_font, PREFS.customBoldFontName)
+ binding.settingsInclude.chooseFont.text =
+ getString(if (!PREFS.customFontInstalled) R.string.choose_font else R.string.remove_font)
+ binding.settingsInclude.chooseLightFont.text =
+ getString(if (PREFS.customLightFontPath == null) R.string.choose_light_font else R.string.remove_light_font)
+ binding.settingsInclude.chooseBoldFont.text =
+ getString(if (PREFS.customBoldFontPath == null) R.string.choose_bold_font else R.string.remove_bold_font)
+ binding.settingsInclude.currentFont.visibility =
+ if (!PREFS.customFontInstalled) View.GONE else View.VISIBLE
+ binding.settingsInclude.currentLightFont.visibility =
+ if (PREFS.customLightFontPath == null) View.GONE else View.VISIBLE
+ binding.settingsInclude.currentBoldFont.visibility =
+ if (PREFS.customBoldFontPath == null) View.GONE else View.VISIBLE
+ if (PREFS.customFontInstalled) binding.settingsInclude.currentFont.text =
+ getString(R.string.current_font, PREFS.customFontName)
+ if (PREFS.customLightFontPath != null) binding.settingsInclude.currentLightFont.text =
+ getString(R.string.current_light_font, PREFS.customLightFontName)
+ if (PREFS.customBoldFontPath != null) binding.settingsInclude.currentBoldFont.text =
+ getString(R.string.current_bold_font, PREFS.customBoldFontName)
setFont()
}
+
private fun setFont() {
customFont?.let {
binding.settingsInclude.currentFont.typeface = it
@@ -154,21 +174,23 @@ class FontsSettingsActivity: AppCompatActivity() {
binding.settingsInclude.testBoldFontText.typeface = it
}
}
+
private fun selectCustomFont(fontType: String) {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "font/*"
}
- when(fontType) {
+ when (fontType) {
"regular" -> regularFontPickerLauncher.launch(intent)
"light" -> lightFontPickerLauncher.launch(intent)
"bold" -> boldFontPickerLauncher.launch(intent)
else -> regularFontPickerLauncher.launch(intent)
}
}
+
private fun removeCustomFont(fontType: String) {
PREFS.apply {
- when(fontType) {
+ when (fontType) {
"regular" -> {
customFontPath = null
customFontName = null
@@ -178,10 +200,12 @@ class FontsSettingsActivity: AppCompatActivity() {
customBoldFontPath = null
customBoldFontName = null
}
+
"light" -> {
customLightFontPath = null
customLightFontName = null
}
+
"bold" -> {
customBoldFontPath = null
customBoldFontName = null
@@ -191,24 +215,47 @@ class FontsSettingsActivity: AppCompatActivity() {
activateNewFont()
recreate()
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/IconSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/IconSettingsActivity.kt
index 37780bc..a32c6c8 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/IconSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/IconSettingsActivity.kt
@@ -24,7 +24,7 @@ import ru.dimon6018.metrolauncher.helpers.ui.WPDialog
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class IconSettingsActivity: AppCompatActivity() {
+class IconSettingsActivity : AppCompatActivity() {
private val iconPackManager: IconPackManager by lazy {
IconPackManager(this)
@@ -53,6 +53,7 @@ class IconSettingsActivity: AppCompatActivity() {
applyWindowInsets(binding.root)
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsLabel.typeface = it
@@ -68,6 +69,7 @@ class IconSettingsActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun createDialog() {
dialog = WPDialog(this).setTopDialog(true)
.setTitle(getString(R.string.tip))
@@ -78,8 +80,8 @@ class IconSettingsActivity: AppCompatActivity() {
private fun initView() {
binding.settingsInclude.chooseIconPack.setOnClickListener {
setIconPacks()
- if(!isIconPackListEmpty) {
- if(!isListVisible) {
+ if (!isIconPackListEmpty) {
+ if (!isListVisible) {
isListVisible = true
binding.settingsInclude.iconPackList.visibility = View.VISIBLE
} else {
@@ -100,16 +102,22 @@ class IconSettingsActivity: AppCompatActivity() {
setUi()
}
binding.settingsInclude.downloadIconPacks.setOnClickListener {
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/queuejw/mpl_updates/releases/download/release/Lawnicons.apk")))
+ startActivity(
+ Intent(
+ Intent.ACTION_VIEW,
+ Uri.parse("https://github.com/queuejw/mpl_updates/releases/download/release/Lawnicons.apk")
+ )
+ )
}
}
+
private fun setIconPacks() {
isError = false
iconPackArrayList = iconPackManager.getAvailableIconPacks(true)
isIconPackListEmpty = iconPackArrayList.isEmpty()
setUi()
appList.clear()
- if(iconPackArrayList.isNotEmpty()) {
+ if (iconPackArrayList.isNotEmpty()) {
for (i in iconPackArrayList) {
val app = IconPackItem()
app.appPackage = i.packageName!!
@@ -117,7 +125,7 @@ class IconSettingsActivity: AppCompatActivity() {
appList.add(app)
}
}
- if(mAdapter != null) {
+ if (mAdapter != null) {
mAdapter = null
}
mAdapter = IconPackAdapterList(appList)
@@ -132,11 +140,12 @@ class IconSettingsActivity: AppCompatActivity() {
binding.settingsInclude.currentIconPackText.visibility = View.GONE
binding.settingsInclude.currentIconPackError.apply {
visibility = View.VISIBLE
- text = if(isError) getString(R.string.error) else getString(R.string.iconpack_error)
+ text =
+ if (isError) getString(R.string.error) else getString(R.string.iconpack_error)
}
binding.settingsInclude.removeIconPack.visibility = View.GONE
} else {
- val label = if(PREFS.iconPackPackage == "null") {
+ val label = if (PREFS.iconPackPackage == "null") {
binding.settingsInclude.currentIconPackText.visibility = View.GONE
binding.settingsInclude.removeIconPack.visibility = View.GONE
binding.settingsInclude.currentIconPackError.apply {
@@ -149,7 +158,12 @@ class IconSettingsActivity: AppCompatActivity() {
binding.settingsInclude.currentIconPackText.visibility = View.VISIBLE
binding.settingsInclude.currentIconPackError.visibility = View.GONE
binding.settingsInclude.removeIconPack.visibility = View.VISIBLE
- packageManager!!.getApplicationLabel(packageManager.getApplicationInfo(PREFS.iconPackPackage!!, 0)).toString()
+ packageManager!!.getApplicationLabel(
+ packageManager.getApplicationInfo(
+ PREFS.iconPackPackage!!,
+ 0
+ )
+ ).toString()
}.getOrElse {
binding.settingsInclude.currentIconPackText.visibility = View.GONE
binding.settingsInclude.currentIconPackError.apply {
@@ -159,26 +173,50 @@ class IconSettingsActivity: AppCompatActivity() {
"null"
}
}
- binding.settingsInclude.currentIconPackText.text = getString(R.string.current_iconpack, label)
+ binding.settingsInclude.currentIconPackText.text =
+ getString(R.string.current_iconpack, label)
}
- binding.settingsInclude.chooseIconPack.text = if(isListVisible) getString(android.R.string.cancel) else getString(R.string.choose_icon_pack)
+ binding.settingsInclude.chooseIconPack.text =
+ if (isListVisible) getString(android.R.string.cancel) else getString(R.string.choose_icon_pack)
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ private fun createObjectAnimator(
+ target: Any,
+ property: String,
+ startValue: Float,
+ endValue: Float
+ ): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}
@@ -191,12 +229,16 @@ class IconSettingsActivity: AppCompatActivity() {
enterAnimation(true)
super.onPause()
}
- inner class IconPackAdapterList(private var list: MutableList) : RecyclerView.Adapter() {
+
+ inner class IconPackAdapterList(private var list: MutableList) :
+ RecyclerView.Adapter() {
private var iconSize = resources.getDimensionPixelSize(R.dimen.iconAppsListSize)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
- return IconPackHolder(LayoutInflater.from(parent.context).inflate(R.layout.app, parent, false))
+ return IconPackHolder(
+ LayoutInflater.from(parent.context).inflate(R.layout.app, parent, false)
+ )
}
override fun getItemCount(): Int {
@@ -207,7 +249,9 @@ class IconSettingsActivity: AppCompatActivity() {
holder as IconPackHolder
val item = list[position]
holder.label.text = item.name
- holder.icon.setImageBitmap(packageManager.getApplicationIcon(item.appPackage).toBitmap(iconSize, iconSize))
+ holder.icon.setImageBitmap(
+ packageManager.getApplicationIcon(item.appPackage).toBitmap(iconSize, iconSize)
+ )
holder.itemView.setOnClickListener {
PREFS.apply {
iconPackPackage = item.appPackage
@@ -220,10 +264,12 @@ class IconSettingsActivity: AppCompatActivity() {
}
}
}
+
class IconPackHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val icon: ImageView = itemView.findViewById(R.id.app_icon)
val label: MaterialTextView = itemView.findViewById(R.id.app_label)
}
+
class IconPackItem {
var name: String = ""
var appPackage: String = ""
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/NavBarSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/NavBarSettingsActivity.kt
index bc4af43..07da743 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/NavBarSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/NavBarSettingsActivity.kt
@@ -17,7 +17,7 @@ import ru.dimon6018.metrolauncher.databinding.LauncherSettingsNavbarBinding
import ru.dimon6018.metrolauncher.databinding.SettingsNavbarIconChooseBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class NavBarSettingsActivity: AppCompatActivity() {
+class NavBarSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsNavbarBinding
@@ -39,10 +39,10 @@ class NavBarSettingsActivity: AppCompatActivity() {
}
binding.settingsInclude.searchBarSwitch.apply {
isChecked = PREFS.isSearchBarEnabled
- text = if(PREFS.isSearchBarEnabled) getString(R.string.on) else getString(R.string.off)
+ text = if (PREFS.isSearchBarEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
PREFS.isSearchBarEnabled = isChecked
- text = if(isChecked) getString(R.string.on) else getString(R.string.off)
+ text = if (isChecked) getString(R.string.on) else getString(R.string.off)
PREFS.isPrefsChanged = true
}
}
@@ -54,6 +54,7 @@ class NavBarSettingsActivity: AppCompatActivity() {
}
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsSectionLabel.typeface = it
@@ -77,8 +78,9 @@ class NavBarSettingsActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun setNavBarColorRadioGroup() {
- when(PREFS.navBarColor) {
+ when (PREFS.navBarColor) {
0 -> {
binding.settingsInclude.alwaysDark.isChecked = true
binding.settingsInclude.alwaysLight.isChecked = false
@@ -86,6 +88,7 @@ class NavBarSettingsActivity: AppCompatActivity() {
binding.settingsInclude.hidden.isChecked = false
binding.settingsInclude.auto.isChecked = false
}
+
1 -> {
binding.settingsInclude.alwaysDark.isChecked = false
binding.settingsInclude.alwaysLight.isChecked = true
@@ -93,6 +96,7 @@ class NavBarSettingsActivity: AppCompatActivity() {
binding.settingsInclude.hidden.isChecked = false
binding.settingsInclude.auto.isChecked = false
}
+
2 -> {
binding.settingsInclude.alwaysDark.isChecked = false
binding.settingsInclude.alwaysLight.isChecked = false
@@ -100,6 +104,7 @@ class NavBarSettingsActivity: AppCompatActivity() {
binding.settingsInclude.hidden.isChecked = false
binding.settingsInclude.auto.isChecked = false
}
+
3 -> {
binding.settingsInclude.alwaysDark.isChecked = false
binding.settingsInclude.alwaysLight.isChecked = false
@@ -107,6 +112,7 @@ class NavBarSettingsActivity: AppCompatActivity() {
binding.settingsInclude.hidden.isChecked = true
binding.settingsInclude.auto.isChecked = false
}
+
4 -> {
binding.settingsInclude.alwaysDark.isChecked = false
binding.settingsInclude.alwaysLight.isChecked = false
@@ -116,41 +122,70 @@ class NavBarSettingsActivity: AppCompatActivity() {
}
}
}
+
private fun updateCurrentIcon() {
- binding.settingsInclude.currentStartIcon.setImageDrawable(when(PREFS.navBarIconValue) {
- 0 -> {
- ContextCompat.getDrawable(this, R.drawable.ic_os_windows_8)
- }
- 1 -> {
- ContextCompat.getDrawable(this, R.drawable.ic_os_windows)
- }
- 2 -> {
- ContextCompat.getDrawable(this, R.drawable.ic_os_android)
- }
- else -> {
- ContextCompat.getDrawable(this, R.drawable.ic_os_windows_8)
+ binding.settingsInclude.currentStartIcon.setImageDrawable(
+ when (PREFS.navBarIconValue) {
+ 0 -> {
+ ContextCompat.getDrawable(this, R.drawable.ic_os_windows_8)
+ }
+
+ 1 -> {
+ ContextCompat.getDrawable(this, R.drawable.ic_os_windows)
+ }
+
+ 2 -> {
+ ContextCompat.getDrawable(this, R.drawable.ic_os_android)
+ }
+
+ else -> {
+ ContextCompat.getDrawable(this, R.drawable.ic_os_windows_8)
+ }
}
- })
+ )
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
@@ -162,19 +197,23 @@ class NavBarSettingsActivity: AppCompatActivity() {
}
fun changeNavBarColor(checkedId: Int) {
- when(checkedId) {
+ when (checkedId) {
binding.settingsInclude.alwaysDark.id -> {
PREFS.navBarColor = 0
}
+
binding.settingsInclude.alwaysLight.id -> {
PREFS.navBarColor = 1
}
+
binding.settingsInclude.byTheme.id -> {
PREFS.navBarColor = 2
}
+
binding.settingsInclude.hidden.id -> {
PREFS.navBarColor = 3
}
+
binding.settingsInclude.auto.id -> {
PREFS.navBarColor = 4
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ThemeSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ThemeSettingsActivity.kt
index 9d5550b..b7a14b2 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ThemeSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/ThemeSettingsActivity.kt
@@ -45,6 +45,7 @@ class ThemeSettingsActivity : AppCompatActivity() {
prepareTip()
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsSectionLabel.typeface = it
@@ -85,6 +86,7 @@ class ThemeSettingsActivity : AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun configure() {
binding.settingsInclude.chosenAccentName.text = accentName(this)
binding.settingsInclude.chooseTheme.apply {
@@ -143,10 +145,10 @@ class ThemeSettingsActivity : AppCompatActivity() {
}
}
binding.settingsInclude.wallpaperShowSwitch.apply {
- isChecked = PREFS.isWallpaperUsed
- text = if (PREFS.isWallpaperUsed) getString(R.string.on) else getString(R.string.off)
+ isChecked = PREFS.isWallpaperEnabled
+ text = if (PREFS.isWallpaperEnabled) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, check ->
- PREFS.isWallpaperUsed = check
+ PREFS.isWallpaperEnabled = check
PREFS.isPrefsChanged = true
text = if (check) getString(R.string.on) else getString(R.string.off)
}
@@ -159,7 +161,8 @@ class ThemeSettingsActivity : AppCompatActivity() {
text = if (isChecked) getString(R.string.on) else getString(R.string.off)
setOnCheckedChangeListener { _, isChecked ->
if (DynamicColors.isDynamicColorAvailable()) {
- PREFS.accentColor = if (isChecked) 20 else PREFS.prefs.getInt("previous_accent_color", 5)
+ PREFS.accentColor =
+ if (isChecked) 20 else PREFS.prefs.getInt("previous_accent_color", 5)
recreate()
} else {
Snackbar.make(
@@ -346,6 +349,7 @@ class ThemeSettingsActivity : AppCompatActivity() {
requireActivity().recreate()
}
}
+
companion object {
private const val TAG = "accentD"
fun display(fragmentManager: FragmentManager?): AccentDialog {
@@ -355,6 +359,7 @@ class ThemeSettingsActivity : AppCompatActivity() {
}
}
}
+
fun setOrientationButtons() {
val orientations = mapOf(
"p" to Triple(true, false, false),
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/TileSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/TileSettingsActivity.kt
index f83c3ce..f143c17 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/TileSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/TileSettingsActivity.kt
@@ -11,7 +11,7 @@ import ru.dimon6018.metrolauncher.Application.Companion.customFont
import ru.dimon6018.metrolauncher.databinding.LauncherSettingsTilesBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class TileSettingsActivity: AppCompatActivity() {
+class TileSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsTilesBinding
@@ -44,28 +44,52 @@ class TileSettingsActivity: AppCompatActivity() {
})
}
}
+
override fun onResume() {
super.onResume()
enterAnimation(false)
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ private fun createObjectAnimator(
+ target: Any,
+ property: String,
+ startValue: Float,
+ endValue: Float
+ ): ObjectAnimator {
return ObjectAnimator.ofFloat(target, property, startValue, endValue)
}
+
override fun onPause() {
enterAnimation(true)
super.onPause()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/UpdateActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/UpdateActivity.kt
index 00cccb9..e94f5e1 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/UpdateActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/UpdateActivity.kt
@@ -44,7 +44,7 @@ import java.io.IOException
import java.net.HttpURLConnection
import java.net.URL
-class UpdateActivity: AppCompatActivity() {
+class UpdateActivity : AppCompatActivity() {
private var db: BSOD? = null
private var manager: DownloadManager? = null
@@ -68,6 +68,7 @@ class UpdateActivity: AppCompatActivity() {
prepareTip()
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsSectionLabel.typeface = it
@@ -86,9 +87,11 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun init() {
db = BSOD.getData(this)
}
+
private fun setOnClickers() {
binding.settingsInclude.AutoUpdateCheckBox.setOnCheckedChangeListener { _, isChecked ->
PREFS.isAutoUpdateEnabled = isChecked
@@ -106,17 +109,24 @@ class UpdateActivity: AppCompatActivity() {
.setPositiveButton(getString(android.R.string.ok), null).show()
}
binding.settingsInclude.checkForUpdatesBtn.setOnClickListener {
- if(!checkStoragePermissions(this)) {
+ if (!checkStoragePermissions(this)) {
PREFS.updateState = 5
refreshUi()
showPermsDialog()
return@setOnClickListener
}
- when(PREFS.updateState) {
+ when (PREFS.updateState) {
4 -> {
try {
- val file = File(Environment.getExternalStorageDirectory().toString() + "/Download/", "MPL_update.apk")
- val uri = FileProvider.getUriForFile(this, applicationContext.packageName + ".provider", file)
+ val file = File(
+ Environment.getExternalStorageDirectory().toString() + "/Download/",
+ "MPL_update.apk"
+ )
+ val uri = FileProvider.getUriForFile(
+ this,
+ applicationContext.packageName + ".provider",
+ file
+ )
PREFS.prefs.edit().putBoolean("updateInstalled", true).apply()
openFile(uri, this)
} catch (e: Exception) {
@@ -127,9 +137,11 @@ class UpdateActivity: AppCompatActivity() {
}
return@setOnClickListener
}
+
6, 7 -> {
checkDownload()
}
+
else -> {
PREFS.updateState = 1
refreshUi()
@@ -156,10 +168,15 @@ class UpdateActivity: AppCompatActivity() {
deleteUpdateFile(this)
refreshUi()
}
- if(PREFS.prefs.getBoolean("permsDialogUpdateScreenEnabled", true) && !checkStoragePermissions(this)) showPermsDialog()
+ if (PREFS.prefs.getBoolean(
+ "permsDialogUpdateScreenEnabled",
+ true
+ ) && !checkStoragePermissions(this)
+ ) showPermsDialog()
}
+
private fun prepareTip() {
- if(PREFS.prefs.getBoolean("tipSettingsUpdatesEnabled", true)) {
+ if (PREFS.prefs.getBoolean("tipSettingsUpdatesEnabled", true)) {
WPDialog(this).setTopDialog(true)
.setTitle(getString(R.string.tip))
.setMessage(getString(R.string.tipSettingsUpdates))
@@ -168,24 +185,47 @@ class UpdateActivity: AppCompatActivity() {
PREFS.prefs.edit().putBoolean("tipSettingsUpdatesEnabled", false).apply()
}
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
@@ -195,6 +235,7 @@ class UpdateActivity: AppCompatActivity() {
enterAnimation(true)
super.onPause()
}
+
private fun showPermsDialog() {
val dialog = WPDialog(this).setTopDialog(true)
.setTitle(getString(R.string.perms_req))
@@ -209,28 +250,35 @@ class UpdateActivity: AppCompatActivity() {
hideDialogForever()
dialog.dismiss()
}
- .setPositiveButton(getString(R.string.no)){ dialog.dismiss()
+ .setPositiveButton(getString(R.string.no)) {
+ dialog.dismiss()
}
dialog.show()
}
+
private fun getUpdateMessage(): String {
- return if(UpdateDataParser.updateMsg == null) {
+ return if (UpdateDataParser.updateMsg == null) {
PREFS.updateMessage
} else {
UpdateDataParser.updateMsg!!
}
}
+
override fun onDestroy() {
coroutineXmlScope.cancel()
coroutineErrorScope.cancel()
super.onDestroy()
}
+
private fun hideDialogForever() {
PREFS.prefs.edit().putBoolean("permsDialogUpdateScreenEnabled", false).apply()
}
+
private fun getPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).setData(Uri.parse(String.format("package:%s", packageName)))
+ val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).setData(
+ Uri.parse(String.format("package:%s", packageName))
+ )
startActivity(intent)
} else {
ActivityCompat.requestPermissions(
@@ -242,6 +290,7 @@ class UpdateActivity: AppCompatActivity() {
)
}
}
+
private fun refreshUi() {
binding.settingsInclude.AutoUpdateCheckBox.apply {
isChecked = PREFS.isAutoUpdateEnabled
@@ -260,13 +309,14 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.updateInfo.visibility = View.GONE
binding.settingsInclude.cancelButton.visibility = View.VISIBLE
}
+
2 -> {
// dowloading state
binding.settingsInclude.checkingUpdatesSub.visibility = View.GONE
binding.settingsInclude.checkForUpdatesBtn.visibility = View.GONE
binding.settingsInclude.updateIndicator.visibility = View.VISIBLE
binding.settingsInclude.cancelButton.visibility = View.VISIBLE
- val progressString = if(isUpdateDownloading) {
+ val progressString = if (isUpdateDownloading) {
binding.settingsInclude.progress.progress = PREFS.updateProgressLevel
getString(R.string.preparing_to_install, PREFS.updateProgressLevel) + "%"
} else {
@@ -275,6 +325,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.progessText.text = progressString
binding.settingsInclude.updateInfo.visibility = View.GONE
}
+
3 -> {
// up to date
binding.settingsInclude.checkingUpdatesSub.apply {
@@ -289,6 +340,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.updateInfo.visibility = View.GONE
binding.settingsInclude.cancelButton.visibility = View.GONE
}
+
4 -> {
// ready to install
binding.settingsInclude.checkingUpdatesSub.apply {
@@ -303,6 +355,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.updateInfo.visibility = View.VISIBLE
binding.settingsInclude.cancelButton.visibility = View.VISIBLE
}
+
5 -> {
// error
binding.settingsInclude.checkingUpdatesSub.apply {
@@ -317,6 +370,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.updateInfo.visibility = View.GONE
binding.settingsInclude.cancelButton.visibility = View.GONE
}
+
6 -> {
// ready for download
binding.settingsInclude.checkingUpdatesSub.apply {
@@ -331,6 +385,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.updateInfo.visibility = View.VISIBLE
binding.settingsInclude.cancelButton.visibility = View.VISIBLE
}
+
7 -> {
// BETA is ready for download
binding.settingsInclude.checkingUpdatesSub.apply {
@@ -345,6 +400,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.updateInfo.visibility = View.VISIBLE
binding.settingsInclude.cancelButton.visibility = View.VISIBLE
}
+
8 -> {
// current version is newer
binding.settingsInclude.checkingUpdatesSub.apply {
@@ -359,6 +415,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.updateInfo.visibility = View.GONE
binding.settingsInclude.cancelButton.visibility = View.GONE
}
+
0 -> {
// default
binding.settingsInclude.checkForUpdatesBtn.apply {
@@ -371,7 +428,7 @@ class UpdateActivity: AppCompatActivity() {
binding.settingsInclude.cancelButton.visibility = View.GONE
}
}
- if(!BuildConfig.UPDATES_ACITVE) {
+ if (!BuildConfig.UPDATES_ACITVE) {
binding.settingsInclude.checkForUpdatesBtn.visibility = View.GONE
binding.settingsInclude.checkingUpdatesSub.apply {
visibility = View.VISIBLE
@@ -379,6 +436,7 @@ class UpdateActivity: AppCompatActivity() {
}
}
}
+
private fun checkForUpdates() {
CoroutineScope(Dispatchers.IO).launch {
try {
@@ -397,6 +455,7 @@ class UpdateActivity: AppCompatActivity() {
cancel()
}
}
+
private fun checkUpdateInfo() {
coroutineXmlScope.launch {
if (UpdateDataParser.verCode == null) {
@@ -407,7 +466,7 @@ class UpdateActivity: AppCompatActivity() {
PREFS.updateState = 3
} else if (VERSION_CODE > UpdateDataParser.verCode!!) {
PREFS.updateState = 8
- } else if(UpdateDataParser.verCode!! > VERSION_CODE) {
+ } else if (UpdateDataParser.verCode!! > VERSION_CODE) {
if (UpdateDataParser.isBeta == true) {
PREFS.updateState = 7
} else {
@@ -421,6 +480,7 @@ class UpdateActivity: AppCompatActivity() {
cancel()
}
}
+
private fun checkDownload() {
if (UpdateDataParser.isBeta == true) {
Log.i("CheckForUpdates", "download beta")
@@ -430,6 +490,7 @@ class UpdateActivity: AppCompatActivity() {
downloadFile("MPL", URL_RELEASE_FILE)
}
}
+
@SuppressLint("Range")
private fun downloadFile(fileName: String, url: String) {
coroutineDownloadingScope.launch {
@@ -453,7 +514,10 @@ class UpdateActivity: AppCompatActivity() {
request.setDescription(getString(R.string.update_notification))
request.setTitle(fileName)
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
- request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "MPL_update.apk")
+ request.setDestinationInExternalPublicDir(
+ Environment.DIRECTORY_DOWNLOADS,
+ "MPL_update.apk"
+ )
manager = getSystemService(DOWNLOAD_SERVICE) as DownloadManager
downloadId = manager?.enqueue(request)
isUpdateDownloading = true
@@ -468,10 +532,13 @@ class UpdateActivity: AppCompatActivity() {
while (isUpdateDownloading) {
cursor = manager!!.query(q)
if (cursor != null && cursor.moveToFirst()) {
- val downloaded = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR))
- val total = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
+ val downloaded =
+ cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR))
+ val total =
+ cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
val progress: Int = ((downloaded * 100L / total)).toInt()
- val progressString = getString(R.string.preparing_to_install, progress) + "%"
+ val progressString =
+ getString(R.string.preparing_to_install, progress) + "%"
PREFS.updateProgressLevel = progress
withContext(mainDispatcher) {
binding.settingsInclude.progessText.text = progressString
@@ -507,7 +574,7 @@ class UpdateActivity: AppCompatActivity() {
}
} catch (e: Exception) {
saveError(e.toString(), db!!)
- if(downloadId != null) {
+ if (downloadId != null) {
manager?.remove(downloadId!!)
}
isUpdateDownloading = false
@@ -523,6 +590,7 @@ class UpdateActivity: AppCompatActivity() {
cancel()
}
}
+
private suspend fun downloadXmlActivity() {
Log.i("CheckForUpdates", "download xml")
val url = URL(URL)
@@ -545,10 +613,14 @@ class UpdateActivity: AppCompatActivity() {
}
}
}
+
companion object {
- const val URL: String = "https://github.com/queuejw/mpl_updates/releases/download/release/update.xml"
- const val URL_BETA_FILE: String = "https://github.com/queuejw/mpl_updates/releases/download/release/MPL-beta.apk"
- const val URL_RELEASE_FILE: String = "https://github.com/queuejw/mpl_updates/releases/download/release/MPL.apk"
+ const val URL: String =
+ "https://github.com/queuejw/mpl_updates/releases/download/release/update.xml"
+ const val URL_BETA_FILE: String =
+ "https://github.com/queuejw/mpl_updates/releases/download/release/MPL-beta.apk"
+ const val URL_RELEASE_FILE: String =
+ "https://github.com/queuejw/mpl_updates/releases/download/release/MPL.apk"
fun downloadXml(link: String) {
Log.i("CheckForUpdates", "download xml")
@@ -564,8 +636,9 @@ class UpdateActivity: AppCompatActivity() {
Log.e("CheckForUpdates", "something went wrong: $e")
}
}
+
fun isUpdateAvailable(): Boolean {
- if(UpdateDataParser.verCode == null || VERSION_CODE > UpdateDataParser.verCode!! || !BuildConfig.UPDATES_ACITVE) {
+ if (UpdateDataParser.verCode == null || VERSION_CODE > UpdateDataParser.verCode!! || !BuildConfig.UPDATES_ACITVE) {
return false
}
val boolean: Boolean = if (UpdateDataParser.verCode == VERSION_CODE) {
@@ -577,6 +650,7 @@ class UpdateActivity: AppCompatActivity() {
}
return boolean
}
+
fun openFile(fileUri: Uri, activity: Activity) {
try {
val intent = Intent(Intent.ACTION_VIEW)
@@ -588,10 +662,15 @@ class UpdateActivity: AppCompatActivity() {
Log.e("installAPK", e.toString())
}
}
+
fun deleteUpdateFile(context: Context) {
try {
- val file = File(Environment.getExternalStorageDirectory().toString() + "/Download/", "MPL_update.apk")
- val uri = FileProvider.getUriForFile(context, context.packageName + ".provider", file)
+ val file = File(
+ Environment.getExternalStorageDirectory().toString() + "/Download/",
+ "MPL_update.apk"
+ )
+ val uri =
+ FileProvider.getUriForFile(context, context.packageName + ".provider", file)
context.contentResolver.delete(uri, null, null)
} catch (e: IOException) {
Log.e("Update", e.toString())
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/WeatherSettingsActivity.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/WeatherSettingsActivity.kt
index ca190e4..df9d6eb 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/WeatherSettingsActivity.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/settings/activities/WeatherSettingsActivity.kt
@@ -10,7 +10,7 @@ import ru.dimon6018.metrolauncher.Application.Companion.customFont
import ru.dimon6018.metrolauncher.databinding.LauncherSettingsWeatherBinding
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.applyWindowInsets
-class WeatherSettingsActivity: AppCompatActivity() {
+class WeatherSettingsActivity : AppCompatActivity() {
private lateinit var binding: LauncherSettingsWeatherBinding
@@ -21,6 +21,7 @@ class WeatherSettingsActivity: AppCompatActivity() {
applyWindowInsets(binding.root)
setupFont()
}
+
private fun setupFont() {
customFont?.let {
binding.settingsSectionLabel.typeface = it
@@ -31,24 +32,47 @@ class WeatherSettingsActivity: AppCompatActivity() {
binding.settingsLabel.typeface = it
}
}
+
private fun enterAnimation(exit: Boolean) {
if (!PREFS.isTransitionAnimEnabled) return
val main = binding.root
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,
+ "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,
+ "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.start()
}
- private fun createObjectAnimator(target: Any, property: String, startValue: Float, endValue: Float): ObjectAnimator {
+
+ 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()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/CacheUtils.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/CacheUtils.kt
index 42c0fab..e6f1673 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/CacheUtils.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/CacheUtils.kt
@@ -15,6 +15,7 @@ class CacheUtils {
val cachePath = context.cacheDir.path
return File(cachePath + File.separator + "icons")
}
+
fun initDiskCache(context: Context): DiskLruCache? {
try {
val cacheDir = getDiskCacheDir(context)
@@ -25,8 +26,9 @@ class CacheUtils {
return null
}
}
+
fun saveIconToDiskCache(diskLruCache: DiskLruCache?, key: String, bitmap: Bitmap?) {
- if(diskLruCache != null && bitmap != null) {
+ if (diskLruCache != null && bitmap != null) {
val editor = diskLruCache.edit(key.toMd5())
if (editor != null) {
try {
@@ -42,16 +44,19 @@ class CacheUtils {
Log.d("saveIconToDiskCache", "diskLruCache or bitmap is null")
}
}
+
private fun String.toMd5(): String {
val md = MessageDigest.getInstance("MD5")
return md.digest(toByteArray())
.joinToString("") { "%02x".format(it) }
}
+
fun loadIconFromDiskCache(diskLruCache: DiskLruCache, key: String): Bitmap? {
val snapshot = diskLruCache.get(key.toMd5()) ?: return null
val inputStream = snapshot.getInputStream(0)
return BitmapFactory.decodeStream(inputStream)
}
+
fun closeDiskCache(diskLruCache: DiskLruCache): Boolean {
try {
diskLruCache.close()
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/DiskLruCache.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/DiskLruCache.kt
index c148e7d..694dae2 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/DiskLruCache.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/disklru/DiskLruCache.kt
@@ -792,6 +792,7 @@ class DiskLruCache private constructor(
}
}
}
+
inner class Entry(val key: String) {
/** Lengths of this entry's files. */
val lengths: LongArray = LongArray(valueCount)
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt
index 27b57de..a3f0095 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt
@@ -7,28 +7,38 @@ import ru.dimon6018.metrolauncher.Application.Companion.PREFS
import ru.dimon6018.metrolauncher.content.Start
class ItemTouchCallback(private val mAdapter: Start.NewStartAdapter) : ItemTouchHelper.Callback() {
- override fun getMovementFlags(recyclerView: RecyclerView,
- viewHolder: RecyclerView.ViewHolder): Int {
+ override fun getMovementFlags(
+ recyclerView: RecyclerView,
+ viewHolder: RecyclerView.ViewHolder
+ ): Int {
val dragFlags = ItemTouchHelper.UP or ItemTouchHelper.DOWN or
ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT
val swipeFlags = 0
return makeMovementFlags(dragFlags, swipeFlags)
}
- override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
+
+ override fun onMove(
+ recyclerView: RecyclerView,
+ viewHolder: RecyclerView.ViewHolder,
+ target: RecyclerView.ViewHolder
+ ): Boolean {
Log.d("moved", "move")
- return if(!PREFS.isStartBlocked && mAdapter.isEditMode && viewHolder.itemViewType != mAdapter.spaceType) {
+ return if (!PREFS.isStartBlocked && mAdapter.isEditMode && viewHolder.itemViewType != mAdapter.spaceType) {
mAdapter.onItemMove(viewHolder.bindingAdapterPosition, target.bindingAdapterPosition)
true
} else {
false
}
}
+
override fun isItemViewSwipeEnabled(): Boolean {
return false
}
+
override fun isLongPressDragEnabled(): Boolean {
return mAdapter.isEditMode
}
+
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, i: Int) {}
override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
super.clearView(recyclerView, viewHolder)
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/iconpack/IconPackManager.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/iconpack/IconPackManager.kt
index 0e1ba31..0f3055b 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/iconpack/IconPackManager.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/iconpack/IconPackManager.kt
@@ -36,6 +36,7 @@ class IconPackManager(context: Context) {
private var mFactor = 1.0f
private var iconPackRes: Resources? = null
+
@SuppressLint("DiscouragedApi")
private fun load() {
// load appfilter.xml from the icon pack package
@@ -62,33 +63,40 @@ class IconPackManager(context: Context) {
var eventType = xpp.eventType
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
- when(xpp.name) {
+ when (xpp.name) {
"iconback" -> {
for (i in 0 until xpp.attributeCount) {
if (xpp.getAttributeName(i).startsWith("img")) {
val drawableName = xpp.getAttributeValue(i)
val iconback = loadBitmap(drawableName)
- if (iconback != null) mBackImages.append(iconback.hashCode(),iconback)
+ if (iconback != null) mBackImages.append(
+ iconback.hashCode(),
+ iconback
+ )
}
}
}
+
"iconmask" -> {
if (xpp.attributeCount > 0 && xpp.getAttributeName(0) == "img1") {
val drawableName = xpp.getAttributeValue(0)
mMaskImage = loadBitmap(drawableName)
}
}
+
"iconupon" -> {
if (xpp.attributeCount > 0 && xpp.getAttributeName(0) == "img1") {
val drawableName = xpp.getAttributeValue(0)
mFrontImage = loadBitmap(drawableName)
}
}
+
"scale" -> {
if (xpp.attributeCount > 0 && xpp.getAttributeName(0) == "factor") {
mFactor = xpp.getAttributeValue(0).toFloat()
}
}
+
"item" -> {
var componentName: String? = null
var drawableName: String? = null
@@ -131,12 +139,16 @@ class IconPackManager(context: Context) {
}
@SuppressLint("DiscouragedApi")
- fun getDrawableIconForPackage(appPackageName: String?, defaultDrawable: Drawable?): Drawable? {
+ fun getDrawableIconForPackage(
+ appPackageName: String?,
+ defaultDrawable: Drawable?
+ ): Drawable? {
if (!mLoaded) load()
val pm = mContext.packageManager
val launchIntent = pm.getLaunchIntentForPackage(appPackageName!!)
var componentName: String? = null
- if (launchIntent != null) componentName = pm.getLaunchIntentForPackage(appPackageName)!!.component.toString()
+ if (launchIntent != null) componentName =
+ pm.getLaunchIntentForPackage(appPackageName)!!.component.toString()
var drawable = mPackagesDrawables[componentName]
if (drawable != null) {
return loadDrawable(drawable)
@@ -146,8 +158,15 @@ class IconPackManager(context: Context) {
val start = componentName.indexOf("{") + 1
val end = componentName.indexOf("}", start)
if (end > start) {
- drawable = componentName.substring(start, end).lowercase(Locale.getDefault()).replace(".", "_").replace("/", "_")
- if (iconPackRes!!.getIdentifier(drawable, "drawable", packageName) > 0) return loadDrawable(drawable)
+ drawable =
+ componentName.substring(start, end).lowercase(Locale.getDefault())
+ .replace(".", "_").replace("/", "_")
+ if (iconPackRes!!.getIdentifier(
+ drawable,
+ "drawable",
+ packageName
+ ) > 0
+ ) return loadDrawable(drawable)
}
}
}
@@ -161,7 +180,8 @@ class IconPackManager(context: Context) {
val pm = mContext.packageManager
val launchIntent = pm.getLaunchIntentForPackage(appPackageName!!)
var componentName: String? = null
- if (launchIntent != null) componentName = pm.getLaunchIntentForPackage(appPackageName)!!.component.toString()
+ if (launchIntent != null) componentName =
+ pm.getLaunchIntentForPackage(appPackageName)!!.component.toString()
var drawable = mPackagesDrawables[componentName]
if (drawable != null) {
val bmp = loadBitmap(drawable)
@@ -172,8 +192,15 @@ class IconPackManager(context: Context) {
val start = componentName.indexOf("{") + 1
val end = componentName.indexOf("}", start)
if (end > start) {
- drawable = componentName.substring(start, end).lowercase(Locale.getDefault()).replace(".", "_").replace("/", "_")
- if (iconPackRes!!.getIdentifier(drawable, "drawable", packageName) > 0) return loadBitmap(drawable)
+ drawable =
+ componentName.substring(start, end).lowercase(Locale.getDefault())
+ .replace(".", "_").replace("/", "_")
+ if (iconPackRes!!.getIdentifier(
+ drawable,
+ "drawable",
+ packageName
+ ) > 0
+ ) return loadBitmap(drawable)
}
}
}
@@ -197,11 +224,17 @@ class IconPackManager(context: Context) {
mCanvas.drawBitmap(backImage, 0f, 0f, null)
// create a mutable mask bitmap with the same mask
- val scaledBitmap: Bitmap = if (defaultBitmap.getWidth() > w || defaultBitmap.getHeight() > h) {
- Bitmap.createScaledBitmap(defaultBitmap, (w * mFactor).toInt(), (h * mFactor).toInt(), false)
- } else {
- Bitmap.createBitmap(defaultBitmap)
- }
+ val scaledBitmap: Bitmap =
+ if (defaultBitmap.getWidth() > w || defaultBitmap.getHeight() > h) {
+ Bitmap.createScaledBitmap(
+ defaultBitmap,
+ (w * mFactor).toInt(),
+ (h * mFactor).toInt(),
+ false
+ )
+ } else {
+ Bitmap.createBitmap(defaultBitmap)
+ }
val mutableMask = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
val maskCanvas = Canvas(mutableMask)
if (mMaskImage != null) {
@@ -212,7 +245,12 @@ class IconPackManager(context: Context) {
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_OUT)
mCanvas.apply {
- drawBitmap(scaledBitmap, (w - scaledBitmap.getWidth()).toFloat() / 2, (h - scaledBitmap.getHeight()).toFloat() / 2, null)
+ drawBitmap(
+ scaledBitmap,
+ (w - scaledBitmap.getWidth()).toFloat() / 2,
+ (h - scaledBitmap.getHeight()).toFloat() / 2,
+ null
+ )
drawBitmap(mutableMask, 0f, 0f, paint)
}
paint.xfermode = null
@@ -224,7 +262,12 @@ class IconPackManager(context: Context) {
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_IN)
mCanvas.apply {
- drawBitmap(scaledBitmap, (w - scaledBitmap.getWidth()).toFloat() / 2, (h - scaledBitmap.getHeight()).toFloat() / 2, null)
+ drawBitmap(
+ scaledBitmap,
+ (w - scaledBitmap.getWidth()).toFloat() / 2,
+ (h - scaledBitmap.getHeight()).toFloat() / 2,
+ null
+ )
drawBitmap(mutableMask, 0f, 0f, paint)
}
paint.xfermode = null
@@ -254,6 +297,7 @@ class IconPackManager(context: Context) {
return result
}
}
+
private var iconPacks: ArrayList? = null
fun getAvailableIconPacks(forceReload: Boolean): ArrayList {
@@ -262,8 +306,14 @@ class IconPackManager(context: Context) {
// find apps with intent-filter "com.gau.go.launcherex.theme" and return build the HashMap
val pm = mContext.packageManager
- val adwLauncherThemes = pm.queryIntentActivities(Intent("org.adw.launcher.THEMES"), PackageManager.GET_META_DATA)
- val goLauncherThemes = pm.queryIntentActivities(Intent("com.gau.go.launcherex.theme"), PackageManager.GET_META_DATA)
+ val adwLauncherThemes = pm.queryIntentActivities(
+ Intent("org.adw.launcher.THEMES"),
+ PackageManager.GET_META_DATA
+ )
+ val goLauncherThemes = pm.queryIntentActivities(
+ Intent("com.gau.go.launcherex.theme"),
+ PackageManager.GET_META_DATA
+ )
// merge those lists
val resolveInfo: MutableList = ArrayList(adwLauncherThemes)
@@ -286,7 +336,7 @@ class IconPackManager(context: Context) {
val pm = mContext.packageManager
val targetPack = IconPack()
targetPack.packageName = packageName
- if(iconPacks == null) {
+ if (iconPacks == null) {
iconPacks = getAvailableIconPacks(true)
}
if (iconPacks!!.contains(targetPack)) {
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/receivers/PackageChangesReceiver.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/receivers/PackageChangesReceiver.kt
index 31b679e..8246d76 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/receivers/PackageChangesReceiver.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/receivers/PackageChangesReceiver.kt
@@ -23,10 +23,10 @@ open class PackageChangesReceiver : BroadcastReceiver() {
Intent.ACTION_PACKAGE_ADDED -> PACKAGE_INSTALLED
Intent.ACTION_PACKAGE_REMOVED, Intent.ACTION_PACKAGE_FULLY_REMOVED -> PACKAGE_REMOVED
Intent.ACTION_PACKAGE_CHANGED -> PACKAGE_MISC
- else -> - 1
+ else -> -1
}
// Receive intent from broadcast.
- if (packageAction != -1 && ! packageName.contains(context.packageName)) {
+ if (packageAction != -1 && !packageName.contains(context.packageName)) {
Log.d("Broadcaster", "send broadcast")
Intent().apply {
putExtra("action", packageAction)
@@ -38,6 +38,7 @@ open class PackageChangesReceiver : BroadcastReceiver() {
}
}
}
+
companion object {
const val PACKAGE_REMOVED = 0
const val PACKAGE_INSTALLED = 1
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt
index 782b5f4..7887ca8 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt
@@ -5,7 +5,9 @@ import android.util.AttributeSet
import android.view.MotionEvent
import androidx.recyclerview.widget.RecyclerView
-class MetroRecyclerView @JvmOverloads constructor(
+// RecyclerView that can block scrolling
+
+open class MetroRecyclerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
@@ -14,14 +16,16 @@ class MetroRecyclerView @JvmOverloads constructor(
var isScrollEnabled = true
override fun onTouchEvent(e: MotionEvent): Boolean {
- if(e.action == MotionEvent.ACTION_DOWN) {
+ if (e.action == MotionEvent.ACTION_DOWN) {
performClick()
}
return isScrollEnabled && super.onTouchEvent(e)
}
+
override fun onInterceptTouchEvent(e: MotionEvent): Boolean {
return isScrollEnabled && super.onInterceptTouchEvent(e)
}
+
override fun performClick(): Boolean {
return super.performClick()
}
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/StartRecyclerView.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/StartRecyclerView.kt
new file mode 100644
index 0000000..06f0309
--- /dev/null
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/StartRecyclerView.kt
@@ -0,0 +1,84 @@
+package ru.dimon6018.metrolauncher.helpers.ui
+
+import android.content.Context
+import android.graphics.Canvas
+import android.graphics.Matrix
+import android.graphics.Paint
+import android.graphics.PorterDuff
+import android.graphics.PorterDuffXfermode
+import android.graphics.RectF
+import android.util.AttributeSet
+import android.view.View
+import android.view.ViewParent
+import ru.dimon6018.metrolauncher.helpers.utils.Utils
+
+// RecyclerView which is used by tiles on the start screen
+class StartRecyclerView @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
+) : MetroRecyclerView(context, attrs, defStyleAttr) {
+
+ var isUpdateEnabled = false
+
+ private val overlayPaint by lazy {
+ Paint().apply {
+ color = Utils.launcherBackgroundColor(context.theme)
+ }
+ }
+
+ private val clearPaint by lazy {
+ Paint().apply {
+ xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR)
+ }
+ }
+
+ private val tempRectF by lazy {
+ RectF()
+ }
+ private val tempMatrix by lazy {
+ Matrix()
+ }
+
+ override fun dispatchDraw(canvas: Canvas) {
+ if (isUpdateEnabled) update(canvas)
+ super.dispatchDraw(canvas)
+ }
+
+ private fun update(canvas: Canvas) {
+ val saveCount = canvas.saveLayer(0f, 0f, width.toFloat(), height.toFloat(), overlayPaint)
+ try {
+ canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), overlayPaint)
+
+ for (i in 0 until childCount) {
+ val child = getChildAt(i)
+ if (getChildViewHolder(child)?.itemViewType == -1) continue
+
+ tempMatrix.reset()
+ child.getMatrixTransform(tempMatrix)
+
+ tempRectF.set(0f, 0f, child.width.toFloat(), child.height.toFloat())
+ tempMatrix.mapRect(tempRectF)
+
+ canvas.drawRect(tempRectF, clearPaint)
+ }
+ } finally {
+ canvas.restoreToCount(saveCount)
+ }
+ }
+
+ private fun View.getMatrixTransform(outMatrix: Matrix) {
+ outMatrix.set(matrix)
+ outMatrix.postTranslate(left.toFloat(), top.toFloat())
+
+ var parentView: ViewParent? = parent
+ while (parentView is View) {
+ val parentMatrix = Matrix().apply {
+ set(parentView.matrix)
+ postTranslate(parentView.left.toFloat(), parentView.top.toFloat())
+ }
+ outMatrix.postConcat(parentMatrix)
+ parentView = parentView.parent
+ }
+ }
+}
\ No newline at end of file
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 92c3452..24e1a98 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
@@ -29,6 +29,7 @@ class WPDialog(private val mContext: Context) {
private var onTop = false
private var light = false
private var mView: View? = null
+
//监听器
private var okButtonListener: View.OnClickListener? = null
private var cancelButtonListener: View.OnClickListener? = null
@@ -37,7 +38,7 @@ class WPDialog(private val mContext: Context) {
//Show方法
fun show(): WPDialog {
- if(!isDarkMode) {
+ if (!isDarkMode) {
setLightTheme()
}
Builder()
@@ -47,14 +48,17 @@ class WPDialog(private val mContext: Context) {
}
return this
}
+
//SnackBar消失方法
fun dismiss(): WPDialog {
wp?.dismiss()
return this
}
+
init {
defStyle = R.style.CustomDialog
}
+
//创建
private inner class Builder {
@@ -70,7 +74,8 @@ class WPDialog(private val mContext: Context) {
if (this.window != null) {
this.window!!.setFlags(
WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
- WindowManager.LayoutParams.FLAG_BLUR_BEHIND)
+ WindowManager.LayoutParams.FLAG_BLUR_BEHIND
+ )
}
this.setContentView(binding.root)
val dialogWindow = this.window
@@ -89,6 +94,7 @@ class WPDialog(private val mContext: Context) {
this.setCancelable(cancelable)
}
}
+
//设置布局
private fun setCustomView(dialog: Dialog) {
//控件实例化
@@ -112,16 +118,21 @@ class WPDialog(private val mContext: Context) {
view.setPadding(10, 0, 10, 20)
binding.wpView.addView(view)
}
- if (title.isEmpty()) binding.wpTitle.visibility = View.GONE else binding.wpTitle.text = title
- if (messageText.isEmpty()) binding.wpMessage.visibility = View.GONE else binding.wpMessage.text = messageText
- if (okText.isEmpty()) binding.wpOkBg.visibility = View.GONE else binding.wpOk.text = okText
- if (cancleText.isEmpty()) binding.wpCancleBg.visibility = View.GONE else binding.wpCancel.text = cancleText
- if (neutral.isEmpty()) binding.wpNeutralBg.visibility = View.GONE else binding.wpNeutral.text = neutral
+ if (title.isEmpty()) binding.wpTitle.visibility =
+ View.GONE else binding.wpTitle.text = title
+ if (messageText.isEmpty()) binding.wpMessage.visibility =
+ View.GONE else binding.wpMessage.text = messageText
+ if (okText.isEmpty()) binding.wpOkBg.visibility = View.GONE else binding.wpOk.text =
+ okText
+ if (cancleText.isEmpty()) binding.wpCancleBg.visibility =
+ View.GONE else binding.wpCancel.text = cancleText
+ if (neutral.isEmpty()) binding.wpNeutralBg.visibility =
+ View.GONE else binding.wpNeutral.text = neutral
binding.wpOk.setOnClickListener(if (okButtonListener != null) okButtonListener else OnDialogButtonClickListener())
binding.wpCancel.setOnClickListener(if (cancelButtonListener != null) cancelButtonListener else OnDialogButtonClickListener())
binding.wpNeutral.setOnClickListener(if (neutralListener != null) neutralListener else OnDialogButtonClickListener())
- if(dismissListener != null) setOnDismissListener(dismissListener)
- if(PREFS.customFontInstalled) {
+ if (dismissListener != null) setOnDismissListener(dismissListener)
+ if (PREFS.customFontInstalled) {
customFont?.let { font ->
binding.wpTitle.typeface = font
binding.wpMessage.typeface = font
@@ -134,22 +145,26 @@ class WPDialog(private val mContext: Context) {
}
}
}
+
fun setTitle(text: String): WPDialog {
title = text
return this
}
+
fun setMessage(text: String): WPDialog {
messageText = text
return this
}
+
/**fun setView(view: View?): WPDialog {
- mView = view
- return this
+ 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/java/ru/dimon6018/metrolauncher/helpers/update/UpdateDataParser.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/update/UpdateDataParser.kt
index a60ede7..896c322 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/update/UpdateDataParser.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/update/UpdateDataParser.kt
@@ -30,7 +30,9 @@ class UpdateDataParser {
private fun readPreferences(parser: XmlPullParser) {
parser.require(XmlPullParser.START_TAG, ns, "map")
while (parser.next() != XmlPullParser.END_TAG) {
- if (parser.eventType != XmlPullParser.START_TAG) { continue }
+ if (parser.eventType != XmlPullParser.START_TAG) {
+ continue
+ }
val node = parser.name
when (node) {
"string" -> readName(parser)
@@ -47,25 +49,26 @@ class UpdateDataParser {
val valueKey = parser.getAttributeValue(null, "name")
val name = readTextName(parser)
parser.require(XmlPullParser.END_TAG, ns, "string")
- if(valueKey == "versionName") {
+ if (valueKey == "versionName") {
verName = name
}
- when(getDefaultLocale().language) {
+ when (getDefaultLocale().language) {
"ru" -> {
- if(valueKey == "message_ru") {
+ if (valueKey == "message_ru") {
updateMsg = name
PREFS.updateMessage = name
}
}
+
else -> {
- if(valueKey == "message") {
+ if (valueKey == "message") {
updateMsg = name
PREFS.updateMessage = name
}
}
}
- if(valueKey == "tag") {
+ if (valueKey == "tag") {
tag = name
}
Log.i("parserText", "key: $valueKey value: $name")
@@ -83,12 +86,13 @@ class UpdateDataParser {
}
return result
}
+
private fun readBool(parser: XmlPullParser) {
try {
parser.require(XmlPullParser.START_TAG, ns, "boolean")
val valueData = parser.getAttributeValue(null, "value")
val valueKey = parser.getAttributeValue(null, "name")
- if(valueKey == "beta") {
+ if (valueKey == "beta") {
isBeta = valueData.toBoolean()
}
parser.nextTag()
@@ -97,12 +101,13 @@ class UpdateDataParser {
Log.e("update_parser", exception.toString())
}
}
+
private fun readValueInt(parser: XmlPullParser) {
try {
parser.require(XmlPullParser.START_TAG, ns, "int")
val valueData = parser.getAttributeValue(null, "value")
val valueKey = parser.getAttributeValue(null, "name")
- if(valueKey == "versionCode") {
+ if (valueKey == "versionCode") {
verCode = valueData.toInt()
PREFS.versionCode = valueData.toInt()
}
@@ -124,6 +129,7 @@ class UpdateDataParser {
}
}
}
+
companion object {
private val ns: String? = null
var verCode: Int? = null
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/update/UpdateWorker.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/update/UpdateWorker.kt
index ccb197e..b2872ee 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/update/UpdateWorker.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/update/UpdateWorker.kt
@@ -43,60 +43,80 @@ import java.util.concurrent.TimeUnit
private const val CHAN_ID = "MPL-updates"
-class UpdateWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
+class UpdateWorker(context: Context, workerParams: WorkerParameters) :
+ Worker(context, workerParams) {
private fun buildNotificationN(context: Context): NotificationCompat.Builder {
val icon = IconCompat.createWithResource(context, R.drawable.ic_download)
val intent = Intent(Intent.ACTION_MAIN)
- .setClass(context, UpdateActivity::class.java)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
+ .setClass(context, UpdateActivity::class.java)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
NotificationCompat.Builder(context, CHAN_ID)
- .setSmallIcon(icon)
- .setContentTitle(context.getString(R.string.app_name))
- .setShowWhen(true)
- .setCategory(Notification.CATEGORY_RECOMMENDATION)
- .setContentText(context.getString(R.string.update_is_available))
- .setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE))
- .setAutoCancel(true)
+ .setSmallIcon(icon)
+ .setContentTitle(context.getString(R.string.app_name))
+ .setShowWhen(true)
+ .setCategory(Notification.CATEGORY_RECOMMENDATION)
+ .setContentText(context.getString(R.string.update_is_available))
+ .setContentIntent(
+ PendingIntent.getActivity(
+ context,
+ 0,
+ intent,
+ PendingIntent.FLAG_IMMUTABLE
+ )
+ )
+ .setAutoCancel(true)
} else {
NotificationCompat.Builder(context, CHAN_ID)
.setContentTitle(context.getString(R.string.app_name))
.setShowWhen(true)
.setCategory(Notification.CATEGORY_RECOMMENDATION)
.setContentText(context.getString(R.string.update_is_available))
- .setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE))
+ .setContentIntent(
+ PendingIntent.getActivity(
+ context,
+ 0,
+ intent,
+ PendingIntent.FLAG_IMMUTABLE
+ )
+ )
.setAutoCancel(true)
}
}
+
@RequiresApi(Build.VERSION_CODES.O)
fun buildNotificationO(context: Context): Notification.Builder {
val icon = Icon.createWithResource(context, R.drawable.ic_download)
val intent = Intent(Intent.ACTION_MAIN)
- .setClass(context, UpdateActivity::class.java)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
+ .setClass(context, UpdateActivity::class.java)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
return Notification.Builder(context, CHAN_ID)
- .setSmallIcon(icon)
- .setContentTitle(context.getString(R.string.app_name))
- .setShowWhen(true)
- .setCategory(Notification.CATEGORY_RECOMMENDATION)
- .setContentText(context.getString(R.string.update_is_available))
- .setContentIntent(
- PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE))
- .setAutoCancel(true)
+ .setSmallIcon(icon)
+ .setContentTitle(context.getString(R.string.app_name))
+ .setShowWhen(true)
+ .setCategory(Notification.CATEGORY_RECOMMENDATION)
+ .setContentText(context.getString(R.string.update_is_available))
+ .setContentIntent(
+ PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
+ )
+ .setAutoCancel(true)
}
+
override fun doWork(): Result {
val context = applicationContext
val prefs = Prefs(context)
val state: Result = try {
downloadXml(URL)
- if(isUpdateAvailable()) {
- if(PREFS.isAutoUpdateEnabled) {
- val name = if(UpdateDataParser.isBeta == true) "MPL BETA" else "MPL"
- val link = if(UpdateDataParser.isBeta == true) URL_BETA_FILE else URL_RELEASE_FILE
+ if (isUpdateAvailable()) {
+ if (PREFS.isAutoUpdateEnabled) {
+ val name = if (UpdateDataParser.isBeta == true) "MPL BETA" else "MPL"
+ val link =
+ if (UpdateDataParser.isBeta == true) URL_BETA_FILE else URL_RELEASE_FILE
downloadFile(name, link, context)
} else {
prefs.updateState = 6
- val noman = ContextCompat.getSystemService(context, NotificationManager::class.java)
+ val noman =
+ ContextCompat.getSystemService(context, NotificationManager::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val builder = buildNotificationO(context)
noman?.notify(1, builder.build())
@@ -115,6 +135,7 @@ class UpdateWorker(context: Context, workerParams: WorkerParameters) : Worker(co
scheduleWork(context)
return state
}
+
@SuppressLint("Range")
private fun downloadFile(fileName: String, url: String, context: Context) {
CoroutineScope(Dispatchers.IO).launch {
@@ -131,7 +152,10 @@ class UpdateWorker(context: Context, workerParams: WorkerParameters) : Worker(co
request.setDescription(context.getString(R.string.update_notification))
request.setTitle(fileName)
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
- request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "MPL_update.apk")
+ request.setDestinationInExternalPublicDir(
+ Environment.DIRECTORY_DOWNLOADS,
+ "MPL_update.apk"
+ )
val manager = context.getSystemService(DOWNLOAD_SERVICE) as DownloadManager
val downloadId = manager.enqueue(request)
isUpdateDownloading = true
@@ -143,8 +167,10 @@ class UpdateWorker(context: Context, workerParams: WorkerParameters) : Worker(co
while (isUpdateDownloading) {
cursor = manager.query(q)
if (cursor != null && cursor.moveToFirst()) {
- val downloaded = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR))
- val total = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
+ val downloaded =
+ cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR))
+ val total =
+ cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
val progress: Int = ((downloaded * 100L / total)).toInt()
PREFS.updateProgressLevel = progress
if (cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_SUCCESSFUL) {
@@ -169,27 +195,33 @@ class UpdateWorker(context: Context, workerParams: WorkerParameters) : Worker(co
}
}
}
+
companion object {
fun setupNotificationChannels(context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val noman = context.getSystemService(NotificationManager::class.java)
- val channel = NotificationChannel(CHAN_ID,
- context.getString(R.string.notification_channel_name),
- NotificationManager.IMPORTANCE_DEFAULT)
+ val channel = NotificationChannel(
+ CHAN_ID,
+ context.getString(R.string.notification_channel_name),
+ NotificationManager.IMPORTANCE_DEFAULT
+ )
channel.setSound(Uri.EMPTY, Notification.AUDIO_ATTRIBUTES_DEFAULT)
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
noman.createNotificationChannel(channel)
}
}
+
fun scheduleWork(context: Context) {
Log.i("backgroundWork", "scheduleWork")
val time = 390L
- val workFoodRequest: OneTimeWorkRequest = OneTimeWorkRequest.Builder(UpdateWorker::class.java)
+ val workFoodRequest: OneTimeWorkRequest =
+ OneTimeWorkRequest.Builder(UpdateWorker::class.java)
.addTag("UPDATE_WORK")
.setInitialDelay(time, TimeUnit.MINUTES)
.build()
WorkManager.getInstance(context).enqueue(workFoodRequest)
}
+
fun stopWork(context: Context) {
Log.i("backgroundWork", "stopWork")
WorkManager.getInstance(context).cancelAllWorkByTag("UPDATE_WORK")
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/utils/Utils.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/utils/Utils.kt
index 085dab0..6771d75 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/utils/Utils.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/utils/Utils.kt
@@ -119,12 +119,12 @@ class Utils {
R.style.AppTheme_Magenta, R.style.AppTheme_Crimson, R.style.AppTheme_Red,
R.style.AppTheme_Orange, R.style.AppTheme_Amber, R.style.AppTheme_Yellow,
R.style.AppTheme_Brown, R.style.AppTheme_Olive, R.style.AppTheme_Steel,
- R.style.AppTheme_Mauve, R.style.AppTheme_Taupe, R.style.AppTheme_Dynamic
+ R.style.AppTheme_Mauve, R.style.AppTheme_Taupe, R.style.AppTheme_Dynamic
)
fun accentColorFromPrefs(context: Context): Int {
val selectedColor = Prefs(context).accentColor
- if(selectedColor == 20) {
+ if (selectedColor == 20) {
return launcherAccentColor(context.theme)
}
return if (selectedColor >= 0 && selectedColor < accentColors.size) {
@@ -158,6 +158,7 @@ class Utils {
R.style.AppTheme_Cobalt
}
}
+
fun launcherAccentColor(theme: Resources.Theme): Int {
val typedValue = TypedValue()
theme.resolveAttribute(
@@ -167,6 +168,17 @@ class Utils {
)
return typedValue.data
}
+
+ fun launcherBackgroundColor(theme: Resources.Theme): Int {
+ val typedValue = TypedValue()
+ theme.resolveAttribute(
+ android.R.attr.colorBackground,
+ typedValue,
+ true
+ )
+ return typedValue.data
+ }
+
fun launcherSurfaceColor(theme: Resources.Theme): Int {
val typedValue = TypedValue()
theme.resolveAttribute(
@@ -176,6 +188,7 @@ class Utils {
)
return typedValue.data
}
+
fun launcherOnSurfaceColor(theme: Resources.Theme): Int {
val typedValue = TypedValue()
theme.resolveAttribute(
@@ -185,6 +198,7 @@ class Utils {
)
return typedValue.data
}
+
fun accentName(context: Context): String {
val selectedColor = PREFS.accentColor
return if (selectedColor >= 0 && selectedColor < accentNames.size) {
@@ -264,6 +278,7 @@ class Utils {
}
userLanguageApps[header]?.add(app)
}
+
label.matches(Regex("^[a-zA-Z].*")) -> {
val header = label[0].lowercase(defaultLocale)
englishHeaders.add(header)
@@ -272,7 +287,10 @@ class Utils {
}
englishApps[header]?.add(app)
}
- else -> { otherApps.add(app) }
+
+ else -> {
+ otherApps.add(app)
+ }
}
}
val list = mutableListOf()
@@ -303,18 +321,21 @@ class Utils {
db.clearAllTables()
pos = 0
}
+
1 -> {
if (dao.getBsodList().size >= 5) {
dao.removeLog(dao.getBsodList().first())
}
pos = db.getDao().getBsodList().size
}
+
2 -> {
if (dao.getBsodList().size >= 10) {
dao.removeLog(dao.getBsodList().first())
}
pos = dao.getBsodList().size
}
+
else -> {
pos = dao.getBsodList().size
}
@@ -324,8 +345,9 @@ class Utils {
}
}
}
+
fun generateRandomTileSize(genBigTiles: Boolean): String {
- val int = if(!genBigTiles) Random.nextInt(0, 2) else Random.nextInt(0, 3)
+ val int = if (!genBigTiles) Random.nextInt(0, 2) else Random.nextInt(0, 3)
return when (int) {
0 -> "small"
1 -> "medium"
@@ -333,6 +355,7 @@ class Utils {
else -> "medium"
}
}
+
fun sendCrash(text: String, activity: Activity) {
val intent = Intent(Intent.ACTION_SENDTO)
intent.setData(Uri.parse("mailto:dimon6018t@gmail.com"))
@@ -342,6 +365,7 @@ class Utils {
activity.startActivity(intent)
}
}
+
@SuppressLint("InlinedApi", "UnspecifiedRegisterReceiverFlag")
fun registerPackageReceiver(
activity: AppCompatActivity,
@@ -361,6 +385,7 @@ class Utils {
}
}
}
+
fun unregisterPackageReceiver(
activity: AppCompatActivity,
packageReceiver: PackageChangesReceiver?
@@ -371,6 +396,7 @@ class Utils {
Log.w("Utils", "unregisterPackageReceiver error: $w")
}
}
+
fun isScreenOn(context: Context?): Boolean {
if (context != null) {
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager?
@@ -379,10 +405,14 @@ class Utils {
return false
}
}
+
fun isDevMode(context: Context): Boolean {
- return Settings.Secure.getInt(context.contentResolver,
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0
+ return Settings.Secure.getInt(
+ context.contentResolver,
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0
+ ) != 0
}
+
@SuppressLint("ClickableViewAccessibility")
fun setViewInteractAnimation(view: View) {
view.setOnTouchListener { _, event ->
@@ -392,13 +422,17 @@ class Utils {
MotionEvent.ACTION_DOWN -> {
val rotationX = (event.y - centerY) / centerY * 5
val rotationY = (centerX - event.x) / centerX * 5
- ObjectAnimator.ofFloat(view, "rotationX", -rotationX).setDuration(200).start()
- ObjectAnimator.ofFloat(view, "rotationY", -rotationY).setDuration(200).start()
+ ObjectAnimator.ofFloat(view, "rotationX", -rotationX).setDuration(200)
+ .start()
+ ObjectAnimator.ofFloat(view, "rotationY", -rotationY).setDuration(200)
+ .start()
}
+
MotionEvent.ACTION_UP -> {
ObjectAnimator.ofFloat(view, "rotationX", 0f).setDuration(200).start()
ObjectAnimator.ofFloat(view, "rotationY", 0f).setDuration(200).start()
}
+
MotionEvent.ACTION_CANCEL -> {
ObjectAnimator.ofFloat(view, "rotationX", 0f).setDuration(200).start()
ObjectAnimator.ofFloat(view, "rotationY", 0f).setDuration(200).start()
@@ -407,6 +441,7 @@ class Utils {
false
}
}
+
fun getUserLanguageRegexCompat(locale: Locale): Regex {
return when (locale.language) {
"ru" -> Regex("[а-яА-ЯёЁ]")
@@ -414,6 +449,7 @@ class Utils {
else -> Regex("[a-zA-Z]")
}
}
+
@RequiresApi(Build.VERSION_CODES.N)
fun getUserLanguageRegex(locale: Locale): Pattern {
val uLocale = ULocale.forLocale(locale)
@@ -427,6 +463,7 @@ class Utils {
val regexPattern = "[${lowercaseLetters.toPattern(false)}]"
return Pattern.compile(regexPattern)
}
+
fun getAlphabetCompat(languageCode: String): List? {
val alphabets = mapOf(
"en" to ('A'..'Z').map { it.toString() },
@@ -435,6 +472,7 @@ class Utils {
val alphabet = alphabets[languageCode] ?: alphabets["en"]
return alphabet
}
+
@RequiresApi(Build.VERSION_CODES.N)
fun getAlphabet(languageCode: String): List {
val index = AlphabeticIndex(ULocale(languageCode))
@@ -448,12 +486,14 @@ class Utils {
alphabet.removeAt(alphabet.size - 1)
return alphabet
}
+
suspend fun generatePlaceholder(call: TileDao, value: Int) {
- val size = if(PREFS.isMoreTilesEnabled) value * 2 else value
+ val size = if (PREFS.isMoreTilesEnabled) value * 2 else value
val startFrom = call.getTilesList().size
val end = startFrom + size
for (i in startFrom..end) {
- val placeholder = Tile(i, (i + 1).toLong(), -1, -1,
+ val placeholder = Tile(
+ i, (i + 1).toLong(), -1, -1,
isSelected = false,
tileSize = "small",
tileLabel = "",
@@ -462,26 +502,36 @@ class Utils {
call.addTile(placeholder)
}
}
+
fun getDefaultLocale(): Locale {
return Locale.getDefault()
}
+
fun getEnglishLanguage(): String {
return Locale.ENGLISH.language
}
+
fun checkStoragePermissions(context: Context): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Environment.isExternalStorageManager()
} else {
val write =
- ContextCompat.checkSelfPermission(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
+ ContextCompat.checkSelfPermission(
+ context,
+ android.Manifest.permission.WRITE_EXTERNAL_STORAGE
+ )
val read =
- ContextCompat.checkSelfPermission(context, android.Manifest.permission.READ_EXTERNAL_STORAGE)
+ ContextCompat.checkSelfPermission(
+ context,
+ android.Manifest.permission.READ_EXTERNAL_STORAGE
+ )
read == PackageManager.PERMISSION_GRANTED && write == PackageManager.PERMISSION_GRANTED
}
}
+
fun getCustomFont(): Typeface? {
val path = PREFS.customFontPath
- if(!PREFS.customFontInstalled || path == null) return null
+ if (!PREFS.customFontInstalled || path == null) return null
return path.let {
val fontFile = File(it)
if (fontFile.exists()) {
@@ -495,6 +545,7 @@ class Utils {
}
}
}
+
fun getCustomLightFont(): Typeface? {
val path = PREFS.customLightFontPath
if (!PREFS.customFontInstalled || path == null) return null
@@ -510,6 +561,7 @@ class Utils {
}
}
}
+
fun getCustomBoldFont(): Typeface? {
val path = PREFS.customBoldFontPath
if (!PREFS.customFontInstalled || path == null) return null
@@ -526,6 +578,7 @@ class Utils {
}
}
}
+
class MarginItemDecoration(private val spaceSize: Int) : ItemDecoration() {
override fun getItemOffsets(
outRect: Rect, view: View,
@@ -540,6 +593,7 @@ class Utils {
}
}
}
+
class BottomOffsetDecoration(private val bottomOffset: Int) : ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
diff --git a/app/src/main/res/layout/launcher_all_apps_screen.xml b/app/src/main/res/layout/launcher_all_apps_screen.xml
index 4156ffc..63543b2 100644
--- a/app/src/main/res/layout/launcher_all_apps_screen.xml
+++ b/app/src/main/res/layout/launcher_all_apps_screen.xml
@@ -5,7 +5,8 @@
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:background="?android:attr/colorBackground">
-
+ android:paddingEnd="6dp" />
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 3ebcc22..ac1c7fc 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -20,4 +20,5 @@
64dp
156dp
4dp
+ 16dp
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index e7580a4..316c53d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,6 +2,6 @@
plugins {
id 'com.android.application' version '8.7.2' apply false
id 'com.android.library' version '8.7.2' apply false
- id 'org.jetbrains.kotlin.android' version '2.0.21' apply false
- id 'com.google.devtools.ksp' version "2.0.21-1.0.28" apply false
+ id 'org.jetbrains.kotlin.android' version '2.1.0' apply false
+ id 'com.google.devtools.ksp' version "2.1.0-1.0.29" apply false
}
diff --git a/gradle.properties b/gradle.properties
index 5709a8e..48ab4be 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1024m -Dfile.encoding=UTF-8
+org.gradle.jvmargs=-Xmx1024m -Dfile.encoding=UTF-8 -XX:+UseZGC -XX:+ZGenerational
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 513f6d3..e35da78 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Nov 20 15:25:12 SAMT 2024
+#Sun Nov 24 13:37:17 SAMT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists