Fix: Fixed a few issues with app draw including icons as well as work profile stuff.
This commit is contained in:
@@ -18,6 +18,15 @@
|
|||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
|
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.MANAGE_USERS"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.INTERACT_ACROSS_USERS"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
||||||
|
|
||||||
<uses-permission android:name="${fineLocationPermission}" />
|
<uses-permission android:name="${fineLocationPermission}" />
|
||||||
<uses-permission android:name="${coarseLocationPermission}" />
|
<uses-permission android:name="${coarseLocationPermission}" />
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.content.pm.PackageManager
|
|||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.AdaptiveIconDrawable
|
import android.graphics.drawable.AdaptiveIconDrawable
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
@@ -33,6 +34,7 @@ import androidx.core.graphics.drawable.IconCompat
|
|||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import androidx.lifecycle.LifecycleObserver
|
import androidx.lifecycle.LifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import com.github.droidworksstudio.launcher.R
|
||||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||||
import com.github.droidworksstudio.launcher.ui.activities.LauncherActivity
|
import com.github.droidworksstudio.launcher.ui.activities.LauncherActivity
|
||||||
@@ -193,15 +195,61 @@ fun Context.resetDefaultLauncher() {
|
|||||||
fun Context.unInstallApp(appInfo: AppInfo) {
|
fun Context.unInstallApp(appInfo: AppInfo) {
|
||||||
val intent = Intent(Intent.ACTION_DELETE)
|
val intent = Intent(Intent.ACTION_DELETE)
|
||||||
intent.data = Uri.parse("package:${appInfo.packageName}")
|
intent.data = Uri.parse("package:${appInfo.packageName}")
|
||||||
this.startActivity(intent)
|
if (appInfo.userHandle > 0) this.showShortToast(getString(R.string.work_permission_message))
|
||||||
|
else this.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.appInfo(appInfo: AppInfo) {
|
fun Context.appInfo(appInfo: AppInfo) {
|
||||||
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||||
intent.data = Uri.fromParts("package", appInfo.packageName, null)
|
intent.data = Uri.fromParts("package", appInfo.packageName, null)
|
||||||
this.startActivity(intent)
|
// this.test()
|
||||||
|
if (appInfo.userHandle > 0) this.showShortToast(getString(R.string.work_permission_message))
|
||||||
|
else this.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fun Context.test() {
|
||||||
|
// // Get the UserManager system service
|
||||||
|
// val userManager = getSystemService(Context.USER_SERVICE) as? UserManager
|
||||||
|
// val packageManager = packageManager
|
||||||
|
//
|
||||||
|
// // Check if the UserManager is available
|
||||||
|
// if (userManager == null) {
|
||||||
|
// Log.e("Error", "UserManager is not available on this device")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Log available user profiles
|
||||||
|
// val users = userManager.userProfiles
|
||||||
|
// Log.d("UserManager", "User profiles: $users")
|
||||||
|
// // Iterate through users to check for work profiles
|
||||||
|
// for (userHandle in users) {
|
||||||
|
// try {
|
||||||
|
// // Get the UserInfo object for each user
|
||||||
|
// val userInfo = userManager.getUserInfo(userHandle)
|
||||||
|
// Log.d("UserManager", "User info for handle $userHandle: ${userInfo.name}")
|
||||||
|
//
|
||||||
|
// // Check if this user is a managed (work) profile
|
||||||
|
// if (userInfo.isManagedProfile) {
|
||||||
|
// Log.d("WorkProfile", "Work profile found for user: ${userInfo.name}")
|
||||||
|
//
|
||||||
|
// // Get installed apps for this work profile
|
||||||
|
// val appsInWorkProfile = packageManager.getInstalledPackages(PackageManager.GET_META_DATA)
|
||||||
|
//
|
||||||
|
// // Log installed apps in the work profile
|
||||||
|
// for (appInfo in appsInWorkProfile) {
|
||||||
|
// appInfo.applicationInfo?.let {
|
||||||
|
// if (it.flags and ApplicationInfo.FLAG_SYSTEM == 0) {
|
||||||
|
// Log.d("App", "Possible app managing work profile: ${appInfo.packageName}")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e("Error", "Failed to get user info for handle $userHandle: ${e.message}")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
fun Context.launchApp(appInfo: AppInfo) {
|
fun Context.launchApp(appInfo: AppInfo) {
|
||||||
val packageName = appInfo.packageName
|
val packageName = appInfo.packageName
|
||||||
val primaryUserHandle = android.os.Process.myUserHandle()
|
val primaryUserHandle = android.os.Process.myUserHandle()
|
||||||
@@ -360,6 +408,36 @@ fun Context.isWorkProfileEnabled(): Boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.getAllProfileAppIcons(): Map<Pair<Int?, String?>, Drawable?> {
|
||||||
|
val launcherApps = this.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
|
val userManager = this.getSystemService(Context.USER_SERVICE) as UserManager
|
||||||
|
val userHandles = userManager.userProfiles
|
||||||
|
val appInfoMap = mutableMapOf<Pair<Int?, String?>, Drawable?>()
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (userHandle in userHandles) {
|
||||||
|
val apps = launcherApps.getActivityList(null, userHandle)
|
||||||
|
apps.forEach { activityInfo ->
|
||||||
|
val packageName = activityInfo.applicationInfo.packageName // App's package name
|
||||||
|
val icon = activityInfo.getBadgedIcon(0) // Drawable for the app's icon
|
||||||
|
val userHandle = activityInfo.user // UserHandle for the profile the app belongs to
|
||||||
|
val userId = userHandle.hashCode() // Get the unique integer ID of the UserHandle
|
||||||
|
|
||||||
|
// Construct the key as Pair(UserHandle, String)
|
||||||
|
val key = Pair(userId, packageName)
|
||||||
|
|
||||||
|
// Store the pair of UserHandle and label as the key, with the icon as the value
|
||||||
|
appInfoMap[key] = icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
return appInfoMap
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun Context.hasInternetPermission(): Boolean {
|
fun Context.hasInternetPermission(): Boolean {
|
||||||
val permission = Manifest.permission.INTERNET
|
val permission = Manifest.permission.INTERNET
|
||||||
val result = ContextCompat.checkSelfPermission(this, permission)
|
val result = ContextCompat.checkSelfPermission(this, permission)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import androidx.room.RoomDatabase
|
|||||||
import com.github.droidworksstudio.launcher.data.dao.AppInfoDAO
|
import com.github.droidworksstudio.launcher.data.dao.AppInfoDAO
|
||||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||||
|
|
||||||
@Database(entities = [AppInfo::class], version = 1, exportSchema = true)
|
@Database(entities = [AppInfo::class], version = 1, exportSchema = false)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
abstract fun appDao(): AppInfoDAO
|
abstract fun appDao(): AppInfoDAO
|
||||||
}
|
}
|
||||||
@@ -419,7 +419,6 @@ class AppHelper @Inject constructor() {
|
|||||||
dao.resetAutoIncrement() // Resets the ID counter
|
dao.resetAutoIncrement() // Resets the ID counter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getActionType(actionType: Constants.Swipe): NavOptions {
|
fun getActionType(actionType: Constants.Swipe): NavOptions {
|
||||||
return when (actionType) {
|
return when (actionType) {
|
||||||
Constants.Swipe.DoubleTap -> {
|
Constants.Swipe.DoubleTap -> {
|
||||||
|
|||||||
@@ -175,8 +175,22 @@ class AppInfoRepository @Inject constructor(
|
|||||||
launcherApps.getActivityList(null, profile)
|
launcherApps.getActivityList(null, profile)
|
||||||
.mapNotNull { app ->
|
.mapNotNull { app ->
|
||||||
val packageName = app.applicationInfo.packageName
|
val packageName = app.applicationInfo.packageName
|
||||||
val existingApp = getAppByPackageNameWork(packageName)
|
val currentDateTime = LocalDateTime.now()
|
||||||
existingApp
|
if (packageName !in existingPackageNames && packageName !in excludedPackageNames) {
|
||||||
|
AppInfo(
|
||||||
|
appName = app.label.toString(),
|
||||||
|
packageName = packageName,
|
||||||
|
favorite = false,
|
||||||
|
hidden = false,
|
||||||
|
lock = false,
|
||||||
|
createTime = currentDateTime.toString(),
|
||||||
|
userHandle = userId,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
val existingApp = getAppByPackageNameWork(packageName)
|
||||||
|
existingApp?.let { appList.add(it) }
|
||||||
|
existingApp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ class AppInfoBottomSheetFragment(private val appInfo: AppInfo) : BottomSheetDial
|
|||||||
bottomSheetRename.setText(appInfo.appName)
|
bottomSheetRename.setText(appInfo.appName)
|
||||||
bottomSheetOrder.text = "${appInfo.appOrder}"
|
bottomSheetOrder.text = "${appInfo.appOrder}"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@@ -108,10 +110,28 @@ class DrawFragment : Fragment(),
|
|||||||
|
|
||||||
private fun setupRecyclerView() {
|
private fun setupRecyclerView() {
|
||||||
|
|
||||||
|
// Ensure correct type for layout params
|
||||||
|
val layoutParams = (binding.drawAdapter.layoutParams as? LinearLayout.LayoutParams)
|
||||||
|
?: LinearLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
)
|
||||||
|
|
||||||
|
// Set gravity to align RecyclerView to the bottom
|
||||||
|
layoutParams.gravity = when (preferenceHelper.homeAppAlignment) {
|
||||||
|
Gravity.START -> Gravity.START or Gravity.BOTTOM
|
||||||
|
Gravity.CENTER -> Gravity.CENTER or Gravity.BOTTOM
|
||||||
|
Gravity.END -> Gravity.END or Gravity.BOTTOM
|
||||||
|
else -> Gravity.BOTTOM
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply configurations to RecyclerView
|
||||||
binding.drawAdapter.apply {
|
binding.drawAdapter.apply {
|
||||||
adapter = drawAdapter
|
adapter = drawAdapter
|
||||||
layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
this.layoutParams = layoutParams
|
||||||
setHasFixedSize(false)
|
setHasFixedSize(false)
|
||||||
|
layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||||
|
isNestedScrollingEnabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +193,8 @@ class DrawFragment : Fragment(),
|
|||||||
private fun observeSwipeTouchListener() {
|
private fun observeSwipeTouchListener() {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
mainView.setOnTouchListener(getSwipeGestureListener(context))
|
mainView.setOnTouchListener(getSwipeGestureListener(context))
|
||||||
drawAdapter.setOnTouchListener(getSwipeGestureListener(context))
|
touchArea.setOnTouchListener(getSwipeGestureListener(context))
|
||||||
|
appListTouchArea.setOnTouchListener(getSwipeGestureListener(context))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.github.droidworksstudio.launcher.ui.drawer
|
package com.github.droidworksstudio.launcher.ui.drawer
|
||||||
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -9,6 +8,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.droidworksstudio.common.ColorIconsExtensions
|
import com.github.droidworksstudio.common.ColorIconsExtensions
|
||||||
import com.github.droidworksstudio.common.dpToPx
|
import com.github.droidworksstudio.common.dpToPx
|
||||||
|
import com.github.droidworksstudio.common.getAllProfileAppIcons
|
||||||
import com.github.droidworksstudio.launcher.R
|
import com.github.droidworksstudio.launcher.R
|
||||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||||
import com.github.droidworksstudio.launcher.databinding.ItemDrawBinding
|
import com.github.droidworksstudio.launcher.databinding.ItemDrawBinding
|
||||||
@@ -20,7 +20,7 @@ class DrawViewHolder(
|
|||||||
private val binding: ItemDrawBinding,
|
private val binding: ItemDrawBinding,
|
||||||
private val onAppClickedListener: OnItemClickedListener.OnAppsClickedListener,
|
private val onAppClickedListener: OnItemClickedListener.OnAppsClickedListener,
|
||||||
private val onAppLongClickedListener: OnItemClickedListener.OnAppLongClickedListener,
|
private val onAppLongClickedListener: OnItemClickedListener.OnAppLongClickedListener,
|
||||||
private val preferenceHelper: PreferenceHelper
|
private val preferenceHelper: PreferenceHelper,
|
||||||
) :
|
) :
|
||||||
|
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
@@ -43,48 +43,57 @@ class DrawViewHolder(
|
|||||||
appDrawName.gravity = preferenceHelper.homeAppAlignment
|
appDrawName.gravity = preferenceHelper.homeAppAlignment
|
||||||
|
|
||||||
if (preferenceHelper.showAppIcon) {
|
if (preferenceHelper.showAppIcon) {
|
||||||
val pm: PackageManager = binding.root.context.packageManager
|
val appInfoMap = root.context.getAllProfileAppIcons()
|
||||||
val appIcon = pm.getApplicationIcon(appInfo.packageName)
|
appInfoMap.forEach { (key, icon) ->
|
||||||
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.iconPack == Constants.IconPacks.System) 2f else 1.1f).toInt()
|
val userHandle: Int? = key.first
|
||||||
|
val packageName: String? = key.second
|
||||||
|
if (appInfo.packageName == packageName && appInfo.userHandle == userHandle) {
|
||||||
|
val easyDot = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
||||||
|
val appIcon = icon
|
||||||
|
val nonNullDrawable: Drawable = appIcon ?: easyDot
|
||||||
|
|
||||||
val layoutParams = LinearLayoutCompat.LayoutParams(appIconSize, appIconSize)
|
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.iconPack == Constants.IconPacks.System) 2f else 1.1f).toInt()
|
||||||
val appNewIcon: Drawable? = if (preferenceHelper.iconPack == Constants.IconPacks.EasyDots) {
|
|
||||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
|
||||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
|
||||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
|
||||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
|
||||||
} else if (preferenceHelper.iconPack == Constants.IconPacks.NiagaraDots) {
|
|
||||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_niagara_dot_icon)!!
|
|
||||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
|
||||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
|
||||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
appDrawIcon.layoutParams = layoutParams
|
val layoutParams = LinearLayoutCompat.LayoutParams(appIconSize, appIconSize)
|
||||||
appDrawIcon.setImageDrawable(appNewIcon ?: appIcon)
|
val appNewIcon: Drawable? = if (preferenceHelper.iconPack == Constants.IconPacks.EasyDots) {
|
||||||
appDrawIcon.visibility = View.VISIBLE
|
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
||||||
|
val bitmap = ColorIconsExtensions.drawableToBitmap(nonNullDrawable)
|
||||||
|
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||||
|
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||||
|
} else if (preferenceHelper.iconPack == Constants.IconPacks.NiagaraDots) {
|
||||||
|
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_niagara_dot_icon)!!
|
||||||
|
val bitmap = ColorIconsExtensions.drawableToBitmap(nonNullDrawable)
|
||||||
|
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||||
|
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
val parentLayout = appDrawName.parent as LinearLayoutCompat
|
appDrawIcon.layoutParams = layoutParams
|
||||||
parentLayout.orientation = LinearLayoutCompat.HORIZONTAL
|
appDrawIcon.setImageDrawable(appNewIcon ?: nonNullDrawable)
|
||||||
parentLayout.removeAllViews()
|
appDrawIcon.visibility = View.VISIBLE
|
||||||
|
|
||||||
when (preferenceHelper.homeAppAlignment) {
|
val parentLayout = appDrawName.parent as LinearLayoutCompat
|
||||||
Gravity.START -> {
|
parentLayout.orientation = LinearLayoutCompat.HORIZONTAL
|
||||||
layoutParams.marginEnd = 10.dpToPx()
|
parentLayout.removeAllViews()
|
||||||
parentLayout.addView(appDrawIcon)
|
|
||||||
parentLayout.addView(appDrawName)
|
|
||||||
}
|
|
||||||
|
|
||||||
Gravity.END -> {
|
when (preferenceHelper.homeAppAlignment) {
|
||||||
layoutParams.marginStart = 10.dpToPx()
|
Gravity.START -> {
|
||||||
parentLayout.addView(appDrawName)
|
layoutParams.marginEnd = 10.dpToPx()
|
||||||
parentLayout.addView(appDrawIcon)
|
parentLayout.addView(appDrawIcon)
|
||||||
}
|
parentLayout.addView(appDrawName)
|
||||||
|
}
|
||||||
|
|
||||||
else -> {
|
Gravity.END -> {
|
||||||
appDrawIcon.visibility = View.GONE
|
layoutParams.marginStart = 10.dpToPx()
|
||||||
|
parentLayout.addView(appDrawName)
|
||||||
|
parentLayout.addView(appDrawIcon)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
parentLayout.addView(appDrawName)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -97,9 +106,7 @@ class DrawViewHolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
itemView.setOnLongClickListener {
|
itemView.setOnLongClickListener {
|
||||||
if (appInfo.userHandle <= 0) {
|
onAppLongClickedListener.onAppLongClicked(appInfo)
|
||||||
onAppLongClickedListener.onAppLongClicked(appInfo)
|
|
||||||
}
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.github.droidworksstudio.launcher.ui.home
|
package com.github.droidworksstudio.launcher.ui.home
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -10,6 +9,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.droidworksstudio.common.ColorIconsExtensions
|
import com.github.droidworksstudio.common.ColorIconsExtensions
|
||||||
import com.github.droidworksstudio.common.dpToPx
|
import com.github.droidworksstudio.common.dpToPx
|
||||||
|
import com.github.droidworksstudio.common.getAllProfileAppIcons
|
||||||
import com.github.droidworksstudio.launcher.R
|
import com.github.droidworksstudio.launcher.R
|
||||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||||
import com.github.droidworksstudio.launcher.databinding.ItemHomeBinding
|
import com.github.droidworksstudio.launcher.databinding.ItemHomeBinding
|
||||||
@@ -43,60 +43,71 @@ class HomeViewHolder @Inject constructor(
|
|||||||
appHomeName.gravity = preferenceHelper.homeAppAlignment
|
appHomeName.gravity = preferenceHelper.homeAppAlignment
|
||||||
|
|
||||||
if (preferenceHelper.showAppIcon) {
|
if (preferenceHelper.showAppIcon) {
|
||||||
val pm: PackageManager = binding.root.context.packageManager
|
val appInfoMap = root.context.getAllProfileAppIcons()
|
||||||
val appIcon = pm.getApplicationIcon(appInfo.packageName)
|
appInfoMap.forEach { (key, icon) ->
|
||||||
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.iconPack == Constants.IconPacks.System) 2f else 1.1f).toInt()
|
val userHandle: Int? = key.first
|
||||||
|
val packageName: String? = key.second
|
||||||
|
if (appInfo.packageName == packageName && appInfo.userHandle == userHandle) {
|
||||||
|
val easyDot = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
||||||
|
val appIcon = icon
|
||||||
|
val nonNullDrawable: Drawable = appIcon ?: easyDot
|
||||||
|
|
||||||
val layoutParams = LinearLayoutCompat.LayoutParams(appIconSize, appIconSize)
|
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.iconPack == Constants.IconPacks.System) 2f else 1.1f).toInt()
|
||||||
val appNewIcon: Drawable? = if (preferenceHelper.iconPack == Constants.IconPacks.EasyDots) {
|
|
||||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
|
||||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
|
||||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
|
||||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
|
||||||
} else if (preferenceHelper.iconPack == Constants.IconPacks.NiagaraDots) {
|
|
||||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_niagara_dot_icon)!!
|
|
||||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
|
||||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
|
||||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
appHomeIcon.layoutParams = layoutParams
|
val layoutParams = LinearLayoutCompat.LayoutParams(appIconSize, appIconSize)
|
||||||
appHomeIcon.setImageDrawable(appNewIcon ?: appIcon)
|
val appNewIcon: Drawable? = if (preferenceHelper.iconPack == Constants.IconPacks.EasyDots) {
|
||||||
appHomeIcon.visibility = View.VISIBLE
|
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
||||||
|
val bitmap = ColorIconsExtensions.drawableToBitmap(nonNullDrawable)
|
||||||
|
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||||
|
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||||
|
} else if (preferenceHelper.iconPack == Constants.IconPacks.NiagaraDots) {
|
||||||
|
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_niagara_dot_icon)!!
|
||||||
|
val bitmap = ColorIconsExtensions.drawableToBitmap(nonNullDrawable)
|
||||||
|
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||||
|
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
val parentLayout = appHomeName.parent as LinearLayoutCompat
|
appHomeIcon.layoutParams = layoutParams
|
||||||
parentLayout.orientation = LinearLayoutCompat.HORIZONTAL
|
appHomeIcon.setImageDrawable(appNewIcon ?: nonNullDrawable)
|
||||||
parentLayout.removeAllViews()
|
appHomeIcon.visibility = View.VISIBLE
|
||||||
|
|
||||||
when (preferenceHelper.homeAppAlignment) {
|
val parentLayout = appHomeName.parent as LinearLayoutCompat
|
||||||
Gravity.START -> {
|
parentLayout.orientation = LinearLayoutCompat.HORIZONTAL
|
||||||
layoutParams.marginEnd = 10.dpToPx()
|
parentLayout.removeAllViews()
|
||||||
parentLayout.addView(appHomeIcon)
|
|
||||||
parentLayout.addView(appHomeName)
|
|
||||||
}
|
|
||||||
|
|
||||||
Gravity.END -> {
|
when (preferenceHelper.homeAppAlignment) {
|
||||||
layoutParams.marginStart = 10.dpToPx()
|
Gravity.START -> {
|
||||||
parentLayout.addView(appHomeName)
|
layoutParams.marginEnd = 10.dpToPx()
|
||||||
parentLayout.addView(appHomeIcon)
|
parentLayout.addView(appHomeIcon)
|
||||||
}
|
parentLayout.addView(appHomeName)
|
||||||
|
}
|
||||||
|
|
||||||
else -> {
|
Gravity.END -> {
|
||||||
parentLayout.addView(appHomeName)
|
layoutParams.marginStart = 10.dpToPx()
|
||||||
|
parentLayout.addView(appHomeName)
|
||||||
|
parentLayout.addView(appHomeIcon)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
parentLayout.addView(appHomeName)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
appHomeIcon.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
itemView.setOnClickListener {
|
appHomeName.setOnClickListener {
|
||||||
onAppClickedListener.onAppClicked(appInfo)
|
onAppClickedListener.onAppClicked(appInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.setOnLongClickListener {
|
appHomeName.setOnLongClickListener {
|
||||||
onAppLongClickedListener.onAppLongClicked(appInfo)
|
onAppLongClickedListener.onAppLongClicked(appInfo)
|
||||||
true
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:text="@string/bottom_dialog_app_rename"
|
android:text="@string/bottom_dialog_app_rename"
|
||||||
android:textSize="@dimen/bottom_dialog_text_large"></androidx.appcompat.widget.AppCompatEditText>
|
android:textSize="@dimen/bottom_dialog_text_large" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/bottom_sheet_rename_done"
|
android:id="@+id/bottom_sheet_rename_done"
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/bottom_sheet1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
@@ -66,6 +67,7 @@
|
|||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/bottom_sheet2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
@@ -88,6 +90,7 @@
|
|||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/bottom_sheet3"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
@@ -109,6 +112,7 @@
|
|||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/bottom_sheet4"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
@@ -130,6 +134,7 @@
|
|||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/bottom_sheet5"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
@@ -150,7 +155,7 @@
|
|||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
android:id="@+id/bottom_sheet4"
|
android:id="@+id/bottom_sheet6"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.drawer.DrawFragment">
|
tools:context=".ui.drawer.DrawFragment">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/touchArea"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginVertical="20dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
android:id="@+id/mainView"
|
android:id="@+id/mainView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -44,11 +50,18 @@
|
|||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
android:id="@+id/drawAdapter"
|
android:id="@+id/appListTouchArea"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/search_view_text" />
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/drawAdapter"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/search_view_text" />
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
|||||||
@@ -12,22 +12,11 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:ignore="MissingConstraints">
|
tools:ignore="MissingConstraints">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/appDrawDots_icon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_marginTop="1dp"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/appDraw_icon"
|
android:id="@+id/appDraw_icon"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_marginTop="1dp"
|
android:layout_marginTop="1dp"
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
|||||||
@@ -229,6 +229,7 @@
|
|||||||
<string name="acra_mail_body">A crash has occurred in the application.\n\nBelow are the details of the device. The error log has been attached as a file for your reference. We would appreciate your assistance in resolving this issue.\n\nDevice Information: \n[PLEASE fill in the information below also removing anything between the square brackets or this will be ignored.]\n\n- App Version: [11.11.11]\n- Android Version: [Apple 1.16]\n- Device Name: [Android Apple Phone 69]\n- Install Location: [Github, Fdroid, Obtanium, Tesla Space Station]\n\nYour prompt attention to this matter is greatly appreciated.\n\nThank you.\n</string>
|
<string name="acra_mail_body">A crash has occurred in the application.\n\nBelow are the details of the device. The error log has been attached as a file for your reference. We would appreciate your assistance in resolving this issue.\n\nDevice Information: \n[PLEASE fill in the information below also removing anything between the square brackets or this will be ignored.]\n\n- App Version: [11.11.11]\n- Android Version: [Apple 1.16]\n- Device Name: [Android Apple Phone 69]\n- Install Location: [Github, Fdroid, Obtanium, Tesla Space Station]\n\nYour prompt attention to this matter is greatly appreciated.\n\nThank you.\n</string>
|
||||||
|
|
||||||
<string name="admin_permission_message">mLauncher promises to use lock screen permission responsibly. mLauncher does not collect or share any data.</string>
|
<string name="admin_permission_message">mLauncher promises to use lock screen permission responsibly. mLauncher does not collect or share any data.</string>
|
||||||
|
<string name="work_permission_message">You must use the Work Profile Manager to perform this action.</string>
|
||||||
|
|
||||||
<string-array name="alignment_options">
|
<string-array name="alignment_options">
|
||||||
<item>Left</item>
|
<item>Left</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user