mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-01-28 22:49:54 +01:00
adding an initial implementation of icon hiding
This commit is contained in:
parent
415c8501dd
commit
645dee47bc
@ -43,6 +43,7 @@ import com.simplemobiletools.launcher.fragments.WidgetsFragment
|
||||
import com.simplemobiletools.launcher.helpers.*
|
||||
import com.simplemobiletools.launcher.interfaces.FlingListener
|
||||
import com.simplemobiletools.launcher.models.AppLauncher
|
||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||
import com.simplemobiletools.launcher.models.HomeScreenGridItem
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_main.view.*
|
||||
@ -326,7 +327,9 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||
(Math.abs(mTouchDownX - event.x) > mMoveGestureThreshold) || (Math.abs(mTouchDownY - event.y) > mMoveGestureThreshold)
|
||||
|
||||
private fun refetchLaunchers() {
|
||||
val launchers = getAllAppLaunchers()
|
||||
val hiddenIcons = hiddenIconsDB.getHiddenIcons().map { it.getIconIdentifier() }
|
||||
val launchers = getAllAppLaunchers().filter { !hiddenIcons.contains(it.getLauncherIdentifier()) }.toMutableList() as ArrayList<AppLauncher>
|
||||
|
||||
(all_apps_fragment as AllAppsFragment).gotLaunchers(launchers)
|
||||
(widgets_fragment as WidgetsFragment).getAppWidgets()
|
||||
|
||||
@ -485,7 +488,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||
}
|
||||
|
||||
private fun handleGridItemPopupMenu(anchorView: View, gridItem: HomeScreenGridItem, isOnAllAppsFragment: Boolean): PopupMenu {
|
||||
var visibleMenuButtons = 5
|
||||
var visibleMenuButtons = 6
|
||||
visibleMenuButtons -= when (gridItem.type) {
|
||||
ITEM_TYPE_ICON -> 1
|
||||
ITEM_TYPE_WIDGET -> 3
|
||||
@ -511,6 +514,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||
|
||||
inflate(R.menu.menu_app_icon)
|
||||
menu.findItem(R.id.rename).isVisible = gridItem.type == ITEM_TYPE_ICON && !isOnAllAppsFragment
|
||||
menu.findItem(R.id.hide_icon).isVisible = gridItem.type == ITEM_TYPE_ICON && isOnAllAppsFragment
|
||||
menu.findItem(R.id.resize).isVisible = gridItem.type == ITEM_TYPE_WIDGET
|
||||
menu.findItem(R.id.app_info).isVisible = gridItem.type == ITEM_TYPE_ICON
|
||||
menu.findItem(R.id.uninstall).isVisible = gridItem.type == ITEM_TYPE_ICON
|
||||
@ -518,6 +522,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||
setOnMenuItemClickListener { item ->
|
||||
resetFragmentTouches()
|
||||
when (item.itemId) {
|
||||
R.id.hide_icon -> hideIcon(gridItem)
|
||||
R.id.rename -> renameItem(gridItem)
|
||||
R.id.resize -> home_screen_grid.widgetLongPressed(gridItem)
|
||||
R.id.app_info -> launchAppInfo(gridItem.packageName)
|
||||
@ -552,6 +557,14 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||
showFragment(widgets_fragment)
|
||||
}
|
||||
|
||||
private fun hideIcon(item: HomeScreenGridItem) {
|
||||
ensureBackgroundThread {
|
||||
val hiddenIcon = HiddenIcon(null, item.packageName, item.activityName, item.title, null)
|
||||
hiddenIconsDB.insert(hiddenIcon)
|
||||
refetchLaunchers()
|
||||
}
|
||||
}
|
||||
|
||||
private fun renameItem(homeScreenGridItem: HomeScreenGridItem) {
|
||||
RenameItemDialog(this, homeScreenGridItem) {
|
||||
home_screen_grid.fetchGridItems()
|
||||
|
@ -12,6 +12,7 @@ import com.simplemobiletools.launcher.R
|
||||
import com.simplemobiletools.launcher.databases.AppsDatabase
|
||||
import com.simplemobiletools.launcher.helpers.Config
|
||||
import com.simplemobiletools.launcher.interfaces.AppLaunchersDao
|
||||
import com.simplemobiletools.launcher.interfaces.HiddenIconDao
|
||||
import com.simplemobiletools.launcher.interfaces.HomeScreenGridItemsDao
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
@ -20,6 +21,8 @@ val Context.launchersDB: AppLaunchersDao get() = AppsDatabase.getInstance(applic
|
||||
|
||||
val Context.homeScreenGridItemsDB: HomeScreenGridItemsDao get() = AppsDatabase.getInstance(applicationContext).HomeScreenGridItemsDao()
|
||||
|
||||
val Context.hiddenIconsDB: HiddenIconDao get() = AppsDatabase.getInstance(applicationContext).HiddenIconsDao()
|
||||
|
||||
fun Context.getColumnCount(): Int {
|
||||
return if (portrait) {
|
||||
resources.getInteger(R.integer.portrait_column_count)
|
||||
|
@ -36,6 +36,8 @@ data class AppLauncher(
|
||||
return copy(id = null, drawable = null).toString()
|
||||
}
|
||||
|
||||
fun getLauncherIdentifier() = "$packageName/$activityName"
|
||||
|
||||
override fun compareTo(other: AppLauncher): Int {
|
||||
var result = when {
|
||||
sorting and SORT_BY_TITLE != 0 -> title.normalizeString().lowercase().compareTo(other.title.normalizeString().lowercase())
|
||||
|
@ -13,4 +13,6 @@ data class HiddenIcon(
|
||||
@Ignore var drawable: Drawable? = null,
|
||||
) {
|
||||
constructor() : this(null, "", "", "", null)
|
||||
|
||||
fun getIconIdentifier() = "$packageName/$activityName"
|
||||
}
|
||||
|
@ -6,6 +6,11 @@
|
||||
android:icon="@drawable/ic_info_vector"
|
||||
android:title="@string/app_info"
|
||||
app:showAsAction="always" />
|
||||
<item
|
||||
android:id="@+id/hide_icon"
|
||||
android:icon="@drawable/ic_hide_vector"
|
||||
android:title="@string/hide"
|
||||
app:showAsAction="always" />
|
||||
<item
|
||||
android:id="@+id/resize"
|
||||
android:icon="@drawable/ic_resize_vector"
|
||||
|
Loading…
x
Reference in New Issue
Block a user