mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
Bind connect and disconnect to the whole cards.
Use snackbars to give early feedback to the user (colors are wrong now, waiting for a change in master). Removed hintTextView for good
This commit is contained in:
parent
a4b7b87b24
commit
8fdb233ef0
@ -52,8 +52,6 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
private DeviceManager deviceManager;
|
||||
private ImageView background;
|
||||
//hidden temporarily?
|
||||
//private TextView hintTextView;
|
||||
|
||||
private List<GBDevice> deviceList;
|
||||
private GBDeviceAdapterv2 mGBDeviceAdapter;
|
||||
@ -106,7 +104,6 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
//end of material design boilerplate
|
||||
deviceManager = GBApplication.getDeviceManager();
|
||||
// hintTextView = (TextView) findViewById(R.id.hintTextView);
|
||||
|
||||
deviceListView = (RecyclerView) findViewById(R.id.deviceListView);
|
||||
deviceListView.setHasFixedSize(true);
|
||||
@ -246,13 +243,6 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
background.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
// if (connectedDevice != null) {
|
||||
// DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(connectedDevice);
|
||||
// hintTextView.setText(coordinator.getTapString());
|
||||
// } else if (!deviceList.isEmpty()) {
|
||||
// hintTextView.setText(R.string.tap_a_device_to_connect);
|
||||
// }
|
||||
|
||||
mGBDeviceAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@ import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.transition.TransitionManager;
|
||||
import android.view.LayoutInflater;
|
||||
@ -62,31 +64,33 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
final GBDevice device = deviceList.get(position);
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
|
||||
|
||||
holder.deviceImageView.setImageResource(R.drawable.level_list_device);
|
||||
//level-list does not allow negative values, hence we always add 100 to the key.
|
||||
holder.deviceImageView.setImageLevel(device.getType().getKey() + 100 + (device.isInitialized() ? 100 : 0));
|
||||
|
||||
holder.deviceImageView.setOnClickListener(new View.OnClickListener() {
|
||||
holder.container.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO: move somewhere else?
|
||||
if (device.isInitialized() || device.isConnected()) {
|
||||
showTransientSnackbar(R.string.controlcenter_snackbar_need_longpress);
|
||||
} else {
|
||||
showTransientSnackbar(R.string.controlcenter_snackbar_connecting);
|
||||
GBApplication.deviceService().connect(device);
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.deviceImageView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
|
||||
holder.container.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
//TODO: move somewhere else?
|
||||
showTransientSnackbar(R.string.controlcenter_snackbar_disconnecting);
|
||||
GBApplication.deviceService().disconnect();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
holder.deviceImageView.setImageResource(R.drawable.level_list_device);
|
||||
//level-list does not allow negative values, hence we always add 100 to the key.
|
||||
holder.deviceImageView.setImageLevel(device.getType().getKey() + 100 + (device.isInitialized() ? 100 : 0));
|
||||
|
||||
holder.deviceNameLabel.setText(getUniqueDeviceName(device));
|
||||
|
||||
//TODO: snackbar!
|
||||
if (device.isBusy()) {
|
||||
holder.deviceStatusLabel.setText(device.getBusyTask());
|
||||
holder.busyIndicator.setVisibility(View.VISIBLE);
|
||||
@ -118,6 +122,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showTransientSnackbar(R.string.busy_task_fetch_activity_data);
|
||||
GBApplication.deviceService().onFetchActivityData();
|
||||
}
|
||||
}
|
||||
@ -131,6 +136,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showTransientSnackbar(R.string.controlcenter_snackbar_requested_screenshot);
|
||||
GBApplication.deviceService().onScreenshotReq();
|
||||
}
|
||||
}
|
||||
@ -276,6 +282,8 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
CardView container;
|
||||
|
||||
ImageView deviceImageView;
|
||||
TextView deviceNameLabel;
|
||||
TextView deviceStatusLabel;
|
||||
@ -301,6 +309,8 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
container = (CardView) view.findViewById(R.id.card_view);
|
||||
|
||||
deviceImageView = (ImageView) view.findViewById(R.id.device_image);
|
||||
deviceNameLabel = (TextView) view.findViewById(R.id.device_name);
|
||||
deviceStatusLabel = (TextView) view.findViewById(R.id.device_status);
|
||||
@ -374,4 +384,18 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showTransientSnackbar(int resource) {
|
||||
Snackbar snackbar = Snackbar.make(parent, resource, Snackbar.LENGTH_SHORT);
|
||||
|
||||
View snackbarView = snackbar.getView();
|
||||
|
||||
// change snackbar text color
|
||||
int snackbarTextId = android.support.design.R.id.snackbar_text;
|
||||
TextView textView = (TextView) snackbarView.findViewById(snackbarTextId);
|
||||
//textView.setTextColor();
|
||||
//snackbarView.setBackgroundColor(Color.MAGENTA);
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,19 +23,6 @@
|
||||
|
||||
<include layout="@layout/activity_controlcenterv2_content_main" />
|
||||
|
||||
<!-- <TextView
|
||||
android:id="@+id/hintTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/secondarytext"
|
||||
android:textStyle="italic"
|
||||
android:text="@string/tap_connected_device_for_app_mananger"
|
||||
android:elevation="0dp" />
|
||||
-->
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -23,7 +23,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:paddingBottom="64dp"
|
||||
android:divider="@null" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -19,12 +19,66 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/device_item_infos_box"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:focusable="false"
|
||||
android:visibility="gone">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/device_item_infos"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toStartOf="@+id/device_action_remove"
|
||||
android:scrollbars="none" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_find"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clickable="true"
|
||||
android:tint="?android:textColorTertiary"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:srcCompat="@drawable/ic_action_find_lost_device"
|
||||
android:contentDescription="@string/controlcenter_find_device" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_remove"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/device_action_find"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clickable="true"
|
||||
android:tint="?android:textColorTertiary"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:srcCompat="@drawable/ic_remove_device"
|
||||
android:contentDescription="@string/controlcenter_delete_device" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_image"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_below="@id/device_item_infos_box"
|
||||
android:contentDescription="@string/candidate_item_device_image"
|
||||
android:clickable="true"
|
||||
android:longClickable="true"
|
||||
@ -35,12 +89,14 @@
|
||||
android:id="@+id/device_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toRightOf="@id/device_image"
|
||||
android:layout_toLeftOf="@id/device_info_image"
|
||||
android:layout_below="@id/device_item_infos_box"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
tools:text="My Pebble Watch" />
|
||||
tools:text="My Pebble Watch"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/device_status"
|
||||
@ -48,10 +104,28 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/device_name"
|
||||
android:layout_toRightOf="@id/device_image"
|
||||
android:layout_toLeftOf="@id/device_info_image"
|
||||
android:gravity="center"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
|
||||
tools:text="@string/connecting" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_info_image"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/device_item_infos_box"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/candidate_item_device_image"
|
||||
android:tint="@color/secondarytext"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:srcCompat="@drawable/ic_more_vert" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/device_battery_status_box"
|
||||
android:layout_width="wrap_content"
|
||||
@ -167,75 +241,8 @@
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/controlcenter_start_activitymonitor" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_info_image"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/device_image"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/candidate_item_device_image"
|
||||
android:tint="@color/secondarytext"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:srcCompat="@drawable/ic_more_vert" />
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/device_item_infos_box"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@id/device_info_image"
|
||||
android:layout_marginTop="8dp"
|
||||
android:focusable="false"
|
||||
android:visibility="gone">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/device_item_infos"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toStartOf="@+id/device_action_remove"
|
||||
android:scrollbars="none" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_find"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clickable="true"
|
||||
android:tint="?android:textColorTertiary"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:srcCompat="@drawable/ic_action_find_lost_device"
|
||||
android:contentDescription="@string/controlcenter_find_device" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_remove"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/device_action_find"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clickable="true"
|
||||
android:tint="?android:textColorTertiary"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:srcCompat="@drawable/ic_remove_device"
|
||||
android:contentDescription="@string/controlcenter_delete_device" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
@ -16,4 +16,9 @@
|
||||
android:icon="@drawable/ic_quit" />
|
||||
</group>
|
||||
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/external_changelog"
|
||||
android:title="@string/changelog_title" />
|
||||
</group>
|
||||
</menu>
|
||||
|
@ -16,6 +16,11 @@
|
||||
<string name="controlcenter_delete_device_dialogmessage">This will delete the device and all associated data!</string>
|
||||
<string name="controlcenter_navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="controlcenter_navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="controlcenter_snackbar_need_longpress">Long press the card to disconnect</string>
|
||||
<string name="controlcenter_snackbar_disconnecting">Disconnecting</string>
|
||||
<string name="controlcenter_snackbar_connecting">Connecting</string>
|
||||
<string name="controlcenter_snackbar_requested_screenshot">Taking a screenshot of the device</string>
|
||||
|
||||
|
||||
<string name="title_activity_debug">Debug</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user