From 6c71bd2e00c6f49066c53bac219f27b5d993cdde Mon Sep 17 00:00:00 2001 From: neel1998 Date: Sun, 25 Aug 2019 13:58:43 +0530 Subject: [PATCH] oscilloscope ui changes --- .../pslab/activity/OscilloscopeActivity.java | 8 +- .../fragment/ChannelParametersFragment.java | 85 +++++-------- .../fragment_channel_parameters.xml | 113 ++++++++++-------- .../main/res/layout/activity_oscilloscope.xml | 20 ++-- .../layout/fragment_channel_parameters.xml | 94 ++++++++------- .../res/layout/fragment_data_analysis.xml | 23 ++-- app/src/main/res/layout/fragment_xyplot.xml | 21 ++-- app/src/main/res/values/dimens.xml | 11 +- app/src/main/res/values/strings.xml | 2 + 9 files changed, 186 insertions(+), 191 deletions(-) diff --git a/app/src/main/java/io/pslab/activity/OscilloscopeActivity.java b/app/src/main/java/io/pslab/activity/OscilloscopeActivity.java index b8573f686..cc2b42066 100644 --- a/app/src/main/java/io/pslab/activity/OscilloscopeActivity.java +++ b/app/src/main/java/io/pslab/activity/OscilloscopeActivity.java @@ -764,17 +764,17 @@ public void onWindowFocusChanged() { RelativeLayout.LayoutParams frameLayoutParams = (RelativeLayout.LayoutParams) frameLayout.getLayoutParams(); if (getResources().getBoolean(R.bool.isTablet)) { lineChartParams.height = height * 3 / 4; - lineChartParams.width = width * 7 / 8; + lineChartParams.width = width * 9 / 10; mChartLayout.setLayoutParams(lineChartParams); frameLayoutParams.height = height / 4; - frameLayoutParams.width = width * 7 / 8; + frameLayoutParams.width = width * 9 / 10; frameLayout.setLayoutParams(frameLayoutParams); } else { lineChartParams.height = height * 3 / 5; - lineChartParams.width = width * 5 / 6; + lineChartParams.width = width * 7 / 8; mChartLayout.setLayoutParams(lineChartParams); frameLayoutParams.height = height * 2 / 5; - frameLayoutParams.width = width * 5 / 6; + frameLayoutParams.width = width * 7 / 8; frameLayout.setLayoutParams(frameLayoutParams); } } diff --git a/app/src/main/java/io/pslab/fragment/ChannelParametersFragment.java b/app/src/main/java/io/pslab/fragment/ChannelParametersFragment.java index 4d629c99f..41f4a9420 100644 --- a/app/src/main/java/io/pslab/fragment/ChannelParametersFragment.java +++ b/app/src/main/java/io/pslab/fragment/ChannelParametersFragment.java @@ -21,7 +21,6 @@ import io.pslab.DataFormatter; import io.pslab.R; import io.pslab.activity.OscilloscopeActivity; -import io.pslab.others.NothingSelectedSpinnerAdapter; public class ChannelParametersFragment extends Fragment { @@ -30,13 +29,11 @@ public class ChannelParametersFragment extends Fragment { private CheckBox checkBoxCH1; private CheckBox checkBoxCH2; private CheckBox checkBoxCH3; - private CheckBox checkBoxMIC; private Spinner spinnerRangeCh1; private Spinner spinnerRangeCh2; private Spinner spinnerChannelSelect; - private Spinner spinnerMICSelect; - private int micSelectedPosition; - + private CheckBox builtInMicCheckBox; + private CheckBox pslabMicCheckBox; public static ChannelParametersFragment newInstance() { return new ChannelParametersFragment(); @@ -56,15 +53,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, spinnerRangeCh1 = v.findViewById(R.id.spinner_range_ch1_cp); spinnerRangeCh2 = v.findViewById(R.id.spinner_range_ch2_cp); spinnerChannelSelect = v.findViewById(R.id.spinner_channel_select_cp); - spinnerMICSelect = v.findViewById(R.id.spinner_mic_select_cp); boolean tabletSize = getResources().getBoolean(R.bool.isTablet); checkBoxCH1 = v.findViewById(R.id.checkBox_ch1_cp); checkBoxCH2 = v.findViewById(R.id.checkBox_ch2_cp); checkBoxCH3 = v.findViewById(R.id.checkBox_ch3_cp); checkBoxCH3.setText(getString(R.string.ch3_value, 3.3)); - checkBoxMIC = v.findViewById(R.id.checkBox_mic_cp); + builtInMicCheckBox = v.findViewById(R.id.built_in_mic_cb); + pslabMicCheckBox = v.findViewById(R.id.pslab_mic_cb); ArrayAdapter rangesAdapter; ArrayAdapter channelsAdapter; ArrayAdapter micsAdapter; @@ -88,9 +85,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, spinnerRangeCh2.setSelection(rangesAdapter.getPosition("+/-16V"), true); spinnerChannelSelect.setAdapter(channelsAdapter); spinnerChannelSelect.setSelection(channelsAdapter.getPosition("CH1"), true); - spinnerMICSelect.setAdapter(new NothingSelectedSpinnerAdapter(micsAdapter, - R.layout.nothing_selected_spinner_row, - getActivity())); spinnerRangeCh1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override @@ -220,31 +214,6 @@ public void onNothingSelected(AdapterView parent) { } }); - spinnerMICSelect.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - micSelectedPosition = position; - if (position == 1) { - ((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = false; - if (checkBoxMIC.isChecked()) { - ((OscilloscopeActivity) getActivity()).isMICSelected = true; - ((OscilloscopeActivity) getActivity()).isAudioInputSelected = true; - } - } else { - ((OscilloscopeActivity) getActivity()).isMICSelected = false; - if (checkBoxMIC.isChecked()) { - ((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = true; - ((OscilloscopeActivity) getActivity()).isAudioInputSelected = true; - } - } - } - - @Override - public void onNothingSelected(AdapterView parent) { - - } - }); - checkBoxCH1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -265,29 +234,37 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ((OscilloscopeActivity) getActivity()).isCH3Selected = isChecked; } }); - checkBoxMIC.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + builtInMicCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (micSelectedPosition == 1) { - ((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked; - ((OscilloscopeActivity) getActivity()).isMICSelected = isChecked; - } else if (micSelectedPosition == 2) { - ((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked; - // check for RECORD_AUDIO permission if has then change boolean - if (isChecked) - if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { - requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, RECORD_AUDIO_REQUEST_CODE); - } else { - ((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = true; - } - else - ((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = false; - } else { - ((OscilloscopeActivity) getActivity()).isAudioInputSelected = false; + ((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = isChecked; + ((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked; + ((OscilloscopeActivity) getActivity()).isMICSelected = !isChecked; + if (isChecked) { + pslabMicCheckBox.setChecked(false); + if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { + requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, RECORD_AUDIO_REQUEST_CODE); + ((OscilloscopeActivity) getActivity()).isAudioInputSelected = false; + } } } }); + pslabMicCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + ((OscilloscopeActivity) getActivity()).isMICSelected = isChecked; + ((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked; + ((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = !isChecked; + if (isChecked) { + builtInMicCheckBox.setChecked(false); + if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { + requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, RECORD_AUDIO_REQUEST_CODE); + ((OscilloscopeActivity) getActivity()).isAudioInputSelected = false; + } + } + } + }); return v; } @@ -298,8 +275,8 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis ((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = true; } else { Toast.makeText(getActivity(), "This feature won't work.", Toast.LENGTH_SHORT).show(); - if (checkBoxMIC.isChecked()) - checkBoxMIC.toggle(); + if (builtInMicCheckBox.isChecked()) + builtInMicCheckBox.toggle(); } } } diff --git a/app/src/main/res/layout-sw600dp/fragment_channel_parameters.xml b/app/src/main/res/layout-sw600dp/fragment_channel_parameters.xml index 00bc2c7a8..0af5562de 100644 --- a/app/src/main/res/layout-sw600dp/fragment_channel_parameters.xml +++ b/app/src/main/res/layout-sw600dp/fragment_channel_parameters.xml @@ -1,7 +1,6 @@ @@ -10,11 +9,10 @@ android:id="@+id/checkBox_ch1_cp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="16dp" - android:layout_marginStart="16dp" - android:layout_marginTop="16dp" + android:layout_marginStart="@dimen/osc_cb_margin2" + android:layout_marginTop="@dimen/osc_cb_margin2" android:text="@string/label_ch1" - android:textSize="18sp" + android:textSize="@dimen/osc_text_size_large" android:textStyle="normal|bold" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -23,11 +21,10 @@ android:id="@+id/checkBox_ch2_cp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="16dp" - android:layout_marginLeft="16dp" - android:layout_marginStart="16dp" + android:layout_marginBottom="@dimen/osc_cb_margin2" + android:layout_marginStart="@dimen/osc_cb_margin2" android:text="@string/label_ch2" - android:textSize="18sp" + android:textSize="@dimen/osc_text_size_large" android:textStyle="normal|bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" /> @@ -36,70 +33,65 @@ android:id="@+id/checkBox_ch3_cp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:layout_marginRight="16dp" - android:layout_marginTop="16dp" + android:layout_marginEnd="@dimen/osc_cb_margin2" + android:layout_marginTop="@dimen/osc_cb_margin2" android:text="@string/ch3_value" - android:textSize="18sp" + android:textSize="@dimen/osc_text_size_large" android:textStyle="normal|bold" - app:layout_constraintRight_toRightOf="parent" + app:layout_constraintEnd_toStartOf="@id/mic_radio_group" + app:layout_constraintStart_toEndOf="@id/spinner_channel_select_cp" app:layout_constraintTop_toTopOf="parent" /> @@ -107,32 +99,47 @@ android:id="@+id/tv_ch2_cp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="24dp" - android:layout_marginLeft="16dp" - android:layout_marginStart="16dp" + android:layout_marginBottom="@dimen/text_elevation" + android:layout_marginStart="@dimen/osc_cb_margin2" android:clickable="true" android:text="@string/label_ch2" android:textColor="@android:color/background_dark" - android:textSize="18sp" + android:textSize="@dimen/osc_text_size_large" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch2_cp" /> - - - + android:layout_marginTop="@dimen/osc_cb_margin2" + android:layout_marginEnd="@dimen/osc_cb_margin2" + android:orientation="vertical" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_oscilloscope.xml b/app/src/main/res/layout/activity_oscilloscope.xml index d07806c02..c6a94168e 100644 --- a/app/src/main/res/layout/activity_oscilloscope.xml +++ b/app/src/main/res/layout/activity_oscilloscope.xml @@ -16,12 +16,15 @@ + android:layout_below="@id/top_app_bar_layout" + android:layout_marginTop="@dimen/osc_main_margin" + android:layout_marginStart="@dimen/osc_main_margin"> + android:layout_height="@dimen/osc_chart_height" + android:layout_marginEnd="@dimen/osc_main_margin"> + android:orientation="vertical" + android:layout_marginBottom="@dimen/osc_main_margin" + android:layout_marginEnd="@dimen/osc_main_margin"> + android:layout_marginEnd="@dimen/osc_main_margin" + android:layout_marginTop="@dimen/osc_main_margin" + android:layout_marginBottom="@dimen/osc_main_margin" + android:layout_toStartOf="@+id/layout_dock_os1"> diff --git a/app/src/main/res/layout/fragment_channel_parameters.xml b/app/src/main/res/layout/fragment_channel_parameters.xml index f661f137b..284fa82d8 100644 --- a/app/src/main/res/layout/fragment_channel_parameters.xml +++ b/app/src/main/res/layout/fragment_channel_parameters.xml @@ -10,9 +10,8 @@ android:id="@+id/checkBox_ch1_cp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" + android:layout_marginStart="@dimen/osc_cb_margin" + android:layout_marginTop="@dimen/osc_cb_margin" android:text="@string/ch1" android:textStyle="normal|bold" app:layout_constraintLeft_toLeftOf="parent" @@ -22,9 +21,8 @@ android:id="@+id/checkBox_ch2_cp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:layout_marginLeft="8dp" - android:layout_marginStart="8dp" + android:layout_marginBottom="@dimen/osc_cb_margin" + android:layout_marginStart="@dimen/osc_cb_margin" android:text="@string/ch2" android:textStyle="normal|bold" app:layout_constraintBottom_toBottomOf="parent" @@ -34,20 +32,19 @@ android:id="@+id/checkBox_ch3_cp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginRight="8dp" - android:layout_marginTop="8dp" + android:layout_marginEnd="@dimen/osc_cb_margin" + android:layout_marginTop="@dimen/osc_cb_margin" android:textStyle="normal|bold" - app:layout_constraintRight_toRightOf="parent" + app:layout_constraintEnd_toStartOf="@id/mic_radio_group" + app:layout_constraintStart_toEndOf="@id/spinner_channel_select_cp" app:layout_constraintTop_toTopOf="parent" /> @@ -80,49 +75,64 @@ + app:layout_constraintTop_toTopOf="parent" + android:layout_marginStart="@dimen/osc_cb_margin"/> - + android:layout_marginTop="@dimen/osc_cb_margin" + android:layout_marginEnd="@dimen/osc_cb_margin" + android:orientation="vertical" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + + + + + diff --git a/app/src/main/res/layout/fragment_data_analysis.xml b/app/src/main/res/layout/fragment_data_analysis.xml index 5b6132c68..db7eafa5e 100644 --- a/app/src/main/res/layout/fragment_data_analysis.xml +++ b/app/src/main/res/layout/fragment_data_analysis.xml @@ -10,20 +10,17 @@ @@ -31,10 +28,8 @@ @@ -42,9 +37,7 @@ android:id="@+id/checkBox_fourier_da" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:layout_marginLeft="8dp" - android:layout_marginStart="8dp" + android:layout_marginBottom="@dimen/osc_cb_margin" android:text="@string/fourier_transforms" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" /> diff --git a/app/src/main/res/layout/fragment_xyplot.xml b/app/src/main/res/layout/fragment_xyplot.xml index 4177dd942..ed7f55b41 100644 --- a/app/src/main/res/layout/fragment_xyplot.xml +++ b/app/src/main/res/layout/fragment_xyplot.xml @@ -11,9 +11,7 @@ android:id="@+id/checkBox_enable_xy_xy" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" + android:layout_marginStart="@dimen/osc_cb_margin" android:text="@string/enable_xy_plot" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -21,11 +19,10 @@ diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 117cd1e66..b3545339e 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -126,16 +126,23 @@ 10dp + 8dp + 16dp + 32dp + 48dp + 20dp 600dp 300dp 9sp 8dp + 10dp 4dp 9dp 16dp - 12sp + 9sp 15dp 1dp + 5dp 2 2dp 24dp @@ -143,6 +150,8 @@ 50dp 10dp 13dp + 18sp + 2dp 40dp 15sp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2243346b0..16f2d8e2e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -682,6 +682,8 @@ 50 % Open instrument + In-Built MIC + PSLab MIC Sine Triangular Square