Skip to content

Commit

Permalink
some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
queuejw committed Oct 27, 2024
1 parent 205fa08 commit ba9295a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId "ru.dimon6018.metrolauncher"
minSdk 21
targetSdk 35
versionCode 54
versionName "Exp. 7743"
versionCode 55
versionName "1.0 Pre-Alpha 5.1.2.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled false
Expand Down Expand Up @@ -65,6 +65,7 @@ dependencies {

implementation 'com.github.shadowalker77:wp7progressbar:1.1.0'
implementation 'io.coil-kt.coil3:coil:3.0.0-rc01'
implementation 'io.coil-kt.coil3:coil-network-okhttp:3.0.0-rc01'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
// testImplementation 'junit:junit:4.13.2'
Expand Down
28 changes: 14 additions & 14 deletions app/src/main/java/ru/dimon6018/metrolauncher/content/NewAllApps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,21 @@ class NewAllApps: Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = AllAppsScreenBinding.inflate(inflater, container, false)
val view = binding.root
Log.d("AllApps", "Init")
mainViewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
binding.settingsBtn.setOnClickListener {
activity?.apply { startActivity(Intent(this, SettingsActivity::class.java)) }
}
if(!PREFS.isSettingsBtnEnabled) {
binding.settingsBtn.visibility = View.GONE
} else {
binding.settingsBtn.visibility = View.VISIBLE
binding.settingsBtn.apply {
visibility = if(!PREFS.isSettingsBtnEnabled) View.GONE else View.VISIBLE
setOnClickListener {
activity?.let { it.startActivity(Intent(it, SettingsActivity::class.java)) }
}
}
binding.searchBtn.setOnClickListener {
searchFunction()
}
binding.searchBackBtn.setOnClickListener {
disableSearch()
}
return view
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -137,11 +134,7 @@ class NewAllApps: Fragment() {
setAlphabetRecyclerView(requireContext())
if (PREFS.prefs.getBoolean("tip2Enabled", true)) {
withContext(mainDispatcher) {
WPDialog(requireContext()).setTopDialog(true)
.setTitle(getString(R.string.tip))
.setMessage(getString(R.string.tip2))
.setPositiveButton(getString(android.R.string.ok), null)
.show()
tipDialog()
}
PREFS.prefs.edit().putBoolean("tip2Enabled", false).apply()
}
Expand All @@ -152,6 +145,13 @@ class NewAllApps: Fragment() {
}
registerBroadcast()
}
private fun tipDialog() {
WPDialog(requireContext()).setTopDialog(true)
.setTitle(getString(R.string.tip))
.setMessage(getString(R.string.tip2))
.setPositiveButton(getString(android.R.string.ok), null)
.show()
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
52 changes: 21 additions & 31 deletions app/src/main/java/ru/dimon6018/metrolauncher/content/NewStart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import ru.dimon6018.metrolauncher.Application.Companion.PREFS
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.isDarkMode
import ru.dimon6018.metrolauncher.Main.Companion.isLandscape
import ru.dimon6018.metrolauncher.MainViewModel
import ru.dimon6018.metrolauncher.R
Expand Down Expand Up @@ -342,26 +341,27 @@ class NewStart: Fragment(), OnStartDragListener {
}
private fun pinApp(packageName: String) {
lifecycleScope.launch(ioDispatcher) {
var dataList = mainViewModel.getTileDao().getTilesList()
var pos = 0
for (i in 0..<dataList.size) {
if (dataList[i].tileType == -1) {
pos = i
break
if(mAdapter != null) {
var pos = 0
for (i in 0..<mAdapter!!.list.size) {
if (mAdapter!!.list[i].tileType == -1) {
pos = i
break
}
}
val id = Random.nextLong(1000, 2000000)
val item = Tile(
pos, id, -1, 0,
isSelected = false,
tileSize = Utils.generateRandomTileSize(true),
tileLabel = activity?.packageManager?.getApplicationInfo(packageName, 0)?.loadLabel(requireActivity().packageManager!!).toString(),
tilePackage = packageName
)
mainViewModel.getTileDao().addTile(item)
val newDataList = mainViewModel.getTileDao().getTilesList()
withContext(mainDispatcher) {
mAdapter!!.setData(newDataList)
}
}
val id = Random.nextLong(1000, 2000000)
val item = Tile(
pos, id, -1, 0,
isSelected = false,
tileSize = Utils.generateRandomTileSize(true),
tileLabel = activity?.packageManager?.getApplicationInfo(packageName, 0)?.loadLabel(requireActivity().packageManager!!).toString(),
tilePackage = packageName
)
mainViewModel.getTileDao().addTile(item)
dataList = mainViewModel.getTileDao().getTilesList()
withContext(mainDispatcher) {
mAdapter?.setData(dataList)
}
}
}
Expand Down Expand Up @@ -412,7 +412,7 @@ class NewStart: Fragment(), OnStartDragListener {
duration += 10L
holder.itemView.animate().rotationY(-110f).translationX(-1000f).translationY(-100f).setInterpolator(interpolator).setDuration(duration).start()
}
delay(100)
delay(250)
duration = 150L
for(i in last downTo first) {
if(tiles!![i] != tiles!![position]) continue
Expand Down Expand Up @@ -468,10 +468,6 @@ class NewStart: Fragment(), OnStartDragListener {
val defaultTileType: Int = 0
val spaceType: Int = -1

private val surfaceColor: Int by lazy {
if(isDarkMode) ContextCompat.getColor(context, android.R.color.background_dark)
else ContextCompat.getColor(context, android.R.color.background_light)
}
private val accentColor: Int by lazy { Utils.launcherAccentColor(requireActivity().theme) }

var isEditMode = false
Expand Down Expand Up @@ -500,9 +496,6 @@ class NewStart: Fragment(), OnStartDragListener {
(requireActivity() as Main).configureViewPagerScroll(false)
addCallback()
binding.startAppsTiles.animate().scaleX(0.9f).scaleY(0.9f).setDuration(300).start()
if(PREFS.isParallaxEnabled || !PREFS.isWallpaperUsed) {
binding.startFrame.setBackgroundColor(surfaceColor)
}
isEditMode = true
animateEditMode()
}
Expand All @@ -511,9 +504,6 @@ class NewStart: Fragment(), OnStartDragListener {
removeCallback()
(requireActivity() as Main).configureViewPagerScroll(true)
binding.startAppsTiles.animate().scaleX(1f).scaleY(1f).setDuration(300).start()
if(PREFS.isParallaxEnabled || !PREFS.isWallpaperUsed) {
binding.startFrame.background = null
}
isEditMode = false
stopEditModeAnimation()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Prefs(context: Context) {
private val autoPinPref = "autoPinApp"
private val settingsBtnPref = "allAppsSettingsBtnEnabled"
private val alphabetPref = "alphabetEnabled"
private val parallaxTilesPref = "parallaxEnabled"
private val tilesTransparencyPref = "tilesTransparency"
private val searchBarPref = "searchBarEnabled"
private val bottomBarIconPref = "bottomBarIcon"
Expand Down Expand Up @@ -59,10 +58,6 @@ class Prefs(context: Context) {
get() = prefs.getBoolean(wallpaperPref, false)
set(value) = prefs.edit().putBoolean(wallpaperPref, value).apply()

var isParallaxEnabled: Boolean
get() = prefs.getBoolean(parallaxTilesPref, false)
set(value) = prefs.edit().putBoolean(parallaxTilesPref, value).apply()

var isMoreTilesEnabled: Boolean
get() = prefs.getBoolean(showMoreTilesPref, false)
set(value) = prefs.edit().putBoolean(showMoreTilesPref, value).apply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SettingsActivity : AppCompatActivity() {
binding.settingsInclude.expSetting to 225
)
}
private var dialogActivated = false

override fun onCreate(savedInstanceState: Bundle?) {
when(PREFS.appTheme) {
Expand All @@ -77,12 +78,12 @@ class SettingsActivity : AppCompatActivity() {
confTouchAnim()
setOnClickers()
applyWindowInsets(binding.root)
checkHome()
prepareMessage()
prepareTip()
checkHome()
}
private fun checkHome() {
if(!isHomeApp() && isDialogEnabled && Random.nextFloat() < 0.2) {
if(!isHomeApp() && isDialogEnabled && Random.nextFloat() < 0.2 && !dialogActivated) {
isDialogEnabled = false
WPDialog(this).setTopDialog(false)
.setTitle(getString(R.string.tip))
Expand All @@ -94,7 +95,8 @@ class SettingsActivity : AppCompatActivity() {
}
}
private fun prepareMessage() {
if(!PREFS.prefs.getBoolean("tipSettingsEnabled", true) && Random.nextFloat() < 0.08 && 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)
setTitle(getString(R.string.developer))
Expand All @@ -108,6 +110,9 @@ class SettingsActivity : AppCompatActivity() {
PREFS.prefs.edit().putBoolean("messageEnabled", false).apply()
dismiss()
}
setDismissListener {
dialogActivated = false
}
show()
}
}
Expand Down Expand Up @@ -186,18 +191,9 @@ class SettingsActivity : AppCompatActivity() {
animatorSet.start()
}
private fun confTouchAnim() {
setViewInteractAnimation(binding.settingsInclude.themeSetting)
setViewInteractAnimation(binding.settingsInclude.allAppsSetting)
setViewInteractAnimation(binding.settingsInclude.tilesSetting)
setViewInteractAnimation(binding.settingsInclude.iconsSetting)
setViewInteractAnimation(binding.settingsInclude.animSetting)
setViewInteractAnimation(binding.settingsInclude.feedbackSetting)
setViewInteractAnimation(binding.settingsInclude.weatherSetting)
setViewInteractAnimation(binding.settingsInclude.updatesSetting)
setViewInteractAnimation(binding.settingsInclude.navbarSetting)
setViewInteractAnimation(binding.settingsInclude.aboutSetting)
setViewInteractAnimation(binding.settingsInclude.leaks)
setViewInteractAnimation(binding.settingsInclude.expSetting)
viewList.forEach {
setViewInteractAnimation(it.first)
}
}
private suspend fun startAnim() {
if (PREFS.isTransitionAnimEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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/916px-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?) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/space.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="?android:attr/colorBackground"
android:background="@android:color/transparent"
android:layout_height="96dp">
</View>

0 comments on commit ba9295a

Please sign in to comment.