mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-24 01:25:50 +01:00
Pebble: Report correct connection state to PebbleKit companion apps (not always connected)
This commit is contained in:
parent
e6f68f445a
commit
9af976657b
@ -1,5 +1,9 @@
|
||||
###Changelog
|
||||
|
||||
####Next Version
|
||||
* Pebble: Report connection state to PebbleKit companion apps via content provider. NOTE: Makes Gadgetbridge mutual exclusive with the original Pebble app.
|
||||
* Ignore generic notification when from SMSSecure when SMS Notifications are on
|
||||
|
||||
####Version 0.7.2
|
||||
* Pebble: Allow replying to generic notifications that contain a wearable reply action (tested with Signal)
|
||||
* Pebble: Support seting up a common suffix for canned replies (defaults to " (canned reply)")
|
||||
|
@ -1,11 +1,21 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.contentprovider;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
public class PebbleContentProvider extends ContentProvider {
|
||||
|
||||
@ -24,8 +34,22 @@ public class PebbleContentProvider extends ContentProvider {
|
||||
static final String URL = "content://" + PROVIDER_NAME + "/state";
|
||||
static final Uri CONTENT_URI = Uri.parse(URL);
|
||||
|
||||
private GBDevice mGBDevice = null;
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
|
||||
mGBDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
LocalBroadcastManager.getInstance(this.getContext()).registerReceiver(mReceiver, new IntentFilter(GBDevice.ACTION_DEVICE_CHANGED));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -33,7 +57,17 @@ public class PebbleContentProvider extends ContentProvider {
|
||||
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
if (uri.equals(CONTENT_URI)) {
|
||||
MatrixCursor mc = new MatrixCursor(columnNames);
|
||||
mc.addRow(new Object[]{1, 1, 0, 3, 8, 0, "Gadgetbridge"});
|
||||
int connected = 0;
|
||||
int appMessage = 0;
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.getContext());
|
||||
if (sharedPrefs.getBoolean("pebble_enable_pebblekit", false)) {
|
||||
appMessage = 1;
|
||||
}
|
||||
if (mGBDevice != null && mGBDevice.getType() == DeviceType.PEBBLE && mGBDevice.isInitialized()) {
|
||||
connected = 1;
|
||||
}
|
||||
mc.addRow(new Object[]{connected, appMessage, 0, 3, 8, 2, "Gadgetbridge"});
|
||||
|
||||
return mc;
|
||||
} else {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user