1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 08:52:58 +01:00

ensure that correct device is used for activity launched from widget

remove code to trigger error, forgotten from testing
update changelog
This commit is contained in:
vanous 2020-12-21 11:18:03 +01:00
parent 43144d6353
commit be53130dba
4 changed files with 25 additions and 21 deletions

View File

@ -4,13 +4,13 @@
* Amazfit Bip U: Initial support
* Amazfit Verge Lite: Initial Support
* Amazfit T-Rex: Add missing menu items, remove non-existent
* Amazfit Bip S: Fix crash with notifictions with only a title (GitNex does this)
* Amazfit Bip S: Fix crash with notifications with only a title (GitNex does this)
* Casio GBX-100: Add step count data and more device settings
* Fossil Hybrid Q: Support firmware upgrade
* Bangle.js: Support for HRM and steps activity recording
* Huami: Add new option to disting to properly distinguish connected adverising and 3rd party hr exposure
* Huami: Add new option to properly distinguish connected advertising and 3rd party hr exposure
* Huami: Use blue icon instead of rainbow color icon for Signal (the rainbow icon was blue in early days)
* Completele overhaul of the daily stats widget
* Complete overhaul of the daily stats widget
* Better error message for invalid authentication keys
#### 0.50.0

View File

@ -34,7 +34,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
@ -71,11 +70,9 @@ import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.WidgetPreferenceStorage;
public class Widget extends AppWidgetProvider {
public static final String WIDGET_CLICK = "nodomain.freeyourgadget.gadgetbridge.WidgetClick";
public static final String APPWIDGET_DELETED = "android.appwidget.action.APPWIDGET_DELETED";
public static final String APPWIDGET_CONFIGURE = "nodomain.freeyourgadget.gadgetbridge.APPWIDGET_CONFIGURE";
private static final Logger LOG = LoggerFactory.getLogger(Widget.class);
static BroadcastReceiver broadcastReceiver = null;
@ -112,8 +109,6 @@ public class Widget extends AppWidgetProvider {
DailyTotals ds = new DailyTotals();
return ds.getDailyTotalsForDevice(selectedDevice, day);
//return ds.getDailyTotalsForAllDevices(day);
}
private String getHM(long value) {
@ -137,8 +132,7 @@ public class Widget extends AppWidgetProvider {
intent.setAction(WIDGET_CLICK);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
PendingIntent refreshDataIntent = PendingIntent.getBroadcast(
context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
//views.setOnClickPendingIntent(R.id.todaywidget_bottom_layout, refreshDataIntent);
context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.todaywidget_header_container, refreshDataIntent);
//open GB main window
@ -148,16 +142,15 @@ public class Widget extends AppWidgetProvider {
//alarms popup menu
Intent startAlarmListIntent = new Intent(context, WidgetAlarmsActivity.class);
PendingIntent startAlarmListPIntent = PendingIntent.getActivity(context, 0, startAlarmListIntent, 0);
startAlarmListIntent.putExtra(GBDevice.EXTRA_DEVICE, selectedDevice);
PendingIntent startAlarmListPIntent = PendingIntent.getActivity(context, appWidgetId, startAlarmListIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.todaywidget_header_alarm_icon, startAlarmListPIntent);
//charts, requires device
if (selectedDevice != null) {
Intent startChartsIntent = new Intent(context, ChartsActivity.class);
startChartsIntent.putExtra(GBDevice.EXTRA_DEVICE, selectedDevice);
PendingIntent startChartsPIntent = PendingIntent.getActivity(context, 0, startChartsIntent, 0);
views.setOnClickPendingIntent(R.id.todaywidget_bottom_layout, startChartsPIntent);
}
//charts
Intent startChartsIntent = new Intent(context, ChartsActivity.class);
startChartsIntent.putExtra(GBDevice.EXTRA_DEVICE, selectedDevice);
PendingIntent startChartsPIntent = PendingIntent.getActivity(context, appWidgetId, startChartsIntent, PendingIntent.FLAG_CANCEL_CURRENT);
views.setOnClickPendingIntent(R.id.todaywidget_bottom_layout, startChartsPIntent);
long[] dailyTotals = getSteps();
int steps = (int) dailyTotals[0];

View File

@ -46,13 +46,25 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen
super.onCreate(savedInstanceState);
Context appContext = this.getApplicationContext();
GBDevice selectedDevice;
Bundle extras = getIntent().getExtras();
if (extras != null) {
selectedDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
} else {
GB.toast(this,
"Error no device",
Toast.LENGTH_LONG, GB.ERROR);
return;
}
if (appContext instanceof GBApplication) {
GBApplication gbApp = (GBApplication) appContext;
GBDevice selectedDevice = gbApp.getDeviceManager().getSelectedDevice();
if (selectedDevice == null || !selectedDevice.isInitialized()) {
GB.toast(this,
this.getString(R.string.not_connected),
Toast.LENGTH_LONG, GB.WARN);
Toast.LENGTH_LONG, GB.INFO);
} else {
setContentView(R.layout.widget_alarms_activity_list);

View File

@ -25,7 +25,6 @@ public class WidgetPreferenceStorage {
JSONArray savedWidgetsPreferencesDataArray = null;
try {
savedWidgetsPreferencesDataArray = new JSONArray(savedWidgetsPreferencesData);
savedWidgetsPreferencesDataArray = new JSONArray("fdsfdsfsffs");
} catch (
JSONException e) {
LOG.error(e.getMessage());