Skip to content

Commit

Permalink
Option to show pressure in mmHg added
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatApo committed Aug 25, 2019
1 parent b7a475d commit 2e53641
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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":"");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -910,7 +910,7 @@ public List<SlptViewComponent> 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();
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/bool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<bool name="flashing_indicator">false</bool><!-- the : between hours and minutes -->
<!-- Wind direction as arrows -->
<bool name="wind_direction_as_arrows">false</bool> <!-- false = W, S, E, N, SW etc , true = ↖ ↑ ↗ ← → ↙ ↓ ↘ -->
<bool name="pressure_to_mmhg">false</bool> <!-- show pressure as mmHg and not hPa -->

<bool name="flashing_heart_rate_icon">true</bool>

Expand Down

0 comments on commit 2e53641

Please sign in to comment.