diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c4ac0820..f80859dd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/Widget.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/Widget.java index 83fb0b96f..e5274d427 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/Widget.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/Widget.java @@ -34,7 +34,6 @@ along with this program. If not, see . */ 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]; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java index e3a10129d..eddc42b4e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java @@ -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); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WidgetPreferenceStorage.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WidgetPreferenceStorage.java index 557ca2ecb..9a35f1b50 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WidgetPreferenceStorage.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WidgetPreferenceStorage.java @@ -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());