Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added pin layout screens for PSLab v6 #2625

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final String TAG_PINLAYOUT_V6 = "PINLAYOUTV6";
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() {
AsCress marked this conversation as resolved.
Show resolved Hide resolved
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) {
}
}
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file MainActivity.java has formatting issues. Kindly reformat the whole file as we have discussed earlier as well (Ctrl + A, Ctrl + Alt + L)

@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
Loading