Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a pin layout screens for PSLab v6.
  • Loading branch information
samruddhi-Rahegaonkar authored and AsCress committed Feb 6, 2025
1 parent 6e94f1b commit acfd78d
Show file tree
Hide file tree
Showing 14 changed files with 658 additions and 40 deletions.
48 changes: 37 additions & 11 deletions app/src/main/java/io/pslab/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import io.pslab.fragment.HomeFragment;
import io.pslab.fragment.InstrumentsFragment;
import io.pslab.fragment.PSLabPinLayoutFragment;
import io.pslab.fragment.PSLabPinLayoutFragment_v6;
import io.pslab.others.CustomSnackBar;
import io.pslab.others.CustomTabService;
import io.pslab.others.InitializationVariable;
Expand Down Expand Up @@ -86,6 +87,7 @@ public class MainActivity extends AppCompatActivity {
private static final String TAG_INSTRUMENTS = "instruments";
private static final String TAG_ABOUTUS = "aboutUs";
private static final String TAG_PINLAYOUT = "pinLayout";
private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6";
private static final String TAG_FAQ = "faq";
private static String CURRENT_TAG = TAG_INSTRUMENTS;
private String[] activityTitles;
Expand Down Expand Up @@ -337,6 +339,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
OssLicensesMenuActivity.setActivityTitle(getString(R.string.third_party_libs));
startActivity(new Intent(MainActivity.this, OssLicensesMenuActivity.class));
break;

default:
navItemIndex = 0;
}
Expand Down Expand Up @@ -429,14 +432,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.menu_pslab_disconnected:
attemptToConnectPSLab();
break;
case R.id.menu_pslab_layout_front:
case R.id.menu_pslab_layout_front_v5:
PSLabPinLayoutFragment.frontSide = true;
displayPSLabPinLayout();
displayPSLabPinLayout(TAG_PINLAYOUT);
break;
case R.id.menu_pslab_layout_back:
case R.id.menu_pslab_layout_back_v5:
PSLabPinLayoutFragment.frontSide = false;
displayPSLabPinLayout();
displayPSLabPinLayout(TAG_PINLAYOUT);
break;
case R.id.menu_pslab_layout_front_v6:
PSLabPinLayoutFragment_v6.topside=true;
displayPSLabPinLayout(TAG_PINLAYOUT_V6);
break;
case R.id.menu_pslab_layout_back_v6:
PSLabPinLayoutFragment_v6.topside=false;
displayPSLabPinLayout(TAG_PINLAYOUT_V6);
break;

default:
break;
}
Expand Down Expand Up @@ -465,20 +477,36 @@ private void attemptToConnectPSLab() {
}
}

private void displayPSLabPinLayout() {
CURRENT_TAG = TAG_PINLAYOUT;
private void displayPSLabPinLayout(String fragmentTag) {
CURRENT_TAG = fragmentTag;
navigationView.getMenu().getItem(navItemIndex).setChecked(false);
setToolbarTitle(getResources().getString(R.string.pslab_pinlayout));

// Set toolbar title based on the fragment tag
if (fragmentTag.equals(TAG_PINLAYOUT)) {
setToolbarTitle(getResources().getString(R.string.pslab_pinlayout));
} else if (fragmentTag.equals(TAG_PINLAYOUT_V6)) {
setToolbarTitle(getResources().getString(R.string.pslab_pinlayout_v6));
}

Runnable mPendingRunnable = new Runnable() {
@Override
public void run() {
Fragment fragment = PSLabPinLayoutFragment.newInstance();
Fragment fragment;
if (fragmentTag.equals(TAG_PINLAYOUT)) {
fragment = PSLabPinLayoutFragment.newInstance();
} else if (fragmentTag.equals(TAG_PINLAYOUT_V6)) {
fragment = PSLabPinLayoutFragment_v6.newInstance();
} else {
return; // Exit if no valid tag is provided
}

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out)
.replace(R.id.frame, fragment, TAG_PINLAYOUT)
.replace(R.id.frame, fragment, fragmentTag)
.commitAllowingStateLoss();
}
};

mHandler.post(mPendingRunnable);
}

Expand Down Expand Up @@ -561,7 +589,6 @@ public void onReceive(Context context, Intent intent) {
}
}
};

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Expand All @@ -582,7 +609,6 @@ protected void onNewIntent(Intent intent) {
}
}
}

@Override
protected void onPostResume() {
super.onPostResume();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@ private void midPoint(PointF point, MotionEvent event) {
} catch (Exception e) {/**/}
point.set(x / 2, y / 2);
}
}
}
Loading

0 comments on commit acfd78d

Please sign in to comment.