5252import io .pslab .fragment .HomeFragment ;
5353import io .pslab .fragment .InstrumentsFragment ;
5454import io .pslab .fragment .PSLabPinLayoutFragment ;
55+ import io .pslab .fragment .PSLabPinLayoutFragment_v6 ;
5556import io .pslab .others .CustomSnackBar ;
5657import io .pslab .others .CustomTabService ;
5758import io .pslab .others .InitializationVariable ;
@@ -86,6 +87,7 @@ public class MainActivity extends AppCompatActivity {
8687 private static final String TAG_INSTRUMENTS = "instruments" ;
8788 private static final String TAG_ABOUTUS = "aboutUs" ;
8889 private static final String TAG_PINLAYOUT = "pinLayout" ;
90+ private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6" ;
8991 private static final String TAG_FAQ = "faq" ;
9092 private static String CURRENT_TAG = TAG_INSTRUMENTS ;
9193 private String [] activityTitles ;
@@ -337,6 +339,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
337339 OssLicensesMenuActivity .setActivityTitle (getString (R .string .third_party_libs ));
338340 startActivity (new Intent (MainActivity .this , OssLicensesMenuActivity .class ));
339341 break ;
342+
340343 default :
341344 navItemIndex = 0 ;
342345 }
@@ -429,14 +432,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
429432 case R .id .menu_pslab_disconnected :
430433 attemptToConnectPSLab ();
431434 break ;
432- case R .id .menu_pslab_layout_front :
435+ case R .id .menu_pslab_layout_front_v5 :
433436 PSLabPinLayoutFragment .frontSide = true ;
434- displayPSLabPinLayout ();
437+ displayPSLabPinLayout (TAG_PINLAYOUT );
435438 break ;
436- case R .id .menu_pslab_layout_back :
439+ case R .id .menu_pslab_layout_back_v5 :
437440 PSLabPinLayoutFragment .frontSide = false ;
438- displayPSLabPinLayout ();
441+ displayPSLabPinLayout (TAG_PINLAYOUT );
442+ break ;
443+ case R .id .menu_pslab_layout_front_v6 :
444+ PSLabPinLayoutFragment_v6 .topside =true ;
445+ displayPSLabPinLayout (TAG_PINLAYOUT_V6 );
446+ break ;
447+ case R .id .menu_pslab_layout_back_v6 :
448+ PSLabPinLayoutFragment_v6 .topside =false ;
449+ displayPSLabPinLayout (TAG_PINLAYOUT_V6 );
439450 break ;
451+
440452 default :
441453 break ;
442454 }
@@ -465,20 +477,36 @@ private void attemptToConnectPSLab() {
465477 }
466478 }
467479
468- private void displayPSLabPinLayout () {
469- CURRENT_TAG = TAG_PINLAYOUT ;
480+ private void displayPSLabPinLayout (String fragmentTag ) {
481+ CURRENT_TAG = fragmentTag ;
470482 navigationView .getMenu ().getItem (navItemIndex ).setChecked (false );
471- setToolbarTitle (getResources ().getString (R .string .pslab_pinlayout ));
483+
484+ // Set toolbar title based on the fragment tag
485+ if (fragmentTag .equals (TAG_PINLAYOUT )) {
486+ setToolbarTitle (getResources ().getString (R .string .pslab_pinlayout ));
487+ } else if (fragmentTag .equals (TAG_PINLAYOUT_V6 )) {
488+ setToolbarTitle (getResources ().getString (R .string .pslab_pinlayout_v6 ));
489+ }
490+
472491 Runnable mPendingRunnable = new Runnable () {
473492 @ Override
474493 public void run () {
475- Fragment fragment = PSLabPinLayoutFragment .newInstance ();
494+ Fragment fragment ;
495+ if (fragmentTag .equals (TAG_PINLAYOUT )) {
496+ fragment = PSLabPinLayoutFragment .newInstance ();
497+ } else if (fragmentTag .equals (TAG_PINLAYOUT_V6 )) {
498+ fragment = PSLabPinLayoutFragment_v6 .newInstance ();
499+ } else {
500+ return ; // Exit if no valid tag is provided
501+ }
502+
476503 FragmentTransaction fragmentTransaction = getSupportFragmentManager ().beginTransaction ();
477504 fragmentTransaction .setCustomAnimations (R .anim .fade_in , R .anim .fade_out )
478- .replace (R .id .frame , fragment , TAG_PINLAYOUT )
505+ .replace (R .id .frame , fragment , fragmentTag )
479506 .commitAllowingStateLoss ();
480507 }
481508 };
509+
482510 mHandler .post (mPendingRunnable );
483511 }
484512
@@ -561,7 +589,6 @@ public void onReceive(Context context, Intent intent) {
561589 }
562590 }
563591 };
564-
565592 @ Override
566593 protected void onNewIntent (Intent intent ) {
567594 super .onNewIntent (intent );
@@ -582,7 +609,6 @@ protected void onNewIntent(Intent intent) {
582609 }
583610 }
584611 }
585-
586612 @ Override
587613 protected void onPostResume () {
588614 super .onPostResume ();
0 commit comments