mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 01:09:47 +01:00
Add confirmation dialog to Find device, fixes #1330
This commit is contained in:
parent
329c47fff2
commit
6960b10e5d
@ -57,7 +57,6 @@ import java.util.Locale;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.ActivitySummariesActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.ActivitySummariesActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.ActivitySummaryDetail;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.ConfigureAlarms;
|
import nodomain.freeyourgadget.gadgetbridge.activities.ConfigureAlarms;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.VibrationActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.VibrationActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity;
|
||||||
@ -288,32 +287,47 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
);
|
);
|
||||||
|
|
||||||
holder.findDevice.setVisibility(device.isInitialized() && coordinator.supportsFindDevice() ? View.VISIBLE : View.GONE);
|
holder.findDevice.setVisibility(device.isInitialized() && coordinator.supportsFindDevice() ? View.VISIBLE : View.GONE);
|
||||||
holder.findDevice.setOnClickListener(new View.OnClickListener()
|
holder.findDevice.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (device.getType() == DeviceType.VIBRATISSIMO) {
|
new AlertDialog.Builder(context)
|
||||||
Intent startIntent;
|
.setCancelable(true)
|
||||||
startIntent = new Intent(context, VibrationActivity.class);
|
.setTitle(context.getString(R.string.controlcenter_find_device))
|
||||||
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
|
.setMessage(context.getString(R.string.find_lost_device_message, device.getName()))
|
||||||
context.startActivity(startIntent);
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
return;
|
@Override
|
||||||
}
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
GBApplication.deviceService().onFindDevice(true);
|
if (device.getType() == DeviceType.VIBRATISSIMO) {
|
||||||
Snackbar.make(parent, R.string.control_center_find_lost_device, Snackbar.LENGTH_INDEFINITE).setAction(R.string.find_lost_device_you_found_it, new View.OnClickListener() {
|
Intent startIntent;
|
||||||
@Override
|
startIntent = new Intent(context, VibrationActivity.class);
|
||||||
public void onClick(View v) {
|
startIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
|
||||||
GBApplication.deviceService().onFindDevice(false);
|
context.startActivity(startIntent);
|
||||||
}
|
return;
|
||||||
}).setCallback(new Snackbar.Callback() {
|
}
|
||||||
@Override
|
GBApplication.deviceService().onFindDevice(true);
|
||||||
public void onDismissed(Snackbar snackbar, int event) {
|
Snackbar.make(parent, R.string.control_center_find_lost_device, Snackbar.LENGTH_INDEFINITE).setAction(R.string.find_lost_device_you_found_it, new View.OnClickListener() {
|
||||||
GBApplication.deviceService().onFindDevice(false);
|
@Override
|
||||||
super.onDismissed(snackbar, event);
|
public void onClick(View v) {
|
||||||
}
|
GBApplication.deviceService().onFindDevice(false);
|
||||||
}).show();
|
}
|
||||||
// ProgressDialog.show(
|
}).setCallback(new Snackbar.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onDismissed(Snackbar snackbar, int event) {
|
||||||
|
GBApplication.deviceService().onFindDevice(false);
|
||||||
|
super.onDismissed(snackbar, event);
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
// ProgressDialog.show(
|
||||||
// context,
|
// context,
|
||||||
// context.getString(R.string.control_center_find_lost_device),
|
// context.getString(R.string.control_center_find_lost_device),
|
||||||
// context.getString(R.string.control_center_cancel_to_stop_vibration),
|
// context.getString(R.string.control_center_cancel_to_stop_vibration),
|
||||||
@ -326,7 +340,6 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
holder.calibrateDevice.setVisibility(device.isInitialized() && (coordinator.getCalibrationActivity() != null) ? View.VISIBLE : View.GONE);
|
holder.calibrateDevice.setVisibility(device.isInitialized() && (coordinator.getCalibrationActivity() != null) ? View.VISIBLE : View.GONE);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<string name="action_donate">Donate</string>
|
<string name="action_donate">Donate</string>
|
||||||
<string name="controlcenter_fetch_activity_data">Synchronize</string>
|
<string name="controlcenter_fetch_activity_data">Synchronize</string>
|
||||||
<string name="controlcenter_find_device">Find lost device</string>
|
<string name="controlcenter_find_device">Find lost device</string>
|
||||||
|
<string name="find_lost_device_message">Search for %1$s?</string>
|
||||||
<string name="controlcenter_take_screenshot">Take Screenshot</string>
|
<string name="controlcenter_take_screenshot">Take Screenshot</string>
|
||||||
<string name="controlcenter_change_led_color">Change LED Color</string>
|
<string name="controlcenter_change_led_color">Change LED Color</string>
|
||||||
<string name="controlcenter_change_fm_frequency">Change FM Frequency</string>
|
<string name="controlcenter_change_fm_frequency">Change FM Frequency</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user