mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-11 03:04:25 +02:00
refactored app settings to support preference headers.
add a customizable weight reminder
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
|
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme" >
|
||||||
<activity
|
<activity
|
||||||
android:name="com.health.openscale.gui.MainActivity"
|
android:name=".gui.MainActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@@ -25,9 +26,15 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.health.openscale.gui.SettingsActivity"></activity>
|
<activity android:name=".gui.SettingsActivity"></activity>
|
||||||
<activity android:name=".gui.DataEntryActivity" android:theme="@android:style/Theme.Holo.Light.Dialog"></activity>
|
<activity android:name=".gui.DataEntryActivity" android:theme="@android:style/Theme.Holo.Light.Dialog"></activity>
|
||||||
<activity android:name=".gui.UserSettingsActivity" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/label_title_user"></activity>
|
<activity android:name=".gui.UserSettingsActivity" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/label_title_user"></activity>
|
||||||
|
|
||||||
|
<receiver android:name=".gui.ReminderBootReceiver" android:enabled="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@@ -0,0 +1,72 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.health.openscale.gui;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
import com.health.openscale.gui.preferences.ReminderPreferences;
|
||||||
|
|
||||||
|
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||||
|
|
||||||
|
public class ReminderBootReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
|
if (intent.hasExtra("alarmIntent")) {
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
String notifyText = prefs.getString("reminderNotifyText", context.getResources().getString(R.string.default_value_reminder_notify_text));
|
||||||
|
|
||||||
|
NotificationCompat.Builder mBuilder =
|
||||||
|
new NotificationCompat.Builder(context)
|
||||||
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
|
.setContentTitle("openScale")
|
||||||
|
.setContentText(notifyText)
|
||||||
|
.setAutoCancel(true);
|
||||||
|
|
||||||
|
Intent notifyIntent = new Intent(context, MainActivity.class);
|
||||||
|
|
||||||
|
PendingIntent notifyPendingIntent =
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
context,
|
||||||
|
0,
|
||||||
|
notifyIntent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
);
|
||||||
|
|
||||||
|
mBuilder.setContentIntent(notifyPendingIntent);
|
||||||
|
|
||||||
|
NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
|
||||||
|
mNotifyMgr.notify(0x01, mBuilder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intent.getAction() != null) {
|
||||||
|
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
|
||||||
|
ReminderPreferences.scheduleAlarms(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -15,165 +15,28 @@
|
|||||||
*/
|
*/
|
||||||
package com.health.openscale.gui;
|
package com.health.openscale.gui;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.EditTextPreference;
|
|
||||||
import android.preference.ListPreference;
|
|
||||||
import android.preference.MultiSelectListPreference;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceCategory;
|
|
||||||
import android.preference.PreferenceGroup;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
import com.health.openscale.core.OpenScale;
|
|
||||||
import com.health.openscale.core.ScaleUser;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
|
public class SettingsActivity extends PreferenceActivity {
|
||||||
|
private static List<String> fragments = new ArrayList<String>();
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
|
||||||
initSummary(getPreferenceScreen());
|
|
||||||
|
|
||||||
updateUserPreferences();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void updateUserPreferences()
|
|
||||||
{
|
|
||||||
PreferenceCategory usersCategory = (PreferenceCategory)findPreference("catUsers");
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
|
||||||
|
|
||||||
usersCategory.removeAll();
|
|
||||||
|
|
||||||
OpenScale openScale = OpenScale.getInstance(this);
|
|
||||||
|
|
||||||
ArrayList<ScaleUser> scaleUserList = openScale.getScaleUserList();
|
|
||||||
|
|
||||||
for (ScaleUser scaleUser : scaleUserList)
|
|
||||||
{
|
|
||||||
Preference prefUser = new Preference(this);
|
|
||||||
prefUser.setOnPreferenceClickListener(new onClickListenerUserSelect());
|
|
||||||
|
|
||||||
if (scaleUser.id == selectedUserId) {
|
|
||||||
prefUser.setTitle("> " + scaleUser.user_name);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
prefUser.setTitle(scaleUser.user_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
prefUser.setKey(Integer.toString(scaleUser.id));
|
|
||||||
|
|
||||||
usersCategory.addPreference(prefUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Preference prefAddUser = new Preference(this);
|
|
||||||
|
|
||||||
prefAddUser.setOnPreferenceClickListener(new onClickListenerAddUser());
|
|
||||||
prefAddUser.setTitle("+ " + getResources().getString(R.string.label_add_user));
|
|
||||||
|
|
||||||
usersCategory.addPreference(prefAddUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
// Set up a listener whenever a key changes
|
|
||||||
getPreferenceScreen().getSharedPreferences()
|
|
||||||
.registerOnSharedPreferenceChangeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
// Unregister the listener whenever a key changes
|
|
||||||
getPreferenceScreen().getSharedPreferences()
|
|
||||||
.unregisterOnSharedPreferenceChangeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
|
||||||
updatePrefSummary(findPreference(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initSummary(Preference p) {
|
|
||||||
if (p instanceof PreferenceGroup) {
|
|
||||||
PreferenceGroup pGrp = (PreferenceGroup) p;
|
|
||||||
for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
|
|
||||||
initSummary(pGrp.getPreference(i));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
updatePrefSummary(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePrefSummary(Preference p) {
|
|
||||||
if (p instanceof ListPreference) {
|
|
||||||
ListPreference listPref = (ListPreference) p;
|
|
||||||
p.setSummary(listPref.getEntry());
|
|
||||||
}
|
|
||||||
if (p instanceof EditTextPreference) {
|
|
||||||
EditTextPreference editTextPref = (EditTextPreference) p;
|
|
||||||
if (p.getTitle().toString().contains("assword"))
|
|
||||||
{
|
|
||||||
p.setSummary("******");
|
|
||||||
} else {
|
|
||||||
p.setSummary(editTextPref.getText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (p instanceof MultiSelectListPreference) {
|
|
||||||
EditTextPreference editTextPref = (EditTextPreference) p;
|
|
||||||
p.setSummary(editTextPref.getText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
public void onBuildHeaders(List<Header> target) {
|
||||||
{
|
loadHeadersFromResource(R.xml.header_preferences, target);
|
||||||
if (requestCode == UserSettingsActivity.ADD_USER_REQUEST) {
|
|
||||||
if(resultCode == RESULT_OK){
|
|
||||||
updateUserPreferences();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
fragments.clear();
|
||||||
if (requestCode == UserSettingsActivity.EDIT_USER_REQUEST) {
|
for (Header header : target) {
|
||||||
if(resultCode == RESULT_OK){
|
fragments.add(header.fragment);
|
||||||
updateUserPreferences();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class onClickListenerUserSelect implements Preference.OnPreferenceClickListener {
|
@Override
|
||||||
@Override
|
protected boolean isValidFragment (String fragmentName) {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
return fragments.contains(fragmentName);
|
||||||
Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class);
|
|
||||||
intent.putExtra("mode", UserSettingsActivity.EDIT_USER_REQUEST);
|
|
||||||
intent.putExtra("id", Integer.parseInt(preference.getKey()));
|
|
||||||
startActivityForResult(intent, UserSettingsActivity.EDIT_USER_REQUEST);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class onClickListenerAddUser implements Preference.OnPreferenceClickListener {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class);
|
|
||||||
intent.putExtra("mode", UserSettingsActivity.ADD_USER_REQUEST);
|
|
||||||
startActivityForResult(intent, UserSettingsActivity.ADD_USER_REQUEST);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,103 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package com.health.openscale.gui.preferences;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.preference.MultiSelectListPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceFragment;
|
||||||
|
import android.preference.PreferenceGroup;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class BluetoothPreferences extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.bluetooth_preferences);
|
||||||
|
|
||||||
|
initSummary(getPreferenceScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSummary(Preference p) {
|
||||||
|
if (p instanceof PreferenceGroup) {
|
||||||
|
PreferenceGroup pGrp = (PreferenceGroup) p;
|
||||||
|
for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
|
||||||
|
initSummary(pGrp.getPreference(i));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updatePrefSummary(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
|
updatePrefSummary(findPreference(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePrefSummary(Preference p) {
|
||||||
|
if (p instanceof ListPreference) {
|
||||||
|
ListPreference listPref = (ListPreference) p;
|
||||||
|
p.setSummary(listPref.getEntry());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p instanceof EditTextPreference) {
|
||||||
|
EditTextPreference editTextPref = (EditTextPreference) p;
|
||||||
|
if (p.getTitle().toString().contains("assword"))
|
||||||
|
{
|
||||||
|
p.setSummary("******");
|
||||||
|
} else {
|
||||||
|
p.setSummary(editTextPref.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p instanceof MultiSelectListPreference) {
|
||||||
|
MultiSelectListPreference editMultiListPref = (MultiSelectListPreference) p;
|
||||||
|
|
||||||
|
CharSequence[] entries = editMultiListPref.getEntries();
|
||||||
|
CharSequence[] entryValues = editMultiListPref.getEntryValues();
|
||||||
|
List<String> currentEntries = new ArrayList<>();
|
||||||
|
Set<String> currentEntryValues = editMultiListPref.getValues();
|
||||||
|
|
||||||
|
for (int i = 0; i < entries.length; i++)
|
||||||
|
if (currentEntryValues.contains(entryValues[i]))
|
||||||
|
currentEntries.add(entries[i].toString());
|
||||||
|
|
||||||
|
p.setSummary(currentEntries.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package com.health.openscale.gui.preferences;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceFragment;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
|
||||||
|
public class GraphPreferences extends PreferenceFragment {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.graph_preferences);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package com.health.openscale.gui.preferences;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceFragment;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
|
||||||
|
public class MeasurementPreferences extends PreferenceFragment {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.measurement_preferences);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,230 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package com.health.openscale.gui.preferences;
|
||||||
|
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.preference.MultiSelectListPreference;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceFragment;
|
||||||
|
import android.preference.PreferenceGroup;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
import com.health.openscale.gui.ReminderBootReceiver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ReminderPreferences extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
|
private CheckBoxPreference reminderEnable;
|
||||||
|
private MultiSelectListPreference reminderWeekdays;
|
||||||
|
private TimePreferenceDialog reminderTime;
|
||||||
|
private EditTextPreference reminderNotifyText;
|
||||||
|
|
||||||
|
private static ArrayList<PendingIntent> pendingAlarms = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.reminder_preferences);
|
||||||
|
|
||||||
|
reminderEnable = (CheckBoxPreference)findPreference("reminderEnable");
|
||||||
|
reminderWeekdays = (MultiSelectListPreference)findPreference("reminderWeekdays");
|
||||||
|
reminderTime = (TimePreferenceDialog)findPreference("reminderTime");
|
||||||
|
reminderNotifyText = (EditTextPreference)findPreference("reminderNotifyText");
|
||||||
|
|
||||||
|
updateAlarmPreferences();
|
||||||
|
initSummary(getPreferenceScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSummary(Preference p) {
|
||||||
|
if (p instanceof PreferenceGroup) {
|
||||||
|
PreferenceGroup pGrp = (PreferenceGroup) p;
|
||||||
|
for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
|
||||||
|
initSummary(pGrp.getPreference(i));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updatePrefSummary(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
|
updatePrefSummary(findPreference(key));
|
||||||
|
updateAlarmPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAlarmPreferences() {
|
||||||
|
ComponentName receiver = new ComponentName(getActivity().getApplicationContext(), ReminderBootReceiver.class);
|
||||||
|
PackageManager pm = getActivity().getApplicationContext().getPackageManager();
|
||||||
|
|
||||||
|
if (reminderEnable.isChecked()) {
|
||||||
|
scheduleAlarms(getActivity());
|
||||||
|
|
||||||
|
pm.setComponentEnabledSetting(receiver,
|
||||||
|
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||||
|
PackageManager.DONT_KILL_APP);
|
||||||
|
|
||||||
|
reminderWeekdays.setEnabled(true);
|
||||||
|
reminderTime.setEnabled(true);
|
||||||
|
reminderNotifyText.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
disableAllAlarms(getActivity());
|
||||||
|
|
||||||
|
pm.setComponentEnabledSetting(receiver,
|
||||||
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||||
|
PackageManager.DONT_KILL_APP);
|
||||||
|
|
||||||
|
reminderWeekdays.setEnabled(false);
|
||||||
|
reminderTime.setEnabled(false);
|
||||||
|
reminderNotifyText.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePrefSummary(Preference p) {
|
||||||
|
if (p instanceof ListPreference) {
|
||||||
|
ListPreference listPref = (ListPreference) p;
|
||||||
|
p.setSummary(listPref.getEntry());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p instanceof EditTextPreference) {
|
||||||
|
EditTextPreference editTextPref = (EditTextPreference) p;
|
||||||
|
if (p.getTitle().toString().contains("assword"))
|
||||||
|
{
|
||||||
|
p.setSummary("******");
|
||||||
|
} else {
|
||||||
|
p.setSummary(editTextPref.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p instanceof MultiSelectListPreference) {
|
||||||
|
MultiSelectListPreference editMultiListPref = (MultiSelectListPreference) p;
|
||||||
|
|
||||||
|
CharSequence[] entries = editMultiListPref.getEntries();
|
||||||
|
CharSequence[] entryValues = editMultiListPref.getEntryValues();
|
||||||
|
List<String> currentEntries = new ArrayList<>();
|
||||||
|
Set<String> currentEntryValues = editMultiListPref.getValues();
|
||||||
|
|
||||||
|
for (int i = 0; i < entries.length; i++)
|
||||||
|
if (currentEntryValues.contains(entryValues[i]))
|
||||||
|
currentEntries.add(entries[i].toString());
|
||||||
|
|
||||||
|
p.setSummary(currentEntries.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void scheduleAlarms(Context context) {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
Set<String> reminderWeekdays = prefs.getStringSet("reminderWeekdays", new HashSet<String>());
|
||||||
|
Long reminderTimeInMillis = prefs.getLong("reminderTime", System.currentTimeMillis());
|
||||||
|
|
||||||
|
Iterator iterWeekdays = reminderWeekdays.iterator();
|
||||||
|
|
||||||
|
disableAllAlarms(context);
|
||||||
|
|
||||||
|
while (iterWeekdays.hasNext()) {
|
||||||
|
String strWeekdays = iterWeekdays.next().toString();
|
||||||
|
|
||||||
|
switch (Integer.parseInt(strWeekdays)){
|
||||||
|
case 0:
|
||||||
|
pendingAlarms.add(enableAlarm(context, Calendar.MONDAY, reminderTimeInMillis));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
pendingAlarms.add(enableAlarm(context, Calendar.TUESDAY, reminderTimeInMillis));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pendingAlarms.add(enableAlarm(context, Calendar.WEDNESDAY, reminderTimeInMillis));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
pendingAlarms.add(enableAlarm(context, Calendar.THURSDAY, reminderTimeInMillis));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
pendingAlarms.add(enableAlarm(context, Calendar.FRIDAY, reminderTimeInMillis));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
pendingAlarms.add(enableAlarm(context, Calendar.SATURDAY, reminderTimeInMillis));
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
pendingAlarms.add(enableAlarm(context, Calendar.SUNDAY, reminderTimeInMillis));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PendingIntent enableAlarm(Context context, int dayOfWeek, long timeInMillis) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(Calendar.DAY_OF_WEEK, dayOfWeek);
|
||||||
|
|
||||||
|
// Check we aren't setting it in the past which would trigger it to fire instantly
|
||||||
|
if(calendar.getTimeInMillis() < System.currentTimeMillis()) {
|
||||||
|
calendar.add(Calendar.DAY_OF_YEAR, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
|
||||||
|
Intent alarmIntent = new Intent(context, ReminderBootReceiver.class);
|
||||||
|
alarmIntent.putExtra("alarmIntent", true);
|
||||||
|
|
||||||
|
PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
|
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, timeInMillis,
|
||||||
|
AlarmManager.INTERVAL_DAY * 7, alarmPendingIntent);
|
||||||
|
|
||||||
|
return alarmPendingIntent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void disableAllAlarms(Context context) {
|
||||||
|
AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
|
||||||
|
for (int i=0; i<pendingAlarms.size(); i++) {
|
||||||
|
alarmMgr.cancel(pendingAlarms.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingAlarms.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,116 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package com.health.openscale.gui.preferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.preference.DialogPreference;
|
||||||
|
import android.text.format.DateFormat;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
public class TimePreferenceDialog extends DialogPreference {
|
||||||
|
private Calendar calendar;
|
||||||
|
private TimePicker picker = null;
|
||||||
|
|
||||||
|
public TimePreferenceDialog(Context ctxt) {
|
||||||
|
this(ctxt, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimePreferenceDialog(Context ctxt, AttributeSet attrs) {
|
||||||
|
this(ctxt, attrs, android.R.attr.dialogPreferenceStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimePreferenceDialog(Context ctxt, AttributeSet attrs, int defStyle) {
|
||||||
|
super(ctxt, attrs, defStyle);
|
||||||
|
|
||||||
|
setPositiveButtonText(R.string.label_ok);
|
||||||
|
setNegativeButtonText(R.string.label_cancel);
|
||||||
|
calendar = new GregorianCalendar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View onCreateDialogView() {
|
||||||
|
picker = new TimePicker(getContext());
|
||||||
|
return (picker);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindDialogView(View v) {
|
||||||
|
super.onBindDialogView(v);
|
||||||
|
picker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
|
||||||
|
picker.setCurrentMinute(calendar.get(Calendar.MINUTE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDialogClosed(boolean positiveResult) {
|
||||||
|
super.onDialogClosed(positiveResult);
|
||||||
|
|
||||||
|
if (positiveResult) {
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, picker.getCurrentHour());
|
||||||
|
calendar.set(Calendar.MINUTE, picker.getCurrentMinute());
|
||||||
|
|
||||||
|
setSummary(getSummary());
|
||||||
|
if (callChangeListener(calendar.getTimeInMillis())) {
|
||||||
|
persistLong(calendar.getTimeInMillis());
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||||
|
return (a.getString(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
|
||||||
|
|
||||||
|
if (restoreValue) {
|
||||||
|
if (defaultValue == null) {
|
||||||
|
calendar.setTimeInMillis(getPersistedLong(System.currentTimeMillis()));
|
||||||
|
} else {
|
||||||
|
calendar.setTimeInMillis(Long.parseLong(getPersistedString((String) defaultValue)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (defaultValue == null) {
|
||||||
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
} else {
|
||||||
|
calendar.setTimeInMillis(Long.parseLong((String) defaultValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSummary(getSummary());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
if (calendar == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return DateFormat.getTimeFormat(getContext()).format(new Date(calendar.getTimeInMillis()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimeInMillis() {
|
||||||
|
return calendar.getTimeInMillis();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,121 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package com.health.openscale.gui.preferences;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceFragment;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
import com.health.openscale.core.OpenScale;
|
||||||
|
import com.health.openscale.core.ScaleUser;
|
||||||
|
import com.health.openscale.gui.UserSettingsActivity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
|
||||||
|
public class UsersPreferences extends PreferenceFragment {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.users_preferences);
|
||||||
|
|
||||||
|
updateUserPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUserPreferences()
|
||||||
|
{
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
|
getPreferenceScreen().removeAll();
|
||||||
|
|
||||||
|
OpenScale openScale = OpenScale.getInstance(getActivity().getApplicationContext());
|
||||||
|
|
||||||
|
ArrayList<ScaleUser> scaleUserList = openScale.getScaleUserList();
|
||||||
|
|
||||||
|
for (ScaleUser scaleUser : scaleUserList)
|
||||||
|
{
|
||||||
|
Preference prefUser = new Preference(getActivity().getBaseContext());
|
||||||
|
prefUser.setOnPreferenceClickListener(new onClickListenerUserSelect());
|
||||||
|
|
||||||
|
if (scaleUser.id == selectedUserId) {
|
||||||
|
prefUser.setTitle("> " + scaleUser.user_name);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefUser.setTitle(scaleUser.user_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefUser.setKey(Integer.toString(scaleUser.id));
|
||||||
|
|
||||||
|
getPreferenceScreen().addPreference(prefUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Preference prefAddUser = new Preference(getActivity().getBaseContext());
|
||||||
|
|
||||||
|
prefAddUser.setOnPreferenceClickListener(new onClickListenerAddUser());
|
||||||
|
prefAddUser.setTitle("+ " + getResources().getString(R.string.label_add_user));
|
||||||
|
|
||||||
|
getPreferenceScreen().addPreference(prefAddUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||||
|
{
|
||||||
|
if (requestCode == UserSettingsActivity.ADD_USER_REQUEST) {
|
||||||
|
if(resultCode == RESULT_OK){
|
||||||
|
updateUserPreferences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (requestCode == UserSettingsActivity.EDIT_USER_REQUEST) {
|
||||||
|
if(resultCode == RESULT_OK){
|
||||||
|
updateUserPreferences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class onClickListenerUserSelect implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class);
|
||||||
|
intent.putExtra("mode", UserSettingsActivity.EDIT_USER_REQUEST);
|
||||||
|
intent.putExtra("id", Integer.parseInt(preference.getKey()));
|
||||||
|
startActivityForResult(intent, UserSettingsActivity.EDIT_USER_REQUEST);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class onClickListenerAddUser implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class);
|
||||||
|
intent.putExtra("mode", UserSettingsActivity.ADD_USER_REQUEST);
|
||||||
|
startActivityForResult(intent, UserSettingsActivity.ADD_USER_REQUEST);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -105,4 +105,10 @@
|
|||||||
<string name="label_device_type">Gerätetyp</string>
|
<string name="label_device_type">Gerätetyp</string>
|
||||||
<string name="info_bluetooth_init">Initializiere Bluetooth Gerät</string>
|
<string name="info_bluetooth_init">Initializiere Bluetooth Gerät</string>
|
||||||
<string name="label_smartUserAssign">Intelligente Benutzer Zuweisung</string>
|
<string name="label_smartUserAssign">Intelligente Benutzer Zuweisung</string>
|
||||||
|
<string name="default_value_reminder_notify_text">Zeit zum Wiegen</string>
|
||||||
|
<string name="label_reminder">Erinnerung</string>
|
||||||
|
<string name="label_reminder_notify_text">Benachrichtigungstext</string>
|
||||||
|
<string name="label_reminder_time">Zeit</string>
|
||||||
|
<string name="label_reminder_weekdays">Wochentage</string>
|
||||||
|
<string name="title_measurements">Messwerte</string>
|
||||||
</resources>
|
</resources>
|
@@ -105,4 +105,10 @@
|
|||||||
<string name="label_device_type">デバイスタイプ</string>
|
<string name="label_device_type">デバイスタイプ</string>
|
||||||
<string name="info_bluetooth_init">Bluetooth接続を初期化する</string>
|
<string name="info_bluetooth_init">Bluetooth接続を初期化する</string>
|
||||||
<string name="label_smartUserAssign">スマートユーザーのアサイン</string>
|
<string name="label_smartUserAssign">スマートユーザーのアサイン</string>
|
||||||
|
<string name="default_value_reminder_notify_text">重量までの時間</string>
|
||||||
|
<string name="label_reminder">リマインダー</string>
|
||||||
|
<string name="label_reminder_notify_text">通知テキスト</string>
|
||||||
|
<string name="label_reminder_time">時刻</string>
|
||||||
|
<string name="label_reminder_weekdays">平日</string>
|
||||||
|
<string name="title_measurements">観測</string>
|
||||||
</resources>
|
</resources>
|
@@ -7,6 +7,7 @@
|
|||||||
<string name="title_frag">Table</string>
|
<string name="title_frag">Table</string>
|
||||||
<string name="title_users">Users</string>
|
<string name="title_users">Users</string>
|
||||||
<string name="title_data">Data</string>
|
<string name="title_data">Data</string>
|
||||||
|
<string name="title_measurements">Measurements</string>
|
||||||
|
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="action_bluetooth_status">Bluetooth Status</string>
|
<string name="action_bluetooth_status">Bluetooth Status</string>
|
||||||
@@ -114,6 +115,12 @@
|
|||||||
|
|
||||||
<string name="label_enable_labels">Label on data point</string>
|
<string name="label_enable_labels">Label on data point</string>
|
||||||
|
|
||||||
|
<string name="label_reminder">Reminder</string>
|
||||||
|
<string name="label_reminder_weekdays">Weekdays</string>
|
||||||
|
<string name="label_reminder_time">Time</string>
|
||||||
|
<string name="label_reminder_notify_text">Notification text</string>
|
||||||
|
<string name="default_value_reminder_notify_text">Time to weight</string>
|
||||||
|
|
||||||
<string name="info_your_weight">Your weight was</string>
|
<string name="info_your_weight">Your weight was</string>
|
||||||
<string name="info_your_fat">Your body fat was</string>
|
<string name="info_your_fat">Your body fat was</string>
|
||||||
<string name="info_your_water">Your water percentage was</string>
|
<string name="info_your_water">Your water percentage was</string>
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||||
<string-array name="btDeviceTypes">
|
<string-array name="bt_device_entries">
|
||||||
<item>Xiaomi Mi Scale</item>
|
<item>Xiaomi Mi Scale</item>
|
||||||
<item>openScale Custom Scale</item>
|
<item>openScale Custom Scale</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="btDeviceTypesAlias">
|
<string-array name="bt_device_values">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
</string-array>
|
</string-array>
|
24
android_app/app/src/main/res/values/type_weekdays.xml
Normal file
24
android_app/app/src/main/res/values/type_weekdays.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string-array name="weekdays_entries">
|
||||||
|
<item>Monday</item>
|
||||||
|
<item>Tuesday</item>
|
||||||
|
<item>Wednesday</item>
|
||||||
|
<item>Thursday</item>
|
||||||
|
<item>Friday</item>
|
||||||
|
<item>Saturday</item>
|
||||||
|
<item>Sunday</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="weekdays_values">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
<item>4</item>
|
||||||
|
<item>5</item>
|
||||||
|
<item>6</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="weekdays_default"></string-array>
|
||||||
|
</resources>
|
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<ListPreference android:title="@string/label_device_type" android:key="btDeviceTypes" android:entries="@array/bt_device_entries" android:entryValues="@array/bt_device_values" android:defaultValue="0"/>
|
||||||
|
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="MI_SCALE" />
|
||||||
|
<CheckBoxPreference android:title="@string/label_bluetooth_enable" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="btEnable" android:defaultValue="false"/>
|
||||||
|
<CheckBoxPreference android:title="@string/label_smartUserAssign" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="smartUserAssign" android:defaultValue="false"/>
|
||||||
|
</PreferenceScreen>
|
4
android_app/app/src/main/res/xml/graph_preferences.xml
Normal file
4
android_app/app/src/main/res/xml/graph_preferences.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:title="@string/label_enable_labels" android:summaryOn="@string/info_is_visible" android:summaryOff="@string/info_is_not_visible" android:key="labelsEnable" android:defaultValue="true"/>
|
||||||
|
</PreferenceScreen>
|
18
android_app/app/src/main/res/xml/header_preferences.xml
Normal file
18
android_app/app/src/main/res/xml/header_preferences.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<header
|
||||||
|
android:fragment="com.health.openscale.gui.preferences.UsersPreferences"
|
||||||
|
android:title="@string/title_users" />
|
||||||
|
<header
|
||||||
|
android:fragment="com.health.openscale.gui.preferences.BluetoothPreferences"
|
||||||
|
android:title="@string/label_bluetooth_title" />
|
||||||
|
<header
|
||||||
|
android:fragment="com.health.openscale.gui.preferences.MeasurementPreferences"
|
||||||
|
android:title="@string/title_measurements" />
|
||||||
|
<header
|
||||||
|
android:fragment="com.health.openscale.gui.preferences.GraphPreferences"
|
||||||
|
android:title="@string/title_graph" />
|
||||||
|
<header
|
||||||
|
android:fragment="com.health.openscale.gui.preferences.ReminderPreferences"
|
||||||
|
android:title="@string/label_reminder" />
|
||||||
|
</preference-headers>
|
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:title="@string/label_fat" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="fatEnable" android:defaultValue="true"/>
|
||||||
|
<CheckBoxPreference android:title="@string/label_water" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="waterEnable" android:defaultValue="true"/>
|
||||||
|
<CheckBoxPreference android:title="@string/label_muscle" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="muscleEnable" android:defaultValue="true"/>
|
||||||
|
<CheckBoxPreference android:title="@string/label_waist" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="waistEnable" android:defaultValue="false"/>
|
||||||
|
<CheckBoxPreference android:title="@string/label_hip" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="hipEnable" android:defaultValue="false"/>
|
||||||
|
</PreferenceScreen>
|
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/title_users" android:key="catUsers">
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/label_bluetooth_title">
|
|
||||||
<CheckBoxPreference android:title="@string/label_bluetooth_enable" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="btEnable" android:defaultValue="false"/>
|
|
||||||
<ListPreference android:title="@string/label_device_type" android:key="btDeviceTypes" android:entries="@array/btDeviceTypes" android:entryValues="@array/btDeviceTypesAlias" android:defaultValue="0"/>
|
|
||||||
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="MI_SCALE" />
|
|
||||||
<CheckBoxPreference android:title="@string/label_smartUserAssign" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="smartUserAssign" android:defaultValue="false"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/title_graph">
|
|
||||||
<CheckBoxPreference android:title="@string/label_enable_labels" android:summaryOn="@string/info_is_visible" android:summaryOff="@string/info_is_not_visible" android:key="labelsEnable" android:defaultValue="true"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/title_data">
|
|
||||||
<CheckBoxPreference android:title="@string/label_fat" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="fatEnable" android:defaultValue="true"/>
|
|
||||||
<CheckBoxPreference android:title="@string/label_water" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="waterEnable" android:defaultValue="true"/>
|
|
||||||
<CheckBoxPreference android:title="@string/label_muscle" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="muscleEnable" android:defaultValue="true"/>
|
|
||||||
<CheckBoxPreference android:title="@string/label_waist" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="waistEnable" android:defaultValue="false"/>
|
|
||||||
<CheckBoxPreference android:title="@string/label_hip" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="hipEnable" android:defaultValue="false"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
27
android_app/app/src/main/res/xml/reminder_preferences.xml
Normal file
27
android_app/app/src/main/res/xml/reminder_preferences.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference android:title="@string/label_reminder" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="reminderEnable" android:defaultValue="false"/>
|
||||||
|
|
||||||
|
<MultiSelectListPreference
|
||||||
|
android:dialogTitle="@string/label_reminder_weekdays"
|
||||||
|
android:key="reminderWeekdays"
|
||||||
|
android:title="@string/label_reminder_weekdays"
|
||||||
|
android:entries="@array/weekdays_entries"
|
||||||
|
android:entryValues="@array/weekdays_values"
|
||||||
|
android:defaultValue="@array/weekdays_default"
|
||||||
|
android:enabled="false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.health.openscale.gui.preferences.TimePreferenceDialog
|
||||||
|
android:title="@string/label_reminder_time"
|
||||||
|
android:key="reminderTime"
|
||||||
|
android:enabled="false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/label_reminder_notify_text"
|
||||||
|
android:key="reminderNotifyText"
|
||||||
|
android:defaultValue="@string/default_value_reminder_notify_text"
|
||||||
|
android:enabled="false"
|
||||||
|
/>
|
||||||
|
</PreferenceScreen>
|
4
android_app/app/src/main/res/xml/users_preferences.xml
Normal file
4
android_app/app/src/main/res/xml/users_preferences.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
Reference in New Issue
Block a user