Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/xingyiz/Trackie into main
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldd98 committed Apr 22, 2021
2 parents 1f2ac17 + 551b392 commit f3dec7c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static android.os.SystemClock.sleep;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.longClick;
import static androidx.test.espresso.action.ViewActions.swipeLeft;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.assertThat;
Expand Down Expand Up @@ -101,6 +102,12 @@ public void clickOptions() throws Exception{

}

@Test
public void testDelete() throws Exception{
holdLoc(0);
onView(withText("Confirm Delete?")).check(matches(isDisplayed()));
}

private void setLoc(int i) {
onView(withId(R.id.locations_recycler_view))
.perform(RecyclerViewActions.actionOnItemAtPosition(i, click()));
Expand All @@ -123,6 +130,12 @@ private void clickOptionButton(int i) {

}

private void holdLoc(int i) {
onView(withId(R.id.locations_recycler_view))
.perform(RecyclerViewActions.actionOnItemAtPosition(i, longClick()));

}

private void navigateToScreen() {
TestingUtils.openDrawer();
onView(withId(R.id.nav_locations))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static void setTEST_B2L2(Context context, boolean isTESTB2L2) {

public static String getModelType(Context context) {
if (preferences == null) intializeSharedPref(context);
return preferences.getString(MODEL_TYPE_KEY, null);
return preferences.getString(MODEL_TYPE_KEY, "clf");
}

public static void setModelType(Context context, String model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import com.example.trackie.ui.Prefs;

public class SettingsFragment extends Fragment {

Context context;

boolean buttonState;

private SettingsViewModel settingsViewModel;
Expand All @@ -35,6 +38,10 @@ public class SettingsFragment extends Fragment {
EditText numberOfScansEditText;
Button numberOfScansButton;

// Test Mode Models
SwitchCompat MLModeToggle;
SwitchCompat regressionToggle;

public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
settingsViewModel =
Expand All @@ -48,6 +55,7 @@ public void onChanged(@Nullable String s) {
}
});

context = root.getContext();
buttonState = Prefs.getDarkModeState(getContext());

darkModeSwitch = root.findViewById(R.id.toggle_dark_mode);
Expand Down Expand Up @@ -119,12 +127,35 @@ public void onClick(View v) {
}
});

SwitchCompat TEST_B2L2_toggle = root.findViewById(R.id.toggle_TEST_B2L2MODE);
TEST_B2L2_toggle.setChecked(Prefs.getTEST_B2L2(getContext()));
TEST_B2L2_toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
MLModeToggle = root.findViewById(R.id.toggle_ML_Mode);
String model = Prefs.getModelType(context);

// Create view on instantiated
// reg is true, clf is false
switch (model) {
case ("reg"):
MLModeToggle.setText("Regression");
MLModeToggle.setChecked(true);
break;
case ("clf"):
MLModeToggle.setText("Classificaton");
MLModeToggle.setChecked(false);
break;
}

MLModeToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Prefs.setTEST_B2L2(getContext(), isChecked);
if (isChecked) {
MLModeToggle.setText("Regression");
MLModeToggle.setChecked(true);
Prefs.setModelType(context, "reg");

} else {
MLModeToggle.setText("Classificaton");
MLModeToggle.setChecked(false);
Prefs.setModelType(context, "clf");
}
}
});

Expand All @@ -136,4 +167,5 @@ private void hideKeyboard(EditText editText) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public ModelPrediction(String credentials, String legal_points) {
this.CREDENTIALS_KEY = credentials;
this.LEGAL_POINTS = legal_points;

// THIS IS AN IMPT LINE, DO NOT REMOVE
System.out.println("MODEL PRED: " + LEGAL_POINTS);

// set classification as default
this.modelType = "clf";
this.modelName = "B2L2_XTC";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
getLegalPoints.execute(new OnCompleteCallback() {
@Override
public void onSuccess() {
System.out.println("GET LEGAL POINTS: " + getLegalPoints.getLEGAL_POINTS());
// System.out.println("GET LEGAL POINTS: " + getLegalPointegalPoints.getLEGAL_POINTS());
LEGAL_POINTS = getLegalPoints.getLEGAL_POINTS();
Toast.makeText(getContext(), "LEGAL_POINTS retrieval success!", Toast.LENGTH_SHORT).show();
}
Expand Down
6 changes: 3 additions & 3 deletions Trackie/app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="TEST"
android:text="Test Mode Model"
android:textSize="20sp"
app:layout_constraintTop_toBottomOf="@id/number_of_scans_set_button"
tools:layout_editor_absoluteX="8dp"
Expand All @@ -212,11 +212,11 @@
android:layout_marginTop="@dimen/activity_vertical_margin">

<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggle_TEST_B2L2MODE"
android:id="@+id/toggle_ML_Mode"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingHorizontal="@dimen/switch_padding"
android:text="TESTING AT B1L2 RN"
android:text="Classification"
android:textColor="?attr/colorOnBackground"
app:layout_constraintTop_toTopOf="parent" />
</androidx.cardview.widget.CardView>
Expand Down

0 comments on commit f3dec7c

Please sign in to comment.