mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-28 02:27:32 +01:00
Added "Fetch Activity Data" to the context menu.
With some kind of progress reporting during the fetching #45
This commit is contained in:
parent
9e4e50be47
commit
020d8d74d6
@ -151,7 +151,7 @@ public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSynchronizeActivityData() {
|
public void onFetchActivityData() {
|
||||||
byte[] bytes = gbDeviceProtocol.encodeSynchronizeActivityData();
|
byte[] bytes = gbDeviceProtocol.encodeSynchronizeActivityData();
|
||||||
sendToDevice(bytes);
|
sendToDevice(bytes);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ public class BluetoothCommunicationService extends Service {
|
|||||||
public static final String ACTION_INSTALL_PEBBLEAPP
|
public static final String ACTION_INSTALL_PEBBLEAPP
|
||||||
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.install_pebbbleapp";
|
= "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.install_pebbbleapp";
|
||||||
public static final String ACTION_REBOOT = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.reboot";
|
public static final String ACTION_REBOOT = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.reboot";
|
||||||
|
public static final String ACTION_FETCH_ACTIVITY_DATA = "nodomain.freeyourgadget.gadgetbride.bluetoothcommunicationservice.action.fetch_activity_data";
|
||||||
public static final String EXTRA_PERFORM_PAIR = "perform_pair";
|
public static final String EXTRA_PERFORM_PAIR = "perform_pair";
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(BluetoothCommunicationService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(BluetoothCommunicationService.class);
|
||||||
@ -200,6 +201,10 @@ public class BluetoothCommunicationService extends Service {
|
|||||||
mDeviceSupport.onReboot();
|
mDeviceSupport.onReboot();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ACTION_FETCH_ACTIVITY_DATA: {
|
||||||
|
mDeviceSupport.onFetchActivityData();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ACTION_CALLSTATE:
|
case ACTION_CALLSTATE:
|
||||||
GBCommand command = GBCommand.values()[intent.getIntExtra("call_command", 0)]; // UGLY
|
GBCommand command = GBCommand.values()[intent.getIntExtra("call_command", 0)]; // UGLY
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ public class ControlCenter extends Activity {
|
|||||||
}
|
}
|
||||||
refreshPairedDevices();
|
refreshPairedDevices();
|
||||||
|
|
||||||
|
refreshBusyState(dev);
|
||||||
|
|
||||||
if (dev.isConnected() && dev.getFirmwareVersion() == null && !dev.isInitializing()) {
|
if (dev.isConnected() && dev.getFirmwareVersion() == null && !dev.isInitializing()) {
|
||||||
LOG.info("device connected, requesting more info");
|
LOG.info("device connected, requesting more info");
|
||||||
requestDeviceInfo();
|
requestDeviceInfo();
|
||||||
@ -81,6 +83,10 @@ public class ControlCenter extends Activity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void refreshBusyState(GBDevice dev) {
|
||||||
|
mGBDeviceAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -171,6 +177,12 @@ public class ControlCenter extends Activity {
|
|||||||
startActivity(startIntent);
|
startActivity(startIntent);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.controlcenter_fetch_activity_data:
|
||||||
|
if (selectedDevice != null) {
|
||||||
|
Intent startIntent = new Intent(this, BluetoothCommunicationService.class);
|
||||||
|
startIntent.setAction(BluetoothCommunicationService.ACTION_FETCH_ACTIVITY_DATA);
|
||||||
|
startService(startIntent);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return super.onContextItemSelected(item);
|
return super.onContextItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public interface EventHandler {
|
|||||||
|
|
||||||
void onPhoneVersion(byte os);
|
void onPhoneVersion(byte os);
|
||||||
|
|
||||||
void onSynchronizeActivityData();
|
void onFetchActivityData();
|
||||||
|
|
||||||
void onReboot();
|
void onReboot();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -38,11 +39,23 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
|||||||
TextView deviceInfoLabel = (TextView) view.findViewById(R.id.device_info);
|
TextView deviceInfoLabel = (TextView) view.findViewById(R.id.device_info);
|
||||||
TextView batteryStatusLabel = (TextView) view.findViewById(R.id.battery_status);
|
TextView batteryStatusLabel = (TextView) view.findViewById(R.id.battery_status);
|
||||||
ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image);
|
ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image);
|
||||||
|
ProgressBar busyIndicator = (ProgressBar) view.findViewById(R.id.device_busy_indicator);
|
||||||
|
|
||||||
deviceStatusLabel.setText(device.getStateString());
|
|
||||||
deviceNameLabel.setText(device.getName());
|
deviceNameLabel.setText(device.getName());
|
||||||
deviceInfoLabel.setText(device.getInfoString());
|
deviceInfoLabel.setText(device.getInfoString());
|
||||||
|
|
||||||
|
if (device.isBusy()) {
|
||||||
|
deviceStatusLabel.setText(device.getBusyTask());
|
||||||
|
busyIndicator.setVisibility(View.VISIBLE);
|
||||||
|
batteryStatusLabel.setVisibility(View.GONE);
|
||||||
|
deviceInfoLabel.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
deviceStatusLabel.setText(device.getStateString());
|
||||||
|
busyIndicator.setVisibility(View.GONE);
|
||||||
|
batteryStatusLabel.setVisibility(View.VISIBLE);
|
||||||
|
deviceInfoLabel.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
short batteryLevel = device.getBatteryLevel();
|
short batteryLevel = device.getBatteryLevel();
|
||||||
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
|
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
|
||||||
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
||||||
|
@ -369,7 +369,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSynchronizeActivityData() {
|
public void onFetchActivityData() {
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("fetch activity data");
|
TransactionBuilder builder = performInitialized("fetch activity data");
|
||||||
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.busy_task_fetch_activity_data), getContext()));
|
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.busy_task_fetch_activity_data), getContext()));
|
||||||
|
@ -31,6 +31,13 @@
|
|||||||
android:textColor="@color/primarytext"
|
android:textColor="@color/primarytext"
|
||||||
android:typeface="sans" />
|
android:typeface="sans" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/device_busy_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignEnd="@+id/device_info"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/statuswrapper"
|
android:id="@+id/statuswrapper"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item
|
||||||
|
android:id="@+id/controlcenter_fetch_activity_data"
|
||||||
|
android:title="@string/controlcenter_fetch_activity_data"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/controlcenter_start_sleepmonitor"
|
android:id="@+id/controlcenter_start_sleepmonitor"
|
||||||
android:title="@string/controlcenter_start_sleepmonitor"/>
|
android:title="@string/controlcenter_start_sleepmonitor"/>
|
||||||
|
@ -106,5 +106,6 @@
|
|||||||
<string name="pref_write_logfiles">Write Log Files (needs restart)</string>
|
<string name="pref_write_logfiles">Write Log Files (needs restart)</string>
|
||||||
<string name="initializing">initializing</string>
|
<string name="initializing">initializing</string>
|
||||||
<string name="busy_task_fetch_activity_data">Fetching Activity Data</string>
|
<string name="busy_task_fetch_activity_data">Fetching Activity Data</string>
|
||||||
|
<string name="controlcenter_fetch_activity_data">Fetch Activity Data</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user