adding 2 new fields to HomeScreenGridItem for shortcuts
This commit is contained in:
parent
9ed0e55c15
commit
593b0d575e
|
@ -521,7 +521,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
try {
|
try {
|
||||||
val defaultDialerPackage = (getSystemService(Context.TELECOM_SERVICE) as TelecomManager).defaultDialerPackage
|
val defaultDialerPackage = (getSystemService(Context.TELECOM_SERVICE) as TelecomManager).defaultDialerPackage
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultDialerPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultDialerPackage }?.apply {
|
||||||
val dialerIcon = HomeScreenGridItem(null, 0, ROW_COUNT - 1, 0, ROW_COUNT - 1, defaultDialerPackage, title, ITEM_TYPE_ICON, "", -1)
|
val dialerIcon = HomeScreenGridItem(null, 0, ROW_COUNT - 1, 0, ROW_COUNT - 1, defaultDialerPackage, title, ITEM_TYPE_ICON, "", -1, "", null)
|
||||||
homeScreenGridItems.add(dialerIcon)
|
homeScreenGridItems.add(dialerIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -531,7 +531,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
val defaultSMSMessengerPackage = Telephony.Sms.getDefaultSmsPackage(this)
|
val defaultSMSMessengerPackage = Telephony.Sms.getDefaultSmsPackage(this)
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultSMSMessengerPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultSMSMessengerPackage }?.apply {
|
||||||
val SMSMessengerIcon =
|
val SMSMessengerIcon =
|
||||||
HomeScreenGridItem(null, 1, ROW_COUNT - 1, 1, ROW_COUNT - 1, defaultSMSMessengerPackage, title, ITEM_TYPE_ICON, "", -1)
|
HomeScreenGridItem(null, 1, ROW_COUNT - 1, 1, ROW_COUNT - 1, defaultSMSMessengerPackage, title, ITEM_TYPE_ICON, "", -1, "", null)
|
||||||
homeScreenGridItems.add(SMSMessengerIcon)
|
homeScreenGridItems.add(SMSMessengerIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -543,7 +543,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
val defaultBrowserPackage = resolveInfo!!.activityInfo.packageName
|
val defaultBrowserPackage = resolveInfo!!.activityInfo.packageName
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultBrowserPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultBrowserPackage }?.apply {
|
||||||
val browserIcon =
|
val browserIcon =
|
||||||
HomeScreenGridItem(null, 2, ROW_COUNT - 1, 2, ROW_COUNT - 1, defaultBrowserPackage, title, ITEM_TYPE_ICON, "", -1)
|
HomeScreenGridItem(null, 2, ROW_COUNT - 1, 2, ROW_COUNT - 1, defaultBrowserPackage, title, ITEM_TYPE_ICON, "", -1, "", null)
|
||||||
homeScreenGridItems.add(browserIcon)
|
homeScreenGridItems.add(browserIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -554,7 +554,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
val storePackage = potentialStores.firstOrNull { isPackageInstalled(it) && appLaunchers.map { it.packageName }.contains(it) }
|
val storePackage = potentialStores.firstOrNull { isPackageInstalled(it) && appLaunchers.map { it.packageName }.contains(it) }
|
||||||
if (storePackage != null) {
|
if (storePackage != null) {
|
||||||
appLaunchers.firstOrNull { it.packageName == storePackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == storePackage }?.apply {
|
||||||
val storeIcon = HomeScreenGridItem(null, 3, ROW_COUNT - 1, 3, ROW_COUNT - 1, storePackage, title, ITEM_TYPE_ICON, "", -1)
|
val storeIcon = HomeScreenGridItem(null, 3, ROW_COUNT - 1, 3, ROW_COUNT - 1, storePackage, title, ITEM_TYPE_ICON, "", -1, "", null)
|
||||||
homeScreenGridItems.add(storeIcon)
|
homeScreenGridItems.add(storeIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,7 +566,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
||||||
val resolveInfo = packageManager.resolveActivity(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY)
|
val resolveInfo = packageManager.resolveActivity(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY)
|
||||||
val defaultCameraPackage = resolveInfo!!.activityInfo.packageName
|
val defaultCameraPackage = resolveInfo!!.activityInfo.packageName
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultCameraPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultCameraPackage }?.apply {
|
||||||
val cameraIcon = HomeScreenGridItem(null, 4, ROW_COUNT - 1, 4, ROW_COUNT - 1, defaultCameraPackage, title, ITEM_TYPE_ICON, "", -1)
|
val cameraIcon = HomeScreenGridItem(null, 4, ROW_COUNT - 1, 4, ROW_COUNT - 1, defaultCameraPackage, title, ITEM_TYPE_ICON, "", -1, "", null)
|
||||||
homeScreenGridItems.add(cameraIcon)
|
homeScreenGridItems.add(cameraIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
|
@ -141,7 +141,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
|
|
||||||
override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) {
|
override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) {
|
||||||
val gridItem =
|
val gridItem =
|
||||||
HomeScreenGridItem(null, -1, -1, -1, -1, appLauncher.packageName, appLauncher.title, ITEM_TYPE_ICON, "", -1, appLauncher.drawable)
|
HomeScreenGridItem(null, -1, -1, -1, -1, appLauncher.packageName, appLauncher.title, ITEM_TYPE_ICON, "", -1, "", null, appLauncher.drawable)
|
||||||
activity?.showHomeIconMenu(x, y, gridItem, true)
|
activity?.showHomeIconMenu(x, y, gridItem, true)
|
||||||
ignoreTouches = true
|
ignoreTouches = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,8 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
||||||
type,
|
type,
|
||||||
appWidget.className,
|
appWidget.className,
|
||||||
-1,
|
-1,
|
||||||
|
"",
|
||||||
|
null,
|
||||||
appWidget.widgetPreviewImage,
|
appWidget.widgetPreviewImage,
|
||||||
appWidget.providerInfo,
|
appWidget.providerInfo,
|
||||||
appWidget.activityInfo,
|
appWidget.activityInfo,
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.simplemobiletools.launcher.helpers
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
class Converters {
|
||||||
|
@TypeConverter
|
||||||
|
fun toBitmap(bytes: ByteArray): Bitmap? {
|
||||||
|
return BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
@TypeConverter
|
||||||
|
fun fromBitmap(bmp: Bitmap?): ByteArray {
|
||||||
|
val outputStream = ByteArrayOutputStream()
|
||||||
|
bmp?.compress(Bitmap.CompressFormat.PNG, 100, outputStream)
|
||||||
|
return outputStream.toByteArray()
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.launcher.models
|
||||||
import android.appwidget.AppWidgetProviderInfo
|
import android.appwidget.AppWidgetProviderInfo
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import androidx.room.*
|
import androidx.room.*
|
||||||
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_ICON
|
import com.simplemobiletools.launcher.helpers.ITEM_TYPE_ICON
|
||||||
|
@ -20,6 +21,8 @@ data class HomeScreenGridItem(
|
||||||
@ColumnInfo(name = "type") var type: Int,
|
@ColumnInfo(name = "type") var type: Int,
|
||||||
@ColumnInfo(name = "class_name") var className: String,
|
@ColumnInfo(name = "class_name") var className: String,
|
||||||
@ColumnInfo(name = "widget_id") var widgetId: Int,
|
@ColumnInfo(name = "widget_id") var widgetId: Int,
|
||||||
|
@ColumnInfo(name = "intent") var intent: String, // used at shortcuts on click
|
||||||
|
@ColumnInfo(name = "icon") var icon: Bitmap?, // store only images of shortcuts, those cannot be retrieved anytime
|
||||||
|
|
||||||
@Ignore var drawable: Drawable? = null,
|
@Ignore var drawable: Drawable? = null,
|
||||||
@Ignore var providerInfo: AppWidgetProviderInfo? = null, // used at widgets
|
@Ignore var providerInfo: AppWidgetProviderInfo? = null, // used at widgets
|
||||||
|
@ -27,7 +30,7 @@ data class HomeScreenGridItem(
|
||||||
@Ignore var widthCells: Int = 1,
|
@Ignore var widthCells: Int = 1,
|
||||||
@Ignore var heightCells: Int = 1
|
@Ignore var heightCells: Int = 1
|
||||||
) {
|
) {
|
||||||
constructor() : this(null, -1, -1, -1, -1, "", "", ITEM_TYPE_ICON, "", -1, null, null, null, 1, 1)
|
constructor() : this(null, -1, -1, -1, -1, "", "", ITEM_TYPE_ICON, "", -1, "", null, null, null, null, 1, 1)
|
||||||
|
|
||||||
fun getWidthInCells() = if (right == -1 || left == -1) {
|
fun getWidthInCells() = if (right == -1 || left == -1) {
|
||||||
widthCells
|
widthCells
|
||||||
|
|
|
@ -273,6 +273,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
draggedItem!!.type,
|
draggedItem!!.type,
|
||||||
"",
|
"",
|
||||||
-1,
|
-1,
|
||||||
|
"",
|
||||||
|
draggedItem!!.icon,
|
||||||
draggedItem!!.drawable,
|
draggedItem!!.drawable,
|
||||||
draggedItem!!.providerInfo,
|
draggedItem!!.providerInfo,
|
||||||
draggedItem!!.activityInfo
|
draggedItem!!.activityInfo
|
||||||
|
|
Loading…
Reference in New Issue