50
50
import io .pslab .fragment .HomeFragment ;
51
51
import io .pslab .fragment .InstrumentsFragment ;
52
52
import io .pslab .fragment .PSLabPinLayoutFragment ;
53
+ import io .pslab .fragment .PSLabPinLayoutFragment_v6 ;
53
54
import io .pslab .others .CustomSnackBar ;
54
55
import io .pslab .others .CustomTabService ;
55
56
import io .pslab .others .InitializationVariable ;
@@ -83,6 +84,7 @@ public class MainActivity extends AppCompatActivity {
83
84
private static final String TAG_INSTRUMENTS = "instruments" ;
84
85
private static final String TAG_ABOUTUS = "aboutUs" ;
85
86
private static final String TAG_PINLAYOUT = "pinLayout" ;
87
+ private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6" ;
86
88
private static final String TAG_FAQ = "faq" ;
87
89
private static String CURRENT_TAG = TAG_INSTRUMENTS ;
88
90
private String [] activityTitles ;
@@ -329,6 +331,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
329
331
OssLicensesMenuActivity .setActivityTitle (getString (R .string .third_party_libs ));
330
332
startActivity (new Intent (MainActivity .this , OssLicensesMenuActivity .class ));
331
333
break ;
334
+
332
335
default :
333
336
navItemIndex = 0 ;
334
337
}
@@ -421,14 +424,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
421
424
case R .id .menu_pslab_disconnected :
422
425
attemptToConnectPSLab ();
423
426
break ;
424
- case R .id .menu_pslab_layout_front :
427
+ case R .id .menu_pslab_layout_front_v5 :
425
428
PSLabPinLayoutFragment .frontSide = true ;
426
- displayPSLabPinLayout ();
429
+ displayPSLabPinLayout (TAG_PINLAYOUT );
427
430
break ;
428
- case R .id .menu_pslab_layout_back :
431
+ case R .id .menu_pslab_layout_back_v5 :
429
432
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 );
431
442
break ;
443
+
432
444
default :
433
445
break ;
434
446
}
@@ -457,20 +469,36 @@ private void attemptToConnectPSLab() {
457
469
}
458
470
}
459
471
460
- private void displayPSLabPinLayout () {
461
- CURRENT_TAG = TAG_PINLAYOUT ;
472
+ private void displayPSLabPinLayout (String fragmentTag ) {
473
+ CURRENT_TAG = fragmentTag ;
462
474
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
+
464
483
Runnable mPendingRunnable = new Runnable () {
465
484
@ Override
466
485
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
+
468
495
FragmentTransaction fragmentTransaction = getSupportFragmentManager ().beginTransaction ();
469
496
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 )
471
498
.commitAllowingStateLoss ();
472
499
}
473
500
};
501
+
474
502
mHandler .post (mPendingRunnable );
475
503
}
476
504
@@ -552,7 +580,6 @@ public void onReceive(Context context, Intent intent) {
552
580
}
553
581
}
554
582
};
555
-
556
583
@ Override
557
584
protected void onNewIntent (Intent intent ) {
558
585
super .onNewIntent (intent );
@@ -573,7 +600,6 @@ protected void onNewIntent(Intent intent) {
573
600
}
574
601
}
575
602
}
576
-
577
603
@ Override
578
604
protected void onPostResume () {
579
605
super .onPostResume ();
0 commit comments