52
52
import io .pslab .fragment .HomeFragment ;
53
53
import io .pslab .fragment .InstrumentsFragment ;
54
54
import io .pslab .fragment .PSLabPinLayoutFragment ;
55
+ import io .pslab .fragment .PSLabPinLayoutFragment_v6 ;
55
56
import io .pslab .others .CustomSnackBar ;
56
57
import io .pslab .others .CustomTabService ;
57
58
import io .pslab .others .InitializationVariable ;
@@ -86,6 +87,7 @@ public class MainActivity extends AppCompatActivity {
86
87
private static final String TAG_INSTRUMENTS = "instruments" ;
87
88
private static final String TAG_ABOUTUS = "aboutUs" ;
88
89
private static final String TAG_PINLAYOUT = "pinLayout" ;
90
+ private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6" ;
89
91
private static final String TAG_FAQ = "faq" ;
90
92
private static String CURRENT_TAG = TAG_INSTRUMENTS ;
91
93
private String [] activityTitles ;
@@ -337,6 +339,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
337
339
OssLicensesMenuActivity .setActivityTitle (getString (R .string .third_party_libs ));
338
340
startActivity (new Intent (MainActivity .this , OssLicensesMenuActivity .class ));
339
341
break ;
342
+
340
343
default :
341
344
navItemIndex = 0 ;
342
345
}
@@ -429,14 +432,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
429
432
case R .id .menu_pslab_disconnected :
430
433
attemptToConnectPSLab ();
431
434
break ;
432
- case R .id .menu_pslab_layout_front :
435
+ case R .id .menu_pslab_layout_front_v5 :
433
436
PSLabPinLayoutFragment .frontSide = true ;
434
- displayPSLabPinLayout ();
437
+ displayPSLabPinLayout (TAG_PINLAYOUT );
435
438
break ;
436
- case R .id .menu_pslab_layout_back :
439
+ case R .id .menu_pslab_layout_back_v5 :
437
440
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 );
439
450
break ;
451
+
440
452
default :
441
453
break ;
442
454
}
@@ -465,20 +477,36 @@ private void attemptToConnectPSLab() {
465
477
}
466
478
}
467
479
468
- private void displayPSLabPinLayout () {
469
- CURRENT_TAG = TAG_PINLAYOUT ;
480
+ private void displayPSLabPinLayout (String fragmentTag ) {
481
+ CURRENT_TAG = fragmentTag ;
470
482
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
+
472
491
Runnable mPendingRunnable = new Runnable () {
473
492
@ Override
474
493
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
+
476
503
FragmentTransaction fragmentTransaction = getSupportFragmentManager ().beginTransaction ();
477
504
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 )
479
506
.commitAllowingStateLoss ();
480
507
}
481
508
};
509
+
482
510
mHandler .post (mPendingRunnable );
483
511
}
484
512
@@ -561,7 +589,6 @@ public void onReceive(Context context, Intent intent) {
561
589
}
562
590
}
563
591
};
564
-
565
592
@ Override
566
593
protected void onNewIntent (Intent intent ) {
567
594
super .onNewIntent (intent );
@@ -582,7 +609,6 @@ protected void onNewIntent(Intent intent) {
582
609
}
583
610
}
584
611
}
585
-
586
612
@ Override
587
613
protected void onPostResume () {
588
614
super .onPostResume ();
0 commit comments