Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae7fe0b4 authored by Suphon Thanakornpakapong's avatar Suphon Thanakornpakapong
Browse files

Add weather widget by default

parent a616ca5b
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public class Preferences {

    private static final String CURRENT_MIGRATION_VERSION = "current_migration_version";

    private static final String ADDED_WEATHER_WIDGET = "added_weather_widget";
    private static final String ADDED_ECLOUD_WIDGET = "added_ecloud_widget";
    private static final String ADDED_PRIVACY_WIDGET = "added_privacy_widget";

@@ -364,6 +365,14 @@ public class Preferences {
        return getPrefs(context).getBoolean(ENABLE_LOCATION, false);
    }

    public static void setAddedWeatherWidget(Context context) {
        getPrefs(context).edit().putBoolean(ADDED_WEATHER_WIDGET, true).apply();
    }

    public static boolean getAddedWeatherWidget(Context context) {
        return getPrefs(context).getBoolean(ADDED_WEATHER_WIDGET, false);
    }

    public static void setAddedEcloudWidget(Context context) {
        getPrefs(context).edit().putBoolean(ADDED_ECLOUD_WIDGET, true).apply();
    }
+9 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public class Preferences {

    private static final String CURRENT_MIGRATION_VERSION = "current_migration_version";

    private static final String ADDED_WEATHER_WIDGET = "added_weather_widget";
    private static final String ADDED_ECLOUD_WIDGET = "added_ecloud_widget";
    private static final String ADDED_PRIVACY_WIDGET = "added_privacy_widget";

@@ -364,6 +365,14 @@ public class Preferences {
        return getPrefs(context).getBoolean(ENABLE_LOCATION, false);
    }

    public static void setAddedWeatherWidget(Context context) {
        getPrefs(context).edit().putBoolean(ADDED_WEATHER_WIDGET, true).apply();
    }

    public static boolean getAddedWeatherWidget(Context context) {
        return getPrefs(context).getBoolean(ADDED_WEATHER_WIDGET, false);
    }

    public static void setAddedEcloudWidget(Context context) {
        getPrefs(context).edit().putBoolean(ADDED_ECLOUD_WIDGET, true).apply();
    }
+8 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ import foundation.e.blisslauncher.features.suggestions.SuggestionsResult;
import foundation.e.blisslauncher.features.usagestats.AppUsageStats;
import foundation.e.blisslauncher.features.weather.DeviceStatusService;
import foundation.e.blisslauncher.features.weather.ForecastBuilder;
import foundation.e.blisslauncher.features.weather.WeatherAppWidgetProvider;
import foundation.e.blisslauncher.features.weather.WeatherPreferences;
import foundation.e.blisslauncher.features.weather.WeatherSourceListenerService;
import foundation.e.blisslauncher.features.weather.WeatherUpdateService;
@@ -384,6 +385,13 @@ public class LauncherActivity extends AppCompatActivity implements
    }

    private void addDefaultWidgets() {
        if (!Preferences.getAddedWeatherWidget(this)) {
            ComponentName provider = new ComponentName(this, WeatherAppWidgetProvider.class);
            if (allocateAndBindWidget(provider)) {
                Preferences.setAddedWeatherWidget(this);
            }
        }

        if (!Preferences.getAddedEcloudWidget(this)) {
            ComponentName provider = new ComponentName("foundation.e.drive", "foundation.e.drive.widgets.EDriveWidget");
            if (allocateAndBindWidget(provider)) {