Loading app/src/apiNougat/java/foundation/e/blisslauncher/core/Preferences.java +7 −26 Original line number Original line Diff line number Diff line Loading @@ -48,18 +48,7 @@ public class Preferences { private static final String ENABLE_LOCATION = "enable_location"; private static final String ENABLE_LOCATION = "enable_location"; private static final String ACTION_USAGE = "foundation.e.blisslauncher.ACTION_USAGE"; /** * User Preference related keys and constants. */ public static final String MANAGED_USER_PREFERENCES_KEY = "org.indin.blisslaunchero.prefs"; /** * Launcher related keys and constants. */ public static final String LAYOUT_PRESENT = "layout_present"; public static final String FIRST_TIME = "org.indin.blisslaunchero.FIRST_TIME"; private static final String ACTION_USAGE = "org.indin.blisslaunchero.ACTION_USAGE"; private Preferences() { private Preferences() { } } Loading Loading @@ -333,14 +322,6 @@ public class Preferences { getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); } } public static boolean isFirstTime(Context context){ return getPrefs(context).getBoolean(FIRST_TIME, true); } public static void setFirstTimeDone(Context context){ getPrefs(context).edit().putBoolean(FIRST_TIME, false).apply(); } public static boolean shouldOpenUsageAccess(Context context) { public static boolean shouldOpenUsageAccess(Context context) { return getPrefs(context).getBoolean(ACTION_USAGE, true); return getPrefs(context).getBoolean(ACTION_USAGE, true); } } Loading @@ -349,12 +330,12 @@ public class Preferences { getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); } } public static boolean getNotificationAccess(Context context){ public static boolean shouldAskForNotificationAccess(Context context) { return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, false); return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, true); } } public static void setNotificationAccess(Context context){ public static void setNotToAskForNotificationAccess(Context context) { getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, true).apply(); getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, false).apply(); } } public static SharedPreferences getPrefs(Context context) { public static SharedPreferences getPrefs(Context context) { Loading app/src/apiOreo/java/foundation/e/blisslauncher/core/Preferences.java +7 −26 Original line number Original line Diff line number Diff line Loading @@ -48,18 +48,7 @@ public class Preferences { private static final String ENABLE_LOCATION = "enable_location"; private static final String ENABLE_LOCATION = "enable_location"; private static final String ACTION_USAGE = "foundation.e.blisslauncher.ACTION_USAGE"; /** * User Preference related keys and constants. */ public static final String MANAGED_USER_PREFERENCES_KEY = "org.indin.blisslaunchero.prefs"; /** * Launcher related keys and constants. */ public static final String LAYOUT_PRESENT = "layout_present"; public static final String FIRST_TIME = "org.indin.blisslaunchero.FIRST_TIME"; private static final String ACTION_USAGE = "org.indin.blisslaunchero.ACTION_USAGE"; private Preferences() { private Preferences() { } } Loading Loading @@ -333,14 +322,6 @@ public class Preferences { getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); } } public static boolean isFirstTime(Context context){ return getPrefs(context).getBoolean(FIRST_TIME, true); } public static void setFirstTimeDone(Context context){ getPrefs(context).edit().putBoolean(FIRST_TIME, false).apply(); } public static boolean shouldOpenUsageAccess(Context context) { public static boolean shouldOpenUsageAccess(Context context) { return getPrefs(context).getBoolean(ACTION_USAGE, true); return getPrefs(context).getBoolean(ACTION_USAGE, true); } } Loading @@ -349,12 +330,12 @@ public class Preferences { getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); } } public static boolean getNotificationAccess(Context context){ public static boolean shouldAskForNotificationAccess(Context context) { return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, false); return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, true); } } public static void setNotificationAccess(Context context){ public static void setNotToAskForNotificationAccess(Context context) { getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, true).apply(); getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, false).apply(); } } public static SharedPreferences getPrefs(Context context) { public static SharedPreferences getPrefs(Context context) { Loading app/src/main/java/foundation/e/blisslauncher/core/utils/Constants.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ package foundation.e.blisslauncher.core.utils; public class Constants { public class Constants { public static final boolean DEBUG = true; public static final boolean DEBUG = true; public static final String PREF_NAME = "BLISS_LAUNCHER"; public static final String PREF_NAME = "foundation.e.blisslauncher.prefs"; public static final String WEATHER_SOURCE = "weather_source"; public static final String WEATHER_SOURCE = "weather_source"; public static final String WEATHER_USE_CUSTOM_LOCATION = "weather_use_custom_location"; public static final String WEATHER_USE_CUSTOM_LOCATION = "weather_use_custom_location"; Loading @@ -47,8 +47,6 @@ public class Constants { public static final String USER_CREATION_TIME_KEY = "user_creation_time_"; public static final String USER_CREATION_TIME_KEY = "user_creation_time_"; public static final String LOAD_OVER = "org.indin.blisslaunchero.LOAD_OVER"; /** /** * Represents types of item displayed in Launcher. * Represents types of item displayed in Launcher. */ */ Loading app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +31 −23 Original line number Original line Diff line number Diff line Loading @@ -81,7 +81,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.BuildConfig; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Alarm; import foundation.e.blisslauncher.core.Alarm; import foundation.e.blisslauncher.core.DeviceProfile; import foundation.e.blisslauncher.core.DeviceProfile; Loading Loading @@ -223,19 +222,23 @@ public class LauncherActivity extends AppCompatActivity implements mAppWidgetManager = BlissLauncher.getApplication(this).getAppWidgetManager(); mAppWidgetManager = BlissLauncher.getApplication(this).getAppWidgetManager(); mAppWidgetHost = BlissLauncher.getApplication(this).getAppWidgetHost(); mAppWidgetHost = BlissLauncher.getApplication(this).getAppWidgetHost(); mLauncherView = LayoutInflater.from(this).inflate(foundation.e.blisslauncher.R.layout.activity_main, null); mLauncherView = LayoutInflater.from(this).inflate( foundation.e.blisslauncher.R.layout.activity_main, null); setContentView(mLauncherView); setContentView(mLauncherView); setupViews(); setupViews(); mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE); if (Preferences.shouldAskForNotificationAccess(this)) { ContentResolver cr = getContentResolver(); ContentResolver cr = getContentResolver(); String setting = "enabled_notification_listeners"; String setting = "enabled_notification_listeners"; String permissionString = Settings.Secure.getString(cr, setting); String permissionString = Settings.Secure.getString(cr, setting); if (permissionString == null || !permissionString.contains(getPackageName())) { if (permissionString == null || !permissionString.contains(getPackageName())) { if (BuildConfig.DEBUG) { startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")); startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")); } else if (!Preferences.getNotificationAccess(this)) { //TODO: Uncomment it when priv-app permission issue resolved. /*if (BuildConfig.DEBUG) { } else if (!Preferences.shouldAskForNotificationAccess(this)) { ComponentName cn = new ComponentName(this, NotificationService.class); ComponentName cn = new ComponentName(this, NotificationService.class); if (permissionString == null) { if (permissionString == null) { permissionString = ""; permissionString = ""; Loading @@ -247,8 +250,11 @@ public class LauncherActivity extends AppCompatActivity implements if (success) { if (success) { Preferences.setNotificationAccess(this); Preferences.setNotificationAccess(this); } } }*/ } } Preferences.setNotToAskForNotificationAccess(this); } } // Start NotificationService to add count badge to Icons // Start NotificationService to add count badge to Icons Intent notificationServiceIntent = new Intent(this, NotificationService.class); Intent notificationServiceIntent = new Intent(this, NotificationService.class); startService(notificationServiceIntent); startService(notificationServiceIntent); Loading Loading @@ -1335,9 +1341,11 @@ public class LauncherActivity extends AppCompatActivity implements private void updateWidgetOption(int appWidgetId, AppWidgetProviderInfo info) { private void updateWidgetOption(int appWidgetId, AppWidgetProviderInfo info) { Bundle newOps = new Bundle(); Bundle newOps = new Bundle(); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, info.minWidth); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, info.minWidth); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, BlissLauncher.getApplication(this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, info.minHeight); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, info.minHeight); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, BlissLauncher.getApplication(this).getDeviceProfile().getMaxWidgetHeight()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetHeight()); mAppWidgetManager.updateAppWidgetOptions(appWidgetId, newOps); mAppWidgetManager.updateAppWidgetOptions(appWidgetId, newOps); } } Loading app/src/main/java/foundation/e/blisslauncher/features/notification/NotificationService.java +6 −0 Original line number Original line Diff line number Diff line package foundation.e.blisslauncher.features.notification; package foundation.e.blisslauncher.features.notification; import android.content.Intent; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification; Loading Loading @@ -38,4 +39,9 @@ public class NotificationService extends NotificationListenerService { public void onNotificationRemoved(StatusBarNotification sbn) { public void onNotificationRemoved(StatusBarNotification sbn) { mNotificationRepository.updateNotification(ListUtil.asSafeList(getActiveNotifications())); mNotificationRepository.updateNotification(ListUtil.asSafeList(getActiveNotifications())); } } @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } } } Loading
app/src/apiNougat/java/foundation/e/blisslauncher/core/Preferences.java +7 −26 Original line number Original line Diff line number Diff line Loading @@ -48,18 +48,7 @@ public class Preferences { private static final String ENABLE_LOCATION = "enable_location"; private static final String ENABLE_LOCATION = "enable_location"; private static final String ACTION_USAGE = "foundation.e.blisslauncher.ACTION_USAGE"; /** * User Preference related keys and constants. */ public static final String MANAGED_USER_PREFERENCES_KEY = "org.indin.blisslaunchero.prefs"; /** * Launcher related keys and constants. */ public static final String LAYOUT_PRESENT = "layout_present"; public static final String FIRST_TIME = "org.indin.blisslaunchero.FIRST_TIME"; private static final String ACTION_USAGE = "org.indin.blisslaunchero.ACTION_USAGE"; private Preferences() { private Preferences() { } } Loading Loading @@ -333,14 +322,6 @@ public class Preferences { getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); } } public static boolean isFirstTime(Context context){ return getPrefs(context).getBoolean(FIRST_TIME, true); } public static void setFirstTimeDone(Context context){ getPrefs(context).edit().putBoolean(FIRST_TIME, false).apply(); } public static boolean shouldOpenUsageAccess(Context context) { public static boolean shouldOpenUsageAccess(Context context) { return getPrefs(context).getBoolean(ACTION_USAGE, true); return getPrefs(context).getBoolean(ACTION_USAGE, true); } } Loading @@ -349,12 +330,12 @@ public class Preferences { getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); } } public static boolean getNotificationAccess(Context context){ public static boolean shouldAskForNotificationAccess(Context context) { return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, false); return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, true); } } public static void setNotificationAccess(Context context){ public static void setNotToAskForNotificationAccess(Context context) { getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, true).apply(); getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, false).apply(); } } public static SharedPreferences getPrefs(Context context) { public static SharedPreferences getPrefs(Context context) { Loading
app/src/apiOreo/java/foundation/e/blisslauncher/core/Preferences.java +7 −26 Original line number Original line Diff line number Diff line Loading @@ -48,18 +48,7 @@ public class Preferences { private static final String ENABLE_LOCATION = "enable_location"; private static final String ENABLE_LOCATION = "enable_location"; private static final String ACTION_USAGE = "foundation.e.blisslauncher.ACTION_USAGE"; /** * User Preference related keys and constants. */ public static final String MANAGED_USER_PREFERENCES_KEY = "org.indin.blisslaunchero.prefs"; /** * Launcher related keys and constants. */ public static final String LAYOUT_PRESENT = "layout_present"; public static final String FIRST_TIME = "org.indin.blisslaunchero.FIRST_TIME"; private static final String ACTION_USAGE = "org.indin.blisslaunchero.ACTION_USAGE"; private Preferences() { private Preferences() { } } Loading Loading @@ -333,14 +322,6 @@ public class Preferences { getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply(); } } public static boolean isFirstTime(Context context){ return getPrefs(context).getBoolean(FIRST_TIME, true); } public static void setFirstTimeDone(Context context){ getPrefs(context).edit().putBoolean(FIRST_TIME, false).apply(); } public static boolean shouldOpenUsageAccess(Context context) { public static boolean shouldOpenUsageAccess(Context context) { return getPrefs(context).getBoolean(ACTION_USAGE, true); return getPrefs(context).getBoolean(ACTION_USAGE, true); } } Loading @@ -349,12 +330,12 @@ public class Preferences { getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply(); } } public static boolean getNotificationAccess(Context context){ public static boolean shouldAskForNotificationAccess(Context context) { return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, false); return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, true); } } public static void setNotificationAccess(Context context){ public static void setNotToAskForNotificationAccess(Context context) { getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, true).apply(); getPrefs(context).edit().putBoolean(NOTIFICATION_ACCESS, false).apply(); } } public static SharedPreferences getPrefs(Context context) { public static SharedPreferences getPrefs(Context context) { Loading
app/src/main/java/foundation/e/blisslauncher/core/utils/Constants.java +1 −3 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ package foundation.e.blisslauncher.core.utils; public class Constants { public class Constants { public static final boolean DEBUG = true; public static final boolean DEBUG = true; public static final String PREF_NAME = "BLISS_LAUNCHER"; public static final String PREF_NAME = "foundation.e.blisslauncher.prefs"; public static final String WEATHER_SOURCE = "weather_source"; public static final String WEATHER_SOURCE = "weather_source"; public static final String WEATHER_USE_CUSTOM_LOCATION = "weather_use_custom_location"; public static final String WEATHER_USE_CUSTOM_LOCATION = "weather_use_custom_location"; Loading @@ -47,8 +47,6 @@ public class Constants { public static final String USER_CREATION_TIME_KEY = "user_creation_time_"; public static final String USER_CREATION_TIME_KEY = "user_creation_time_"; public static final String LOAD_OVER = "org.indin.blisslaunchero.LOAD_OVER"; /** /** * Represents types of item displayed in Launcher. * Represents types of item displayed in Launcher. */ */ Loading
app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +31 −23 Original line number Original line Diff line number Diff line Loading @@ -81,7 +81,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.BlissLauncher; import foundation.e.blisslauncher.BuildConfig; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Alarm; import foundation.e.blisslauncher.core.Alarm; import foundation.e.blisslauncher.core.DeviceProfile; import foundation.e.blisslauncher.core.DeviceProfile; Loading Loading @@ -223,19 +222,23 @@ public class LauncherActivity extends AppCompatActivity implements mAppWidgetManager = BlissLauncher.getApplication(this).getAppWidgetManager(); mAppWidgetManager = BlissLauncher.getApplication(this).getAppWidgetManager(); mAppWidgetHost = BlissLauncher.getApplication(this).getAppWidgetHost(); mAppWidgetHost = BlissLauncher.getApplication(this).getAppWidgetHost(); mLauncherView = LayoutInflater.from(this).inflate(foundation.e.blisslauncher.R.layout.activity_main, null); mLauncherView = LayoutInflater.from(this).inflate( foundation.e.blisslauncher.R.layout.activity_main, null); setContentView(mLauncherView); setContentView(mLauncherView); setupViews(); setupViews(); mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE); if (Preferences.shouldAskForNotificationAccess(this)) { ContentResolver cr = getContentResolver(); ContentResolver cr = getContentResolver(); String setting = "enabled_notification_listeners"; String setting = "enabled_notification_listeners"; String permissionString = Settings.Secure.getString(cr, setting); String permissionString = Settings.Secure.getString(cr, setting); if (permissionString == null || !permissionString.contains(getPackageName())) { if (permissionString == null || !permissionString.contains(getPackageName())) { if (BuildConfig.DEBUG) { startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")); startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")); } else if (!Preferences.getNotificationAccess(this)) { //TODO: Uncomment it when priv-app permission issue resolved. /*if (BuildConfig.DEBUG) { } else if (!Preferences.shouldAskForNotificationAccess(this)) { ComponentName cn = new ComponentName(this, NotificationService.class); ComponentName cn = new ComponentName(this, NotificationService.class); if (permissionString == null) { if (permissionString == null) { permissionString = ""; permissionString = ""; Loading @@ -247,8 +250,11 @@ public class LauncherActivity extends AppCompatActivity implements if (success) { if (success) { Preferences.setNotificationAccess(this); Preferences.setNotificationAccess(this); } } }*/ } } Preferences.setNotToAskForNotificationAccess(this); } } // Start NotificationService to add count badge to Icons // Start NotificationService to add count badge to Icons Intent notificationServiceIntent = new Intent(this, NotificationService.class); Intent notificationServiceIntent = new Intent(this, NotificationService.class); startService(notificationServiceIntent); startService(notificationServiceIntent); Loading Loading @@ -1335,9 +1341,11 @@ public class LauncherActivity extends AppCompatActivity implements private void updateWidgetOption(int appWidgetId, AppWidgetProviderInfo info) { private void updateWidgetOption(int appWidgetId, AppWidgetProviderInfo info) { Bundle newOps = new Bundle(); Bundle newOps = new Bundle(); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, info.minWidth); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, info.minWidth); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, BlissLauncher.getApplication(this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetWidth()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, info.minHeight); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, info.minHeight); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, BlissLauncher.getApplication(this).getDeviceProfile().getMaxWidgetHeight()); newOps.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, BlissLauncher.getApplication( this).getDeviceProfile().getMaxWidgetHeight()); mAppWidgetManager.updateAppWidgetOptions(appWidgetId, newOps); mAppWidgetManager.updateAppWidgetOptions(appWidgetId, newOps); } } Loading
app/src/main/java/foundation/e/blisslauncher/features/notification/NotificationService.java +6 −0 Original line number Original line Diff line number Diff line package foundation.e.blisslauncher.features.notification; package foundation.e.blisslauncher.features.notification; import android.content.Intent; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification; Loading Loading @@ -38,4 +39,9 @@ public class NotificationService extends NotificationListenerService { public void onNotificationRemoved(StatusBarNotification sbn) { public void onNotificationRemoved(StatusBarNotification sbn) { mNotificationRepository.updateNotification(ListUtil.asSafeList(getActiveNotifications())); mNotificationRepository.updateNotification(ListUtil.asSafeList(getActiveNotifications())); } } @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } } }