Skip to content

Commit

Permalink
Top/bottom buttons in app drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrasel committed Sep 18, 2022
1 parent 184a7c7 commit 68585ab
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ plugins {
}

android {
compileSdk 32
compileSdk 33

defaultConfig {
applicationId "rasel.lunar.launcher"
minSdk 26
targetSdk 32
versionCode 17
versionName "17.3"
targetSdk 33
versionCode 18
versionName "17.4"
}

buildTypes {
Expand Down Expand Up @@ -50,13 +50,14 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

namespace 'rasel.lunar.launcher'
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha04'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'com.google.android.material:material:1.6.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'dev.chrisbanes.insetter:insetter:0.6.1'
Expand Down
25 changes: 18 additions & 7 deletions app/src/main/java/rasel/lunar/launcher/apps/AppDrawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -53,8 +54,8 @@ internal class AppDrawer : Fragment() {
private lateinit var binding: AppDrawerBinding
private lateinit var fragmentActivity: FragmentActivity
private val leftSearchArray = arrayOf("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m")
private val leftSearchArrayII = arrayOf("0", "1", "2", "3", "4")
private val rightSearchArray = arrayOf("9", "8", "7", "6", "5")
private val leftSearchArrayII = arrayOf("0", "1", "2", "3", "4", "\u290A")
private val rightSearchArray = arrayOf("9", "8", "7", "6", "5", "\u290B")
private val rightSearchArrayII = arrayOf("z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n")
private lateinit var packageNamesArrayList: ArrayList<String>
private lateinit var appsAdapter: ArrayAdapter<String>
Expand Down Expand Up @@ -102,7 +103,6 @@ internal class AppDrawer : Fragment() {
super.onSwipeDown()
UniUtils().expandNotificationPanel(requireContext())
}

override fun onDoubleClick() {
super.onDoubleClick()
UniUtils().lockMethod(
Expand Down Expand Up @@ -140,8 +140,13 @@ internal class AppDrawer : Fragment() {
get() {
searchString = ""
// Fetch all the installed apps
packageList = packageManager.queryIntentActivities(
Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER), 0)
packageList = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager.queryIntentActivities(
Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER), PackageManager.ResolveInfoFlags.of(0))
} else {
@Suppress("DEPRECATION") packageManager.queryIntentActivities(
Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER), 0)
}
// Sort the app list
(packageList as MutableList<ResolveInfo>).sortWith(ResolveInfo.DisplayNameComparator(packageManager))
}
Expand Down Expand Up @@ -195,12 +200,18 @@ internal class AppDrawer : Fragment() {
// Left column 2
binding.leftSearchListII.onItemClickListener =
OnItemClickListener { adapterView: AdapterView<*>, _: View?, i: Int, _: Long ->
searchClickHelper(adapterView, i)
when (i) {
leftSearchArrayII.size - 1 -> binding.appsList.setSelection(0)
else -> searchClickHelper(adapterView, i)
}
}
// Right column 1
binding.rightSearchList.onItemClickListener =
OnItemClickListener { adapterView: AdapterView<*>, _: View?, i: Int, _: Long ->
searchClickHelper(adapterView, i)
when (i) {
rightSearchArray.size - 1 -> binding.appsList.setSelection(appsAdapter.count - 1)
else -> searchClickHelper(adapterView, i)
}
}
// Right column 2
binding.rightSearchListII.onItemClickListener =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal class AppMenuUtils {
@Throws(PackageManager.NameNotFoundException::class)
fun getAppName(packageManager: PackageManager, packageName: String): String {
return packageManager.getApplicationLabel(
packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
@Suppress("DEPRECATION") packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA) // Todo: deprecated
) as String
}

Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/18.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [New] Scroll to top/bottom of apps list
- [Fix] Few visual improvements

0 comments on commit 68585ab

Please sign in to comment.