Skip to content

Commit

Permalink
Address issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Frogbots4634 committed Jun 25, 2018
1 parent ac7260a commit 54c43cb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ protected void onCreate(Bundle savedInstanceState)
addThingBelowConnectionStatusView(R.layout.active_config_box);
activeConfigTxtView = findViewById(R.id.active_config);

addNewFieldBtn.setVisibility(View.INVISIBLE);

if(savedInstanceState != null)
{
FieldData[] dataArray = (FieldData[]) savedInstanceState.getParcelableArray("dataArray");
Expand Down Expand Up @@ -253,7 +251,14 @@ private void setColorCodingAndDatatypeForAll()

public void showAddFieldDialog(View v)
{
new NewFieldDialog(this, this, enableByteDataType, enableButtonDataType).show();
if(currentConfig != null)
{
new NewFieldDialog(this, this, enableByteDataType, enableButtonDataType).show();
}
else
{
showAlertDialog("No config loaded", "You need to load a config before adding fields.");
}
}

/***
Expand All @@ -267,8 +272,7 @@ public void onShowToastRequested(String str)
Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
}

@Override
public void onShowAlertDialogRequested(String title, String msg)
public void showAlertDialog(String title, String msg, Typeface typeface)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);

Expand All @@ -277,9 +281,19 @@ public void onShowAlertDialogRequested(String title, String msg)

AlertDialog d = builder.show();

TextView messageView = (TextView) d.findViewById(android.R.id.message);
messageView.setTypeface(Typeface.MONOSPACE);
TextView messageView = d.findViewById(android.R.id.message);
messageView.setTypeface(typeface);
}

public void showAlertDialog(String title, String msg)
{
showAlertDialog(title, msg, Typeface.DEFAULT);
}

@Override
public void onShowAlertDialogForCodeSampleRequested(String title, String msg)
{
showAlertDialog(title, msg, Typeface.MONOSPACE);
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -474,7 +488,6 @@ private FieldUi findFieldByTag(String tag)

private void unloadCurrentConfig()
{
addNewFieldBtn.setVisibility(View.INVISIBLE);
currentConfig = null;
clearAllFields();
}
Expand All @@ -491,7 +504,6 @@ private void loadConfig(String confName)
addFieldFromSavedBundle(fd);
}

addNewFieldBtn.setVisibility(View.VISIBLE);
activeConfigTxtView.setText("Active config: " + confName);
currentConfig = confName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface FieldInterface
void addNewField(FieldType fieldType, String tag);
void removeField(String tag, boolean longPress);
void onManualInputRequested(FieldUi fieldUi);
void onShowAlertDialogRequested(String title, String msg);
void onShowAlertDialogForCodeSampleRequested(String title, String msg);
void addBtnPressEventToQueue(ButtonPressDatagram datagram);
void onShowFieldSettingsDialogRequested(FieldUi field);
void onRenameField(String currTag, String newTag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public boolean onLongClick(View v)
@Override
public void onClick(View v)
{
fieldInterface.onShowAlertDialogRequested(
fieldInterface.onShowAlertDialogForCodeSampleRequested(
"Access this field with",
String.format("get%s(\"%s\");", getTypeString(), data.tag));
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ This is 100% legal for use in competition. In fact, it falls under essentially t

![img-her](doc/images/load-config.png)

11. Back on the main screen of the Tuner, press the newly visible *Add Field* FAB in the lower right hand corner:
11. Back on the main screen of the Tuner, press the *Add Field* FAB in the lower right hand corner:

![img-her](doc/images/add-fab.png)

Expand Down

0 comments on commit 54c43cb

Please sign in to comment.