Skip to content

Commit 99ed3e5

Browse files
committed
oscilloscope layout changes
1 parent 4e89f60 commit 99ed3e5

File tree

9 files changed

+97
-126
lines changed

9 files changed

+97
-126
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
}

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

Lines changed: 21 additions & 26 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,7 +9,6 @@
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"
1513
android:layout_marginTop="16dp"
1614
android:text="@string/label_ch1"
@@ -24,7 +22,6 @@
2422
android:layout_width="wrap_content"
2523
android:layout_height="wrap_content"
2624
android:layout_marginBottom="16dp"
27-
android:layout_marginLeft="16dp"
2825
android:layout_marginStart="16dp"
2926
android:text="@string/label_ch2"
3027
android:textSize="18sp"
@@ -37,7 +34,6 @@
3734
android:layout_width="wrap_content"
3835
android:layout_height="wrap_content"
3936
android:layout_marginEnd="16dp"
40-
android:layout_marginRight="16dp"
4137
android:layout_marginTop="16dp"
4238
android:text="@string/ch3_value"
4339
android:textSize="18sp"
@@ -49,7 +45,6 @@
4945
android:id="@+id/tv_range1_cp"
5046
android:layout_width="wrap_content"
5147
android:layout_height="32dp"
52-
android:layout_marginLeft="16dp"
5348
android:layout_marginStart="16dp"
5449
android:layout_marginTop="16dp"
5550
android:gravity="center_vertical"
@@ -64,7 +59,6 @@
6459
android:layout_width="wrap_content"
6560
android:layout_height="32dp"
6661
android:layout_marginBottom="16dp"
67-
android:layout_marginLeft="16dp"
6862
android:layout_marginStart="16dp"
6963
android:gravity="fill_vertical"
7064
android:text="@string/range"
@@ -78,7 +72,6 @@
7872
android:layout_width="wrap_content"
7973
android:layout_height="48dp"
8074
android:layout_marginBottom="8dp"
81-
android:layout_marginLeft="16dp"
8275
android:layout_marginStart="16dp"
8376
app:layout_constraintBottom_toBottomOf="parent"
8477
app:layout_constraintLeft_toRightOf="@+id/tv_range2_cp" />
@@ -87,7 +80,6 @@
8780
android:id="@+id/spinner_channel_select_cp"
8881
android:layout_width="wrap_content"
8982
android:layout_height="48dp"
90-
android:layout_marginLeft="16dp"
9183
android:layout_marginStart="16dp"
9284
android:layout_marginTop="8dp"
9385
app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch1_cp"
@@ -97,7 +89,6 @@
9789
android:id="@+id/spinner_range_ch1_cp"
9890
android:layout_width="wrap_content"
9991
android:layout_height="48dp"
100-
android:layout_marginLeft="16dp"
10192
android:layout_marginStart="16dp"
10293
android:layout_marginTop="8dp"
10394
app:layout_constraintLeft_toRightOf="@+id/tv_range1_cp"
@@ -108,7 +99,6 @@
10899
android:layout_width="wrap_content"
109100
android:layout_height="wrap_content"
110101
android:layout_marginBottom="24dp"
111-
android:layout_marginLeft="16dp"
112102
android:layout_marginStart="16dp"
113103
android:clickable="true"
114104
android:text="@string/label_ch2"
@@ -117,22 +107,27 @@
117107
app:layout_constraintBottom_toBottomOf="parent"
118108
app:layout_constraintLeft_toRightOf="@+id/spinner_range_ch2_cp" />
119109

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-
110+
<CheckBox
111+
android:id="@+id/built_in_mic_cb"
112+
android:layout_width="wrap_content"
113+
android:layout_height="wrap_content"
114+
android:text="@string/built_in_mic_option"
115+
android:textSize="18sp"
116+
android:textStyle="normal|bold"
117+
app:layout_constraintBottom_toBottomOf="parent"
118+
app:layout_constraintRight_toLeftOf="@id/pslab_mic_cb"
119+
android:layout_marginEnd="10dp"
120+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"/>
136121

122+
<CheckBox
123+
android:id="@+id/pslab_mic_cb"
124+
android:layout_width="wrap_content"
125+
android:layout_height="wrap_content"
126+
android:text="@string/pslab_mic_option"
127+
android:textSize="18sp"
128+
android:textStyle="normal|bold"
129+
app:layout_constraintBottom_toBottomOf="parent"
130+
app:layout_constraintRight_toRightOf="parent"
131+
style="@style/Base.Widget.AppCompat.CompoundButton.RadioButton"/>
137132

138133
</android.support.constraint.ConstraintLayout>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
<RelativeLayout
1717
android:layout_width="match_parent"
1818
android:layout_height="match_parent"
19-
android:layout_below="@id/top_app_bar_layout">
19+
android:layout_below="@id/top_app_bar_layout"
20+
android:layout_marginTop="@dimen/osc_main_margin"
21+
android:layout_marginStart="@dimen/osc_main_margin">
2022

2123
<RelativeLayout
2224
android:id="@+id/layout_chart_os"
2325
android:layout_width="@dimen/osc_chart_width"
24-
android:layout_height="@dimen/osc_chart_height">
26+
android:layout_height="@dimen/osc_chart_height"
27+
android:layout_marginEnd="@dimen/osc_main_margin">
2528

2629
<com.github.mikephil.charting.charts.LineChart
2730
android:id="@+id/chart_os"
@@ -306,11 +309,8 @@
306309
android:layout_height="match_parent"
307310
android:layout_below="@+id/layout_chart_os"
308311
android:layout_alignParentStart="true"
309-
android:layout_alignParentLeft="true"
310-
android:layout_marginStart="@dimen/length_0dp"
311-
android:layout_marginLeft="@dimen/length_0dp"
312-
android:layout_toStartOf="@+id/layout_dock_os1"
313-
android:layout_toLeftOf="@+id/layout_dock_os1">
312+
android:layout_margin="@dimen/osc_main_margin"
313+
android:layout_toStartOf="@+id/layout_dock_os1">
314314

315315
</FrameLayout>
316316
</RelativeLayout>

0 commit comments

Comments
 (0)