diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ae712d85e20fd2612015edb7c5c73918399f94bc..a6875c99df3c87723793de99c24e223b135fdbcc 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -128,7 +128,6 @@
-
diff --git a/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java b/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java
index 01bba9b3483eb636a990f95968aa265968aad2e7..0f6a5ce3d2793bb375a45e7c550583ddf4f7de90 100644
--- a/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java
+++ b/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java
@@ -86,7 +86,7 @@ public class Preferences {
}
public static long weatherRefreshIntervalInMs(Context context) {
- String value = getPrefs(context).getString(Constants.WEATHER_REFRESH_INTERVAL, "60");
+ String value = getPrefs(context).getString(Constants.WEATHER_REFRESH_INTERVAL, "15");
return Long.parseLong(value) * 60L * 1000L;
}
diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java
index f74e5a067aad918b31e6cc92a7e6ff2d12ad0a1c..91753c8cacf456502303a838682a0a14fab907b7 100755
--- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java
+++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java
@@ -75,7 +75,6 @@ import androidx.core.graphics.ColorUtils;
import androidx.core.view.GestureDetectorCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;
@@ -146,7 +145,6 @@ import foundation.e.blisslauncher.features.suggestions.SearchSuggestionUtil;
import foundation.e.blisslauncher.features.suggestions.SuggestionProvider;
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.WeatherPreferences;
import foundation.e.blisslauncher.features.weather.WeatherSourceListenerService;
import foundation.e.blisslauncher.features.weather.WeatherUpdateService;
@@ -176,7 +174,6 @@ public class LauncherActivity extends AppCompatActivity
private static final int REQUEST_PERMISSION_CALL_PHONE = 14;
private static final int REQUEST_LOCATION_SOURCE_SETTING = 267;
private static final int STORAGE_PERMISSION_REQUEST_CODE = 586;
- public static final String ACTION_LAUNCHER_RESUME = "foundation.e.blisslauncher.LauncherActivity.LAUNCHER_RESUME";
public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
public static final String NOTIFICATION_SETTING = "enabled_notification_listeners";
@@ -532,9 +529,6 @@ public class LauncherActivity extends AppCompatActivity
refreshSuggestedApps(widgetsPage, forceRefreshSuggestedApps);
}
- final Intent resumeIntent = new Intent(ACTION_LAUNCHER_RESUME);
- LocalBroadcastManager.getInstance(this).sendBroadcast(resumeIntent);
-
if (widgetContainer != null) {
WidgetManager widgetManager = WidgetManager.getInstance();
Integer id = widgetManager.dequeRemoveId();
@@ -1474,7 +1468,6 @@ public class LauncherActivity extends AppCompatActivity
if (WeatherUtils.isWeatherServiceAvailable(this)) {
startService(new Intent(this, WeatherSourceListenerService.class));
- startService(new Intent(this, DeviceStatusService.class));
}
if (!Preferences.useCustomWeatherLocation(this)) {
diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/DeviceStatusService.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/DeviceStatusService.java
deleted file mode 100644
index 5367100594337c54739895a89db36600c0cd6568..0000000000000000000000000000000000000000
--- a/app/src/main/java/foundation/e/blisslauncher/features/weather/DeviceStatusService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package foundation.e.blisslauncher.features.weather;
-
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.ConnectivityManager;
-import android.os.IBinder;
-import foundation.e.blisslauncher.core.utils.Constants;
-import timber.log.Timber;
-
-public class DeviceStatusService extends Service {
-
- private static final String TAG = DeviceStatusService.class.getSimpleName();
- private static final boolean D = Constants.DEBUG;
-
- private BroadcastReceiver mDeviceStatusListenerReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
-
- // Network connection has changed, make sure the weather update service knows
- // about it
- if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
- boolean hasConnection = !intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
-
- if (D)
- Timber.tag(TAG).d("Got connectivity change, has connection: " + hasConnection);
-
- Intent i = new Intent(context, WeatherUpdateService.class);
- if (hasConnection) {
- context.startService(i);
- } else {
- context.stopService(i);
- }
- }
- }
- };
-
- @Override
- public void onCreate() {
- IntentFilter deviceStatusFilter = new IntentFilter();
- deviceStatusFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
- deviceStatusFilter.addAction(Intent.ACTION_SCREEN_OFF);
- deviceStatusFilter.addAction(Intent.ACTION_SCREEN_ON);
- registerReceiver(mDeviceStatusListenerReceiver, deviceStatusFilter);
- }
-
- @Override
- public void onDestroy() {
- if (D)
- Timber.tag(TAG).d("Stopping service");
- unregisterReceiver(mDeviceStatusListenerReceiver);
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- if (D)
- Timber.tag(TAG).d("Starting service");
- return START_STICKY;
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-}
diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java
index 54d8927ca184c5b6aba2000ba2df407e8344538a..89354bb2d4728dab1985a19c5a22cee536116faa 100644
--- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java
+++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java
@@ -12,7 +12,6 @@ import android.widget.TextView;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import foundation.e.blisslauncher.R;
import foundation.e.blisslauncher.core.Preferences;
-import foundation.e.blisslauncher.features.launcher.LauncherActivity;
import timber.log.Timber;
public class WeatherInfoView extends LinearLayout {
@@ -37,13 +36,6 @@ public class WeatherInfoView extends LinearLayout {
}
};
- private final BroadcastReceiver mResumeReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- updateWeatherPanel();
- }
- };
-
public WeatherInfoView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -76,7 +68,6 @@ public class WeatherInfoView extends LinearLayout {
intentFilter.addAction(WeatherUpdateService.ACTION_UPDATE_CITY_FINISHED);
broadcastManager.registerReceiver(mWeatherReceiver, intentFilter);
- broadcastManager.registerReceiver(mResumeReceiver, new IntentFilter(LauncherActivity.ACTION_LAUNCHER_RESUME));
updateWeatherPanel();
}
@@ -85,7 +76,6 @@ public class WeatherInfoView extends LinearLayout {
super.onDetachedFromWindow();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext());
broadcastManager.unregisterReceiver(mWeatherReceiver);
- broadcastManager.unregisterReceiver(mResumeReceiver);
}
private void updateWeatherPanel() {
diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java
index 5668135c8a5fc2bb88b638b85bbba0ab7b3b5f35..4ba7fd5a4c35c8c3a0ee5806c22cbc3cb68d8617 100644
--- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java
+++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java
@@ -19,7 +19,7 @@ public class WeatherUpdateService extends Service {
public static final String ACTION_UPDATE_CITY_FINISHED = "org.indin.blisslauncher.action.WEATHER_UPDATE_CITY_FINISHED";
public static final String EXTRA_UPDATE_CITY_KEY = "city";
- private static final long UPDATE_PERIOD_IN_MS = 5L * 1000L;
+ private static final long UPDATE_PERIOD_IN_MS = 60L * 1000L;
private HandlerThread mHandlerThread;
private Handler mHandler;
diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java
index 1f68471460009226a31de478d173579d60487cd6..1bb1f56b6c257c82807f66b8fc22643ce4ddcc53 100644
--- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java
+++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java
@@ -49,6 +49,8 @@ public class WeatherUpdater {
private long mLastWeatherUpdateInMs = 0;
+ private Location mLastLocation;
+
private static WeatherUpdater mInstance = null;
public static WeatherUpdater getInstance(@NonNull Context context) {
@@ -134,11 +136,16 @@ public class WeatherUpdater {
}
private synchronized void onNewLocationFetched(@Nullable Location location) {
- if (location == null) {
+ if (location == null && mLastLocation == null) {
Timber.tag(TAG).i("Could not fetch any location");
return;
}
+ if (location != null) {
+ mLastLocation = location;
+ }
+
+ location = mLastLocation;
Timber.tag(TAG).i("New location fetched:%s", location);
requestWeatherUpdate(location);