diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c6d81d0ecf..31af1e0c78 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -614,6 +614,10 @@
android:name=".devices.qhybrid.CalibrationActivity"
android:label="@string/qhybrid_title_calibration"
android:parentActivityName=".devices.qhybrid.HRConfigActivity" />
+
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/CommuteActionsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/CommuteActionsActivity.java
new file mode 100644
index 0000000000..78d03b0b66
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/CommuteActionsActivity.java
@@ -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 . */
+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 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 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));
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/CommuteActionsListAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/CommuteActionsListAdapter.java
new file mode 100644
index 0000000000..e7fc04dd59
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/CommuteActionsListAdapter.java
@@ -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 . */
+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 {
+ private CommuteActionsActivity parentActivity;
+ private List mData;
+ private LayoutInflater mInflater;
+ private ItemClickListener mClickListener;
+
+ // data is passed into the constructor
+ public CommuteActionsListAdapter(Context context, List 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);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java
index 38a81e77a0..b0d3f90265 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HRConfigActivity.java
@@ -16,7 +16,6 @@
along with this program. If not, see . */
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 menuActions = new ArrayList<>();
private ArrayList customWidgets = new ArrayList<>();
SparseArray 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 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 {
public WidgetListAdapter(@NonNull List objects) {
super(HRConfigActivity.this, 0, objects);
@@ -562,66 +423,4 @@ public class HRConfigActivity extends AbstractGBActivity implements View.OnClick
return view;
}
}
-
- class ActionListAdapter extends ArrayAdapter {
- public ActionListAdapter(@NonNull ArrayList 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;
- }
- }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java
index bbfd91788a..8b3a12068d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java
@@ -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++)
diff --git a/app/src/main/res/layout/activity_commute_actions.xml b/app/src/main/res/layout/activity_commute_actions.xml
new file mode 100644
index 0000000000..2e8243ac33
--- /dev/null
+++ b/app/src/main/res/layout/activity_commute_actions.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_qhybrid_hr_settings.xml b/app/src/main/res/layout/activity_qhybrid_hr_settings.xml
index 13c758595a..d67a2243d8 100644
--- a/app/src/main/res/layout/activity_qhybrid_hr_settings.xml
+++ b/app/src/main/res/layout/activity_qhybrid_hr_settings.xml
@@ -5,18 +5,6 @@
android:orientation="vertical"
android:weightSum="1">
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 81740fc321..805ed765e7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1175,4 +1175,9 @@
Calibrate the watch hands
Send the messages configured below to your device
Dismiss calls from the watch with an SMS message
-
\ No newline at end of file
+ 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.
+ delete
+ Edit action
+ cancel
+ New action
+
diff --git a/app/src/main/res/xml/devicesettings_fossilhybridhr.xml b/app/src/main/res/xml/devicesettings_fossilhybridhr.xml
index c3684aef2f..73d97a8281 100644
--- a/app/src/main/res/xml/devicesettings_fossilhybridhr.xml
+++ b/app/src/main/res/xml/devicesettings_fossilhybridhr.xml
@@ -72,6 +72,14 @@
-->
+
+
+
+