Loading .gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,4 @@ bin/ local.properties build/ .DS_Store blissWithQuickstep/ bliss/res/values/arrays.xml +4 −0 Original line number Diff line number Diff line Loading @@ -12,4 +12,8 @@ <string-array name="aliased_apps"> <item>com.generalmagic.magicearth</item> <item>@string/maps</item> </string-array> <string-array name="blacklisted_widget_options"> <item>org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderDino</item> </string-array> </resources> bliss/src/foundation/e/bliss/LauncherAppMonitor.java +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.Utilities; import com.android.launcher3.LauncherPrefs; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; Loading Loading @@ -103,7 +103,7 @@ public class LauncherAppMonitor extends LauncherApps.Callback } public void onUserUnlocked(Context context) { Utilities.getPrefs(context).registerOnSharedPreferenceChangeListener(this); LauncherPrefs.getPrefs(context).registerOnSharedPreferenceChangeListener(this); } @Override Loading bliss/src/foundation/e/bliss/multimode/MultiModeController.kt +7 −28 Original line number Diff line number Diff line Loading @@ -8,11 +8,8 @@ package foundation.e.bliss.multimode import android.content.Context import android.content.SharedPreferences import android.content.res.Resources import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.LauncherPrefs import com.android.launcher3.model.data.AppInfo import com.android.launcher3.util.Executors.MODEL_EXECUTOR import foundation.e.bliss.BaseController Loading Loading @@ -69,8 +66,7 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) } init { sharedPreferences = Utilities.getPrefs(context.createDeviceProtectedStorageContext()) resources = context.resources prefs = LauncherPrefs.get(context) monitor.registerCallback(mAppMonitorCallback) } Loading @@ -88,31 +84,14 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) companion object { private const val TAG = "MultiModeController" @JvmField var sharedPreferences: SharedPreferences? = null @JvmField var resources: Resources? = null private fun throwIfControllerNotInit() { val launcherAppMonitor = LauncherAppMonitor.getInstanceNoCreate() if (launcherAppMonitor == null || launcherAppMonitor.multiModeController == null) { throw RuntimeException("MultiModeController is not init.") } } private lateinit var prefs: LauncherPrefs @JvmStatic val isSingleLayerMode: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean( BlissPrefs.PREF_SINGLE_LAYER_MODE, resources!!.getBoolean(R.bool.default_single_mode) ) } val isSingleLayerMode get() = prefs.get(LauncherPrefs.IS_SINGLE_LAYER_ENABLED) @JvmStatic val isNotifCountEnabled: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean(BlissPrefs.PREF_NOTIF_COUNT, true) } val isNotifCountEnabled get() = prefs.get(LauncherPrefs.IS_NOTIF_COUNT_ENABLED) } } bliss/src/foundation/e/bliss/utils/BlissDbUtils.kt +57 −8 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.content.ComponentName import android.content.ContentValues import android.content.Context import android.content.Intent import android.net.Uri import android.os.UserHandle import android.os.UserManager import com.android.launcher3.InvariantDeviceProfile Loading Loading @@ -43,20 +44,18 @@ object BlissDbUtils { private const val folderType = 2 @JvmStatic fun migrateDataFromDb(context: Context): Boolean { fun migrateDataFromDb(context: Context, dbHelper: LauncherProvider.DatabaseHelper): Boolean { // Check if old database exists val oldFile = context.getDatabasePath(oldDbName) if (!oldFile.exists()) return false // Current database details val currentDbName = InvariantDeviceProfile.INSTANCE[context].dbFile val rowCount = InvariantDeviceProfile.INSTANCE[context].numRows val columnCount = InvariantDeviceProfile.INSTANCE[context].numColumns val numFolderRows = InvariantDeviceProfile.INSTANCE[context].numFolderRows val numFolderColumns = InvariantDeviceProfile.INSTANCE[context].numFolderColumns // Init database helper classes val dbHelper = LauncherProvider.DatabaseHelper(context, currentDbName, false) val oldDbHelper = BlissDbHelper(context, oldDbName) // Retrieve data from the old table Loading Loading @@ -148,6 +147,15 @@ object BlissDbUtils { } } val installedPwaList = getInstalledPwa(context) if (installedPwaList.isNotEmpty() && appsPwaList.isNotEmpty()) { installedPwaList.forEach { installedPwa -> if (!appsPwaList.any { it.itemId == installedPwa.shortcutId }) { deleteInstalledPwa(context, installedPwa.shortcutId) } } } // Insert folder first, so we can store it's id and use it for apps/pwa. for (item in folderList) { val fav = item.key Loading Loading @@ -217,8 +225,6 @@ object BlissDbUtils { } } dbHelper.close() // Rename the database to old val newFile = context.getDatabasePath(oldDbName + "_old") oldFile.renameTo(newFile) Loading @@ -226,6 +232,51 @@ object BlissDbUtils { return true } private fun deleteInstalledPwa(context: Context, shortcutId: String) { try { context.contentResolver.delete( Uri.parse("content://foundation.e.pwaplayer.provider/pwa"), null, arrayOf(shortcutId) ) } catch (e: Exception) { Logger.e(TAG, "deleteInstalledPwa: ", e) } } private fun getInstalledPwa(context: Context): MutableList<PwaItems> { val pwaInfoList = mutableListOf<PwaItems>() try { context.contentResolver .query( Uri.parse("content://foundation.e.pwaplayer.provider/pwa"), null, null, null, null ) ?.let { cursor -> cursor.moveToFirst() while (!cursor.isAfterLast) { val pwaItemDbId = cursor.getLong(cursor.columnNames.indexOf("_id")) val pwaItemUrl = cursor.getString(cursor.columnNames.indexOf("url")) val pwaShortcutId = cursor.getString(cursor.columnNames.indexOf("shortcutId")) val pwaTitle = cursor.getString(cursor.columnNames.indexOf("title")) pwaInfoList.add(PwaItems(pwaItemDbId, pwaItemUrl, pwaShortcutId, pwaTitle)) cursor.moveToNext() } cursor.close() } } catch (e: Exception) { Logger.e(TAG, "getInstalledPwa: ", e) } return pwaInfoList } data class PwaItems(val id: Long, val url: String, val shortcutId: String, val title: String) fun getWidgetDetails(context: Context): MutableList<WidgetItems> { val widgetsInfoList = mutableListOf<WidgetItems>() Loading Loading @@ -258,14 +309,12 @@ object BlissDbUtils { val widgetInfo = appWidgetManager.getAppWidgetInfo(id) if (widgetInfo != null) { var provider: ComponentName = widgetInfo.provider widgetsInfoList.add( WidgetItems( id, height, order, provider, widgetInfo.provider, ) ) } Loading Loading
.gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,4 @@ bin/ local.properties build/ .DS_Store blissWithQuickstep/
bliss/res/values/arrays.xml +4 −0 Original line number Diff line number Diff line Loading @@ -12,4 +12,8 @@ <string-array name="aliased_apps"> <item>com.generalmagic.magicearth</item> <item>@string/maps</item> </string-array> <string-array name="blacklisted_widget_options"> <item>org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderDino</item> </string-array> </resources>
bliss/src/foundation/e/bliss/LauncherAppMonitor.java +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.Utilities; import com.android.launcher3.LauncherPrefs; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; Loading Loading @@ -103,7 +103,7 @@ public class LauncherAppMonitor extends LauncherApps.Callback } public void onUserUnlocked(Context context) { Utilities.getPrefs(context).registerOnSharedPreferenceChangeListener(this); LauncherPrefs.getPrefs(context).registerOnSharedPreferenceChangeListener(this); } @Override Loading
bliss/src/foundation/e/bliss/multimode/MultiModeController.kt +7 −28 Original line number Diff line number Diff line Loading @@ -8,11 +8,8 @@ package foundation.e.bliss.multimode import android.content.Context import android.content.SharedPreferences import android.content.res.Resources import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.LauncherPrefs import com.android.launcher3.model.data.AppInfo import com.android.launcher3.util.Executors.MODEL_EXECUTOR import foundation.e.bliss.BaseController Loading Loading @@ -69,8 +66,7 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) } init { sharedPreferences = Utilities.getPrefs(context.createDeviceProtectedStorageContext()) resources = context.resources prefs = LauncherPrefs.get(context) monitor.registerCallback(mAppMonitorCallback) } Loading @@ -88,31 +84,14 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) companion object { private const val TAG = "MultiModeController" @JvmField var sharedPreferences: SharedPreferences? = null @JvmField var resources: Resources? = null private fun throwIfControllerNotInit() { val launcherAppMonitor = LauncherAppMonitor.getInstanceNoCreate() if (launcherAppMonitor == null || launcherAppMonitor.multiModeController == null) { throw RuntimeException("MultiModeController is not init.") } } private lateinit var prefs: LauncherPrefs @JvmStatic val isSingleLayerMode: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean( BlissPrefs.PREF_SINGLE_LAYER_MODE, resources!!.getBoolean(R.bool.default_single_mode) ) } val isSingleLayerMode get() = prefs.get(LauncherPrefs.IS_SINGLE_LAYER_ENABLED) @JvmStatic val isNotifCountEnabled: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean(BlissPrefs.PREF_NOTIF_COUNT, true) } val isNotifCountEnabled get() = prefs.get(LauncherPrefs.IS_NOTIF_COUNT_ENABLED) } }
bliss/src/foundation/e/bliss/utils/BlissDbUtils.kt +57 −8 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.content.ComponentName import android.content.ContentValues import android.content.Context import android.content.Intent import android.net.Uri import android.os.UserHandle import android.os.UserManager import com.android.launcher3.InvariantDeviceProfile Loading Loading @@ -43,20 +44,18 @@ object BlissDbUtils { private const val folderType = 2 @JvmStatic fun migrateDataFromDb(context: Context): Boolean { fun migrateDataFromDb(context: Context, dbHelper: LauncherProvider.DatabaseHelper): Boolean { // Check if old database exists val oldFile = context.getDatabasePath(oldDbName) if (!oldFile.exists()) return false // Current database details val currentDbName = InvariantDeviceProfile.INSTANCE[context].dbFile val rowCount = InvariantDeviceProfile.INSTANCE[context].numRows val columnCount = InvariantDeviceProfile.INSTANCE[context].numColumns val numFolderRows = InvariantDeviceProfile.INSTANCE[context].numFolderRows val numFolderColumns = InvariantDeviceProfile.INSTANCE[context].numFolderColumns // Init database helper classes val dbHelper = LauncherProvider.DatabaseHelper(context, currentDbName, false) val oldDbHelper = BlissDbHelper(context, oldDbName) // Retrieve data from the old table Loading Loading @@ -148,6 +147,15 @@ object BlissDbUtils { } } val installedPwaList = getInstalledPwa(context) if (installedPwaList.isNotEmpty() && appsPwaList.isNotEmpty()) { installedPwaList.forEach { installedPwa -> if (!appsPwaList.any { it.itemId == installedPwa.shortcutId }) { deleteInstalledPwa(context, installedPwa.shortcutId) } } } // Insert folder first, so we can store it's id and use it for apps/pwa. for (item in folderList) { val fav = item.key Loading Loading @@ -217,8 +225,6 @@ object BlissDbUtils { } } dbHelper.close() // Rename the database to old val newFile = context.getDatabasePath(oldDbName + "_old") oldFile.renameTo(newFile) Loading @@ -226,6 +232,51 @@ object BlissDbUtils { return true } private fun deleteInstalledPwa(context: Context, shortcutId: String) { try { context.contentResolver.delete( Uri.parse("content://foundation.e.pwaplayer.provider/pwa"), null, arrayOf(shortcutId) ) } catch (e: Exception) { Logger.e(TAG, "deleteInstalledPwa: ", e) } } private fun getInstalledPwa(context: Context): MutableList<PwaItems> { val pwaInfoList = mutableListOf<PwaItems>() try { context.contentResolver .query( Uri.parse("content://foundation.e.pwaplayer.provider/pwa"), null, null, null, null ) ?.let { cursor -> cursor.moveToFirst() while (!cursor.isAfterLast) { val pwaItemDbId = cursor.getLong(cursor.columnNames.indexOf("_id")) val pwaItemUrl = cursor.getString(cursor.columnNames.indexOf("url")) val pwaShortcutId = cursor.getString(cursor.columnNames.indexOf("shortcutId")) val pwaTitle = cursor.getString(cursor.columnNames.indexOf("title")) pwaInfoList.add(PwaItems(pwaItemDbId, pwaItemUrl, pwaShortcutId, pwaTitle)) cursor.moveToNext() } cursor.close() } } catch (e: Exception) { Logger.e(TAG, "getInstalledPwa: ", e) } return pwaInfoList } data class PwaItems(val id: Long, val url: String, val shortcutId: String, val title: String) fun getWidgetDetails(context: Context): MutableList<WidgetItems> { val widgetsInfoList = mutableListOf<WidgetItems>() Loading Loading @@ -258,14 +309,12 @@ object BlissDbUtils { val widgetInfo = appWidgetManager.getAppWidgetInfo(id) if (widgetInfo != null) { var provider: ComponentName = widgetInfo.provider widgetsInfoList.add( WidgetItems( id, height, order, provider, widgetInfo.provider, ) ) } Loading