Skip to content
Permalink
Browse files

[Mobile,Widget] Added Receiver to stop WidgetListenerService when app…

… is updated/replaced.
  • Loading branch information...
thecosmicfrog committed Jun 12, 2019
1 parent d555cb7 commit bd94d707e9fe6201f7dec41141c994f69145f461
@@ -8,8 +8,8 @@ android {
applicationId "org.thecosmicfrog.luasataglance"
minSdkVersion 21
targetSdkVersion 28
versionCode 135
versionName "0.135"
versionCode 136
versionName "0.136"
}
buildTypes {
release {
@@ -79,6 +79,11 @@
<action android:name="org.thecosmicfrog.luasataglance.activity.NotifyTimeActivity" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.OnAppUpdateReceiver">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<receiver android:name=".widget.StopForecastWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@@ -0,0 +1,58 @@
/**
* @author Aaron Hastings
*
* Copyright 2015-2019 Aaron Hastings
*
* This file is part of Luas at a Glance.
*
* Luas at a Glance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Luas at a Glance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Luas at a Glance. If not, see <http://www.gnu.org/licenses/>.
*/

package org.thecosmicfrog.luasataglance.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.util.Log;

import org.thecosmicfrog.luasataglance.service.WidgetListenerService;

public class OnAppUpdateReceiver extends BroadcastReceiver {

private final String LOG_TAG = OnAppUpdateReceiver.class.getSimpleName();

@Override
public void onReceive(final Context context, Intent intent) {
if (intent.getAction() != null
&& intent.getAction().equals(Intent.ACTION_MY_PACKAGE_REPLACED)) {
stopWidgetListenerServer(context);
}
}

/**
* When the app is updated (e.g. via the Google Play Store), ensure the WidgetListenerService is
* stopped, to ensure consistency across app updates.
* @param context Context.
*/
private void stopWidgetListenerServer(@NonNull Context context) {
Log.i(LOG_TAG, "App updated. Stopping WidgetListenerService if running.");

Intent intentWidgetListenerService =
new Intent(context.getApplicationContext(), WidgetListenerService.class);

/* Stop the WidgetListenerService. */
context.stopService(intentWidgetListenerService);
}
}
@@ -23,8 +23,8 @@
App
-->
<string name="app_name">Luas at a Glance</string>
<string name="version_code" translatable="false">135</string>
<string name="version_name" translatable="false">0.135</string>
<string name="version_code" translatable="false">136</string>
<string name="version_name" translatable="false">0.136</string>

<!--
Activities
@@ -167,7 +167,7 @@
<!--
What's New
-->
<string name="whatsnew_title_current" translatable="false">Version 0.135 (2nd June 2019)
<string name="whatsnew_title_current" translatable="false">Version 0.136 (4th June 2019)
</string>
<string name="whatsnew_content_current" translatable="false">\u2022 [FIXED] Fixed issue where
a widget notification occasionally got stuck for some users. Thanks to everyone who reported
@@ -10,8 +10,8 @@ android {
applicationId "org.thecosmicfrog.luasataglance"
minSdkVersion 21
targetSdkVersion 28
versionCode 13500
versionName "0.135"
versionCode 13600
versionName "0.136"
}
buildTypes {
release {
@@ -23,7 +23,7 @@ android {
productFlavors {
wear2 {
minSdkVersion 25
versionCode 13501
versionCode 13601
}
}
}
@@ -23,8 +23,8 @@
App
-->
<string name="app_name">Luas at a Glance</string>
<string name="version_code" translatable="false">135</string>
<string name="version_name" translatable="false">0.135</string>
<string name="version_code" translatable="false">136</string>
<string name="version_name" translatable="false">0.136</string>

<!--
Activities

0 comments on commit bd94d70

Please sign in to comment.
You can’t perform that action at this time.