From 473a9bf0347caca113b244cb1c5a76d35f9d9d7f Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Mon, 6 Sep 2021 12:29:21 +0200 Subject: [PATCH 01/12] added new PAX item to variables setting array list --- app/src/main/res/values/arrays.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 46601bd..2d0cedc 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -39,6 +39,7 @@ CO2 CO2T CO2H + PAX Temp Humi Alt @@ -53,6 +54,7 @@ CO2 CO2T CO2H + PAX tmp hum alt From 77c181bcae27876e9d2100d69202bdbc45b7cecd Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Mon, 6 Sep 2021 12:32:51 +0200 Subject: [PATCH 02/12] added menu action item for launch variable filter dialog (not works yet) --- .../main/java/hpsaturn/pollutionreporter/BaseActivity.java | 6 +++++- .../main/java/hpsaturn/pollutionreporter/MainActivity.java | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java b/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java index a801eeb..0fb86c3 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java @@ -221,6 +221,10 @@ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case R.id.action_var_filter: + actionVarFilter(); + break; + case R.id.action_unpair: actionUnPair(); break; @@ -247,7 +251,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } abstract void actionUnPair(); - + abstract void actionVarFilter(); /** * A native method that is implemented by the 'native-lib' native library, diff --git a/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java b/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java index c85d6ce..3aa513f 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java @@ -2,6 +2,7 @@ import android.Manifest; import android.content.Intent; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import androidx.annotation.NonNull; @@ -518,6 +519,11 @@ void actionUnPair() { } } + @Override + void actionVarFilter() { +// selectedVarsUpdated(); + } + @Override protected void onDestroy() { stopRecordTrackService(); From cad5da91bd3688bf39bbb791c4919dec1c4856c6 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Mon, 6 Sep 2021 12:33:24 +0200 Subject: [PATCH 03/12] added new variable to chart and complete flow: PAX counter --- .../java/hpsaturn/pollutionreporter/models/SensorData.java | 2 ++ .../main/java/hpsaturn/pollutionreporter/view/ChartVar.java | 3 +++ app/src/main/res/menu/menu_main.xml | 5 +++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 11 insertions(+) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/models/SensorData.java b/app/src/main/java/hpsaturn/pollutionreporter/models/SensorData.java index faa682f..ffb25a0 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/models/SensorData.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/models/SensorData.java @@ -20,6 +20,8 @@ public class SensorData { public float CO2H; + public int PAX; + public int P10; public int P1; diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java index f54b836..264c9f8 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java @@ -46,6 +46,9 @@ public ChartVar(Context ctx, String type,String label) { dataSet = getMainLineDataSet(entries, R.color.black, label,1.5F); break; + case "PAX": + dataSet = getGenericLineDataSet(entries, R.color.green, label,1.5F); + break; case "P1": dataSet = getGenericLineDataSet(entries, R.color.brown, label,1F); diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index ae9fe39..3bc85dc 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -3,6 +3,11 @@ xmlns:tools="http://schemas.android.com/tools" tools:context="hpsaturn.pollutionreporter.MainActivity"> + + key_setting_altitude_offset Set Altitude to enable. 0 disable. CO2 Altitude compensation + Variables… From dca5afa6b845f14f11f35ea20de2b5bb6f812ec8 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Mon, 6 Sep 2021 15:16:33 +0200 Subject: [PATCH 04/12] added quick access dialog for chart variable filter --- .../pollutionreporter/MainActivity.java | 5 +- .../view/VariableFileterFragment.java | 77 +++++++++++++++++++ gradle.properties | 4 +- 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java diff --git a/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java b/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java index 3aa513f..40acc16 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java @@ -1,6 +1,8 @@ package hpsaturn.pollutionreporter; import android.Manifest; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Build; @@ -53,6 +55,7 @@ import hpsaturn.pollutionreporter.view.ScanFragment; import hpsaturn.pollutionreporter.view.SettingsFixedStation; import hpsaturn.pollutionreporter.view.SettingsFragment; +import hpsaturn.pollutionreporter.view.VariableFileterFragment; /** * Created by Antonio Vanegas @hpsaturn on 6/11/18. @@ -521,7 +524,7 @@ void actionUnPair() { @Override void actionVarFilter() { -// selectedVarsUpdated(); + showDialogFragment(new VariableFileterFragment(),VariableFileterFragment.TAG); } @Override diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java b/app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java new file mode 100644 index 0000000..12cebe8 --- /dev/null +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java @@ -0,0 +1,77 @@ +package hpsaturn.pollutionreporter.view; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.os.Bundle; + +import androidx.fragment.app.DialogFragment; +import androidx.preference.PreferenceManager; + +import com.hpsaturn.tools.Logger; + +import java.util.Set; + +import hpsaturn.pollutionreporter.MainActivity; +import hpsaturn.pollutionreporter.R; + +/** + * Created by Antonio Vanegas @hpsaturn on 5/22/21. + */ +public class VariableFileterFragment extends DialogFragment { + + public static final String TAG = VariableFileterFragment.class.getSimpleName(); + + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + + + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getMain()); + Set values = preferences.getStringSet(getString(R.string.key_setting_vars), null); + + String[] options = getResources().getStringArray(R.array.pref_vars_values); + + boolean[] selected = new boolean[options.length]; + + for (int i = 0 ; i < options.length ; i++) { + selected[i] = values.contains(options[i]); + } + + builder.setMultiChoiceItems(R.array.pref_vars_entries, selected, + (DialogInterface.OnMultiChoiceClickListener) (dialog, item, isChecked) + -> setVaribleFilter(dialog, item, isChecked)); + + return builder.create(); + } + + private void setVaribleFilter(DialogInterface dialog, int item, boolean isChecked) { + Logger.i(TAG, "item: " + item + " isChecked: "+isChecked); + + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getMain()); + Set values = preferences.getStringSet(getString(R.string.key_setting_vars), null); + + String[] options = getResources().getStringArray(R.array.pref_vars_values); + + if(isChecked) values.add(options[item]); + else values.remove(options[item]); + + SharedPreferences.Editor editor = preferences.edit(); + editor.putStringSet(getString(R.string.key_setting_vars),values); + editor.apply(); + } + + @Override + public void onDestroy() { + getMain().selectedVarsUpdated(); + super.onDestroy(); + } + + private MainActivity getMain() { + return ((MainActivity) getActivity()); + } + +} diff --git a/gradle.properties b/gradle.properties index 8877d12..2255213 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 mCompileSdkVersion=30 mMinSdkVersion=19 mTargetSdkVersion=30 -mVersionCode=578 -mVersionName=0.6.9 +mVersionCode=579 +mVersionName=0.7.0 android.useAndroidX=true android.enableJetifier=true From 54e6d10f47a71a780c6a36c27d5ec3ca2e205ba0 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Mon, 6 Sep 2021 15:43:22 +0200 Subject: [PATCH 05/12] rev579 first version for PAX counter version --- .../java/hpsaturn/pollutionreporter/view/ChartFragment.java | 5 +++++ .../main/java/hpsaturn/pollutionreporter/view/ChartVar.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java index 938074b..485b2e9 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java @@ -4,6 +4,7 @@ import android.graphics.Paint; import android.os.Bundle; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; @@ -17,8 +18,12 @@ import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.components.Description; import com.github.mikephil.charting.components.XAxis; +import com.github.mikephil.charting.components.YAxis; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; +import com.github.mikephil.charting.listener.ChartTouchListener; +import com.github.mikephil.charting.listener.OnChartGestureListener; +import com.github.mikephil.charting.utils.MPPointD; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java index 264c9f8..bec88ed 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java @@ -47,7 +47,7 @@ public ChartVar(Context ctx, String type,String label) { break; case "PAX": - dataSet = getGenericLineDataSet(entries, R.color.green, label,1.5F); + dataSet = getGenericLineDataSet(entries, R.color.light_red, label,2.0F); break; case "P1": From eef6a9f2a024a7f87503aae237fb247bc3c23dd3 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Wed, 8 Sep 2021 09:47:43 +0200 Subject: [PATCH 06/12] fixed issue on post info framgent with vars filter dialog --- .../hpsaturn/pollutionreporter/BaseActivity.java | 12 ++++++++++++ .../hpsaturn/pollutionreporter/MainActivity.java | 2 ++ .../pollutionreporter/view/ChartFragment.java | 5 +---- .../view/VariableFileterFragment.java | 5 ++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java b/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java index 0fb86c3..493c0a7 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/BaseActivity.java @@ -201,6 +201,18 @@ public boolean isFragmentInStack(String tag) { } } + public Fragment getFragmentInStack(String tag) { + try { + if (getSupportFragmentManager().getBackStackEntryCount() == 0) return null; + FragmentManager fm = getSupportFragmentManager(); + Fragment match = fm.findFragmentByTag(tag); + if (match != null) return match; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + /*********************************************** * MENU OPTIONS ***********************************************/ diff --git a/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java b/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java index 40acc16..3665a57 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/MainActivity.java @@ -585,6 +585,8 @@ public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Prefer public void selectedVarsUpdated() { if (chartFragment!=null)chartFragment.loadSelectedVariables(); + ChartFragment infoFragment = (ChartFragment) getFragmentInStack(ChartFragment.TAG_INFO); + if (infoFragment!=null)infoFragment.loadSelectedVariables(); } public void showTrackInfoFragment(String trackId) { diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java index 485b2e9..38d21bc 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java @@ -241,7 +241,6 @@ public void loadSelectedVariables(){ requireActivity().runOnUiThread(this::loadData); } - private void calculateReferenceTime(){ ArrayList data = Storage.getSensorData(getActivity()); if (data.isEmpty()) { @@ -253,8 +252,6 @@ private void calculateReferenceTime(){ XAxis xAxis = chart.getXAxis(); xAxis.setValueFormatter(xAxisFormatter); } - - /** * Add data from previous data (recorded track for example) * @param data @@ -289,10 +286,10 @@ private void addValue(long time, SensorData data) { boolean loadMap = recordId != null && (var.type.equals("P25") || var.type.equals("CO2")); if(loadMap)addMapSegment(var,data); } - } private void refreshDataSets() { + dataSets.clear(); Iterator it = variables.iterator(); diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java b/app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java index 12cebe8..f8bbd86 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java @@ -41,9 +41,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { selected[i] = values.contains(options[i]); } - builder.setMultiChoiceItems(R.array.pref_vars_entries, selected, - (DialogInterface.OnMultiChoiceClickListener) (dialog, item, isChecked) - -> setVaribleFilter(dialog, item, isChecked)); + builder.setMultiChoiceItems(R.array.pref_vars_entries, selected, this::setVaribleFilter); return builder.create(); } @@ -66,6 +64,7 @@ private void setVaribleFilter(DialogInterface dialog, int item, boolean isChecke @Override public void onDestroy() { + Logger.d(TAG,"onDestroy"); getMain().selectedVarsUpdated(); super.onDestroy(); } From ce477e28525ff158e5e3b31effbdb124b240712f Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Wed, 8 Sep 2021 11:06:02 +0200 Subject: [PATCH 07/12] PAX set to MainLineDataSet (Main value with circle colors) --- .../java/hpsaturn/pollutionreporter/view/RecordsFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/RecordsFragment.java b/app/src/main/java/hpsaturn/pollutionreporter/view/RecordsFragment.java index ed4176b..12591dd 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/RecordsFragment.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/RecordsFragment.java @@ -111,7 +111,7 @@ public void onItemClick(AdapterView adapterView, View view, int position, lon String recordId = mRecordsAdapter.getItem(position).name; Logger.i(TAG, "showing record: "+recordId); chart = ChartFragment.newInstance(recordId); - getMain().addFragmentPopup(chart,ChartFragment.TAG); + getMain().addFragmentPopup(chart,ChartFragment.TAG_INFO); showingData=true; } }; From d2e9a1b913f657e1641f296712a4e3feaf1b0424 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Wed, 8 Sep 2021 11:07:02 +0200 Subject: [PATCH 08/12] fixed issue on share info fragment with variable filter --- .../main/java/hpsaturn/pollutionreporter/view/ChartVar.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java index bec88ed..d15694c 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java @@ -47,7 +47,7 @@ public ChartVar(Context ctx, String type,String label) { break; case "PAX": - dataSet = getGenericLineDataSet(entries, R.color.light_red, label,2.0F); + dataSet = getMainLineDataSet(entries, R.color.light_red, label,2.0F); break; case "P1": @@ -131,6 +131,7 @@ public void addValue(float time,SensorData data){ else colors.add(ctx.getResources().getColor(R.color.brown)); break; case "P25": + case "PAX": if (data.P25 <= 13) colors.add(ctx.getResources().getColor(R.color.green)); else if (data.P25 <= 35) colors.add(ctx.getResources().getColor(R.color.yellow_dark)); else if (data.P25 <= 55) colors.add(ctx.getResources().getColor(R.color.orange)); @@ -157,6 +158,7 @@ public void refresh(){ case "CO2": case "P25": + case "PAX": dataSet.setCircleColors(colors); break; From 1c4693e3dd1603f041dfd289996786e97999c417 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Wed, 8 Sep 2021 14:00:17 +0200 Subject: [PATCH 09/12] rev580 fixed var filter for info fragments instances --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2255213..4b77e50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 mCompileSdkVersion=30 mMinSdkVersion=19 mTargetSdkVersion=30 -mVersionCode=579 +mVersionCode=580 mVersionName=0.7.0 android.useAndroidX=true android.enableJetifier=true From 8e19645fc2a6d77edeffd57af16bc2f63f1b3661 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Wed, 8 Sep 2021 22:13:52 +0200 Subject: [PATCH 10/12] fixed circule colors on line dataset for PAX variable --- .../pollutionreporter/view/ChartFragment.java | 3 +- .../pollutionreporter/view/ChartVar.java | 36 ++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java index 38d21bc..f1fb9a6 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartFragment.java @@ -283,7 +283,8 @@ private void addValue(long time, SensorData data) { while (it.hasNext()){ ChartVar var = it.next(); var.addValue(time,data); - boolean loadMap = recordId != null && (var.type.equals("P25") || var.type.equals("CO2")); + boolean loadMap = recordId != null && + (var.type.equals("P25") || var.type.equals("CO2") || var.type.equals("PAX")); if(loadMap)addMapSegment(var,data); } } diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java index d15694c..fd1d43b 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java @@ -24,11 +24,11 @@ public class ChartVar { public String type; - public List entries = new ArrayList(); + public List entries = new ArrayList<>(); public LineDataSet dataSet; - public ArrayList colors = new ArrayList(); + public ArrayList colors = new ArrayList<>(); public ChartVar(Context ctx, String type,String label) { @@ -39,15 +39,15 @@ public ChartVar(Context ctx, String type,String label) { switch (type) { case "P25": - dataSet = getMainLineDataSet(entries, R.color.grey, label,1.5F); + dataSet = getMainLineDataSet(entries, R.color.grey, label,1.5F,5.0F); break; case "CO2": - dataSet = getMainLineDataSet(entries, R.color.black, label,1.5F); + dataSet = getMainLineDataSet(entries, R.color.black, label,1.5F,3.0F); break; case "PAX": - dataSet = getMainLineDataSet(entries, R.color.light_red, label,2.0F); + dataSet = getMainLineDataSet(entries, R.color.light_red, label,2.0F,3.0F); break; case "P1": @@ -59,7 +59,7 @@ public ChartVar(Context ctx, String type,String label) { break; case "P10": - dataSet = getGenericLineDataSet(entries, R.color.colorAccentWeb, label,1F); + dataSet = getGenericLineDataSet(entries, R.color.colorAccentWeb, label,2F); break; case "CO2T": @@ -75,7 +75,7 @@ public ChartVar(Context ctx, String type,String label) { break; case "hum": - dataSet = getGenericLineDataSet(entries, R.color.blue, label,1F); + dataSet = getGenericLineDataSet(entries, R.color.blue, label,2F); break; case "alt": @@ -94,13 +94,13 @@ public ChartVar(Context ctx, String type,String label) { } - private LineDataSet getMainLineDataSet(List entry, int color, String label,float width) { + private LineDataSet getMainLineDataSet(List entry, int color, String label, float width, float radious) { LineDataSet dataSet = new LineDataSet(entry,label); dataSet.setColor(ctx.getResources().getColor(color)); dataSet.setDrawValues(false); dataSet.setHighlightEnabled(true); - dataSet.setCircleRadius(4.0f); + dataSet.setCircleRadius(radious); dataSet.setAxisDependency(YAxis.AxisDependency.RIGHT); dataSet.setLineWidth(width); @@ -131,21 +131,26 @@ public void addValue(float time,SensorData data){ else colors.add(ctx.getResources().getColor(R.color.brown)); break; case "P25": - case "PAX": if (data.P25 <= 13) colors.add(ctx.getResources().getColor(R.color.green)); else if (data.P25 <= 35) colors.add(ctx.getResources().getColor(R.color.yellow_dark)); else if (data.P25 <= 55) colors.add(ctx.getResources().getColor(R.color.orange)); - else if (data.P25 <= 150)colors.add(ctx.getResources().getColor(R.color.red)); - else if (data.P25 <= 250)colors.add(ctx.getResources().getColor(R.color.purple)); + else if (data.P25 <= 150) colors.add(ctx.getResources().getColor(R.color.red)); + else if (data.P25 <= 250) colors.add(ctx.getResources().getColor(R.color.purple)); + else colors.add(ctx.getResources().getColor(R.color.brown)); + break; + case "PAX": + if (data.PAX <= 13) colors.add(ctx.getResources().getColor(R.color.green)); + else if (data.PAX <= 35) colors.add(ctx.getResources().getColor(R.color.yellow_dark)); + else if (data.PAX <= 55) colors.add(ctx.getResources().getColor(R.color.orange)); + else if (data.PAX <= 150) colors.add(ctx.getResources().getColor(R.color.red)); + else if (data.PAX <= 250) colors.add(ctx.getResources().getColor(R.color.purple)); else colors.add(ctx.getResources().getColor(R.color.brown)); break; } try { float value = data.getClass().getField(type).getFloat(data); -// Logger.i(TAG,"--> "+type+ ":"+value); - dataSet.addEntry(new Entry(time,value)); - + dataSet.addEntry(new Entry(time, value)); } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } @@ -156,7 +161,6 @@ public void addValue(float time,SensorData data){ public void refresh(){ switch (type){ case "CO2": - case "P25": case "PAX": dataSet.setCircleColors(colors); From 53954b225b5674f6ab6f84698d8cf02e43883dca Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Wed, 8 Sep 2021 23:42:45 +0200 Subject: [PATCH 11/12] changed PAX colors suggested by @roberbike in Telegram https://t.me/canairio/14876 --- .../java/hpsaturn/pollutionreporter/view/ChartVar.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java index fd1d43b..c59a2a1 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java @@ -139,11 +139,11 @@ public void addValue(float time,SensorData data){ else colors.add(ctx.getResources().getColor(R.color.brown)); break; case "PAX": - if (data.PAX <= 13) colors.add(ctx.getResources().getColor(R.color.green)); - else if (data.PAX <= 35) colors.add(ctx.getResources().getColor(R.color.yellow_dark)); - else if (data.PAX <= 55) colors.add(ctx.getResources().getColor(R.color.orange)); - else if (data.PAX <= 150) colors.add(ctx.getResources().getColor(R.color.red)); - else if (data.PAX <= 250) colors.add(ctx.getResources().getColor(R.color.purple)); + if (data.PAX <= 20) colors.add(ctx.getResources().getColor(R.color.green)); + else if (data.PAX <= 50) colors.add(ctx.getResources().getColor(R.color.yellow_dark)); + else if (data.PAX <= 100) colors.add(ctx.getResources().getColor(R.color.orange)); + else if (data.PAX <= 400) colors.add(ctx.getResources().getColor(R.color.red)); + else if (data.PAX <= 800) colors.add(ctx.getResources().getColor(R.color.purple)); else colors.add(ctx.getResources().getColor(R.color.brown)); break; } From c4a9801455461cb2ff276e609ef0663145c7ea79 Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Thu, 9 Sep 2021 12:21:13 +0200 Subject: [PATCH 12/12] rev581 improved colors on main variables on all charts --- .../main/java/hpsaturn/pollutionreporter/view/ChartVar.java | 3 +-- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java index c59a2a1..92925d2 100644 --- a/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java +++ b/app/src/main/java/hpsaturn/pollutionreporter/view/ChartVar.java @@ -154,8 +154,7 @@ public void addValue(float time,SensorData data){ } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } - - + } public void refresh(){ diff --git a/gradle.properties b/gradle.properties index 4b77e50..8c76f76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 mCompileSdkVersion=30 mMinSdkVersion=19 mTargetSdkVersion=30 -mVersionCode=580 +mVersionCode=581 mVersionName=0.7.0 android.useAndroidX=true android.enableJetifier=true