Skip to content

Commit 503eb34

Browse files
Added a pin layout screens for PSLab v6.
1 parent ec28bb5 commit 503eb34

14 files changed

+658
-40
lines changed

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

+37-11
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import io.pslab.fragment.HomeFragment;
5151
import io.pslab.fragment.InstrumentsFragment;
5252
import io.pslab.fragment.PSLabPinLayoutFragment;
53+
import io.pslab.fragment.PSLabPinLayoutFragment_v6;
5354
import io.pslab.others.CustomSnackBar;
5455
import io.pslab.others.CustomTabService;
5556
import io.pslab.others.InitializationVariable;
@@ -83,6 +84,7 @@ public class MainActivity extends AppCompatActivity {
8384
private static final String TAG_INSTRUMENTS = "instruments";
8485
private static final String TAG_ABOUTUS = "aboutUs";
8586
private static final String TAG_PINLAYOUT = "pinLayout";
87+
private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6";
8688
private static final String TAG_FAQ = "faq";
8789
private static String CURRENT_TAG = TAG_INSTRUMENTS;
8890
private String[] activityTitles;
@@ -329,6 +331,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
329331
OssLicensesMenuActivity.setActivityTitle(getString(R.string.third_party_libs));
330332
startActivity(new Intent(MainActivity.this, OssLicensesMenuActivity.class));
331333
break;
334+
332335
default:
333336
navItemIndex = 0;
334337
}
@@ -421,14 +424,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
421424
case R.id.menu_pslab_disconnected:
422425
attemptToConnectPSLab();
423426
break;
424-
case R.id.menu_pslab_layout_front:
427+
case R.id.menu_pslab_layout_front_v5:
425428
PSLabPinLayoutFragment.frontSide = true;
426-
displayPSLabPinLayout();
429+
displayPSLabPinLayout(TAG_PINLAYOUT);
427430
break;
428-
case R.id.menu_pslab_layout_back:
431+
case R.id.menu_pslab_layout_back_v5:
429432
PSLabPinLayoutFragment.frontSide = false;
430-
displayPSLabPinLayout();
433+
displayPSLabPinLayout(TAG_PINLAYOUT);
434+
break;
435+
case R.id.menu_pslab_layout_front_v6:
436+
PSLabPinLayoutFragment_v6.topside=true;
437+
displayPSLabPinLayout(TAG_PINLAYOUT_V6);
438+
break;
439+
case R.id.menu_pslab_layout_back_v6:
440+
PSLabPinLayoutFragment_v6.topside=false;
441+
displayPSLabPinLayout(TAG_PINLAYOUT_V6);
431442
break;
443+
432444
default:
433445
break;
434446
}
@@ -457,20 +469,36 @@ private void attemptToConnectPSLab() {
457469
}
458470
}
459471

460-
private void displayPSLabPinLayout() {
461-
CURRENT_TAG = TAG_PINLAYOUT;
472+
private void displayPSLabPinLayout(String fragmentTag) {
473+
CURRENT_TAG = fragmentTag;
462474
navigationView.getMenu().getItem(navItemIndex).setChecked(false);
463-
setToolbarTitle(getResources().getString(R.string.pslab_pinlayout));
475+
476+
// Set toolbar title based on the fragment tag
477+
if (fragmentTag.equals(TAG_PINLAYOUT)) {
478+
setToolbarTitle(getResources().getString(R.string.pslab_pinlayout));
479+
} else if (fragmentTag.equals(TAG_PINLAYOUT_V6)) {
480+
setToolbarTitle(getResources().getString(R.string.pslab_pinlayout_v6));
481+
}
482+
464483
Runnable mPendingRunnable = new Runnable() {
465484
@Override
466485
public void run() {
467-
Fragment fragment = PSLabPinLayoutFragment.newInstance();
486+
Fragment fragment;
487+
if (fragmentTag.equals(TAG_PINLAYOUT)) {
488+
fragment = PSLabPinLayoutFragment.newInstance();
489+
} else if (fragmentTag.equals(TAG_PINLAYOUT_V6)) {
490+
fragment = PSLabPinLayoutFragment_v6.newInstance();
491+
} else {
492+
return; // Exit if no valid tag is provided
493+
}
494+
468495
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
469496
fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out)
470-
.replace(R.id.frame, fragment, TAG_PINLAYOUT)
497+
.replace(R.id.frame, fragment, fragmentTag)
471498
.commitAllowingStateLoss();
472499
}
473500
};
501+
474502
mHandler.post(mPendingRunnable);
475503
}
476504

@@ -552,7 +580,6 @@ public void onReceive(Context context, Intent intent) {
552580
}
553581
}
554582
};
555-
556583
@Override
557584
protected void onNewIntent(Intent intent) {
558585
super.onNewIntent(intent);
@@ -573,7 +600,6 @@ protected void onNewIntent(Intent intent) {
573600
}
574601
}
575602
}
576-
577603
@Override
578604
protected void onPostResume() {
579605
super.onPostResume();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,4 @@ private void midPoint(PointF point, MotionEvent event) {
247247
} catch (Exception e) {/**/}
248248
point.set(x / 2, y / 2);
249249
}
250-
}
250+
}

0 commit comments

Comments
 (0)