Skip to content

Commit

Permalink
Refactor data entry into a single vertical screen; finish new coat of…
Browse files Browse the repository at this point in the history
… paint
  • Loading branch information
19lmyers committed Mar 7, 2019
1 parent d8b787e commit e8ac839
Show file tree
Hide file tree
Showing 33 changed files with 948 additions and 1,224 deletions.
15 changes: 2 additions & 13 deletions app/src/main/java/com/team980/thunderscout/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
.icon(getTintedIcon(R.drawable.ic_forum_24dp))
.setOnClickAction(() -> {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://www.chiefdelphi.com/forums/member.php?u=91239"));
i.setData(Uri.parse("https://www.chiefdelphi.com/u/19lmyers"));
startActivity(i);
})
.build());
Expand Down Expand Up @@ -181,17 +181,6 @@ protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
})
.build());

teamCard.addItem(new MaterialAboutActionItem.Builder()
.text("Follow us on Snapchat")
.subText("@frcteam980")
.icon(getTintedIcon(R.drawable.ic_snapchat_24dp))
.setOnClickAction(() -> {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://www.snapchat.com/add/frcteam980"));
startActivity(i);
})
.build());

teamCard.addItem(new MaterialAboutActionItem.Builder()
.text("Subscribe to us on YouTube")
.subText("FRC Team 980 Official")
Expand All @@ -209,7 +198,7 @@ protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
.icon(getTintedIcon(R.drawable.ic_web_24dp))
.setOnClickAction(() -> {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("http://team980.com/"));
i.setData(Uri.parse("https://team980.com/"));
startActivity(i);
})
.build());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.team980.thunderscout.scouting_flow;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
Expand All @@ -35,25 +34,41 @@
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;

import com.team980.thunderscout.R;
import com.team980.thunderscout.schema.enumeration.ClimbingStats;
import com.team980.thunderscout.scouting_flow.view.CounterCompoundView;

public class TeleopFragment extends Fragment implements Spinner.OnItemSelectedListener, View.OnClickListener {
public class DataEntryFragment extends Fragment implements View.OnClickListener, AdapterView.OnItemSelectedListener {

private ScoutingFlowActivity scoutingFlowActivity;
ScoutingFlowActivity scoutingFlowActivity;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_teleop, container, false);
return inflater.inflate(R.layout.fragment_data_entry, container, false);
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

// Autonomous
CheckBox crossedAutoLine = getView().findViewById(R.id.auto_checkBoxCrossedAutoLine);
crossedAutoLine.setChecked(scoutingFlowActivity.getData().getCrossedAutoLine());
crossedAutoLine.setOnClickListener(this);

CounterCompoundView auto_powerCubeAllianceSwitchCount = getView().findViewById(R.id.auto_counterPowerCubeAllianceSwitchCount);
auto_powerCubeAllianceSwitchCount.setValue(scoutingFlowActivity.getData().getAutoPowerCubeAllianceSwitchCount());

CounterCompoundView auto_powerCubeScaleCount = getView().findViewById(R.id.auto_counterPowerCubeScaleCount);
auto_powerCubeScaleCount.setValue(scoutingFlowActivity.getData().getAutoPowerCubeScaleCount());

CounterCompoundView auto_powerCubePlayerStationCount = getView().findViewById(R.id.auto_counterPowerCubePlayerStationCount);
auto_powerCubePlayerStationCount.setValue(scoutingFlowActivity.getData().getAutoPowerCubePlayerStationCount());

// Teleoperated
CounterCompoundView powerCubeAllianceSwitchCount = getView().findViewById(R.id.teleop_counterPowerCubeAllianceSwitch);
powerCubeAllianceSwitchCount.setValue(scoutingFlowActivity.getData().getTeleopPowerCubeAllianceSwitchCount());

Expand All @@ -79,6 +94,16 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
CheckBox supportedOtherRobotsWhenClimbing = getView().findViewById(R.id.teleop_checkBoxSupportedOtherRobotsWhenClimbing);
supportedOtherRobotsWhenClimbing.setChecked(scoutingFlowActivity.getData().getSupportedOtherRobots());
supportedOtherRobotsWhenClimbing.setOnClickListener(this);

// Summary
EditText strategies = getView().findViewById(R.id.summary_edittextStrategies);
strategies.setText(scoutingFlowActivity.getData().getStrategies());

EditText difficulties = getView().findViewById(R.id.summary_edittextDifficulties);
difficulties.setText(scoutingFlowActivity.getData().getDifficulties());

EditText comments = getView().findViewById(R.id.summary_edittextComments);
comments.setText(scoutingFlowActivity.getData().getComments());
}

@Override
Expand Down Expand Up @@ -109,9 +134,13 @@ public void onNothingSelected(AdapterView<?> parent) {

@Override
public void onClick(View view) {
if (view.getId() == R.id.teleop_checkBoxSupportedOtherRobotsWhenClimbing) {
if (view.getId() == R.id.auto_checkBoxCrossedAutoLine) {

AppCompatCheckBox checkBox = (AppCompatCheckBox) view;
scoutingFlowActivity.getData().setCrossedAutoLine(checkBox.isChecked());
} else if (view.getId() == R.id.teleop_checkBoxSupportedOtherRobotsWhenClimbing) {

AppCompatCheckBox checkBox = (AppCompatCheckBox) view;
scoutingFlowActivity.getData().setSupportedOtherRobots(checkBox.isChecked());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
Expand All @@ -61,11 +60,11 @@
import java.util.Date;
import java.util.List;

public class ScoutingFlowActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener, View.OnClickListener, ScoutingFlowDialogFragment.ScoutingFlowDialogFragmentListener, StorageWrapper.StorageListener {
public class ScoutingFlowActivity extends AppCompatActivity implements View.OnClickListener, ScoutingFlowDialogFragment.ScoutingFlowDialogFragmentListener, StorageWrapper.StorageListener {

public static final String EXTRA_SCOUT_DATA = "EXTRA_SCOUT_DATA";

private ScoutingFlowViewPagerAdapter viewPagerAdapter;
private DataEntryFragment dataEntryFragment;
private ScoutData scoutData;
private FloatingActionButton fab;

Expand Down Expand Up @@ -97,16 +96,11 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_clear_24dp);

ViewPager viewPager = findViewById(R.id.view_pager);
dataEntryFragment = new DataEntryFragment();

viewPagerAdapter = new ScoutingFlowViewPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(viewPagerAdapter);

viewPager.setOffscreenPageLimit(3);
viewPager.addOnPageChangeListener(this);

TabLayout tabLayout = findViewById(R.id.tab_layout);
tabLayout.setupWithViewPager(viewPager);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.data_entry_fragment, dataEntryFragment);
ft.commit();

fab = findViewById(R.id.fab_finish);
fab.setOnClickListener(this);
Expand All @@ -116,7 +110,6 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setSubtitle("Qualification Match " + scoutData.getMatchNumber());

toolbar.setBackground(new ColorDrawable(getResources().getColor(scoutData.getAllianceStation().getColor().getColorPrimary())));
tabLayout.setBackground(new ColorDrawable(getResources().getColor(scoutData.getAllianceStation().getColor().getColorPrimary())));
findViewById(R.id.app_bar_layout).setBackground(new ColorDrawable(getResources().getColor(scoutData.getAllianceStation().getColor().getColorPrimary())));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Expand Down Expand Up @@ -207,33 +200,6 @@ protected void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putSerializable("ScoutData", scoutData);
}

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
//do nothing
}

@Override
public void onPageSelected(int position) {
switch (position) {
case 2: //SUMMARY tab
fab.show();
fab.setClickable(true);
break;

default: //Other tabs

fab.hide();
fab.setClickable(false);
break;
}
}

@Override
public void onPageScrollStateChanged(int state) {
//Do nothing
}


@Override
public void onBackPressed() {
new AlertDialog.Builder(this)
Expand Down Expand Up @@ -362,52 +328,46 @@ private void initScoutData() { //TODO this SHOULD NOT BE IN THE ACTIVITY CODE
scoutData.setSource(PreferenceManager.getDefaultSharedPreferences(this)
.getString(getResources().getString(R.string.pref_device_name), Build.MANUFACTURER + " " + Build.MODEL));

// Auto
View autoView = viewPagerAdapter.getItem(0).getView();

CheckBox crossedAutoLine = autoView.findViewById(R.id.auto_checkBoxCrossedAutoLine);
// Autonomous
CheckBox crossedAutoLine = findViewById(R.id.auto_checkBoxCrossedAutoLine);
scoutData.setCrossedAutoLine(crossedAutoLine.isChecked());

CounterCompoundView auto_powerCubeAllianceSwitchCount = autoView.findViewById(R.id.auto_counterPowerCubeAllianceSwitchCount);
CounterCompoundView auto_powerCubeAllianceSwitchCount = findViewById(R.id.auto_counterPowerCubeAllianceSwitchCount);
scoutData.setAutoPowerCubeAllianceSwitchCount((int) auto_powerCubeAllianceSwitchCount.getValue());

CounterCompoundView auto_powerCubeScaleCount = autoView.findViewById(R.id.auto_counterPowerCubeScaleCount);
CounterCompoundView auto_powerCubeScaleCount = findViewById(R.id.auto_counterPowerCubeScaleCount);
scoutData.setAutoPowerCubeScaleCount((int) auto_powerCubeScaleCount.getValue());

CounterCompoundView auto_powerCubePlayerStationCount = autoView.findViewById(R.id.auto_counterPowerCubePlayerStationCount);
CounterCompoundView auto_powerCubePlayerStationCount = findViewById(R.id.auto_counterPowerCubePlayerStationCount);
scoutData.setAutoPowerCubePlayerStationCount((int) auto_powerCubePlayerStationCount.getValue());

// Teleop
View teleopView = viewPagerAdapter.getItem(1).getView();

CounterCompoundView teleop_powerCubeAllianceSwitchCount = teleopView.findViewById(R.id.teleop_counterPowerCubeAllianceSwitch);
// Teleoperated
CounterCompoundView teleop_powerCubeAllianceSwitchCount = findViewById(R.id.teleop_counterPowerCubeAllianceSwitch);
scoutData.setTeleopPowerCubeAllianceSwitchCount((int) teleop_powerCubeAllianceSwitchCount.getValue());

CounterCompoundView teleop_powerCubeScaleCount = teleopView.findViewById(R.id.teleop_counterPowerCubeScaleCount);
CounterCompoundView teleop_powerCubeScaleCount = findViewById(R.id.teleop_counterPowerCubeScaleCount);
scoutData.setTeleopPowerCubeScaleCount((int) teleop_powerCubeScaleCount.getValue());

CounterCompoundView teleop_powerCubeOpposingSwitchCount = teleopView.findViewById(R.id.teleop_counterPowerCubeOpposingSwitchCount);
CounterCompoundView teleop_powerCubeOpposingSwitchCount = findViewById(R.id.teleop_counterPowerCubeOpposingSwitchCount);
scoutData.setTeleopPowerCubeOpposingSwitchCount((int) teleop_powerCubeOpposingSwitchCount.getValue());

CounterCompoundView teleop_powerCubePlayerStationCount = teleopView.findViewById(R.id.teleop_counterPowerCubePlayerStationCount);
CounterCompoundView teleop_powerCubePlayerStationCount = findViewById(R.id.teleop_counterPowerCubePlayerStationCount);
scoutData.setTeleopPowerCubePlayerStationCount((int) teleop_powerCubePlayerStationCount.getValue());

Spinner climbingStats = teleopView.findViewById(R.id.teleop_spinnerClimbingStats);
Spinner climbingStats = findViewById(R.id.teleop_spinnerClimbingStats);
scoutData.setClimbingStats(ClimbingStats.values()[climbingStats.getSelectedItemPosition()]);

CheckBox supportedOtherRobotsWhenClimbing = teleopView.findViewById(R.id.teleop_checkBoxSupportedOtherRobotsWhenClimbing);
CheckBox supportedOtherRobotsWhenClimbing = findViewById(R.id.teleop_checkBoxSupportedOtherRobotsWhenClimbing);
scoutData.setSupportedOtherRobots(supportedOtherRobotsWhenClimbing.isChecked());

// Summary
View summaryView = viewPagerAdapter.getItem(2).getView();

EditText strategies = summaryView.findViewById(R.id.summary_edittextStrategies);
EditText strategies = findViewById(R.id.summary_edittextStrategies);
scoutData.setStrategies(strategies.getText().toString());

EditText difficulties = summaryView.findViewById(R.id.summary_edittextDifficulties);
EditText difficulties = findViewById(R.id.summary_edittextDifficulties);
scoutData.setDifficulties(difficulties.getText().toString());

EditText comments = summaryView.findViewById(R.id.summary_edittextComments);
EditText comments = findViewById(R.id.summary_edittextComments);
scoutData.setComments(comments.getText().toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AlertDialog;
Expand Down Expand Up @@ -118,6 +119,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
dialog.setCanceledOnTouchOutside(false);
//Complex code to override auto dismiss
dialog.setOnShowListener(d -> {
//TextView title = dialog.findViewById(R.id.alertTitle);
//title.setTypeface(ResourcesCompat.getFont(getContext(), R.font.arimo));

Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(view -> mListener.onDialogPositiveClick(ScoutingFlowDialogFragment.this));
Expand All @@ -127,6 +130,11 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
return dialog;
}

@Override
public void show(FragmentManager manager, String tag) {
super.show(manager, tag);
}

// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
@Override
public void onAttach(Activity activity) {
Expand Down
Loading

0 comments on commit e8ac839

Please sign in to comment.