1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-29 03:55:49 +01:00

Revert "Introduce app shortcuts"

This reverts commit b4b153c62d.
This commit is contained in:
Andreas Shimokawa 2022-10-06 10:22:41 +02:00
parent 8a8f74182d
commit 25d0d262bf
3 changed files with 6 additions and 39 deletions

View File

@ -248,10 +248,12 @@ dependencies {
implementation 'com.github.wax911:android-emojify:0.1.7'
implementation 'com.google.protobuf:protobuf-javalite:3.10.0'
implementation 'com.android.volley:volley:1.2.1'
implementation('androidx.core:core-google-shortcuts:1.0.1') {
exclude group:'com.google.android.gms'
exclude group:'com.google.firebase'
}
// NON-FOSS dependencies
// implementation('androidx.core:core-google-shortcuts:1.0.1') {
// exclude group:'com.google.android.gms'
// exclude group:'com.google.firebase'
// }
// JSR-310 timezones backport for Android, since we're still API 21
implementation 'com.jakewharton.threetenabp:threetenabp:1.4.0'

View File

@ -86,8 +86,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_CONNECT;
//TODO: extend AbstractGBActivity, but it requires actionbar that is not available
public class ControlCenterv2 extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, GBActivity {
@ -321,7 +319,6 @@ public class ControlCenterv2 extends AppCompatActivity
@Override
protected void onResume() {
super.onResume();
handleShortcut(getIntent());
if (isLanguageInvalid) {
isLanguageInvalid = false;
recreate();
@ -552,17 +549,6 @@ public class ControlCenterv2 extends AppCompatActivity
return new RefreshTask(task, context);
}
private void handleShortcut(Intent intent) {
if (ACTION_CONNECT.equals(intent.getAction())) {
String btDeviceAddress = intent.getStringExtra("device");
if (btDeviceAddress!=null) {
GBDevice candidate = DeviceHelper.getInstance().findAvailableDevice(btDeviceAddress, this);
if (candidate != null && !candidate.isConnected()) {
GBApplication.deviceService(candidate).connect();
}
}
}
}
public class RefreshTask extends DBAccess {
public RefreshTask(String task, Context context) {
super(task, context);

View File

@ -56,9 +56,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
@ -121,8 +118,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.FormatUtils;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_CONNECT;
/**
* Adapter for displaying GBDevice instances.
*/
@ -286,7 +281,6 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
showTransientSnackbar(R.string.controlcenter_snackbar_need_longpress);
} else {
showTransientSnackbar(R.string.controlcenter_snackbar_connecting);
createDynamicShortcut(device);
GBApplication.deviceService(device).connect();
}
}
@ -1407,21 +1401,6 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
return Color.HSVToColor(hsvb);
}
void createDynamicShortcut(GBDevice device) {
Intent intent = new Intent(context, ControlCenterv2.class)
.setAction(ACTION_CONNECT)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("device", device.getAddress());
ShortcutManagerCompat.pushDynamicShortcut(context, new ShortcutInfoCompat.Builder(context, device.getAddress())
.setLongLived(false)
.setShortLabel(device.getAliasOrName())
.setIntent(intent)
.setIcon(IconCompat.createWithResource(context, device.getType().getIcon()))
.build()
);
}
private static class GBDeviceDiffUtil extends DiffUtil.ItemCallback<GBDevice> {
@Override
public boolean areItemsTheSame(@NonNull GBDevice oldItem, @NonNull GBDevice newItem) {