mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Separate AboutUser and link to it from Charts Settings
This commit is contained in:
parent
71f6fd77cb
commit
e3a5a63e08
@ -86,6 +86,10 @@
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:parentActivityName=".activities.ControlCenterv2" />
|
||||
<activity
|
||||
android:name=".activities.AboutUserPreferencesActivity"
|
||||
android:label="@string/activity_prefs_about_you"
|
||||
android:parentActivityName=".activities.AboutUserPreferencesActivity" />
|
||||
<activity
|
||||
android:name=".activities.charts.ChartsPreferencesActivity"
|
||||
android:label="@string/activity_prefs_charts"
|
||||
|
@ -0,0 +1,54 @@
|
||||
/* Copyright (C) 2015-2020 Andreas Shimokawa, Carsten Pfeiffer, Lem Dulfo,
|
||||
vanous
|
||||
|
||||
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.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_ACTIVETIME_MINUTES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_CALORIES_BURNT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_DISTANCE_METERS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_HEIGHT_CM;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_SLEEP_DURATION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_STEPS_GOAL;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_STEP_LENGTH_CM;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_WEIGHT_KG;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_YEAR_OF_BIRTH;
|
||||
|
||||
public class AboutUserPreferencesActivity extends AbstractSettingsActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.about_user);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getPreferenceKeysWithSummary() {
|
||||
return new String[]{
|
||||
PREF_USER_YEAR_OF_BIRTH,
|
||||
PREF_USER_HEIGHT_CM,
|
||||
PREF_USER_WEIGHT_KG,
|
||||
PREF_USER_SLEEP_DURATION,
|
||||
PREF_USER_STEPS_GOAL,
|
||||
PREF_USER_STEP_LENGTH_CM,
|
||||
PREF_USER_ACTIVETIME_MINUTES,
|
||||
PREF_USER_CALORIES_BURNT,
|
||||
PREF_USER_DISTANCE_METERS,};
|
||||
}
|
||||
}
|
@ -65,13 +65,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_HEIGHT_CM;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_SLEEP_DURATION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_STEPS_GOAL;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_WEIGHT_KG;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_YEAR_OF_BIRTH;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_STEP_LENGTH_CM;
|
||||
|
||||
public class SettingsActivity extends AbstractSettingsActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SettingsActivity.class);
|
||||
|
||||
@ -100,6 +93,16 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
}
|
||||
});
|
||||
|
||||
pref = findPreference("pref_category_activity_personal");
|
||||
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent enableIntent = new Intent(SettingsActivity.this, AboutUserPreferencesActivity.class);
|
||||
startActivity(enableIntent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
pref = findPreference("pref_charts");
|
||||
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
@ -455,12 +458,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
"pebble_reconnect_attempts",
|
||||
"location_latitude",
|
||||
"location_longitude",
|
||||
PREF_USER_YEAR_OF_BIRTH,
|
||||
PREF_USER_HEIGHT_CM,
|
||||
PREF_USER_WEIGHT_KG,
|
||||
PREF_USER_SLEEP_DURATION,
|
||||
PREF_USER_STEPS_GOAL,
|
||||
PREF_USER_STEP_LENGTH_CM,
|
||||
"weather_city",
|
||||
};
|
||||
}
|
||||
|
@ -17,10 +17,17 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AboutUserPreferencesActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class ChartsPreferencesActivity extends AbstractSettingsActivity {
|
||||
@Override
|
||||
@ -28,4 +35,32 @@ public class ChartsPreferencesActivity extends AbstractSettingsActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.charts_preferences);
|
||||
}
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
||||
Preference pref = findPreference("pref_category_activity_personal");
|
||||
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent enableIntent = new Intent(ChartsPreferencesActivity.this, AboutUserPreferencesActivity.class);
|
||||
startActivity(enableIntent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String[] getPreferenceKeysWithSummary() {
|
||||
return new String[]{
|
||||
"chart_list_min_session_length",
|
||||
"chart_list_max_idle_phase_length",
|
||||
"chart_list_min_steps_per_minute",
|
||||
"chart_list_min_steps_per_minute_for_run",
|
||||
GBPrefs.CHART_MAX_HEART_RATE,
|
||||
GBPrefs.CHART_MIN_HEART_RATE,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
74
app/src/main/res/xml/about_user.xml
Normal file
74
app/src/main/res/xml/about_user.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:key="pref_category_activity_personal"
|
||||
android:title="@string/activity_prefs_about_you">
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_year_of_birth"
|
||||
android:maxLength="4"
|
||||
android:title="@string/activity_prefs_year_birth" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:entries="@array/gender"
|
||||
android:entryValues="@array/gender_values"
|
||||
android:key="activity_user_gender"
|
||||
android:summary="%s"
|
||||
android:title="@string/activity_prefs_gender" />
|
||||
|
||||
<!--TODO: support localized heights and weights -->
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_height_cm"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_height_cm" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_weight_kg"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_weight_kg" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_step_length_cm"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_step_length_cm" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="10000"
|
||||
android:inputType="number"
|
||||
android:key="mi_fitness_goal"
|
||||
android:maxLength="5"
|
||||
android:title="@string/miband_prefs_fitness_goal" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_sleep_duration"
|
||||
android:maxLength="2"
|
||||
android:title="@string/activity_prefs_sleep_duration" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="2000"
|
||||
android:inputType="number"
|
||||
android:key="activity_user_calories_burnt"
|
||||
android:maxLength="4"
|
||||
android:title="@string/activity_prefs_calories_burnt" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="5"
|
||||
android:inputType="number"
|
||||
android:key="activity_user_distance_meters"
|
||||
android:maxLength="5"
|
||||
android:title="@string/activity_prefs_distance_meters" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="60"
|
||||
android:inputType="number"
|
||||
android:key="activity_user_activetime_minutes"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_activetime_minutes" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
@ -5,55 +5,56 @@
|
||||
android:title="@string/activity_prefs_charts">
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="250"
|
||||
android:inputType="number"
|
||||
android:key="chart_max_heart_rate"
|
||||
android:maxLength="3"
|
||||
android:defaultValue="250"
|
||||
android:title="@string/activity_prefs_chart_max_heart_rate" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="10"
|
||||
android:inputType="number"
|
||||
android:key="chart_min_heart_rate"
|
||||
android:maxLength="3"
|
||||
android:defaultValue="10"
|
||||
android:title="@string/activity_prefs_chart_min_heart_rate" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="false"
|
||||
android:key="chart_heartrate_color"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summaryOff="@string/pref_chart_heartrate_color_orange"
|
||||
android:summaryOn="@string/pref_chart_heartrate_color_red"
|
||||
android:title="@string/pref_title_chart_heartrate_color" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="true"
|
||||
android:key="charts_allow_swipe"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_charts_swipe" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="false"
|
||||
android:key="chart_sleep_range_24h"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summaryOff="@string/pref_chart_sleep_rolling_24_off"
|
||||
android:summaryOn="@string/pref_chart_sleep_rolling_24_on"
|
||||
android:title="@string/pref_title_chart_sleep_rolling_24_hour" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="true"
|
||||
android:key="charts_show_average"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/pref_title_charts_average" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:defaultValue="false"
|
||||
android:key="charts_range"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summaryOff="@string/pref_charts_range_off"
|
||||
android:summaryOn="@string/pref_charts_range_on"
|
||||
android:title="@string/pref_title_charts_range" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pref_charts_activity_list"
|
||||
android:title="@string/charts_activity_list">
|
||||
@ -87,4 +88,12 @@
|
||||
android:title="@string/activity_prefs_chart_min_steps_per_minute_for_run" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pref_category_activity_personal_title"
|
||||
android:title="@string/activity_prefs_about_you">
|
||||
|
||||
<Preference
|
||||
android:key="pref_category_activity_personal"
|
||||
android:title="@string/activity_prefs_about_you" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@ -104,82 +104,15 @@
|
||||
android:summaryOff="@string/pref_summary_minimize_priority_off"
|
||||
android:summaryOn="@string/pref_summary_minimize_priority_on"
|
||||
android:title="@string/pref_title_minimize_priority" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="pref_category_activity_personal"
|
||||
android:title="@string/activity_prefs_about_you">
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_year_of_birth"
|
||||
android:maxLength="4"
|
||||
android:title="@string/activity_prefs_year_birth" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:entries="@array/gender"
|
||||
android:entryValues="@array/gender_values"
|
||||
android:key="activity_user_gender"
|
||||
android:title="@string/activity_prefs_gender"
|
||||
android:summary="%s" />
|
||||
|
||||
<!--TODO: support localized heights and weights -->
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_height_cm"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_height_cm" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_weight_kg"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_weight_kg" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_step_length_cm"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_step_length_cm" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="10000"
|
||||
android:inputType="number"
|
||||
android:key="mi_fitness_goal"
|
||||
android:maxLength="5"
|
||||
android:title="@string/miband_prefs_fitness_goal" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_sleep_duration"
|
||||
android:maxLength="2"
|
||||
android:title="@string/activity_prefs_sleep_duration" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="2000"
|
||||
android:inputType="number"
|
||||
android:key="activity_user_calories_burnt"
|
||||
android:maxLength="4"
|
||||
android:title="@string/activity_prefs_calories_burnt" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="5"
|
||||
android:inputType="number"
|
||||
android:key="activity_user_distance_meters"
|
||||
android:maxLength="5"
|
||||
android:title="@string/activity_prefs_distance_meters" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="60"
|
||||
android:inputType="number"
|
||||
android:key="activity_user_activetime_minutes"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_activetime_minutes" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
<Preference
|
||||
android:key="pref_charts"
|
||||
android:title="@string/activity_prefs_charts"/>
|
||||
|
||||
<Preference
|
||||
android:key="pref_category_activity_personal"
|
||||
android:title="@string/activity_prefs_about_you" />
|
||||
|
||||
<Preference
|
||||
android:key="pref_charts"
|
||||
android:title="@string/activity_prefs_charts" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_datetime"
|
||||
|
Loading…
Reference in New Issue
Block a user