Skip to content

Commit 4336c8e

Browse files
neel1998makoteq
authored andcommitted
oscilloscope ui changes (fossasia#1955)
1 parent 66409f7 commit 4336c8e

File tree

9 files changed

+186
-191
lines changed

9 files changed

+186
-191
lines changed

app/src/main/java/io/pslab/activity/OscilloscopeActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,17 +764,17 @@ public void onWindowFocusChanged() {
764764
RelativeLayout.LayoutParams frameLayoutParams = (RelativeLayout.LayoutParams) frameLayout.getLayoutParams();
765765
if (getResources().getBoolean(R.bool.isTablet)) {
766766
lineChartParams.height = height * 3 / 4;
767-
lineChartParams.width = width * 7 / 8;
767+
lineChartParams.width = width * 9 / 10;
768768
mChartLayout.setLayoutParams(lineChartParams);
769769
frameLayoutParams.height = height / 4;
770-
frameLayoutParams.width = width * 7 / 8;
770+
frameLayoutParams.width = width * 9 / 10;
771771
frameLayout.setLayoutParams(frameLayoutParams);
772772
} else {
773773
lineChartParams.height = height * 3 / 5;
774-
lineChartParams.width = width * 5 / 6;
774+
lineChartParams.width = width * 7 / 8;
775775
mChartLayout.setLayoutParams(lineChartParams);
776776
frameLayoutParams.height = height * 2 / 5;
777-
frameLayoutParams.width = width * 5 / 6;
777+
frameLayoutParams.width = width * 7 / 8;
778778
frameLayout.setLayoutParams(frameLayoutParams);
779779
}
780780
}

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: 60 additions & 53 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,11 +9,10 @@
109
android:id="@+id/checkBox_ch1_cp"
1110
android:layout_width="wrap_content"
1211
android:layout_height="wrap_content"
13-
android:layout_marginLeft="16dp"
14-
android:layout_marginStart="16dp"
15-
android:layout_marginTop="16dp"
12+
android:layout_marginStart="@dimen/osc_cb_margin2"
13+
android:layout_marginTop="@dimen/osc_cb_margin2"
1614
android:text="@string/label_ch1"
17-
android:textSize="18sp"
15+
android:textSize="@dimen/osc_text_size_large"
1816
android:textStyle="normal|bold"
1917
app:layout_constraintLeft_toLeftOf="parent"
2018
app:layout_constraintTop_toTopOf="parent" />
@@ -23,11 +21,10 @@
2321
android:id="@+id/checkBox_ch2_cp"
2422
android:layout_width="wrap_content"
2523
android:layout_height="wrap_content"
26-
android:layout_marginBottom="16dp"
27-
android:layout_marginLeft="16dp"
28-
android:layout_marginStart="16dp"
24+
android:layout_marginBottom="@dimen/osc_cb_margin2"
25+
android:layout_marginStart="@dimen/osc_cb_margin2"
2926
android:text="@string/label_ch2"
30-
android:textSize="18sp"
27+
android:textSize="@dimen/osc_text_size_large"
3128
android:textStyle="normal|bold"
3229
app:layout_constraintBottom_toBottomOf="parent"
3330
app:layout_constraintLeft_toLeftOf="parent" />
@@ -36,103 +33,113 @@
3633
android:id="@+id/checkBox_ch3_cp"
3734
android:layout_width="wrap_content"
3835
android:layout_height="wrap_content"
39-
android:layout_marginEnd="16dp"
40-
android:layout_marginRight="16dp"
41-
android:layout_marginTop="16dp"
36+
android:layout_marginEnd="@dimen/osc_cb_margin2"
37+
android:layout_marginTop="@dimen/osc_cb_margin2"
4238
android:text="@string/ch3_value"
43-
android:textSize="18sp"
39+
android:textSize="@dimen/osc_text_size_large"
4440
android:textStyle="normal|bold"
45-
app:layout_constraintRight_toRightOf="parent"
41+
app:layout_constraintEnd_toStartOf="@id/mic_radio_group"
42+
app:layout_constraintStart_toEndOf="@id/spinner_channel_select_cp"
4643
app:layout_constraintTop_toTopOf="parent" />
4744

4845
<TextView
4946
android:id="@+id/tv_range1_cp"
5047
android:layout_width="wrap_content"
51-
android:layout_height="32dp"
52-
android:layout_marginLeft="16dp"
53-
android:layout_marginStart="16dp"
54-
android:layout_marginTop="16dp"
48+
android:layout_height="@dimen/osc_tv_height"
49+
android:layout_marginStart="@dimen/osc_cb_margin2"
50+
android:layout_marginTop="@dimen/osc_cb_margin2"
5551
android:gravity="center_vertical"
5652
android:text="@string/range"
5753
android:textColor="@color/cardview_dark_background"
58-
android:textSize="18sp"
54+
android:textSize="@dimen/osc_text_size_large"
5955
app:layout_constraintLeft_toRightOf="@+id/checkBox_ch1_cp"
6056
app:layout_constraintTop_toTopOf="parent" />
6157

6258
<TextView
6359
android:id="@+id/tv_range2_cp"
6460
android:layout_width="wrap_content"
65-
android:layout_height="32dp"
66-
android:layout_marginBottom="16dp"
67-
android:layout_marginLeft="16dp"
68-
android:layout_marginStart="16dp"
61+
android:layout_height="@dimen/osc_tv_height"
62+
android:layout_marginBottom="@dimen/osc_cb_margin2"
63+
android:layout_marginStart="@dimen/osc_cb_margin2"
6964
android:gravity="fill_vertical"
7065
android:text="@string/range"
7166
android:textColor="@color/cardview_dark_background"
72-
android:textSize="18sp"
67+
android:textSize="@dimen/osc_text_size_large"
7368
app:layout_constraintBottom_toBottomOf="parent"
7469
app:layout_constraintLeft_toRightOf="@+id/checkBox_ch2_cp" />
7570

7671
<Spinner
7772
android:id="@+id/spinner_range_ch2_cp"
7873
android:layout_width="wrap_content"
79-
android:layout_height="48dp"
80-
android:layout_marginBottom="8dp"
81-
android:layout_marginLeft="16dp"
82-
android:layout_marginStart="16dp"
74+
android:layout_height="@dimen/osc_spinner_height"
75+
android:layout_marginBottom="@dimen/osc_cb_margin"
76+
android:layout_marginStart="@dimen/osc_cb_margin2"
8377
app:layout_constraintBottom_toBottomOf="parent"
8478
app:layout_constraintLeft_toRightOf="@+id/tv_range2_cp" />
8579

8680
<Spinner
8781
android:id="@+id/spinner_channel_select_cp"
8882
android:layout_width="wrap_content"
89-
android:layout_height="48dp"
90-
android:layout_marginLeft="16dp"
91-
android:layout_marginStart="16dp"
92-
android:layout_marginTop="8dp"
83+
android:layout_height="@dimen/osc_spinner_height"
84+
android:layout_marginStart="@dimen/osc_cb_margin2"
85+
android:layout_marginTop="@dimen/osc_cb_margin"
9386
app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch1_cp"
9487
app:layout_constraintTop_toTopOf="parent" />
9588

9689
<Spinner
9790
android:id="@+id/spinner_range_ch1_cp"
9891
android:layout_width="wrap_content"
99-
android:layout_height="48dp"
100-
android:layout_marginLeft="16dp"
101-
android:layout_marginStart="16dp"
102-
android:layout_marginTop="8dp"
92+
android:layout_height="@dimen/osc_spinner_height"
93+
android:layout_marginStart="@dimen/osc_cb_margin2"
94+
android:layout_marginTop="@dimen/osc_cb_margin"
10395
app:layout_constraintLeft_toRightOf="@+id/tv_range1_cp"
10496
app:layout_constraintTop_toTopOf="parent" />
10597

10698
<TextView
10799
android:id="@+id/tv_ch2_cp"
108100
android:layout_width="wrap_content"
109101
android:layout_height="wrap_content"
110-
android:layout_marginBottom="24dp"
111-
android:layout_marginLeft="16dp"
112-
android:layout_marginStart="16dp"
102+
android:layout_marginBottom="@dimen/text_elevation"
103+
android:layout_marginStart="@dimen/osc_cb_margin2"
113104
android:clickable="true"
114105
android:text="@string/label_ch2"
115106
android:textColor="@android:color/background_dark"
116-
android:textSize="18sp"
107+
android:textSize="@dimen/osc_text_size_large"
117108
app:layout_constraintBottom_toBottomOf="parent"
118109
app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch2_cp" />
119110

120-
<CheckBox
111+
<RadioGroup
112+
android:id="@+id/mic_radio_group"
121113
android:layout_width="wrap_content"
122114
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" />
115+
android:layout_marginTop="@dimen/osc_cb_margin2"
116+
android:layout_marginEnd="@dimen/osc_cb_margin2"
117+
android:orientation="vertical"
118+
app:layout_constraintEnd_toEndOf="parent"
119+
app:layout_constraintTop_toTopOf="parent">
135120

121+
<CheckBox
122+
android:id="@+id/built_in_mic_cb"
123+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"
124+
android:layout_width="wrap_content"
125+
android:layout_height="wrap_content"
126+
android:layout_marginEnd="@dimen/osc_tv_margin"
127+
android:text="@string/built_in_mic_option"
128+
android:textSize="@dimen/osc_text_size_large"
129+
android:textStyle="normal|bold"
130+
app:layout_constraintBottom_toBottomOf="parent"
131+
app:layout_constraintRight_toLeftOf="@id/pslab_mic_cb" />
136132

133+
<CheckBox
134+
android:id="@+id/pslab_mic_cb"
135+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"
136+
android:layout_width="wrap_content"
137+
android:layout_height="wrap_content"
138+
android:text="@string/pslab_mic_option"
139+
android:textSize="@dimen/osc_text_size_large"
140+
android:textStyle="normal|bold"
141+
app:layout_constraintBottom_toBottomOf="parent"
142+
app:layout_constraintRight_toRightOf="parent" />
137143

144+
</RadioGroup>
138145
</android.support.constraint.ConstraintLayout>

0 commit comments

Comments
 (0)