-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from kike-canaries/pax_counter_mini
Pax counter mini
- Loading branch information
Showing
11 changed files
with
149 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ public class SensorData { | |
|
||
public float CO2H; | ||
|
||
public int PAX; | ||
|
||
public int P10; | ||
|
||
public int P1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
app/src/main/java/hpsaturn/pollutionreporter/view/VariableFileterFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
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<String> 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, this::setVaribleFilter); | ||
|
||
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<String> 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() { | ||
Logger.d(TAG,"onDestroy"); | ||
getMain().selectedVarsUpdated(); | ||
super.onDestroy(); | ||
} | ||
|
||
private MainActivity getMain() { | ||
return ((MainActivity) getActivity()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters