Skip to content

Commit 71bde3b

Browse files
committed
osc main screen ui changes
1 parent 4e89f60 commit 71bde3b

File tree

4 files changed

+96
-96
lines changed

4 files changed

+96
-96
lines changed

app/src/main/java/io/pslab/fragment/ChannelParametersFragment.java

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import io.pslab.DataFormatter;
2222
import io.pslab.R;
2323
import io.pslab.activity.OscilloscopeActivity;
24-
import io.pslab.others.NothingSelectedSpinnerAdapter;
2524

2625
public class ChannelParametersFragment extends Fragment {
2726

@@ -30,13 +29,11 @@ public class ChannelParametersFragment extends Fragment {
3029
private CheckBox checkBoxCH1;
3130
private CheckBox checkBoxCH2;
3231
private CheckBox checkBoxCH3;
33-
private CheckBox checkBoxMIC;
3432
private Spinner spinnerRangeCh1;
3533
private Spinner spinnerRangeCh2;
3634
private Spinner spinnerChannelSelect;
37-
private Spinner spinnerMICSelect;
38-
private int micSelectedPosition;
39-
35+
private CheckBox builtInMicCheckBox;
36+
private CheckBox pslabMicCheckBox;
4037

4138
public static ChannelParametersFragment newInstance() {
4239
return new ChannelParametersFragment();
@@ -56,15 +53,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
5653
spinnerRangeCh1 = v.findViewById(R.id.spinner_range_ch1_cp);
5754
spinnerRangeCh2 = v.findViewById(R.id.spinner_range_ch2_cp);
5855
spinnerChannelSelect = v.findViewById(R.id.spinner_channel_select_cp);
59-
spinnerMICSelect = v.findViewById(R.id.spinner_mic_select_cp);
6056

6157
boolean tabletSize = getResources().getBoolean(R.bool.isTablet);
6258
checkBoxCH1 = v.findViewById(R.id.checkBox_ch1_cp);
6359
checkBoxCH2 = v.findViewById(R.id.checkBox_ch2_cp);
6460
checkBoxCH3 = v.findViewById(R.id.checkBox_ch3_cp);
6561
checkBoxCH3.setText(getString(R.string.ch3_value, 3.3));
66-
checkBoxMIC = v.findViewById(R.id.checkBox_mic_cp);
6762

63+
builtInMicCheckBox = v.findViewById(R.id.built_in_mic_cb);
64+
pslabMicCheckBox = v.findViewById(R.id.pslab_mic_cb);
6865
ArrayAdapter<String> rangesAdapter;
6966
ArrayAdapter<String> channelsAdapter;
7067
ArrayAdapter<String> micsAdapter;
@@ -88,9 +85,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
8885
spinnerRangeCh2.setSelection(rangesAdapter.getPosition("+/-16V"), true);
8986
spinnerChannelSelect.setAdapter(channelsAdapter);
9087
spinnerChannelSelect.setSelection(channelsAdapter.getPosition("CH1"), true);
91-
spinnerMICSelect.setAdapter(new NothingSelectedSpinnerAdapter(micsAdapter,
92-
R.layout.nothing_selected_spinner_row,
93-
getActivity()));
9488

9589
spinnerRangeCh1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
9690
@Override
@@ -220,31 +214,6 @@ public void onNothingSelected(AdapterView<?> parent) {
220214
}
221215
});
222216

223-
spinnerMICSelect.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
224-
@Override
225-
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
226-
micSelectedPosition = position;
227-
if (position == 1) {
228-
((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = false;
229-
if (checkBoxMIC.isChecked()) {
230-
((OscilloscopeActivity) getActivity()).isMICSelected = true;
231-
((OscilloscopeActivity) getActivity()).isAudioInputSelected = true;
232-
}
233-
} else {
234-
((OscilloscopeActivity) getActivity()).isMICSelected = false;
235-
if (checkBoxMIC.isChecked()) {
236-
((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = true;
237-
((OscilloscopeActivity) getActivity()).isAudioInputSelected = true;
238-
}
239-
}
240-
}
241-
242-
@Override
243-
public void onNothingSelected(AdapterView<?> parent) {
244-
245-
}
246-
});
247-
248217
checkBoxCH1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
249218
@Override
250219
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -265,29 +234,37 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
265234
((OscilloscopeActivity) getActivity()).isCH3Selected = isChecked;
266235
}
267236
});
268-
checkBoxMIC.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
237+
builtInMicCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
269238
@Override
270239
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
271-
if (micSelectedPosition == 1) {
272-
((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked;
273-
((OscilloscopeActivity) getActivity()).isMICSelected = isChecked;
274-
} else if (micSelectedPosition == 2) {
275-
((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked;
276-
// check for RECORD_AUDIO permission if has then change boolean
277-
if (isChecked)
278-
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
279-
requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, RECORD_AUDIO_REQUEST_CODE);
280-
} else {
281-
((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = true;
282-
}
283-
else
284-
((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = false;
285-
} else {
286-
((OscilloscopeActivity) getActivity()).isAudioInputSelected = false;
240+
((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = isChecked;
241+
((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked;
242+
((OscilloscopeActivity) getActivity()).isMICSelected = !isChecked;
243+
if (isChecked) {
244+
pslabMicCheckBox.setChecked(false);
245+
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
246+
requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, RECORD_AUDIO_REQUEST_CODE);
247+
((OscilloscopeActivity) getActivity()).isAudioInputSelected = false;
248+
}
287249
}
288250
}
289251
});
290252

253+
pslabMicCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
254+
@Override
255+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
256+
((OscilloscopeActivity) getActivity()).isMICSelected = isChecked;
257+
((OscilloscopeActivity) getActivity()).isAudioInputSelected = isChecked;
258+
((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = !isChecked;
259+
if (isChecked) {
260+
builtInMicCheckBox.setChecked(false);
261+
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
262+
requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, RECORD_AUDIO_REQUEST_CODE);
263+
((OscilloscopeActivity) getActivity()).isAudioInputSelected = false;
264+
}
265+
}
266+
}
267+
});
291268
return v;
292269
}
293270

@@ -298,8 +275,8 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
298275
((OscilloscopeActivity) getActivity()).isInBuiltMicSelected = true;
299276
} else {
300277
Toast.makeText(getActivity(), "This feature won't work.", Toast.LENGTH_SHORT).show();
301-
if (checkBoxMIC.isChecked())
302-
checkBoxMIC.toggle();
278+
if (builtInMicCheckBox.isChecked())
279+
builtInMicCheckBox.toggle();
303280
}
304281
}
305282
}
Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent"
76
android:orientation="vertical">
@@ -10,8 +9,8 @@
109
android:id="@+id/checkBox_ch1_cp"
1110
android:layout_width="wrap_content"
1211
android:layout_height="wrap_content"
13-
android:layout_marginLeft="16dp"
1412
android:layout_marginStart="16dp"
13+
android:layout_marginLeft="16dp"
1514
android:layout_marginTop="16dp"
1615
android:text="@string/label_ch1"
1716
android:textSize="18sp"
@@ -23,9 +22,9 @@
2322
android:id="@+id/checkBox_ch2_cp"
2423
android:layout_width="wrap_content"
2524
android:layout_height="wrap_content"
26-
android:layout_marginBottom="16dp"
27-
android:layout_marginLeft="16dp"
2825
android:layout_marginStart="16dp"
26+
android:layout_marginLeft="16dp"
27+
android:layout_marginBottom="16dp"
2928
android:text="@string/label_ch2"
3029
android:textSize="18sp"
3130
android:textStyle="normal|bold"
@@ -36,9 +35,9 @@
3635
android:id="@+id/checkBox_ch3_cp"
3736
android:layout_width="wrap_content"
3837
android:layout_height="wrap_content"
38+
android:layout_marginTop="16dp"
3939
android:layout_marginEnd="16dp"
4040
android:layout_marginRight="16dp"
41-
android:layout_marginTop="16dp"
4241
android:text="@string/ch3_value"
4342
android:textSize="18sp"
4443
android:textStyle="normal|bold"
@@ -49,8 +48,8 @@
4948
android:id="@+id/tv_range1_cp"
5049
android:layout_width="wrap_content"
5150
android:layout_height="32dp"
52-
android:layout_marginLeft="16dp"
5351
android:layout_marginStart="16dp"
52+
android:layout_marginLeft="16dp"
5453
android:layout_marginTop="16dp"
5554
android:gravity="center_vertical"
5655
android:text="@string/range"
@@ -63,9 +62,9 @@
6362
android:id="@+id/tv_range2_cp"
6463
android:layout_width="wrap_content"
6564
android:layout_height="32dp"
66-
android:layout_marginBottom="16dp"
67-
android:layout_marginLeft="16dp"
6865
android:layout_marginStart="16dp"
66+
android:layout_marginLeft="16dp"
67+
android:layout_marginBottom="16dp"
6968
android:gravity="fill_vertical"
7069
android:text="@string/range"
7170
android:textColor="@color/cardview_dark_background"
@@ -77,18 +76,18 @@
7776
android:id="@+id/spinner_range_ch2_cp"
7877
android:layout_width="wrap_content"
7978
android:layout_height="48dp"
80-
android:layout_marginBottom="8dp"
81-
android:layout_marginLeft="16dp"
8279
android:layout_marginStart="16dp"
80+
android:layout_marginLeft="16dp"
81+
android:layout_marginBottom="8dp"
8382
app:layout_constraintBottom_toBottomOf="parent"
8483
app:layout_constraintLeft_toRightOf="@+id/tv_range2_cp" />
8584

8685
<Spinner
8786
android:id="@+id/spinner_channel_select_cp"
8887
android:layout_width="wrap_content"
8988
android:layout_height="48dp"
90-
android:layout_marginLeft="16dp"
9189
android:layout_marginStart="16dp"
90+
android:layout_marginLeft="16dp"
9291
android:layout_marginTop="8dp"
9392
app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch1_cp"
9493
app:layout_constraintTop_toTopOf="parent" />
@@ -97,8 +96,8 @@
9796
android:id="@+id/spinner_range_ch1_cp"
9897
android:layout_width="wrap_content"
9998
android:layout_height="48dp"
100-
android:layout_marginLeft="16dp"
10199
android:layout_marginStart="16dp"
100+
android:layout_marginLeft="16dp"
102101
android:layout_marginTop="8dp"
103102
app:layout_constraintLeft_toRightOf="@+id/tv_range1_cp"
104103
app:layout_constraintTop_toTopOf="parent" />
@@ -108,7 +107,6 @@
108107
android:layout_width="wrap_content"
109108
android:layout_height="wrap_content"
110109
android:layout_marginBottom="24dp"
111-
android:layout_marginLeft="16dp"
112110
android:layout_marginStart="16dp"
113111
android:clickable="true"
114112
android:text="@string/label_ch2"
@@ -117,22 +115,27 @@
117115
app:layout_constraintBottom_toBottomOf="parent"
118116
app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch2_cp" />
119117

120-
<CheckBox
121-
android:layout_width="wrap_content"
122-
android:layout_height="wrap_content"
123-
android:id="@+id/checkBox_mic_cp"
124-
app:layout_constraintLeft_toLeftOf="@+id/checkBox_ch3_cp"
125-
app:layout_constraintBottom_toBottomOf="parent"
126-
android:layout_marginBottom="16dp" />
127-
128-
<Spinner
129-
android:layout_width="0dp"
130-
android:layout_height="48dp"
131-
android:id="@+id/spinner_mic_select_cp"
132-
app:layout_constraintLeft_toRightOf="@+id/checkBox_mic_cp"
133-
app:layout_constraintBottom_toBottomOf="parent"
134-
android:layout_marginBottom="8dp" />
135-
118+
<CheckBox
119+
android:id="@+id/built_in_mic_cb"
120+
android:layout_width="wrap_content"
121+
android:layout_height="wrap_content"
122+
android:text="@string/built_in_mic_option"
123+
android:textSize="18sp"
124+
android:textStyle="normal|bold"
125+
app:layout_constraintBottom_toBottomOf="parent"
126+
app:layout_constraintRight_toLeftOf="@id/pslab_mic_cb"
127+
android:layout_marginEnd="10dp"
128+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"/>
136129

130+
<CheckBox
131+
android:id="@+id/pslab_mic_cb"
132+
android:layout_width="wrap_content"
133+
android:layout_height="wrap_content"
134+
android:text="@string/pslab_mic_option"
135+
android:textSize="18sp"
136+
android:textStyle="normal|bold"
137+
app:layout_constraintBottom_toBottomOf="parent"
138+
app:layout_constraintRight_toRightOf="parent"
139+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"/>
137140

138141
</android.support.constraint.ConstraintLayout>

app/src/main/res/layout/fragment_channel_parameters.xml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,47 @@
100100
android:layout_width="wrap_content"
101101
android:layout_height="wrap_content"
102102
android:layout_marginBottom="16dp"
103-
android:layout_marginLeft="16dp"
104-
android:layout_marginStart="16dp"
105103
android:clickable="true"
106104
android:text="@string/ch2"
107-
105+
android:layout_marginStart="8dp"
108106
android:textColor="@android:color/background_dark"
109107
app:layout_constraintBottom_toBottomOf="parent"
110108
app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch2_cp" />
111109

112-
<CheckBox
110+
<RadioGroup
111+
android:id="@+id/mic_radio_group"
113112
android:layout_width="wrap_content"
114113
android:layout_height="wrap_content"
115-
android:id="@+id/checkBox_mic_cp"
116-
app:layout_constraintLeft_toLeftOf="@+id/checkBox_ch3_cp"
117114
app:layout_constraintBottom_toBottomOf="parent"
118-
android:layout_marginBottom="8dp" />
115+
app:layout_constraintEnd_toEndOf="parent"
116+
android:orientation="horizontal"
117+
android:layout_marginEnd="20dp">
118+
119+
<CheckBox
120+
android:id="@+id/built_in_mic_cb"
121+
android:layout_width="wrap_content"
122+
android:layout_height="wrap_content"
123+
android:text="@string/built_in_mic_option"
124+
android:textStyle="normal|bold"
125+
app:layout_constraintBottom_toBottomOf="parent"
126+
app:layout_constraintRight_toLeftOf="@id/pslab_mic_cb"
127+
android:layout_marginEnd="10dp"
128+
android:layout_marginBottom="8dp"
129+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"/>
130+
131+
<CheckBox
132+
android:id="@+id/pslab_mic_cb"
133+
android:layout_width="wrap_content"
134+
android:layout_height="wrap_content"
135+
android:text="@string/pslab_mic_option"
136+
android:textStyle="normal|bold"
137+
app:layout_constraintBottom_toBottomOf="parent"
138+
app:layout_constraintRight_toRightOf="parent"
139+
android:layout_marginBottom="8dp"
140+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"/>
141+
142+
</RadioGroup>
119143

120-
<Spinner
121-
android:layout_width="0dp"
122-
android:layout_height="48dp"
123-
android:id="@+id/spinner_mic_select_cp"
124-
app:layout_constraintLeft_toRightOf="@+id/checkBox_mic_cp"
125-
app:layout_constraintBottom_toBottomOf="parent" />
126144

127145

128146
</android.support.constraint.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@
682682
<string name="duty_holder_text">50 %</string>
683683
<string name="open_instrument">Open instrument</string>
684684

685+
<string name="built_in_mic_option">In-Built MIC</string>
686+
<string name="pslab_mic_option">PSLab MIC</string>
685687
<string name="sine">Sine</string>
686688
<string name="triangular">Triangular</string>
687689
<string name="square">Square</string>

0 commit comments

Comments
 (0)