From 2e53641cd5dca72aee4f8c0e77f4e645ecf276e7 Mon Sep 17 00:00:00 2001 From: Grammatopoulos Apostolos Date: Sun, 25 Aug 2019 06:41:08 +0100 Subject: [PATCH] Option to show pressure in mmHg added --- .../greatfitwatchface/data/Pressure.java | 2 +- .../settings/LoadSettings.java | 2 ++ .../settings/OthersActivity.java | 25 ++++++------------- .../greatfitwatchface/widget/GreatWidget.java | 4 +-- app/src/main/res/values/bool.xml | 1 + 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/dinodevs/greatfitwatchface/data/Pressure.java b/app/src/main/java/com/dinodevs/greatfitwatchface/data/Pressure.java index a5f83a8..6186fee 100644 --- a/app/src/main/java/com/dinodevs/greatfitwatchface/data/Pressure.java +++ b/app/src/main/java/com/dinodevs/greatfitwatchface/data/Pressure.java @@ -60,7 +60,7 @@ public String getPressure(boolean units) { } public String getPressure(boolean units, int unitMode) { if(unitMode==1){ - return Math.round(this.airPressure) + ((units)?" ???":""); + return Math.round(this.airPressure*0.75006157584566) + ((units)?" mmHg":""); }else { return Math.round(this.airPressure) + ((units)?" hPa":""); } diff --git a/app/src/main/java/com/dinodevs/greatfitwatchface/settings/LoadSettings.java b/app/src/main/java/com/dinodevs/greatfitwatchface/settings/LoadSettings.java index 62ed173..2ed3885 100644 --- a/app/src/main/java/com/dinodevs/greatfitwatchface/settings/LoadSettings.java +++ b/app/src/main/java/com/dinodevs/greatfitwatchface/settings/LoadSettings.java @@ -65,6 +65,7 @@ public LoadSettings(Context context){ public int temp_calories; public boolean am_pm_always; public float world_time_zone; + public boolean pressure_to_mmhg; public Paint mGPaint; public List widgets_list; public List circle_bars_list; @@ -561,6 +562,7 @@ private void defaultParameters(){ this.temp_calories = sharedPreferences.getInt( "temp_calories", 0); this.am_pm_always = sharedPreferences.getBoolean( "am_pm_always", context.getResources().getBoolean(R.bool.am_pm_always)); this.world_time_zone = sharedPreferences.getFloat( "world_time_zone", -1f); + this.pressure_to_mmhg = sharedPreferences.getBoolean( "pressure_to_mmhg", context.getResources().getBoolean(R.bool.pressure_to_mmhg)); this.analog_clock = sharedPreferences.getBoolean( "analog_clock", context.getResources().getBoolean(R.bool.analog_clock)); this.digital_clock = sharedPreferences.getBoolean( "digital_clock", context.getResources().getBoolean(R.bool.digital_clock)); diff --git a/app/src/main/java/com/dinodevs/greatfitwatchface/settings/OthersActivity.java b/app/src/main/java/com/dinodevs/greatfitwatchface/settings/OthersActivity.java index 2e039eb..accb3ca 100644 --- a/app/src/main/java/com/dinodevs/greatfitwatchface/settings/OthersActivity.java +++ b/app/src/main/java/com/dinodevs/greatfitwatchface/settings/OthersActivity.java @@ -149,23 +149,6 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) { } }, am_pm_always)); - /* - final int target_calories = sharedPreferences.getInt( "target_calories", 1000); - settings.add(new SeekbarSetting(null, "Target calories", null, new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - sharedPreferences.edit().putInt( "target_calories", progress).apply(); - } - @Override - public void onStartTrackingTouch(SeekBar seekBar) { - } - @Override - public void onStopTrackingTouch(SeekBar seekBar) { - Toast.makeText(seekBar.getContext(), "Target: "+seekBar.getProgress(), Toast.LENGTH_SHORT).show(); - } - }, target_calories, 3000)); - */ - final int target_calories = sharedPreferences.getInt( "target_calories", 1000); settings.add( new IncrementalSetting(null, "Target calories", "Current: "+target_calories, @@ -242,6 +225,14 @@ public void onClick(View view) { }, (custom_refresh_rate/1000<=60)?Math.round(custom_refresh_rate/1000)+" sec":Math.round(custom_refresh_rate/1000)/60+" min") ); + final boolean pressure_to_mmhg = sharedPreferences.getBoolean( "pressure_to_mmhg", getResources().getBoolean(R.bool.pressure_to_mmhg)); + settings.add(new SwitchSetting(null, "Pressure units", "(off: hPa, on: mmHg)", new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + sharedPreferences.edit().putBoolean( "pressure_to_mmhg", b).apply(); + } + }, pressure_to_mmhg)); + final float world_time_zone = sharedPreferences.getFloat( "world_time_zone", 0f); settings.add( new IncrementalSetting(null, "World-time zone", "Current: GMT "+((world_time_zone > 0) ? "+" + world_time_zone : world_time_zone), diff --git a/app/src/main/java/com/dinodevs/greatfitwatchface/widget/GreatWidget.java b/app/src/main/java/com/dinodevs/greatfitwatchface/widget/GreatWidget.java index 59b3677..ac6316b 100644 --- a/app/src/main/java/com/dinodevs/greatfitwatchface/widget/GreatWidget.java +++ b/app/src/main/java/com/dinodevs/greatfitwatchface/widget/GreatWidget.java @@ -354,7 +354,7 @@ public void draw(Canvas canvas, float width, float height, float centerX, float } String pres = "--"; if(this.pressureData!=null) { - pres = pressureData.getPressure(settings.air_pressureUnits); + pres = pressureData.getPressure(settings.air_pressureUnits, settings.pressure_to_mmhg?1:0); } canvas.drawText(pres, settings.air_pressureLeft, settings.air_pressureTop, airPressurePaint); @@ -910,7 +910,7 @@ public List buildSlptViewComponent(Service service, boolean b // Get pressure String pres = "--"; if(this.pressureData!=null) { - pres = pressureData.getPressure(settings.air_pressureUnits); + pres = pressureData.getPressure(settings.air_pressureUnits, settings.pressure_to_mmhg?1:0); } SlptLinearLayout airPressureLayout = new SlptLinearLayout(); SlptPictureView airPressureStr = new SlptPictureView(); diff --git a/app/src/main/res/values/bool.xml b/app/src/main/res/values/bool.xml index f98bd8b..939ac56 100644 --- a/app/src/main/res/values/bool.xml +++ b/app/src/main/res/values/bool.xml @@ -15,6 +15,7 @@ false false + false true