1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-22 06:41:06 +02:00

Fossil Hybrid HR: Move commute actions to device specific settings

This commit is contained in:
Arjan Schrijver 2021-05-22 22:28:26 +02:00
parent ea914a44e7
commit 9f459b1da9
10 changed files with 405 additions and 218 deletions

View File

@ -614,6 +614,10 @@
android:name=".devices.qhybrid.CalibrationActivity"
android:label="@string/qhybrid_title_calibration"
android:parentActivityName=".devices.qhybrid.HRConfigActivity" />
<activity
android:name=".devices.qhybrid.CommuteActionsActivity"
android:label="Actions"
android:parentActivityName=".devices.qhybrid.HRConfigActivity" />
<activity
android:name=".devices.um25.Activity.DataActivity"
android:exported="true" />

View File

@ -0,0 +1,211 @@
/* Copyright (C) 2021 Arjan Schrijver
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import org.json.JSONArray;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
public class CommuteActionsActivity extends AppCompatActivity implements CommuteActionsListAdapter.ItemClickListener, DialogInterface.OnClickListener, View.OnClickListener {
protected final List<String> actionsList = new ArrayList<>();
private static final Logger LOG = LoggerFactory.getLogger(CommuteActionsActivity.class);
private SharedPreferences sharedPreferences;
private ItemTouchHelper actionTouchHelper;
private CommuteActionsListAdapter actionsListAdapter;
static public final String CONFIG_KEY_Q_ACTIONS = "Q_ACTIONS";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_commute_actions);
sharedPreferences = GBApplication.getPrefs().getPreferences();
findViewById(R.id.actionAddFab).setOnClickListener(this);
// set up the RecyclerView
RecyclerView recyclerView = findViewById(R.id.actionsListView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
actionsListAdapter = new CommuteActionsListAdapter(this, actionsList);
actionsListAdapter.setClickListener(this);
recyclerView.setAdapter(actionsListAdapter);
refreshActions();
// set up touch helper for reordering items
ItemTouchHelper.Callback actionTouchHelperCallback = new ActionTouchHelperCallback(actionsListAdapter);
actionTouchHelper = new ItemTouchHelper(actionTouchHelperCallback);
actionTouchHelper.attachToRecyclerView(recyclerView);
}
private void refreshActions() {
JSONArray actionArray = null;
try {
actionArray = new JSONArray(sharedPreferences.getString(CONFIG_KEY_Q_ACTIONS, "[]"));
actionsList.clear();
for (int i = 0; i < actionArray.length(); i++)
actionsList.add(actionArray.getString(i));
actionsListAdapter.notifyDataSetChanged();
} catch (JSONException e) {
LOG.error("Error retrieving commute actions", e);
}
}
private void putActionItems(List<String> actions) {
JSONArray array = new JSONArray();
for (String action : actions) array.put(action);
sharedPreferences.edit().putString(CONFIG_KEY_Q_ACTIONS, array.toString()).apply();
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.actionAddFab) {
final EditText input = new EditText(this);
input.setId(0);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
new AlertDialog.Builder(this)
.setView(input)
.setNegativeButton(R.string.fossil_hr_new_action_cancel, null)
.setPositiveButton(R.string.ok, this)
.setTitle(R.string.fossil_hr_new_action)
.show();
}
}
@Override
public void onItemClick(View view, final int position) {
final EditText input = new EditText(this);
input.setId(0);
input.setText(actionsListAdapter.getItem(position));
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
new AlertDialog.Builder(this)
.setView(input)
.setNegativeButton(R.string.fossil_hr_edit_action_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
actionsList.remove(position);
putActionItems(actionsList);
refreshActions();
LocalBroadcastManager.getInstance(CommuteActionsActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
}
})
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
actionsList.set(position, input.getText().toString());
putActionItems(actionsList);
refreshActions();
LocalBroadcastManager.getInstance(CommuteActionsActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
}
})
.setTitle(R.string.fossil_hr_edit_action)
.show();
}
@Override
public void onClick(DialogInterface dialog, int which) {
EditText actionEditText = ((AlertDialog) dialog).findViewById(0);
String action = actionEditText.getText().toString();
try {
JSONArray actionArray = new JSONArray(sharedPreferences.getString(CONFIG_KEY_Q_ACTIONS, "[]"));
actionArray.put(action);
sharedPreferences.edit().putString(CONFIG_KEY_Q_ACTIONS, actionArray.toString()).apply();
refreshActions();
LocalBroadcastManager.getInstance(CommuteActionsActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
} catch (JSONException e) {
LOG.error("Error adding new commute action", e);
}
}
public void startDragging(RecyclerView.ViewHolder viewHolder) {
actionTouchHelper.startDrag(viewHolder);
}
public class ActionTouchHelperCallback extends ItemTouchHelper.Callback {
private final CommuteActionsListAdapter actionsListAdapter;
public ActionTouchHelperCallback(CommuteActionsListAdapter actionsListAdapter) {
this.actionsListAdapter = actionsListAdapter;
}
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
//we only support up and down movement and only for moving, not for swiping apps away
return makeMovementFlags(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0);
}
@Override
public boolean isLongPressDragEnabled() {
return false;
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) {
actionsListAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition());
putActionItems(actionsList);
return true;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
//nothing to do
}
@Override
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
putActionItems(actionsList);
LocalBroadcastManager.getInstance(CommuteActionsActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
}
}
}

View File

@ -0,0 +1,111 @@
/* Copyright (C) 2021 Arjan Schrijver
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.Collections;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.R;
public class CommuteActionsListAdapter extends RecyclerView.Adapter<CommuteActionsListAdapter.ViewHolder> {
private CommuteActionsActivity parentActivity;
private List<String> mData;
private LayoutInflater mInflater;
private ItemClickListener mClickListener;
// data is passed into the constructor
public CommuteActionsListAdapter(Context context, List<String> data) {
this.mInflater = LayoutInflater.from(context);
this.mData = data;
this.parentActivity = (CommuteActionsActivity) context;
}
// inflates the row layout from xml when needed
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.fossil_hr_row_commute_action, parent, false);
return new ViewHolder(view);
}
// binds the data to the TextView in each row
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
String line = mData.get(position);
holder.mTextView.setText(line);
holder.mDragHandle.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
parentActivity.startDragging(holder);
return true;
}
});
}
// total number of rows
@Override
public int getItemCount() {
return mData.size();
}
public void onItemMove(int from, int to) {
Collections.swap(mData, from, to);
notifyItemMoved(from, to);
}
// stores and recycles views as they are scrolled off screen
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView mTextView;
ImageView mDragHandle;
ViewHolder(View itemView) {
super(itemView);
mTextView = itemView.findViewById(R.id.fossil_hr_row_commute_action);
mDragHandle = (ImageView) itemView.findViewById(R.id.drag_handle);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (mClickListener != null) mClickListener.onItemClick(view, getAdapterPosition());
}
}
// convenience method for getting data at click position
String getItem(int id) {
return mData.get(id);
}
// allows clicks events to be caught
void setClickListener(ItemClickListener itemClickListener) {
this.mClickListener = itemClickListener;
}
// parent activity will implement this method to respond to click events
public interface ItemClickListener {
void onItemClick(View view, int position);
}
}

View File

@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
@ -28,11 +27,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -62,16 +57,13 @@ import nodomain.freeyourgadget.gadgetbridge.util.Version;
import static nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport.QHYBRID_COMMAND_UPDATE_WIDGETS;
public class HRConfigActivity extends AbstractGBActivity implements View.OnClickListener, DialogInterface.OnClickListener, AdapterView.OnItemClickListener {
public class HRConfigActivity extends AbstractGBActivity implements View.OnClickListener {
private SharedPreferences sharedPreferences;
private ActionListAdapter actionListAdapter;
private WidgetListAdapter widgetListAdapter;
private ArrayList<MenuAction> menuActions = new ArrayList<>();
private ArrayList<CustomWidget> customWidgets = new ArrayList<>();
SparseArray<String> widgetButtonsMapping = new SparseArray<>(4);
static public final String CONFIG_KEY_Q_ACTIONS = "Q_ACTIONS";
private static final int REQUEST_CODE_WIDGET_EDIT = 0;
private static final int REQUEST_CODE_IMAGE_PICK = 1;
private static final int REQUEST_CODE_IMAGE_EDIT = 2;
@ -81,7 +73,6 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qhybrid_hr_settings);
findViewById(R.id.qhybrid_action_add).setOnClickListener(this);
findViewById(R.id.qhybrid_apps_management_trigger).setOnClickListener(this);
sharedPreferences = GBApplication.getPrefs().getPreferences();
@ -89,12 +80,6 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
initMappings();
loadWidgetConfigs();
ListView actionListView = findViewById(R.id.qhybrid_action_list);
actionListAdapter = new ActionListAdapter(menuActions);
actionListView.setAdapter(actionListAdapter);
actionListView.setOnItemClickListener(this);
final ListView widgetListView = findViewById(R.id.qhybrid_widget_list);
widgetListAdapter = new WidgetListAdapter(customWidgets);
widgetListView.setAdapter(widgetListAdapter);
@ -184,8 +169,6 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
});
}
updateSettings();
// Disable some functions on watches with too new firmware (from official app 4.6.0 and higher)
String fwVersion_str = GBApplication.app().getDeviceManager().getSelectedDevice().getFirmwareVersion();
fwVersion_str = fwVersion_str.replaceFirst("^DN", "").replaceFirst("r\\.v.*", "");
@ -417,133 +400,11 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
@Override
public void onClick(View v) {
if (v.getId() == R.id.qhybrid_action_add) {
final EditText input = new EditText(this);
input.setId(0);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
new AlertDialog.Builder(this)
.setView(input)
.setNegativeButton("cancel", null)
.setPositiveButton("ok", this)
.setTitle("create action")
.show();
} else if(v.getId() == R.id.qhybrid_apps_management_trigger) {
if (v.getId() == R.id.qhybrid_apps_management_trigger) {
startActivity(new Intent(getApplicationContext(), AppsManagementActivity.class));
}
}
private void updateSettings() {
JSONArray actionArray = null;
try {
actionArray = new JSONArray(sharedPreferences.getString(CONFIG_KEY_Q_ACTIONS, "[]"));
menuActions.clear();
for (int i = 0; i < actionArray.length(); i++)
menuActions.add(new MenuAction(actionArray.getString(i)));
actionListAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onClick(DialogInterface dialog, int which) {
EditText actionEditText = ((AlertDialog) dialog).findViewById(0);
String action = actionEditText.getText().toString();
try {
JSONArray actionArray = new JSONArray(sharedPreferences.getString(CONFIG_KEY_Q_ACTIONS, "[]"));
actionArray.put(action);
sharedPreferences.edit().putString(CONFIG_KEY_Q_ACTIONS, actionArray.toString()).apply();
updateSettings();
LocalBroadcastManager.getInstance(HRConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
final EditText input = new EditText(this);
input.setId(0);
TextView subject = findViewById(0);
input.setText(subject.getText());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
new AlertDialog.Builder(this)
.setView(input)
.setNegativeButton("delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
menuActions.remove(position);
putActionItems(menuActions);
updateSettings();
LocalBroadcastManager.getInstance(HRConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
}
})
.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
menuActions.get(position).setAction(input.getText().toString());
putActionItems(menuActions);
updateSettings();
LocalBroadcastManager.getInstance(HRConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
}
})
.setTitle("edit action")
.show();
}
private void moveActionUp(int position){
this.menuActions.add(position - 1, this.menuActions.remove(position));
this.actionListAdapter.notifyDataSetChanged();
putActionItems(menuActions);
LocalBroadcastManager.getInstance(HRConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
}
private void moveActionDown(int position){
this.menuActions.add(position + 1, this.menuActions.remove(position));
this.actionListAdapter.notifyDataSetChanged();
putActionItems(menuActions);
LocalBroadcastManager.getInstance(HRConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_OVERWRITE_BUTTONS));
}
private void putActionItems(List<MenuAction> actions) {
JSONArray array = new JSONArray();
for (MenuAction action : actions) array.put(action.getAction());
sharedPreferences.edit().putString(CONFIG_KEY_Q_ACTIONS, array.toString()).apply();
}
class MenuAction {
private String action;
public MenuAction(String action) {
this.action = action;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
}
class WidgetListAdapter extends ArrayAdapter<CustomWidget> {
public WidgetListAdapter(@NonNull List<CustomWidget> objects) {
super(HRConfigActivity.this, 0, objects);
@ -562,66 +423,4 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
return view;
}
}
class ActionListAdapter extends ArrayAdapter<MenuAction> {
public ActionListAdapter(@NonNull ArrayList<MenuAction> objects) {
super(HRConfigActivity.this, 0, objects);
}
@SuppressLint("ResourceType")
@NonNull
@Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
RelativeLayout layout = new RelativeLayout(getContext());
TextView text = new TextView(getContext());
text.setId(0);
text.setText(getItem(position).getAction());
// view.setTextColor(Color.WHITE);
text.setTextSize(25);
RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
textParams.addRule(RelativeLayout.ALIGN_PARENT_START, RelativeLayout.TRUE);
layout.addView(text);
try {
getItem(position + 1);
ImageView downView = new ImageView(getContext());
downView.setImageResource(R.drawable.ic_arrow_upward);
downView.setRotation(180);
RelativeLayout.LayoutParams downParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
downParams.addRule(RelativeLayout.ALIGN_PARENT_END, RelativeLayout.TRUE);
downView.setLayoutParams(downParams);
downView.setId(2);
downView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
moveActionDown(position);
}
});
layout.addView(downView);
}catch (IndexOutOfBoundsException e){
// no following item
}
if (position != 0) {
ImageView upView = new ImageView(getContext());
upView.setImageResource(R.drawable.ic_arrow_upward);
RelativeLayout.LayoutParams upParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
upParams.setMarginEnd(100);
upParams.addRule(RelativeLayout.ALIGN_PARENT_END, RelativeLayout.TRUE);
upView.setLayoutParams(upParams);
upView.setId(1);
upView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
moveActionUp(position);
}
});
layout.addView(upView);
}
return layout;
}
}
}

View File

@ -65,7 +65,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallContro
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventNotificationControl;
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.HRConfigActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.CommuteActionsActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.HybridHRActivitySampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationHRConfiguration;
import nodomain.freeyourgadget.gadgetbridge.entities.HybridHRActivitySample;
@ -1279,7 +1279,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
for (ApplicationInformation info : installedApplications) {
if (info.getAppName().equals("commuteApp")) {
JSONArray jsonArray = new JSONArray(
GBApplication.getPrefs().getString(HRConfigActivity.CONFIG_KEY_Q_ACTIONS, "[]")
GBApplication.getPrefs().getString(CommuteActionsActivity.CONFIG_KEY_Q_ACTIONS, "[]")
);
String[] menuItems = new String[jsonArray.length()];
for (int i = 0; i < jsonArray.length(); i++)

View File

@ -0,0 +1,36 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".devices.qhybrid.CommuteActionsActivity">
<TextView
android:id="@+id/fossil_hr_commute_actions_explanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:text="@string/fossil_hr_commute_actions_explanation" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/actionsListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/fossil_hr_commute_actions_explanation"
android:divider="@null" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/actionAddFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_gravity="bottom|end"
app:srcCompat="@drawable/ic_add"
android:layout_margin="16dp" />
</RelativeLayout>

View File

@ -5,18 +5,6 @@
android:orientation="vertical"
android:weightSum="1">
<ListView
android:id="@+id/qhybrid_action_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4" />
<Button
android:id="@+id/qhybrid_action_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="add action" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="@+id/drag_handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
app:srcCompat="@drawable/ic_drag_handle" />
<TextView
android:id="@+id/fossil_hr_row_commute_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_toEndOf="@id/drag_handle"
android:textSize="25sp" />
</RelativeLayout>

View File

@ -1175,4 +1175,9 @@
<string name="qhybrid_summary_calibration">Calibrate the watch hands</string>
<string name="pref_summary_canned_messages_set">Send the messages configured below to your device</string>
<string name="pref_summary_canned_messages_dismisscall">Dismiss calls from the watch with an SMS message</string>
</resources>
<string name="fossil_hr_commute_actions_explanation">The actions configured here will appear in the Commute app on your watch. Read the wiki for information on how to configure Tasker to handle the actions.</string>
<string name="fossil_hr_edit_action_delete">delete</string>
<string name="fossil_hr_edit_action">Edit action</string>
<string name="fossil_hr_new_action_cancel">cancel</string>
<string name="fossil_hr_new_action">New action</string>
</resources>

View File

@ -72,6 +72,14 @@
-->
</PreferenceScreen>
<Preference
android:title="Actions"
android:summary="Actions for the Commute app">
<intent
android:targetPackage="nodomain.freeyourgadget.gadgetbridge"
android:targetClass="nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.CommuteActionsActivity" />
</Preference>
<SeekBarPreference
android:defaultValue="2"
android:key="vibration_strength"