1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Split preferences, add chart settings activity, add button

This commit is contained in:
vanous 2019-09-08 16:11:18 +02:00 committed by Andreas Shimokawa
parent 194f5b04ae
commit 132e92041e
7 changed files with 103 additions and 36 deletions

View File

@ -60,6 +60,10 @@
android:name=".activities.SettingsActivity"
android:label="@string/title_activity_settings"
android:parentActivityName=".activities.ControlCenterv2" />
<activity
android:name=".activities.charts.ChartsPreferencesActivity"
android:label="@string/activity_prefs_charts"
android:parentActivityName=".activities.charts.ChartsPreferencesActivity" />
<activity
android:name=".devices.miband.MiBandPreferencesActivity"
android:label="@string/preferences_miband_settings"

View File

@ -56,6 +56,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandPreferencesActivity;
import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimePreferenceActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsPreferencesActivity;
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
@ -96,6 +97,16 @@ public class SettingsActivity extends AbstractSettingsActivity {
return true;
}
});
pref = findPreference("pref_charts");
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Intent enableIntent = new Intent(SettingsActivity.this, ChartsPreferencesActivity.class);
startActivity(enableIntent);
return true;
}
});
pref = findPreference("pref_key_miband");
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {

View File

@ -261,6 +261,10 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
case R.id.charts_fetch_activity_data:
fetchActivityData();
return true;
case R.id.prefs_charts_menu:
Intent settingsIntent = new Intent(this, ChartsPreferencesActivity.class);
startActivity(settingsIntent);
return true;
default:
break;
}

View File

@ -0,0 +1,38 @@
/* Copyright (C) 2015-2019 Andreas Shimokawa, Carsten Pfeiffer, Christian
Fischer, Daniele Gobbetti, José Rebelo, Szymon Tomasz Stefanek
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.charts;
import android.os.Bundle;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class ChartsPreferencesActivity extends AbstractSettingsActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.charts_preferences);
}
}

View File

@ -7,5 +7,9 @@
app:showAsAction="ifRoom"
android:icon="@android:drawable/stat_notify_sync_noanim"
android:title="@string/controlcenter_fetch_activity_data"/>
<item
android:id="@+id/prefs_charts_menu"
android:icon="@drawable/ic_settings"
android:title="@string/pref_header_charts"
app:showAsAction="ifRoom" />
</menu>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="pref_charts"
android:title="@string/activity_prefs_charts">
<EditTextPreference
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: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="true"
android:key="charts_allow_swipe"
android:title="@string/pref_title_charts_swipe" />
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:defaultValue="true"
android:key="charts_show_average"
android:title="@string/pref_title_charts_average" />
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:defaultValue="false"
android:key="charts_range"
android:summaryOff="@string/pref_charts_range_off"
android:summaryOn="@string/pref_charts_range_on"
android:title="@string/pref_title_charts_range" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -158,42 +158,9 @@
android:title="@string/activity_prefs_activetime_minutes" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceScreen
<Preference
android:key="pref_charts"
android:title="@string/activity_prefs_charts">
<EditTextPreference
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: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="true"
android:key="charts_allow_swipe"
android:title="@string/pref_title_charts_swipe" />
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:defaultValue="true"
android:key="charts_show_average"
android:title="@string/pref_title_charts_average" />
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:defaultValue="false"
android:key="charts_range"
android:summaryOff="@string/pref_charts_range_off"
android:summaryOn="@string/pref_charts_range_on"
android:title="@string/pref_title_charts_range" />
</PreferenceScreen>
android:title="@string/activity_prefs_charts"/>
<PreferenceCategory
android:key="pref_key_datetime"