mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-21 16:02:04 +02:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -35,7 +35,7 @@ android {
|
||||
}
|
||||
|
||||
ext {
|
||||
supportLibVersion = '27.1.0'
|
||||
supportLibVersion = '27.1.1'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@@ -114,7 +114,7 @@ public class ScreenshotRecorder {
|
||||
screenshotRecorder();
|
||||
}
|
||||
|
||||
ScaleUser getTestUser() {
|
||||
private ScaleUser getTestUser() {
|
||||
ScaleUser user = new ScaleUser();
|
||||
user.setUserName("Test");
|
||||
user.setBodyHeight(180);
|
||||
@@ -138,7 +138,7 @@ public class ScreenshotRecorder {
|
||||
return user;
|
||||
}
|
||||
|
||||
List<ScaleMeasurement> getTestMeasurements() {
|
||||
private List<ScaleMeasurement> getTestMeasurements() {
|
||||
List<ScaleMeasurement> scaleMeasurementList = new ArrayList<>();
|
||||
|
||||
String data = "\"dateTime\",\"weight\",\"fat\",\"water\",\"muscle\",\"lbw\",\"bone\",\"waist\",\"hip\",\"comment\"\n" +
|
||||
@@ -193,9 +193,7 @@ public class ScreenshotRecorder {
|
||||
|
||||
try {
|
||||
scaleMeasurementList = CsvHelper.importFrom(new BufferedReader(new StringReader(data)));
|
||||
} catch (IOException e) {
|
||||
Log.e("ScreenshotRecorder", e.getMessage());
|
||||
} catch (ParseException e) {
|
||||
} catch (IOException | ParseException e) {
|
||||
Log.e("ScreenshotRecorder", e.getMessage());
|
||||
}
|
||||
|
||||
|
@@ -160,7 +160,7 @@ public class OpenScale {
|
||||
|
||||
public void selectScaleUser(int userId) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putInt("selectedUserId", userId).commit();
|
||||
prefs.edit().putInt("selectedUserId", userId).apply();
|
||||
|
||||
selectedScaleUser = null;
|
||||
}
|
||||
@@ -365,8 +365,15 @@ public class OpenScale {
|
||||
public String getFilenameFromUriMayThrow(Uri uri) {
|
||||
Cursor cursor = context.getContentResolver().query(
|
||||
uri, null, null, null, null);
|
||||
cursor.moveToFirst();
|
||||
return cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
||||
try {
|
||||
cursor.moveToFirst();
|
||||
return cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
||||
}
|
||||
finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getFilenameFromUri(Uri uri) {
|
||||
@@ -402,9 +409,7 @@ public class OpenScale {
|
||||
measurementDAO.insertAll(csvScaleMeasurementList);
|
||||
updateScaleData();
|
||||
Toast.makeText(context, context.getString(R.string.info_data_imported) + " " + filename, Toast.LENGTH_SHORT).show();
|
||||
} catch (IOException e) {
|
||||
Toast.makeText(context, context.getString(R.string.error_importing) + ": " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
} catch (ParseException e) {
|
||||
} catch (IOException | ParseException e) {
|
||||
Toast.makeText(context, context.getString(R.string.error_importing) + ": " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@@ -423,7 +428,7 @@ public class OpenScale {
|
||||
|
||||
public void clearScaleData(int userId) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putInt("uniqueNumber", 0x00).commit();
|
||||
prefs.edit().putInt("uniqueNumber", 0x00).apply();
|
||||
measurementDAO.deleteAll(userId);
|
||||
|
||||
updateScaleData();
|
||||
|
@@ -66,7 +66,7 @@ public class AlarmHandler
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSameDate(Calendar c1, Calendar c2)
|
||||
private static boolean isSameDate(Calendar c1, Calendar c2)
|
||||
{
|
||||
int[] dateFields = {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH};
|
||||
for (int dateField : dateFields)
|
||||
@@ -126,7 +126,7 @@ public class AlarmHandler
|
||||
alarmMgr.cancel(pendingIntent);
|
||||
}
|
||||
|
||||
public void cancelAndRescheduleAlarmForNextWeek(Context context, Calendar timestamp)
|
||||
private void cancelAndRescheduleAlarmForNextWeek(Context context, Calendar timestamp)
|
||||
{
|
||||
AlarmEntryReader reader = AlarmEntryReader.construct(context);
|
||||
Set<AlarmEntry> alarmEntries = reader.getEntries();
|
||||
@@ -169,7 +169,7 @@ public class AlarmHandler
|
||||
mNotifyMgr.notify(ALARM_NOTIFICATION_ID, notification);
|
||||
}
|
||||
|
||||
public void cancelAlarmNotification(Context context)
|
||||
private void cancelAlarmNotification(Context context)
|
||||
{
|
||||
NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
|
@@ -40,7 +40,7 @@ import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
public final static String TAG = "BeurerSanitas";
|
||||
private final static String TAG = "BeurerSanitas";
|
||||
|
||||
enum DeviceType { BEURER_BF700_800_RT_LIBRA, BEURER_BF710, SANITAS_SBF70_70 }
|
||||
|
||||
@@ -104,7 +104,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
private static final UUID CUSTOM_CHARACTERISTIC_IMG_BLOCK = // write-only, notify
|
||||
UUID.fromString("F000FFC2-0451-4000-8000-000000000000");
|
||||
|
||||
private DeviceType deviceType;
|
||||
private final DeviceType deviceType;
|
||||
private int startByte;
|
||||
private int currentScaleUserId;
|
||||
private int countRegisteredScaleUsers;
|
||||
|
@@ -45,7 +45,7 @@ public abstract class BluetoothCommunication {
|
||||
private Handler callbackBtHandler;
|
||||
private BluetoothGatt bluetoothGatt;
|
||||
private boolean connectionEstablished;
|
||||
protected BluetoothGattCallback gattCallback;
|
||||
private BluetoothGattCallback gattCallback;
|
||||
protected BluetoothAdapter btAdapter;
|
||||
|
||||
private int cmdStepNr;
|
||||
|
@@ -42,10 +42,6 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication {
|
||||
return "Digoo DG-SO38H";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBluetoothDataRead(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic, int status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) {
|
||||
final byte[] data = gattCharacteristic.getValue();
|
||||
|
@@ -91,7 +91,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication {
|
||||
}
|
||||
|
||||
private void parseBytes(byte[] weightBytes) {
|
||||
int userId = (int)(weightBytes[0] & 0x0F);
|
||||
int userId = weightBytes[0] & 0x0F;
|
||||
int gender = (int)(weightBytes[1]); // 0x00 male; 0x01 female
|
||||
int age = (int)(weightBytes[2]); // 10 ~ 99
|
||||
int height = (int)(weightBytes[3]); // 0 ~ 255
|
||||
|
@@ -33,10 +33,10 @@ import java.util.UUID;
|
||||
|
||||
public class BluetoothMGB extends BluetoothCommunication {
|
||||
|
||||
static final UUID uuid_service = UUID.fromString("0000ffb0-0000-1000-8000-00805f9b34fb");
|
||||
static final UUID uuid_char_cfg = UUID.fromString("0000ffb1-0000-1000-8000-00805f9b34fb");
|
||||
static final UUID uuid_char_ctrl = UUID.fromString("0000ffb2-0000-1000-8000-00805f9b34fb");
|
||||
static final UUID uuid_desc_ctrl = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
|
||||
private static final UUID uuid_service = UUID.fromString("0000ffb0-0000-1000-8000-00805f9b34fb");
|
||||
private static final UUID uuid_char_cfg = UUID.fromString("0000ffb1-0000-1000-8000-00805f9b34fb");
|
||||
private static final UUID uuid_char_ctrl = UUID.fromString("0000ffb2-0000-1000-8000-00805f9b34fb");
|
||||
private static final UUID uuid_desc_ctrl = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
|
||||
|
||||
|
||||
private Calendar now;
|
||||
|
@@ -277,7 +277,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
|
||||
Random r = new Random();
|
||||
uniqueNumber = r.nextInt(65535 - 100 + 1) + 100;
|
||||
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).commit();
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).apply();
|
||||
}
|
||||
|
||||
int userId = OpenScale.getInstance(context).getSelectedScaleUserId();
|
||||
|
@@ -248,7 +248,7 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
Random r = new Random();
|
||||
uniqueNumber = r.nextInt(65535 - 100 + 1) + 100;
|
||||
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).commit();
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).apply();
|
||||
}
|
||||
|
||||
int userId = OpenScale.getInstance(context).getSelectedScaleUserId();
|
||||
|
@@ -146,7 +146,7 @@ public class BluetoothYunmaiSE_Mini extends BluetoothCommunication {
|
||||
Random r = new Random();
|
||||
uniqueNumber = r.nextInt(65535 - 100 + 1) + 100;
|
||||
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).commit();
|
||||
prefs.edit().putInt("uniqueNumber", uniqueNumber).apply();
|
||||
}
|
||||
|
||||
int userId = OpenScale.getInstance(context).getSelectedScaleUserId();
|
||||
|
@@ -118,7 +118,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
public ArrayList<ScaleMeasurement> getScaleDataList(int userId) {
|
||||
ArrayList<ScaleMeasurement> scaleMeasurementList = new ArrayList<ScaleMeasurement>();
|
||||
ArrayList<ScaleMeasurement> scaleMeasurementList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
String sortOrder = COLUMN_NAME_DATE_TIME + " DESC";
|
||||
|
@@ -96,7 +96,7 @@ public class ScaleUserDatabase extends SQLiteOpenHelper {
|
||||
|
||||
public ArrayList<ScaleUser> getScaleUserList() {
|
||||
SQLiteDatabase db = getReadableDatabase();
|
||||
ArrayList<ScaleUser> scaleUserDBEntries = new ArrayList<ScaleUser>();
|
||||
ArrayList<ScaleUser> scaleUserDBEntries = new ArrayList<>();
|
||||
|
||||
String sortOrder = COLUMN_NAME_ID + " ASC";
|
||||
|
||||
|
@@ -71,8 +71,8 @@ public class Converters {
|
||||
}
|
||||
}
|
||||
|
||||
private static float KG_LB = 2.20462f;
|
||||
private static float KG_ST = 0.157473f;
|
||||
private static final float KG_LB = 2.20462f;
|
||||
private static final float KG_ST = 0.157473f;
|
||||
|
||||
@TypeConverter
|
||||
public static Date fromTimestamp(Long value) {
|
||||
|
@@ -78,7 +78,7 @@ public class CsvHelper {
|
||||
public static List<ScaleMeasurement> importFrom(BufferedReader reader)
|
||||
throws IOException, ParseException {
|
||||
CsvProcessor<ScaleMeasurement> csvProcessor =
|
||||
new CsvProcessor<ScaleMeasurement>(ScaleMeasurement.class)
|
||||
new CsvProcessor<>(ScaleMeasurement.class)
|
||||
.withHeaderValidation(true)
|
||||
.withFlexibleOrder(true)
|
||||
.withAlwaysTrimInput(true)
|
||||
|
@@ -111,12 +111,12 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Find our drawer view
|
||||
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawerLayout = findViewById(R.id.drawer_layout);
|
||||
|
||||
// Find our drawer view
|
||||
navDrawer = (NavigationView) findViewById(R.id.navigation_view);
|
||||
navDrawer = findViewById(R.id.navigation_view);
|
||||
|
||||
navBottomDrawer = (BottomNavigationView) findViewById(R.id.navigation_bottom_view);
|
||||
navBottomDrawer = findViewById(R.id.navigation_bottom_view);
|
||||
navBottomDrawer.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
@@ -129,15 +129,7 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
|
||||
//Create Drawer Toggle
|
||||
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open_drawer, R.string.close_drawer){
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
super.onDrawerOpened(drawerView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
super.onDrawerClosed(drawerView);
|
||||
}
|
||||
};
|
||||
|
||||
drawerLayout.addDrawerListener(drawerToggle);
|
||||
@@ -154,7 +146,7 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
intent.putExtra(UserSettingsActivity.EXTRA_MODE, UserSettingsActivity.ADD_USER_REQUEST);
|
||||
startActivity(intent);
|
||||
|
||||
prefs.edit().putBoolean("firstStart", false).commit();
|
||||
prefs.edit().putBoolean("firstStart", false).apply();
|
||||
}
|
||||
|
||||
if(!valueOfCountModified){
|
||||
@@ -274,7 +266,7 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
});
|
||||
}
|
||||
|
||||
public void selectDrawerItem(int menuItemId) {
|
||||
private void selectDrawerItem(int menuItemId) {
|
||||
// Create a new fragment and specify the fragment to show based on nav item clicked
|
||||
Class fragmentClass;
|
||||
String fragmentTitle;
|
||||
@@ -309,7 +301,7 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
return;
|
||||
}
|
||||
|
||||
prefs.edit().putInt("lastFragmentId", menuItemId).commit();
|
||||
prefs.edit().putInt("lastFragmentId", menuItemId).apply();
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
@@ -726,7 +718,7 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
public static void disableShiftMode(BottomNavigationView view) {
|
||||
private static void disableShiftMode(BottomNavigationView view) {
|
||||
BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
|
||||
try {
|
||||
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
|
||||
|
@@ -49,8 +49,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class DataEntryActivity extends BaseAppCompatActivity {
|
||||
public static String EXTRA_ID = "id";
|
||||
private static String PREF_EXPAND = "expandEvaluator";
|
||||
public static final String EXTRA_ID = "id";
|
||||
private static final String PREF_EXPAND = "expandEvaluator";
|
||||
|
||||
private MeasurementView.MeasurementViewMode measurementViewMode;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DataEntryActivity extends BaseAppCompatActivity {
|
||||
|
||||
setContentView(R.layout.activity_dataentry);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.dataEntryToolbar);
|
||||
Toolbar toolbar = findViewById(R.id.dataEntryToolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
@@ -95,9 +95,9 @@ public class DataEntryActivity extends BaseAppCompatActivity {
|
||||
dataEntryMeasurements = MeasurementView.getMeasurementList(
|
||||
context, MeasurementView.DateTimeOrder.LAST);
|
||||
|
||||
txtDataNr = (TextView) findViewById(R.id.txtDataNr);
|
||||
btnLeft = (Button) findViewById(R.id.btnLeft);
|
||||
btnRight = (Button) findViewById(R.id.btnRight);
|
||||
txtDataNr = findViewById(R.id.txtDataNr);
|
||||
btnLeft = findViewById(R.id.btnLeft);
|
||||
btnRight = findViewById(R.id.btnRight);
|
||||
|
||||
btnLeft.setVisibility(View.INVISIBLE);
|
||||
btnRight.setVisibility(View.INVISIBLE);
|
||||
|
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
|
||||
public class SettingsActivity extends PreferenceActivity
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static List<String> fragments = new ArrayList<String>();
|
||||
private static List<String> fragments = new ArrayList<>();
|
||||
private Fragment currentFragment;
|
||||
|
||||
@Override
|
||||
|
@@ -45,8 +45,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class UserSettingsActivity extends BaseAppCompatActivity {
|
||||
public static String EXTRA_ID = "id";
|
||||
public static String EXTRA_MODE = "mode";
|
||||
public static final String EXTRA_ID = "id";
|
||||
public static final String EXTRA_MODE = "mode";
|
||||
|
||||
public static final int ADD_USER_REQUEST = 0;
|
||||
public static final int EDIT_USER_REQUEST = 1;
|
||||
@@ -63,7 +63,7 @@ public class UserSettingsActivity extends BaseAppCompatActivity {
|
||||
private RadioGroup radioScaleUnit;
|
||||
private RadioGroup radioGender;
|
||||
|
||||
private DateFormat dateFormat = DateFormat.getDateInstance();
|
||||
private final DateFormat dateFormat = DateFormat.getDateInstance();
|
||||
|
||||
private Context context;
|
||||
|
||||
@@ -74,21 +74,21 @@ public class UserSettingsActivity extends BaseAppCompatActivity {
|
||||
setContentView(R.layout.activity_usersettings);
|
||||
context = this;
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.userEntryToolbar);
|
||||
Toolbar toolbar = findViewById(R.id.userEntryToolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setTitle(R.string.label_add_user);
|
||||
|
||||
txtUserName = (EditText) findViewById(R.id.txtUserName);
|
||||
txtBodyHeight = (EditText) findViewById(R.id.txtBodyHeight);
|
||||
radioScaleUnit = (RadioGroup) findViewById(R.id.groupScaleUnit);
|
||||
radioGender = (RadioGroup) findViewById(R.id.groupGender);
|
||||
txtInitialWeight = (EditText) findViewById(R.id.txtInitialWeight);
|
||||
txtGoalWeight = (EditText) findViewById(R.id.txtGoalWeight);
|
||||
txtUserName = findViewById(R.id.txtUserName);
|
||||
txtBodyHeight = findViewById(R.id.txtBodyHeight);
|
||||
radioScaleUnit = findViewById(R.id.groupScaleUnit);
|
||||
radioGender = findViewById(R.id.groupGender);
|
||||
txtInitialWeight = findViewById(R.id.txtInitialWeight);
|
||||
txtGoalWeight = findViewById(R.id.txtGoalWeight);
|
||||
|
||||
txtBirthday = (EditText) findViewById(R.id.txtBirthday);
|
||||
txtGoalDate = (EditText) findViewById(R.id.txtGoalDate);
|
||||
txtBirthday = findViewById(R.id.txtBirthday);
|
||||
txtGoalDate = findViewById(R.id.txtGoalDate);
|
||||
|
||||
Calendar birthdayCal = Calendar.getInstance();
|
||||
birthdayCal.setTime(birthday);
|
||||
@@ -266,7 +266,7 @@ public class UserSettingsActivity extends BaseAppCompatActivity {
|
||||
return validate;
|
||||
}
|
||||
|
||||
private DatePickerDialog.OnDateSetListener birthdayPickerListener = new DatePickerDialog.OnDateSetListener() {
|
||||
private final DatePickerDialog.OnDateSetListener birthdayPickerListener = new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
@@ -277,7 +277,7 @@ public class UserSettingsActivity extends BaseAppCompatActivity {
|
||||
}
|
||||
};
|
||||
|
||||
private DatePickerDialog.OnDateSetListener goalDatePickerListener = new DatePickerDialog.OnDateSetListener() {
|
||||
private final DatePickerDialog.OnDateSetListener goalDatePickerListener = new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
@@ -91,11 +91,11 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
|
||||
private OpenScale openScale;
|
||||
|
||||
private Calendar calYears;
|
||||
private final Calendar calYears;
|
||||
private Calendar calLastSelected;
|
||||
|
||||
private static String CAL_YEARS_KEY = "calYears";
|
||||
private static String CAL_LAST_SELECTED_KEY = "calLastSelected";
|
||||
private static final String CAL_YEARS_KEY = "calYears";
|
||||
private static final String CAL_LAST_SELECTED_KEY = "calLastSelected";
|
||||
|
||||
private List<ScaleMeasurement> pointIndexScaleMeasurementList;
|
||||
|
||||
@@ -123,8 +123,8 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
|
||||
graphView = inflater.inflate(R.layout.fragment_graph, container, false);
|
||||
|
||||
chartBottom = (LineChartView) graphView.findViewById(R.id.chart_bottom);
|
||||
chartTop = (ColumnChartView) graphView.findViewById(R.id.chart_top);
|
||||
chartBottom = graphView.findViewById(R.id.chart_bottom);
|
||||
chartTop = graphView.findViewById(R.id.chart_top);
|
||||
|
||||
chartBottom.setOnTouchListener(new chartBottomListener());
|
||||
chartBottom.setOnValueTouchListener(new chartBottomValueTouchListener());
|
||||
@@ -133,10 +133,10 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
// HACK: get default text color from hidden text view to set the correct axis colors
|
||||
textColor = ((TextView)graphView.findViewById(R.id.colorHack)).getCurrentTextColor();
|
||||
|
||||
txtYear = (TextView) graphView.findViewById(R.id.txtYear);
|
||||
txtYear = graphView.findViewById(R.id.txtYear);
|
||||
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
|
||||
|
||||
floatingActionBar = (LinearLayout) graphView.findViewById(R.id.floatingActionBar);
|
||||
floatingActionBar = graphView.findViewById(R.id.floatingActionBar);
|
||||
|
||||
ImageView optionMenu = graphView.findViewById(R.id.optionMenu);
|
||||
optionMenu.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -188,10 +188,10 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
case R.id.enableMonth:
|
||||
if (item.isChecked()) {
|
||||
item.setChecked(false);
|
||||
prefs.edit().putBoolean("showMonth", false).commit();
|
||||
prefs.edit().putBoolean("showMonth", false).apply();
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
prefs.edit().putBoolean("showMonth", true).commit();
|
||||
prefs.edit().putBoolean("showMonth", true).apply();
|
||||
}
|
||||
|
||||
generateGraphs();
|
||||
@@ -199,10 +199,10 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
case R.id.enableWeek:
|
||||
if (item.isChecked()) {
|
||||
item.setChecked(false);
|
||||
prefs.edit().putBoolean("showWeek", false).commit();
|
||||
prefs.edit().putBoolean("showWeek", false).apply();
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
prefs.edit().putBoolean("showWeek", true).commit();
|
||||
prefs.edit().putBoolean("showWeek", true).apply();
|
||||
}
|
||||
|
||||
generateGraphs();
|
||||
@@ -311,7 +311,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
calDays.add(field, 1);
|
||||
}
|
||||
|
||||
List<Line> diagramLineList = new ArrayList<Line>();
|
||||
List<Line> diagramLineList = new ArrayList<>();
|
||||
|
||||
Calendar calDB = Calendar.getInstance();
|
||||
|
||||
@@ -408,7 +408,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
defaultTopViewport = new Viewport(calDays.getActualMinimum(field), chartBottom.getCurrentViewport().top, calDays.getMaximum(field)+1, chartBottom.getCurrentViewport().bottom);
|
||||
|
||||
if (prefs.getBoolean("goalLine", true)) {
|
||||
Stack<PointValue> valuesGoalLine = new Stack<PointValue>();
|
||||
Stack<PointValue> valuesGoalLine = new Stack<>();
|
||||
|
||||
float goalWeight = openScale.getSelectedScaleUser().getGoalWeight();
|
||||
|
||||
@@ -457,14 +457,14 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
|
||||
SimpleDateFormat month_date = new SimpleDateFormat("MMM", Locale.getDefault());
|
||||
|
||||
List<AxisValue> axisValues = new ArrayList<AxisValue>();
|
||||
List<Column> columns = new ArrayList<Column>();
|
||||
List<AxisValue> axisValues = new ArrayList<>();
|
||||
List<Column> columns = new ArrayList<>();
|
||||
|
||||
for (int i=0; i<12; i++) {
|
||||
String month_name = month_date.format(calMonths.getTime());
|
||||
|
||||
axisValues.add(new AxisValue(i, month_name.toCharArray()));
|
||||
List<SubcolumnValue> values = new ArrayList<SubcolumnValue>();
|
||||
List<SubcolumnValue> values = new ArrayList<>();
|
||||
values.add(new SubcolumnValue(numOfMonth[i], ChartUtils.COLORS[i % ChartUtils.COLORS.length]));
|
||||
|
||||
columns.add(new Column(values).setHasLabelsOnlyForSelected(true));
|
||||
|
@@ -102,13 +102,13 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
|
||||
context = overviewView.getContext();
|
||||
|
||||
txtTitleUser = (TextView) overviewView.findViewById(R.id.txtTitleUser);
|
||||
txtTitleLastMeasurement = (TextView) overviewView.findViewById(R.id.txtTitleLastMeasurment);
|
||||
txtTitleUser = overviewView.findViewById(R.id.txtTitleUser);
|
||||
txtTitleLastMeasurement = overviewView.findViewById(R.id.txtTitleLastMeasurment);
|
||||
|
||||
pieChartLast = (PieChartView) overviewView.findViewById(R.id.pieChartLast);
|
||||
lineChartLast = (LineChartView) overviewView.findViewById(R.id.lineChartLast);
|
||||
pieChartLast = overviewView.findViewById(R.id.pieChartLast);
|
||||
lineChartLast = overviewView.findViewById(R.id.lineChartLast);
|
||||
|
||||
spinUser = (Spinner) overviewView.findViewById(R.id.spinUser);
|
||||
spinUser = overviewView.findViewById(R.id.spinUser);
|
||||
|
||||
lineChartLast.setOnValueTouchListener(new LineChartTouchListener());
|
||||
|
||||
@@ -232,7 +232,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
}
|
||||
|
||||
FloatMeasurementView measurementView = (FloatMeasurementView) view;
|
||||
Stack<PointValue> valuesStack = new Stack<PointValue>();
|
||||
Stack<PointValue> valuesStack = new Stack<>();
|
||||
|
||||
for (int i = 0; i < max_i; ++i) {
|
||||
ScaleMeasurement measurement = scaleMeasurementList.get(max_i - i - 1);
|
||||
|
@@ -80,13 +80,13 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
|
||||
image.setColorFilter(color);
|
||||
}
|
||||
|
||||
txtGoalWeight = (TextView) statisticsView.findViewById(R.id.txtGoalWeight);
|
||||
txtGoalDiff = (TextView) statisticsView.findViewById(R.id.txtGoalDiff);
|
||||
txtGoalDayLeft = (TextView) statisticsView.findViewById(R.id.txtGoalDayLeft);
|
||||
txtGoalWeight = statisticsView.findViewById(R.id.txtGoalWeight);
|
||||
txtGoalDiff = statisticsView.findViewById(R.id.txtGoalDiff);
|
||||
txtGoalDayLeft = statisticsView.findViewById(R.id.txtGoalDayLeft);
|
||||
|
||||
txtLabelGoalWeight = (TextView) statisticsView.findViewById(R.id.txtLabelGoalWeight);
|
||||
txtLabelGoalDiff = (TextView) statisticsView.findViewById(R.id.txtLabelGoalDiff);
|
||||
txtLabelDayLeft = (TextView) statisticsView.findViewById(R.id.txtLabelDayLeft);
|
||||
txtLabelGoalWeight = statisticsView.findViewById(R.id.txtLabelGoalWeight);
|
||||
txtLabelGoalDiff = statisticsView.findViewById(R.id.txtLabelGoalDiff);
|
||||
txtLabelDayLeft = statisticsView.findViewById(R.id.txtLabelDayLeft);
|
||||
|
||||
TableLayout tableWeekAveragesLayoutColumnA = statisticsView.findViewById(R.id.tableWeekAveragesLayoutColumnA);
|
||||
TableLayout tableWeekAveragesLayoutColumnB = statisticsView.findViewById(R.id.tableWeekAveragesLayoutColumnB);
|
||||
|
@@ -70,10 +70,10 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
||||
{
|
||||
tableView = inflater.inflate(R.layout.fragment_table, container, false);
|
||||
|
||||
subpageView = (LinearLayout) tableView.findViewById(R.id.subpageView);
|
||||
subpageView = tableView.findViewById(R.id.subpageView);
|
||||
|
||||
tableDataView = (ListView) tableView.findViewById(R.id.tableDataView);
|
||||
tableHeaderView = (LinearLayout) tableView.findViewById(R.id.tableHeaderView);
|
||||
tableDataView = tableView.findViewById(R.id.tableDataView);
|
||||
tableHeaderView = tableView.findViewById(R.id.tableHeaderView);
|
||||
|
||||
tableDataView.setAdapter(new ListViewAdapter());
|
||||
tableDataView.setOnItemClickListener(new onClickListenerRow());
|
||||
|
@@ -19,12 +19,8 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
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 android.widget.Toast;
|
||||
|
||||
import com.health.openscale.R;
|
||||
@@ -37,16 +33,14 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BackupPreferences extends PreferenceFragment {
|
||||
private static final String PREFERENCE_KEY_EXPORT_DIR = "exportDir";
|
||||
private static final String PREFERENCE_KEY_IMPORT_BACKUP = "importBackup";
|
||||
private static final String PREFERENCE_KEY_EXPORT_BACKUP = "exportBackup";
|
||||
|
||||
EditTextPreference exportDir;
|
||||
private EditTextPreference exportDir;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@@ -51,9 +51,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MeasurementPreferences extends PreferenceFragment {
|
||||
public static final String PREFERENCE_KEY_DELETE_ALL = "deleteAll";
|
||||
public static final String PREFERENCE_KEY_RESET_ORDER = "resetOrder";
|
||||
public static final String PREFERENCE_KEY_MEASUREMENTS = "measurements";
|
||||
private static final String PREFERENCE_KEY_DELETE_ALL = "deleteAll";
|
||||
private static final String PREFERENCE_KEY_RESET_ORDER = "resetOrder";
|
||||
private static final String PREFERENCE_KEY_MEASUREMENTS = "measurements";
|
||||
|
||||
private PreferenceCategory measurementCategory;
|
||||
|
||||
|
@@ -95,7 +95,7 @@ public class ReminderPreferences extends PreferenceFragment
|
||||
updateAlarmPreferences();
|
||||
}
|
||||
|
||||
public void updateAlarmPreferences()
|
||||
private void updateAlarmPreferences()
|
||||
{
|
||||
ComponentName receiver = new ComponentName(getActivity().getApplicationContext(), ReminderBootReceiver.class);
|
||||
PackageManager pm = getActivity().getApplicationContext().getPackageManager();
|
||||
|
@@ -37,7 +37,7 @@ public class UsersPreferences extends PreferenceFragment {
|
||||
private static final String PREFERENCE_KEY_ADD_USER = "addUser";
|
||||
private static final String PREFERENCE_KEY_USERS = "users";
|
||||
|
||||
PreferenceCategory users;
|
||||
private PreferenceCategory users;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@@ -31,7 +31,7 @@ import java.util.Date;
|
||||
public class DateMeasurementView extends MeasurementView {
|
||||
public static final String KEY = "date";
|
||||
|
||||
private static DateFormat dateFormat = DateFormat.getDateInstance();
|
||||
private static final DateFormat dateFormat = DateFormat.getDateInstance();
|
||||
private Date date;
|
||||
|
||||
public DateMeasurementView(Context context) {
|
||||
|
@@ -51,13 +51,13 @@ import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class FloatMeasurementView extends MeasurementView {
|
||||
private static char SYMBOL_UP = '\u279a';
|
||||
private static char SYMBOL_NEUTRAL = '\u2799';
|
||||
private static char SYMBOL_DOWN = '\u2798';
|
||||
private static final char SYMBOL_UP = '\u279a';
|
||||
private static final char SYMBOL_NEUTRAL = '\u2799';
|
||||
private static final char SYMBOL_DOWN = '\u2798';
|
||||
|
||||
private static float NO_VALUE = -1.0f;
|
||||
private static float AUTO_VALUE = -2.0f;
|
||||
private static float INC_DEC_DELTA = 0.1f;
|
||||
private static final float NO_VALUE = -1.0f;
|
||||
private static final float AUTO_VALUE = -2.0f;
|
||||
private static final float INC_DEC_DELTA = 0.1f;
|
||||
|
||||
private Date dateTime;
|
||||
private float value = NO_VALUE;
|
||||
@@ -65,7 +65,7 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
||||
private float userConvertedWeight;
|
||||
private EvaluationResult evaluationResult;
|
||||
|
||||
private String nameText;
|
||||
private final String nameText;
|
||||
|
||||
private Button incButton;
|
||||
private Button decButton;
|
||||
@@ -593,13 +593,13 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
||||
}
|
||||
|
||||
private class RepeatListener implements OnTouchListener {
|
||||
private Handler handler = new Handler();
|
||||
private final Handler handler = new Handler();
|
||||
|
||||
private int initialInterval;
|
||||
private final int normalInterval;
|
||||
private final OnClickListener clickListener;
|
||||
|
||||
private Runnable handlerRunnable = new Runnable() {
|
||||
private final Runnable handlerRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handler.postDelayed(this, normalInterval);
|
||||
|
@@ -32,16 +32,16 @@ import java.util.Locale;
|
||||
|
||||
public class LinearGaugeView extends View {
|
||||
|
||||
public static final int COLOR_BLUE = Color.parseColor("#33B5E5");
|
||||
public static final int COLOR_GREEN = Color.parseColor("#99CC00");
|
||||
public static final int COLOR_RED = Color.parseColor("#FF4444");
|
||||
private static final int COLOR_BLUE = Color.parseColor("#33B5E5");
|
||||
private static final int COLOR_GREEN = Color.parseColor("#99CC00");
|
||||
private static final int COLOR_RED = Color.parseColor("#FF4444");
|
||||
|
||||
private static final float barHeight = 10;
|
||||
private static final float textOffset = 10.0f;
|
||||
private RectF limitRect = new RectF(0, 0, barHeight / 2, barHeight * 2);
|
||||
private final RectF limitRect = new RectF(0, 0, barHeight / 2, barHeight * 2);
|
||||
|
||||
// Pre-created rect to avoid creating object in onDraw
|
||||
private Rect bounds = new Rect();
|
||||
private final Rect bounds = new Rect();
|
||||
|
||||
private Paint rectPaintLow;
|
||||
private Paint rectPaintNormal;
|
||||
|
@@ -59,7 +59,7 @@ import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode
|
||||
public abstract class MeasurementView extends TableLayout {
|
||||
public enum MeasurementViewMode {VIEW, EDIT, ADD, STATISTIC}
|
||||
|
||||
public static String PREF_MEASUREMENT_ORDER = "measurementOrder";
|
||||
public static final String PREF_MEASUREMENT_ORDER = "measurementOrder";
|
||||
|
||||
private MeasurementViewSettings settings;
|
||||
|
||||
@@ -154,7 +154,7 @@ public abstract class MeasurementView extends TableLayout {
|
||||
}
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit()
|
||||
.putString(PREF_MEASUREMENT_ORDER, TextUtils.join(",", order))
|
||||
.commit();
|
||||
.apply();
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
|
@@ -23,8 +23,8 @@ import com.health.openscale.core.bodymetric.EstimatedLBWMetric;
|
||||
import com.health.openscale.core.bodymetric.EstimatedWaterMetric;
|
||||
|
||||
public class MeasurementViewSettings {
|
||||
private SharedPreferences preferences;
|
||||
private String key;
|
||||
private final SharedPreferences preferences;
|
||||
private final String key;
|
||||
|
||||
private static final String PREFERENCE_SUFFIX_ENABLE = "Enable";
|
||||
private static final String PREFERENCE_SUFFIX_IN_OVERVIEW_GRAPH = "InOverviewGraph";
|
||||
|
@@ -31,7 +31,7 @@ import java.util.Date;
|
||||
public class TimeMeasurementView extends MeasurementView {
|
||||
public static final String KEY = "time";
|
||||
|
||||
private DateFormat timeFormat;
|
||||
private final DateFormat timeFormat;
|
||||
private Date time;
|
||||
|
||||
public TimeMeasurementView(Context context) {
|
||||
|
@@ -82,7 +82,7 @@
|
||||
<TableLayout
|
||||
android:id="@+id/tableLayoutMeasurements"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"></TableLayout>
|
||||
android:layout_height="fill_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
@@ -3,6 +3,8 @@
|
||||
<Preference android:key="resetOrder" android:title="@string/label_set_default_order"/>
|
||||
<PreferenceCategory android:title="@string/label_press_hold_reorder" android:key="measurements" />
|
||||
<PreferenceCategory android:title="@string/label_category_measurement_database">
|
||||
<Preference android:title="@string/label_delete_all" android:key="deleteAll"></Preference>
|
||||
<Preference
|
||||
android:title="@string/label_delete_all"
|
||||
android:key="deleteAll" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public class CsvHelperTest {
|
||||
private static String HEADERS =
|
||||
private static final String HEADERS =
|
||||
"\"bone\",\"comment\",\"dateTime\",\"fat\",\"hip\",\"lbw\","
|
||||
+ "\"muscle\",\"waist\",\"water\",\"weight\"\n";
|
||||
|
||||
|
@@ -25,13 +25,13 @@ import java.util.Calendar;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public class DateTimeHelpersTest {
|
||||
Calendar getDate(int year, int month, int day, int hour, int minute, int second, int ms) {
|
||||
private Calendar getDate(int year, int month, int day, int hour, int minute, int second, int ms) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(year, month - 1, day, hour, minute, second);
|
||||
cal.set(Calendar.MILLISECOND, ms);
|
||||
return cal;
|
||||
}
|
||||
Calendar getDate(int year, int month, int day) {
|
||||
private Calendar getDate(int year, int month, int day) {
|
||||
return getDate(year, month, day, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user