Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/wear-os-hex-editor-watchface.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <a.avdyukhin@norsi-trans.ru>2022-03-14 14:18:51 +0300
committerAlexey 'Cluster' Avdyukhin <a.avdyukhin@norsi-trans.ru>2022-03-14 14:18:51 +0300
commit4119e1d9142eff6ee7da5a65c4d1d0fb913cee0f (patch)
tree70eccc1c6c2fad886c5e1eb82d1808c68454de91
parent4820417a226ecd7fcb6c7c135251805ff97a6345 (diff)
Settings
-rw-r--r--app/src/main/java/com/clusterrr/hexeditorwatchface/Setting.java1
-rw-r--r--app/src/main/java/com/clusterrr/hexeditorwatchface/SettingsMenuAdapter.java112
-rw-r--r--app/src/main/res/layout/menu_item.xml6
-rw-r--r--app/src/main/res/values/strings.xml11
-rw-r--r--app/src/main/res/values/values-notround.xml4
-rw-r--r--app/src/main/res/values/values-round.xml4
6 files changed, 44 insertions, 94 deletions
diff --git a/app/src/main/java/com/clusterrr/hexeditorwatchface/Setting.java b/app/src/main/java/com/clusterrr/hexeditorwatchface/Setting.java
index 7fc117c..cc386bb 100644
--- a/app/src/main/java/com/clusterrr/hexeditorwatchface/Setting.java
+++ b/app/src/main/java/com/clusterrr/hexeditorwatchface/Setting.java
@@ -17,6 +17,7 @@ public class Setting {
mDefaultValue = defaultValue;
}
+ public String getName() { return mName; }
public String[] getValueNames() { return mValueNames.clone(); }
public String getValueName(int i) { return mValueNames[i]; }
public int getValueCount() { return mValueNames.length; }
diff --git a/app/src/main/java/com/clusterrr/hexeditorwatchface/SettingsMenuAdapter.java b/app/src/main/java/com/clusterrr/hexeditorwatchface/SettingsMenuAdapter.java
index 0c2e46c..dccaf57 100644
--- a/app/src/main/java/com/clusterrr/hexeditorwatchface/SettingsMenuAdapter.java
+++ b/app/src/main/java/com/clusterrr/hexeditorwatchface/SettingsMenuAdapter.java
@@ -4,6 +4,7 @@ import static com.clusterrr.hexeditorwatchface.HexWatchFace.TAG;
import android.Manifest;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.util.Log;
import android.view.LayoutInflater;
@@ -22,6 +23,8 @@ import androidx.recyclerview.widget.RecyclerView;
public class SettingsMenuAdapter extends RecyclerView.Adapter<SettingsMenuAdapter.RecyclerViewHolder> {
//private ArrayList<MenuItem> dataSource = new ArrayList<MenuItem>();
+ private Setting[] mSettings;
+
public interface AdapterCallback {
void onItemClicked(Integer menuPosition);
}
@@ -35,6 +38,20 @@ public class SettingsMenuAdapter extends RecyclerView.Adapter<SettingsMenuAdapte
public SettingsMenuAdapter(AppCompatActivity context /*, ArrayList<MenuItem> dataArgs, AdapterCallback callback*/) {
this.context = context;
+ SharedPreferences prefs = context.getPreferences(Context.MODE_PRIVATE);
+ mSettings = new Setting[] {
+ new Setting(prefs, "Time format", new String[] {"12 hours", "24 hours"}, context.getString(R.string.pref_time_format), 1),
+ new Setting(prefs, "Time system", new String[] {"Dec", "Hex", "Hex, dec on tap"}, context.getString(R.string.pref_time_system), 2),
+ new Setting(prefs, "Date", new String[] {"Do not show", "Dec", "Hex, dec on tap"}, context.getString(R.string.pref_date), 0),
+ new Setting(prefs, "Day of the week", new String[] {"Do not show", "Sunday = 0", "Sunday = 7"}, context.getString(R.string.pref_day_week), 0),
+ new Setting(prefs, "Heart rate", new String[] {"Do not show", "Dec", "Hex, dec on tap"}, context.getString(R.string.pref_heart_rate), 0),
+ new Setting(prefs, "Steps", new String[] {"Do not show", "Dec", "Hex, dec on tap"}, context.getString(R.string.pref_steps), 0),
+ new Setting(prefs, "Battery", new String[] {"Do not show", "Dec (0-100)",
+ "Hex (0x00-0xFF)", "Hex (0-100)", "Hex (0x00-0xFF), dec on tap", "Hex (0-100), dec on tap"},
+ context.getString(R.string.pref_battery), 0),
+ new Setting(prefs, "Endianness", new String[] {"Little endian", "Big endian"}, context.getString(R.string.pref_endianness), 0),
+ new Setting(prefs, "Round vignetting", new String[] {"Disabled", "Enabled>"}, context.getString(R.string.pref_vignetting), 0),
+ };
// this.dataSource = dataArgs;
// this.callback = callback;
requestPermissionLauncherLocation = context.registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
@@ -100,105 +117,20 @@ public class SettingsMenuAdapter extends RecyclerView.Adapter<SettingsMenuAdapte
menuContainer = view.findViewById(R.id.settingsContainer);
menuItemSettingKey = view.findViewById(R.id.textViewSettingKey);
menuItemSettingValue = view.findViewById(R.id.textViewSettingValue);
-// menuItem = view.findViewById(R.id.textView);
-// menuIcon = view.findViewById(R.id.menu_icon);
}
}
@Override
public void onBindViewHolder(@NonNull SettingsMenuAdapter.RecyclerViewHolder holder, int position) {
- switch (position){
- case 0:
- holder.menuItemSettingKey.setText("Time format");
- holder.menuItemSettingValue.setText("Dec on tap");
- holder.menuContainer.setOnClickListener(v -> {
- /*
- if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_BACKGROUND_LOCATION)
- != PackageManager.PERMISSION_GRANTED) {
- Log.d(TAG, "ACCESS_BACKGROUND_LOCATION request required");
- requestPermissionLauncherLocation.launch(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
- } else {
- Log.d(TAG, "ACCESS_BACKGROUND_LOCATION request not required");
- }
- */
- requestPermissionLauncherLocation.launch(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
- });
- break;
- case 1:
- holder.menuItemSettingKey.setText("Time numeral system");
- holder.menuItemSettingValue.setText("Dec on tap");
- holder.menuContainer.setOnClickListener(v -> {
- if (ContextCompat.checkSelfPermission(context, Manifest.permission.BODY_SENSORS)
- != PackageManager.PERMISSION_GRANTED) {
- Log.d(TAG, "BODY_SENSORS request required");
- requestPermissionLauncherBody.launch(Manifest.permission.BODY_SENSORS);
- } else {
- Log.d(TAG, "BODY_SENSORS request not required");
- }
- });
- break;
- case 2:
- holder.menuItemSettingKey.setText("Date on the left");
- holder.menuItemSettingValue.setText("Dec on tap");
- holder.menuContainer.setOnClickListener(v -> {
- if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACTIVITY_RECOGNITION)
- != PackageManager.PERMISSION_GRANTED) {
- Log.d(TAG, "ACTIVITY_RECOGNITION request required");
- requestPermissionLauncherSteps.launch(Manifest.permission.ACTIVITY_RECOGNITION);
- } else {
- Log.d(TAG, "ACTIVITY_RECOGNITION request not required");
- }
- });
- break;
- case 3:
- holder.menuItemSettingKey.setText("Show heartrate");
- holder.menuItemSettingValue.setText("Dec on tap");
- break;
- case 4:
- holder.menuItemSettingKey.setText("Show steps");
- holder.menuItemSettingValue.setText("Little endian");
- break;
- case 5:
- holder.menuItemSettingKey.setText("Show temperate");
- holder.menuItemSettingValue.setText("Dec on tap");
- break;
- case 6:
- holder.menuItemSettingKey.setText("Show temperate");
- holder.menuItemSettingValue.setText("Dec on tap");
- break;
- }
-
- //MenuItem data_provider = dataSource.get(position);
-
- //holder.menuItem.setText("TEST");
- //holder.menuIcon.setImageResource(data_provider.getImage());
-
+ holder.menuItemSettingKey.setText(mSettings[position].getName());
+ holder.menuItemSettingValue.setText(mSettings[position].getValueName());
+ holder.menuContainer.setOnClickListener(v -> {
+ });
}
@Override
public int getItemCount() {
- //return dataSource.size();
- return 7;
- }
-}
-/*
-class MenuItem {
- private String text;
- private int image;
-
- public MenuItem(int image, String text) {
- this.image = image;
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
-
- public int getImage() {
- return image;
+ return mSettings.length;
}
}
-
- */ \ No newline at end of file
diff --git a/app/src/main/res/layout/menu_item.xml b/app/src/main/res/layout/menu_item.xml
index f447cdf..084e8b9 100644
--- a/app/src/main/res/layout/menu_item.xml
+++ b/app/src/main/res/layout/menu_item.xml
@@ -33,13 +33,13 @@
<TextView
android:id="@+id/textViewSettingValue"
- android:layout_width="50dp"
+ android:layout_width="70dp"
android:layout_height="wrap_content"
android:gravity="center"
+ android:paddingLeft="10dp"
android:text="value"
android:textSize="12sp"
- android:paddingLeft="10dp"
- android:visibility="visible"/>
+ android:visibility="visible" />
<Switch
android:id="@+id/switchSettingValue"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 20e80cf..1f85221 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -4,4 +4,13 @@
<string name="pref_today_step_start">today_step_start</string>
<string name="pref_steps_day">steps_day</string>
-</resources> \ No newline at end of file
+ <string name="pref_time_format">time_format</string>
+ <string name="pref_time_system">time_system</string>
+ <string name="pref_date">date</string>
+ <string name="pref_day_week">day_week</string>
+ <string name="pref_heart_rate">heart_rate</string>
+ <string name="pref_steps">steps</string>
+ <string name="pref_battery">battery</string>
+ <string name="pref_endianness">endianness</string>
+ <string name="pref_vignetting">vignetting</string>
+</resources>
diff --git a/app/src/main/res/values/values-notround.xml b/app/src/main/res/values/values-notround.xml
new file mode 100644
index 0000000..414e281
--- /dev/null
+++ b/app/src/main/res/values/values-notround.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="default_vignetting">0</integer>
+</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/values-round.xml b/app/src/main/res/values/values-round.xml
new file mode 100644
index 0000000..4162b1d
--- /dev/null
+++ b/app/src/main/res/values/values-round.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="default_vignetting">1</integer>
+</resources> \ No newline at end of file