mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-03-04 11:28:07 +01:00
updating Commons, kotlin, gradle, min Android OS version to 5
This commit is contained in:
parent
c20673a94e
commit
e67423b9f7
@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
|
|||||||
apply plugin: 'kotlin-android-extensions'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion 28
|
||||||
buildToolsVersion "27.0.3"
|
buildToolsVersion "28.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.simplemobiletools.applauncher"
|
applicationId "com.simplemobiletools.applauncher"
|
||||||
minSdkVersion 16
|
minSdkVersion 21
|
||||||
targetSdkVersion 27
|
targetSdkVersion 28
|
||||||
versionCode 15
|
versionCode 15
|
||||||
versionName "4.1.1"
|
versionName "4.1.1"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
@ -42,9 +42,9 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:4.6.7'
|
implementation 'com.simplemobiletools:commons:5.0.18'
|
||||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
implementation 'androidx.multidex:multidex:2.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
Properties props = new Properties()
|
Properties props = new Properties()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.simplemobiletools.applauncher
|
package com.simplemobiletools.applauncher
|
||||||
|
|
||||||
import android.support.multidex.MultiDexApplication
|
import androidx.multidex.MultiDexApplication
|
||||||
import com.facebook.stetho.Stetho
|
import com.facebook.stetho.Stetho
|
||||||
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import com.simplemobiletools.applauncher.models.AppLauncher
|
|||||||
import com.simplemobiletools.commons.extensions.appLaunched
|
import com.simplemobiletools.commons.extensions.appLaunched
|
||||||
import com.simplemobiletools.commons.extensions.checkWhatsNew
|
import com.simplemobiletools.commons.extensions.checkWhatsNew
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
|
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_STETHO
|
import com.simplemobiletools.commons.helpers.LICENSE_STETHO
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
@ -94,7 +93,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun launchAbout() {
|
private fun launchAbout() {
|
||||||
val licenses = LICENSE_MULTISELECT or LICENSE_STETHO
|
val licenses = LICENSE_STETHO
|
||||||
|
|
||||||
val faqItems = arrayListOf(
|
val faqItems = arrayListOf(
|
||||||
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons)
|
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons)
|
||||||
|
@ -17,7 +17,6 @@ import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
|||||||
import com.simplemobiletools.commons.views.FastScroller
|
import com.simplemobiletools.commons.views.FastScroller
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.item_app_launcher.view.*
|
import kotlinx.android.synthetic.main.item_app_launcher.view.*
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppLauncher>, val listener: RefreshRecyclerViewListener?,
|
class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppLauncher>, val listener: RefreshRecyclerViewListener?,
|
||||||
recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
||||||
@ -29,26 +28,6 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppL
|
|||||||
|
|
||||||
override fun getActionMenuId() = R.menu.cab
|
override fun getActionMenuId() = R.menu.cab
|
||||||
|
|
||||||
override fun prepareItemSelection(viewHolder: ViewHolder) {
|
|
||||||
viewHolder.itemView?.launcher_check?.background?.applyColorFilter(primaryColor)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
|
|
||||||
viewHolder?.itemView?.launcher_check?.beInvisibleIf(!select)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_app_launcher, parent)
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
|
||||||
val launcher = launchers[position]
|
|
||||||
val view = holder.bindView(launcher, true, true) { itemView, adapterPosition ->
|
|
||||||
setupView(itemView, launcher)
|
|
||||||
}
|
|
||||||
bindViewHolder(holder, position, view)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount() = launchers.size
|
|
||||||
|
|
||||||
override fun prepareActionMode(menu: Menu) {
|
override fun prepareActionMode(menu: Menu) {
|
||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.cab_edit).isVisible = isOneItemSelected()
|
findItem(R.id.cab_edit).isVisible = isOneItemSelected()
|
||||||
@ -56,18 +35,40 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppL
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun actionItemPressed(id: Int) {
|
override fun actionItemPressed(id: Int) {
|
||||||
|
if (selectedKeys.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
when (id) {
|
when (id) {
|
||||||
R.id.cab_edit -> showEditDialog()
|
R.id.cab_edit -> showEditDialog()
|
||||||
R.id.cab_remove -> tryRemoveLauncher()
|
R.id.cab_remove -> tryRemoveLauncher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_app_launcher, parent)
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
|
val launcher = launchers[position]
|
||||||
|
holder.bindView(launcher, true, true) { itemView, adapterPosition ->
|
||||||
|
setupView(itemView, launcher, isKeySelected(launcher.packageName.hashCode()))
|
||||||
|
}
|
||||||
|
bindViewHolder(holder)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = launchers.size
|
||||||
|
|
||||||
|
private fun getItemWithKey(key: Int): AppLauncher? = launchers.firstOrNull { it.packageName.hashCode() == key }
|
||||||
|
|
||||||
override fun getSelectableItemCount() = launchers.size
|
override fun getSelectableItemCount() = launchers.size
|
||||||
|
|
||||||
override fun getIsItemSelectable(position: Int) = true
|
override fun getIsItemSelectable(position: Int) = true
|
||||||
|
|
||||||
|
override fun getItemSelectionKey(position: Int) = launchers.getOrNull(position)?.packageName?.hashCode()
|
||||||
|
|
||||||
|
override fun getItemKeyPosition(key: Int) = launchers.indexOfFirst { it.packageName.hashCode() == key }
|
||||||
|
|
||||||
private fun showEditDialog() {
|
private fun showEditDialog() {
|
||||||
EditDialog(activity, launchers[selectedPositions.first()]) {
|
EditDialog(activity, getItemWithKey(selectedKeys.first())!!) {
|
||||||
finishActMode()
|
finishActMode()
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
}
|
}
|
||||||
@ -89,24 +90,38 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppL
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun removeItems() {
|
private fun removeItems() {
|
||||||
val removeIds = ArrayList<String>(selectedPositions.size)
|
val removeIds = ArrayList<String>(selectedKeys.size)
|
||||||
val removeLaunchers = ArrayList<AppLauncher>(selectedPositions.size)
|
val removeLaunchers = ArrayList<AppLauncher>(selectedKeys.size)
|
||||||
selectedPositions.sortedDescending().forEach {
|
val positions = ArrayList<Int>(selectedKeys.size)
|
||||||
val launcher = launchers[it]
|
|
||||||
|
for (key in selectedKeys) {
|
||||||
|
val launcher = getItemWithKey(key) ?: continue
|
||||||
removeIds.add(launcher.id.toString())
|
removeIds.add(launcher.id.toString())
|
||||||
removeLaunchers.add(launcher)
|
removeLaunchers.add(launcher)
|
||||||
|
|
||||||
|
val position = launchers.indexOfFirst { it.packageName.hashCode() == key }
|
||||||
|
if (position != -1) {
|
||||||
|
positions.add(position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
launchers.removeAll(removeLaunchers)
|
launchers.removeAll(removeLaunchers)
|
||||||
activity.dbHelper.deleteLaunchers(removeIds)
|
activity.dbHelper.deleteLaunchers(removeIds)
|
||||||
removeSelectedItems()
|
positions.sortDescending()
|
||||||
|
removeSelectedItems(positions)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, launcher: AppLauncher) {
|
private fun setupView(view: View, launcher: AppLauncher, isSelected: Boolean) {
|
||||||
view.apply {
|
view.apply {
|
||||||
|
// setup check icon
|
||||||
|
launcher_check?.beInvisibleIf(!isSelected)
|
||||||
launcher_label.text = launcher.name
|
launcher_label.text = launcher.name
|
||||||
launcher_label.setTextColor(textColor)
|
launcher_label.setTextColor(textColor)
|
||||||
launcher_icon.setImageDrawable(launcher.drawable!!)
|
launcher_icon.setImageDrawable(launcher.drawable!!)
|
||||||
|
|
||||||
|
if (isSelected) {
|
||||||
|
launcher_check?.background?.applyColorFilter(primaryColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,87 +1,74 @@
|
|||||||
package com.simplemobiletools.applauncher.adapters
|
package com.simplemobiletools.applauncher.adapters
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.support.v7.widget.RecyclerView
|
|
||||||
import android.util.SparseArray
|
|
||||||
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 androidx.recyclerview.widget.RecyclerView
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.extensions.config
|
import com.simplemobiletools.applauncher.extensions.config
|
||||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.beInvisibleIf
|
import com.simplemobiletools.commons.extensions.beInvisibleIf
|
||||||
import com.simplemobiletools.commons.interfaces.MyAdapterListener
|
|
||||||
import kotlinx.android.synthetic.main.item_app_launcher.view.*
|
import kotlinx.android.synthetic.main.item_app_launcher.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class LaunchersDialogAdapter(activity: Activity, val launchers: ArrayList<AppLauncher>) : RecyclerView.Adapter<LaunchersDialogAdapter.ViewHolder>() {
|
class LaunchersDialogAdapter(activity: Activity, val launchers: ArrayList<AppLauncher>) : RecyclerView.Adapter<LaunchersDialogAdapter.ViewHolder>() {
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
private var primaryColor = config.primaryColor
|
private var primaryColor = config.primaryColor
|
||||||
private var itemViews = SparseArray<View>()
|
|
||||||
private val selectedPositions = HashSet<Int>()
|
|
||||||
private var textColor = config.textColor
|
private var textColor = config.textColor
|
||||||
|
private var selectedKeys = HashSet<Int>()
|
||||||
|
|
||||||
fun toggleItemSelection(select: Boolean, pos: Int) {
|
fun toggleItemSelection(select: Boolean, pos: Int) {
|
||||||
|
val itemKey = launchers.getOrNull(pos)?.packageName?.hashCode() ?: return
|
||||||
|
|
||||||
if (select) {
|
if (select) {
|
||||||
if (itemViews[pos] != null) {
|
selectedKeys.add(itemKey)
|
||||||
itemViews[pos].launcher_check?.background?.applyColorFilter(primaryColor)
|
|
||||||
selectedPositions.add(pos)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
selectedPositions.remove(pos)
|
selectedKeys.remove(itemKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemViews[pos]?.launcher_check?.beInvisibleIf(!select)
|
notifyItemChanged(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSelectedLaunchers(): ArrayList<AppLauncher> {
|
fun getSelectedLaunchers() = launchers.filter { selectedKeys.contains(it.packageName.hashCode()) } as ArrayList<AppLauncher>
|
||||||
val selectedLaunchers = ArrayList<AppLauncher>()
|
|
||||||
selectedPositions.forEach {
|
|
||||||
selectedLaunchers.add(launchers[it])
|
|
||||||
}
|
|
||||||
return selectedLaunchers
|
|
||||||
}
|
|
||||||
|
|
||||||
private val adapterListener = object : MyAdapterListener {
|
|
||||||
override fun itemLongClicked(position: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toggleItemSelectionAdapter(select: Boolean, position: Int) {
|
|
||||||
toggleItemSelection(select, position)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
itemViews.put(position, holder.bindView(launchers[position], textColor))
|
holder.bindView(launchers[position])
|
||||||
toggleItemSelection(selectedPositions.contains(position), position)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_app_launcher, parent, false)
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_app_launcher, parent, false)
|
||||||
return ViewHolder(view, adapterListener)
|
return ViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = launchers.size
|
override fun getItemCount() = launchers.size
|
||||||
|
|
||||||
class ViewHolder(view: View, val adapterListener: MyAdapterListener) : RecyclerView.ViewHolder(view) {
|
private fun isKeySelected(key: Int) = selectedKeys.contains(key)
|
||||||
fun bindView(launcher: AppLauncher, textColor: Int): View {
|
|
||||||
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
fun bindView(launcher: AppLauncher): View {
|
||||||
|
val isSelected = isKeySelected(launcher.packageName.hashCode())
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
|
launcher_check?.beInvisibleIf(!isSelected)
|
||||||
launcher_label.text = launcher.name
|
launcher_label.text = launcher.name
|
||||||
launcher_label.setTextColor(textColor)
|
launcher_label.setTextColor(textColor)
|
||||||
launcher_icon.setImageDrawable(launcher.drawable!!)
|
launcher_icon.setImageDrawable(launcher.drawable!!)
|
||||||
|
|
||||||
setOnClickListener { viewClicked() }
|
if (isSelected) {
|
||||||
setOnLongClickListener { viewClicked(); true }
|
launcher_check?.background?.applyColorFilter(primaryColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
setOnClickListener { viewClicked(launcher) }
|
||||||
|
setOnLongClickListener { viewClicked(launcher); true }
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemView
|
return itemView
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun viewClicked() {
|
private fun viewClicked(launcher: AppLauncher) {
|
||||||
val isSelected = adapterListener.getSelectedPositions().contains(adapterPosition)
|
val isSelected = selectedKeys.contains(launcher.packageName.hashCode())
|
||||||
adapterListener.toggleItemSelectionAdapter(!isSelected, adapterPosition)
|
toggleItemSelection(!isSelected, adapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.simplemobiletools.applauncher.dialogs
|
package com.simplemobiletools.applauncher.dialogs
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.support.v7.app.AlertDialog
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.adapters.LaunchersDialogAdapter
|
import com.simplemobiletools.applauncher.adapters.LaunchersDialogAdapter
|
||||||
import com.simplemobiletools.applauncher.extensions.dbHelper
|
import com.simplemobiletools.applauncher.extensions.dbHelper
|
||||||
@ -16,7 +16,7 @@ class AddAppLauncherDialog(val activity: Activity, val notDisplayedLaunchers: Ar
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmSelection() })
|
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmSelection() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this) {
|
activity.setupDialogStuff(view, this) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.simplemobiletools.applauncher.dialogs
|
package com.simplemobiletools.applauncher.dialogs
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.support.v7.app.AlertDialog
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.extensions.dbHelper
|
import com.simplemobiletools.applauncher.extensions.dbHelper
|
||||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||||
|
@ -1,22 +1,18 @@
|
|||||||
package com.simplemobiletools.applauncher.extensions
|
package com.simplemobiletools.applauncher.extensions
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.LauncherApps
|
import android.content.pm.LauncherApps
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
|
||||||
import com.simplemobiletools.applauncher.helpers.Config
|
import com.simplemobiletools.applauncher.helpers.Config
|
||||||
import com.simplemobiletools.applauncher.helpers.DBHelper
|
import com.simplemobiletools.applauncher.helpers.DBHelper
|
||||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||||
import com.simplemobiletools.commons.helpers.isLollipopPlus
|
|
||||||
|
|
||||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||||
|
|
||||||
val Context.dbHelper: DBHelper get() = DBHelper.newInstance(applicationContext)
|
val Context.dbHelper: DBHelper get() = DBHelper.newInstance(applicationContext)
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
fun Context.getNotDisplayedLaunchers(displayedLaunchers: ArrayList<AppLauncher>): ArrayList<AppLauncher> {
|
fun Context.getNotDisplayedLaunchers(displayedLaunchers: ArrayList<AppLauncher>): ArrayList<AppLauncher> {
|
||||||
val allApps = ArrayList<AppLauncher>()
|
val allApps = ArrayList<AppLauncher>()
|
||||||
val intent = Intent(Intent.ACTION_MAIN, null)
|
val intent = Intent(Intent.ACTION_MAIN, null)
|
||||||
@ -28,14 +24,12 @@ fun Context.getNotDisplayedLaunchers(displayedLaunchers: ArrayList<AppLauncher>)
|
|||||||
val packageName = componentInfo.packageName
|
val packageName = componentInfo.packageName
|
||||||
|
|
||||||
var drawable: Drawable? = null
|
var drawable: Drawable? = null
|
||||||
if (isLollipopPlus()) {
|
try {
|
||||||
try {
|
// try getting the properly colored launcher icons
|
||||||
// try getting the properly colored launcher icons
|
val launcher = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
val launcher = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
val activityList = launcher.getActivityList(packageName, android.os.Process.myUserHandle())[0]
|
||||||
val activityList = launcher.getActivityList(packageName, android.os.Process.myUserHandle())[0]
|
drawable = activityList.getBadgedIcon(0)
|
||||||
drawable = activityList.getBadgedIcon(0)
|
} catch (e: Exception) {
|
||||||
} catch (e: Exception) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawable == null) {
|
if (drawable == null) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.simplemobiletools.applauncher.helpers
|
package com.simplemobiletools.applauncher.helpers
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.LauncherApps
|
import android.content.pm.LauncherApps
|
||||||
@ -8,7 +7,6 @@ import android.content.pm.PackageManager
|
|||||||
import android.database.sqlite.SQLiteDatabase
|
import android.database.sqlite.SQLiteDatabase
|
||||||
import android.database.sqlite.SQLiteOpenHelper
|
import android.database.sqlite.SQLiteOpenHelper
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.extensions.getLauncherDrawable
|
import com.simplemobiletools.applauncher.extensions.getLauncherDrawable
|
||||||
@ -16,7 +14,6 @@ import com.simplemobiletools.applauncher.extensions.isAPredefinedApp
|
|||||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||||
import com.simplemobiletools.commons.extensions.getIntValue
|
import com.simplemobiletools.commons.extensions.getIntValue
|
||||||
import com.simplemobiletools.commons.extensions.getStringValue
|
import com.simplemobiletools.commons.extensions.getStringValue
|
||||||
import com.simplemobiletools.commons.helpers.isLollipopPlus
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||||
@ -123,7 +120,6 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
return mDb.update(MAIN_TABLE_NAME, values, selection, selectionArgs) == 1
|
return mDb.update(MAIN_TABLE_NAME, values, selection, selectionArgs) == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
fun getLaunchers(): ArrayList<AppLauncher> {
|
fun getLaunchers(): ArrayList<AppLauncher> {
|
||||||
val resources = context.resources
|
val resources = context.resources
|
||||||
val packageManager = context.packageManager
|
val packageManager = context.packageManager
|
||||||
@ -139,18 +135,16 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
val wasRenamed = cursor.getIntValue(COL_WAS_RENAMED) == 1
|
val wasRenamed = cursor.getIntValue(COL_WAS_RENAMED) == 1
|
||||||
|
|
||||||
var drawable: Drawable? = null
|
var drawable: Drawable? = null
|
||||||
if (isLollipopPlus()) {
|
try {
|
||||||
try {
|
// try getting the properly colored launcher icons
|
||||||
// try getting the properly colored launcher icons
|
val launcher = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
val launcher = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
val activityList = launcher.getActivityList(packageName, android.os.Process.myUserHandle())[0]
|
||||||
val activityList = launcher.getActivityList(packageName, android.os.Process.myUserHandle())[0]
|
drawable = activityList.getBadgedIcon(0)
|
||||||
drawable = activityList.getBadgedIcon(0)
|
|
||||||
|
|
||||||
if (!wasRenamed) {
|
if (!wasRenamed) {
|
||||||
name = activityList.label.toString()
|
name = activityList.label.toString()
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawable == null) {
|
if (drawable == null) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.design.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/coordinator_layout"
|
android:id="@+id/coordinator_layout"
|
||||||
@ -45,4 +45,4 @@
|
|||||||
android:layout_margin="@dimen/activity_margin"
|
android:layout_margin="@dimen/activity_margin"
|
||||||
android:src="@drawable/ic_plus"/>
|
android:src="@drawable/ic_plus"/>
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v7.widget.RecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/pick_launchers_holder"
|
android:id="@+id/pick_launchers_holder"
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.60'
|
ext.kotlin_version = '1.2.71'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.1.4'
|
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
@ -19,8 +19,8 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Fri Nov 10 21:55:37 CET 2017
|
#Fri Oct 12 23:02:59 CEST 2018
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user