mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +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:
parent
43144d6353
commit
be53130dba
@ -4,13 +4,13 @@
|
|||||||
* Amazfit Bip U: Initial support
|
* Amazfit Bip U: Initial support
|
||||||
* Amazfit Verge Lite: Initial Support
|
* Amazfit Verge Lite: Initial Support
|
||||||
* Amazfit T-Rex: Add missing menu items, remove non-existent
|
* 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
|
* Casio GBX-100: Add step count data and more device settings
|
||||||
* Fossil Hybrid Q: Support firmware upgrade
|
* Fossil Hybrid Q: Support firmware upgrade
|
||||||
* Bangle.js: Support for HRM and steps activity recording
|
* 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)
|
* 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
|
* Better error message for invalid authentication keys
|
||||||
|
|
||||||
#### 0.50.0
|
#### 0.50.0
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge;
|
package nodomain.freeyourgadget.gadgetbridge;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.appwidget.AppWidgetProvider;
|
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.GB;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.WidgetPreferenceStorage;
|
import nodomain.freeyourgadget.gadgetbridge.util.WidgetPreferenceStorage;
|
||||||
|
|
||||||
|
|
||||||
public class Widget extends AppWidgetProvider {
|
public class Widget extends AppWidgetProvider {
|
||||||
public static final String WIDGET_CLICK = "nodomain.freeyourgadget.gadgetbridge.WidgetClick";
|
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_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);
|
private static final Logger LOG = LoggerFactory.getLogger(Widget.class);
|
||||||
static BroadcastReceiver broadcastReceiver = null;
|
static BroadcastReceiver broadcastReceiver = null;
|
||||||
@ -112,8 +109,6 @@ public class Widget extends AppWidgetProvider {
|
|||||||
DailyTotals ds = new DailyTotals();
|
DailyTotals ds = new DailyTotals();
|
||||||
return ds.getDailyTotalsForDevice(selectedDevice, day);
|
return ds.getDailyTotalsForDevice(selectedDevice, day);
|
||||||
//return ds.getDailyTotalsForAllDevices(day);
|
//return ds.getDailyTotalsForAllDevices(day);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHM(long value) {
|
private String getHM(long value) {
|
||||||
@ -137,8 +132,7 @@ public class Widget extends AppWidgetProvider {
|
|||||||
intent.setAction(WIDGET_CLICK);
|
intent.setAction(WIDGET_CLICK);
|
||||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||||
PendingIntent refreshDataIntent = PendingIntent.getBroadcast(
|
PendingIntent refreshDataIntent = PendingIntent.getBroadcast(
|
||||||
context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
//views.setOnClickPendingIntent(R.id.todaywidget_bottom_layout, refreshDataIntent);
|
|
||||||
views.setOnClickPendingIntent(R.id.todaywidget_header_container, refreshDataIntent);
|
views.setOnClickPendingIntent(R.id.todaywidget_header_container, refreshDataIntent);
|
||||||
|
|
||||||
//open GB main window
|
//open GB main window
|
||||||
@ -148,16 +142,15 @@ public class Widget extends AppWidgetProvider {
|
|||||||
|
|
||||||
//alarms popup menu
|
//alarms popup menu
|
||||||
Intent startAlarmListIntent = new Intent(context, WidgetAlarmsActivity.class);
|
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);
|
views.setOnClickPendingIntent(R.id.todaywidget_header_alarm_icon, startAlarmListPIntent);
|
||||||
|
|
||||||
//charts, requires device
|
//charts
|
||||||
if (selectedDevice != null) {
|
Intent startChartsIntent = new Intent(context, ChartsActivity.class);
|
||||||
Intent startChartsIntent = new Intent(context, ChartsActivity.class);
|
startChartsIntent.putExtra(GBDevice.EXTRA_DEVICE, selectedDevice);
|
||||||
startChartsIntent.putExtra(GBDevice.EXTRA_DEVICE, selectedDevice);
|
PendingIntent startChartsPIntent = PendingIntent.getActivity(context, appWidgetId, startChartsIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
PendingIntent startChartsPIntent = PendingIntent.getActivity(context, 0, startChartsIntent, 0);
|
views.setOnClickPendingIntent(R.id.todaywidget_bottom_layout, startChartsPIntent);
|
||||||
views.setOnClickPendingIntent(R.id.todaywidget_bottom_layout, startChartsPIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
long[] dailyTotals = getSteps();
|
long[] dailyTotals = getSteps();
|
||||||
int steps = (int) dailyTotals[0];
|
int steps = (int) dailyTotals[0];
|
||||||
|
@ -46,13 +46,25 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Context appContext = this.getApplicationContext();
|
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) {
|
if (appContext instanceof GBApplication) {
|
||||||
GBApplication gbApp = (GBApplication) appContext;
|
GBApplication gbApp = (GBApplication) appContext;
|
||||||
GBDevice selectedDevice = gbApp.getDeviceManager().getSelectedDevice();
|
|
||||||
if (selectedDevice == null || !selectedDevice.isInitialized()) {
|
if (selectedDevice == null || !selectedDevice.isInitialized()) {
|
||||||
GB.toast(this,
|
GB.toast(this,
|
||||||
this.getString(R.string.not_connected),
|
this.getString(R.string.not_connected),
|
||||||
Toast.LENGTH_LONG, GB.WARN);
|
Toast.LENGTH_LONG, GB.INFO);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setContentView(R.layout.widget_alarms_activity_list);
|
setContentView(R.layout.widget_alarms_activity_list);
|
||||||
|
@ -25,7 +25,6 @@ public class WidgetPreferenceStorage {
|
|||||||
JSONArray savedWidgetsPreferencesDataArray = null;
|
JSONArray savedWidgetsPreferencesDataArray = null;
|
||||||
try {
|
try {
|
||||||
savedWidgetsPreferencesDataArray = new JSONArray(savedWidgetsPreferencesData);
|
savedWidgetsPreferencesDataArray = new JSONArray(savedWidgetsPreferencesData);
|
||||||
savedWidgetsPreferencesDataArray = new JSONArray("fdsfdsfsffs");
|
|
||||||
} catch (
|
} catch (
|
||||||
JSONException e) {
|
JSONException e) {
|
||||||
LOG.error(e.getMessage());
|
LOG.error(e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user