diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e7fb0dca0..3dafc0da1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -27,6 +27,7 @@
android:theme="@style/AppTheme"
tools:replace="android:icon">
+
instrumentsList;
+ private ArrayList instrumentParamsList;
+ private ArrayList instrumentParamsListTitles;
+ private ListView paramsListView;
+ private int selectedItem = 0;
+ private String intervalUnit = "sec";
+ private EditText intervalEditText;
+ private String interval;
+ private View rootView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_config);
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ rootView = findViewById(R.id.create_config_root_view);
+ paramsListView = findViewById(R.id.params_list);
+ Spinner selectInstrumentSpinner = findViewById(R.id.select_instrument_spinner);
+ Spinner intervalUnitSpinner = findViewById(R.id.interval_unit_spinner);
+ intervalEditText = findViewById(R.id.interval_edit_text);
+ Button createConfigFileBtn = findViewById(R.id.create_config_btn);
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setTitle(R.string.nav_config);
+ if (getSupportActionBar() != null) {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+ }
+ instrumentsList = new ArrayList<>();
+ instrumentParamsList = new ArrayList<>();
+ instrumentParamsListTitles = new ArrayList<>();
+ createArrayLists();
+ selectInstrumentSpinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, instrumentsList));
+ selectInstrumentSpinner.setSelection(0, true);
+ createCheckboxList();
+ selectInstrumentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ selectedItem = position;
+ createCheckboxList();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ selectedItem = 0;
+ }
+ });
+
+ intervalUnitSpinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.interval_units)));
+ intervalUnitSpinner.setSelection(0, true);
+ intervalUnitSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ intervalUnit = (String) parent.getItemAtPosition(position);
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ intervalUnit = "sec";
+ }
+ });
+
+ createConfigFileBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ interval = intervalEditText.getText().toString();
+ if (interval.length() == 0) {
+ Toast.makeText(CreateConfigActivity.this, getResources().getString(R.string.no_interval_message), Toast.LENGTH_SHORT).show();
+ } else {
+ SparseBooleanArray selectedParams = paramsListView.getCheckedItemPositions();
+ ArrayList selectedParamsList = new ArrayList<>();
+ for (int i = 0; i < paramsListView.getCount(); i++) {
+ if (selectedParams.get(i)) {
+ selectedParamsList.add(instrumentParamsList.get(selectedItem)[i]);
+ }
+ }
+ createConfigFile(selectedParamsList);
+ }
+ }
+ });
+ }
+
+ private void createArrayLists() {
+
+ instrumentParamsList.add(getResources().getStringArray(R.array.oscilloscope_params));
+ instrumentParamsList.add(getResources().getStringArray(R.array.multimeter_params));
+ instrumentParamsList.add(getResources().getStringArray(R.array.logic_analyzer_params));
+ instrumentParamsList.add(getResources().getStringArray(R.array.barometer_params));
+ instrumentParamsList.add(getResources().getStringArray(R.array.luxmeter_params));
+ instrumentParamsList.add(getResources().getStringArray(R.array.accelerometer_params));
+
+ instrumentParamsListTitles.add(getResources().getStringArray(R.array.oscilloscope_params_title));
+ instrumentParamsListTitles.add(getResources().getStringArray(R.array.multimeter_params_title));
+ instrumentParamsListTitles.add(getResources().getStringArray(R.array.logic_analyzer_params_title));
+ instrumentParamsListTitles.add(getResources().getStringArray(R.array.barometer_params));
+ instrumentParamsListTitles.add(getResources().getStringArray(R.array.luxmeter_params));
+ instrumentParamsListTitles.add(getResources().getStringArray(R.array.accelerometer_params_title));
+
+ instrumentsList.add(getResources().getString(R.string.oscilloscope));
+ instrumentsList.add(getResources().getString(R.string.multimeter));
+ instrumentsList.add(getResources().getString(R.string.logical_analyzer));
+ instrumentsList.add(getResources().getString(R.string.baro_meter));
+ instrumentsList.add(getResources().getString(R.string.lux_meter));
+ instrumentsList.add(getResources().getString(R.string.accelerometer));
+ }
+
+ private void createCheckboxList() {
+ paramsListView.setAdapter(new ArrayAdapter(CreateConfigActivity.this, android.R.layout.simple_list_item_multiple_choice, instrumentParamsListTitles.get(selectedItem)));
+ paramsListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void createConfigFile(ArrayList params) {
+ String instrumentName = instrumentsList.get(selectedItem);
+ String fileName = "pslab_config.txt";
+ String basepath = Environment.getExternalStorageDirectory().getAbsolutePath();
+
+ File baseDirectory = new File(basepath + File.separator + CSVLogger.CSV_DIRECTORY);
+ if (!baseDirectory.exists()) {
+ try {
+ baseDirectory.mkdir();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ File configFile = new File(basepath + File.separator + CSVLogger.CSV_DIRECTORY + File.separator + fileName);
+ if (!configFile.exists()) {
+ try {
+ configFile.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ FileWriter writer = new FileWriter(configFile);
+ writer.write("instrument: " + instrumentName + "\n");
+ writer.write("interval: " + interval + " " + intervalUnit + "\n");
+ String param = String.join(",", params);
+ writer.write("params: " + param);
+ writer.flush();
+ writer.close();
+ CustomSnackBar.showSnackBar(rootView, getString(R.string.file_created_success_message), null, null, Snackbar.LENGTH_SHORT);
+ } catch (IOException e) {
+ e.printStackTrace();
+ CustomSnackBar.showSnackBar(rootView, getString(R.string.file_created_fail_message), null, null, Snackbar.LENGTH_SHORT);
+ }
+
+ }
+}
diff --git a/app/src/main/java/io/pslab/activity/MainActivity.java b/app/src/main/java/io/pslab/activity/MainActivity.java
index 6af99cc57..53f7109c0 100644
--- a/app/src/main/java/io/pslab/activity/MainActivity.java
+++ b/app/src/main/java/io/pslab/activity/MainActivity.java
@@ -293,6 +293,12 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
startActivity(shareIntent);
return true;
+ case R.id.nav_generate_config:
+ if (drawer != null) {
+ drawer.closeDrawers();
+ }
+ startActivity(new Intent(MainActivity.this, CreateConfigActivity.class));
+ break;
default:
navItemIndex = 0;
}
diff --git a/app/src/main/res/drawable/create_config_icon.xml b/app/src/main/res/drawable/create_config_icon.xml
new file mode 100644
index 000000000..a4dd6d23b
--- /dev/null
+++ b/app/src/main/res/drawable/create_config_icon.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_create_config.xml b/app/src/main/res/layout/activity_create_config.xml
new file mode 100644
index 000000000..389f23e72
--- /dev/null
+++ b/app/src/main/res/layout/activity_create_config.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml
index 9f49ed844..66ec322ec 100644
--- a/app/src/main/res/menu/activity_main_drawer.xml
+++ b/app/src/main/res/menu/activity_main_drawer.xml
@@ -13,6 +13,10 @@
android:id="@+id/sensor_data_logger"
android:icon="@drawable/ic_wifi_tethering_black_24dp"
android:title="@string/logged_data" />
+
- 30dp
36sp
+ 10dp
+ 20dp
+ 22dp
+ 12dp
5dp
40dp
180dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 758755df9..ffbaac2e9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -13,6 +13,7 @@
Feedback & Bugs
FAQs
Share App
+ Generate Config File
Pin Layout
Pin Layout Front
Pin Layout Back
@@ -68,6 +69,99 @@
- CH2
+
+ - CH1
+ - CH2
+ - CH3
+ - MIC
+ - CAP
+ - AN8
+ - RES
+ - C
+ - LA1
+ - LA2
+ - LA3
+ - LA4
+
+
+
+ - Channel 1
+ - Channel 2
+ - Channel 3
+ - Microphone
+ - CAP Voltage
+ - Voltage
+ - Resistance
+ - Capacitance
+ - Logic Analyzer Pin 1
+ - Logic Analyzer Pin 2
+ - Logic Analyzer Pin 3
+ - Logic Analyzer Pin 4
+
+
+
+ - CH1
+ - CH2
+ - CH3
+ - MIC
+
+
+
+ - Channel 1
+ - Channel 2
+ - Channel 3
+ - Microphone
+
+
+
+ - LA1
+ - LA2
+ - LA3
+ - LA4
+
+
+
+ - Logic Analyzer Pin 1
+ - Logic Analyzer Pin 2
+ - Logic Analyzer Pin 3
+ - Logic Analyzer Pin 4
+
+
+
+ - Pressure
+
+
+
+ - Ax
+ - Ay
+ - Az
+
+
+
+ - Acceleration X axis
+ - Acceleration Y axis
+ - Acceleration Z axis
+
+
+
+ - Lux
+
+
+
+ - sec
+ - min
+ - hr
+ - day
+
+ Instrument:
+ Time Interval:
+ Logging Interval
+ Create Config File
+ Select Params
+ Please select logging interval
+ Config file created successfully
+ Create config file failed
+
ID1
ID2
ID3
diff --git a/scripts/upload-apk.sh b/scripts/upload-apk.sh
index cb8c11b60..e8e41ce53 100644
--- a/scripts/upload-apk.sh
+++ b/scripts/upload-apk.sh
@@ -60,5 +60,5 @@ git push origin apk -f --quiet > /dev/null
# Publish App to Play Store
if [ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then
gem install fastlane
- fastlane supply --aab pslab-master-app.aab --track alpha --json_key ../scripts/fastlane.json --package_name $PACKAGE_NAME
+ fastlane supply --aab pslab-master-app.aab --skip_upload_apk true --track alpha --json_key ../scripts/fastlane.json --package_name $PACKAGE_NAME
fi