mirror of
https://github.com/TimeCrafters/TimeCraftersConfigurationTool.git
synced 2025-12-15 05:02:33 +00:00
All rename/edit dialogs finished, refactored some resource ids to use snakecase
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -12,31 +14,21 @@ import android.widget.TextView;
|
||||
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Action;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Group;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Variable;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.ui.editor.ActionsFragment;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.ui.editor.GroupsFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ActionDialog extends TimeCraftersDialog {
|
||||
final String TAG = "ActionDialog";
|
||||
private TextView commentTextView;
|
||||
private Switch nameSwitch;
|
||||
private Group group;
|
||||
private Action action;
|
||||
|
||||
public ActionDialog() {}
|
||||
|
||||
public ActionDialog(Group group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public ActionDialog(Action action, Switch nameSwitch, TextView commentTextView) {
|
||||
this.action = action;
|
||||
this.nameSwitch = nameSwitch;
|
||||
this.commentTextView = commentTextView;
|
||||
}
|
||||
private TextView nameError;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@@ -44,10 +36,19 @@ public class ActionDialog extends TimeCraftersDialog {
|
||||
|
||||
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||
if (getArguments() != null) {
|
||||
this.group = Backend.instance().getConfig().getGroups().get(getArguments().getInt("group_index"));
|
||||
|
||||
if (getArguments().getInt("action_index", -1) != -1) {
|
||||
this.action = group.getActions().get(getArguments().getInt("action_index"));
|
||||
}
|
||||
}
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialog_title);
|
||||
final LinearLayout view = root.findViewById(R.id.dialog_content);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_action, null));
|
||||
final EditText name = view.findViewById(R.id.name);
|
||||
this.nameError = view.findViewById(R.id.name_error);
|
||||
final EditText comment = view.findViewById(R.id.comment);
|
||||
|
||||
final Button cancel = view.findViewById(R.id.cancel);
|
||||
@@ -69,31 +70,78 @@ public class ActionDialog extends TimeCraftersDialog {
|
||||
title.setText("Add Action");
|
||||
}
|
||||
|
||||
name.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
validated(name.getText().toString().trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mutate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (action != null) {
|
||||
action.name = name.getText().toString();
|
||||
final String actionName = name.getText().toString().trim();
|
||||
final String commentValue = comment.getText().toString();
|
||||
|
||||
nameSwitch.setText(name.getText().toString());
|
||||
commentTextView.setText(comment.getText().toString());
|
||||
|
||||
if (comment.getText().toString().length() > 0) {
|
||||
commentTextView.setVisibility(View.VISIBLE);
|
||||
if (validated(actionName) || (action != null && action.name.equals(actionName))) {
|
||||
if (action != null) {
|
||||
action.name = actionName;
|
||||
action.comment = commentValue;
|
||||
} else {
|
||||
commentTextView.setVisibility(View.GONE);
|
||||
Action action = new Action(actionName, commentValue, true, new ArrayList<Variable>());
|
||||
|
||||
group.getActions().add(action);
|
||||
}
|
||||
} else {
|
||||
Action action = new Action(name.getText().toString(), comment.getText().toString(), true, new ArrayList<Variable>());
|
||||
|
||||
group.getActions().add(action);
|
||||
Backend.instance().configChanged();
|
||||
ActionsFragment fragment = (ActionsFragment) getFragmentManager().getPrimaryNavigationFragment();
|
||||
if (fragment != null) {
|
||||
fragment.populateActions();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
Backend.instance().configChanged();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private boolean validated(String name) {
|
||||
String message = "";
|
||||
boolean nameUnique = true;
|
||||
|
||||
for (Action a : group.getActions()) {
|
||||
if (a.name.equals(name)) {
|
||||
nameUnique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nameUnique) {
|
||||
message += "Name is not unique!";
|
||||
|
||||
} else if (name.length() <= 0) {
|
||||
message += "Name cannot be blank!";
|
||||
|
||||
}
|
||||
|
||||
if (message.length() > 0) {
|
||||
nameError.setVisibility(View.VISIBLE);
|
||||
nameError.setText(message);
|
||||
return false;
|
||||
} else {
|
||||
nameError.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -27,10 +26,10 @@ public class ConfigurationDialog extends TimeCraftersDialog {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||
final LinearLayout view = root.findViewById(R.id.dialog_content);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_configuration, null));
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||
final TextView title = root.findViewById(R.id.dialog_title);
|
||||
final EditText name = view.findViewById(R.id.name);
|
||||
this.nameError = view.findViewById(R.id.name_error);
|
||||
final Button cancel = view.findViewById(R.id.cancel);
|
||||
@@ -53,7 +52,7 @@ public class ConfigurationDialog extends TimeCraftersDialog {
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
validated(name.getText().toString());
|
||||
validated(name.getText().toString().trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +71,7 @@ public class ConfigurationDialog extends TimeCraftersDialog {
|
||||
mutate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final String newConfigName = name.getText().toString();
|
||||
final String newConfigName = name.getText().toString().trim();
|
||||
|
||||
if (newConfigName.equals(configName)) {
|
||||
dismiss();
|
||||
|
||||
@@ -42,16 +42,16 @@ public class ConfirmationDialog extends TimeCraftersDialog {
|
||||
}
|
||||
}
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||
final TextView title = root.findViewById(R.id.dialog_title);
|
||||
final ConstraintLayout titlebar = root.findViewById(R.id.titlebar);
|
||||
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||
final LinearLayout view = root.findViewById(R.id.dialog_content);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_confirmation, null));
|
||||
final TextView messageView = root.findViewById(R.id.message);
|
||||
final Button cancel = root.findViewById(R.id.cancel);
|
||||
final Button confirm = root.findViewById(R.id.confirm);
|
||||
|
||||
if (getArguments() != null && getArguments().getBoolean("extreme_danger", false)) {
|
||||
titlebar.setBackgroundColor(getResources().getColor(R.color.dialogError));
|
||||
titlebar.setBackgroundColor(getResources().getColor(R.color.dialog_error));
|
||||
getDialog().getWindow().setDimAmount(0.8f);
|
||||
cancel.setTypeface(cancel.getTypeface(), Typeface.BOLD);
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -11,22 +11,21 @@ import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.text.TextUtilsCompat;
|
||||
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Action;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Group;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.ui.editor.GroupsFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GroupDialog extends TimeCraftersDialog {
|
||||
private static final int HOST_ID = R.id.navigation_editor;
|
||||
final String TAG = "GroupDialog";
|
||||
private Group group;
|
||||
private TextView nameError;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@@ -38,10 +37,11 @@ public class GroupDialog extends TimeCraftersDialog {
|
||||
this.group = Backend.instance().getConfig().getGroups().get(getArguments().getInt("group_index"));
|
||||
}
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||
final TextView title = root.findViewById(R.id.dialog_title);
|
||||
final LinearLayout view = root.findViewById(R.id.dialog_content);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_group, null));
|
||||
final EditText name = view.findViewById(R.id.name);
|
||||
nameError = view.findViewById(R.id.name_error);
|
||||
|
||||
final Button cancel = view.findViewById(R.id.cancel);
|
||||
final Button mutate = view.findViewById(R.id.mutate);
|
||||
@@ -60,26 +60,80 @@ public class GroupDialog extends TimeCraftersDialog {
|
||||
title.setText("Add Group");
|
||||
}
|
||||
|
||||
name.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
validated(name.getText().toString().trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mutate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (group != null) {
|
||||
group.name = name.getText().toString();
|
||||
} else {
|
||||
Group group = new Group(name.getText().toString(), new ArrayList<Action>());
|
||||
|
||||
Backend.instance().getConfig().getGroups().add(group);
|
||||
final String groupName = name.getText().toString().trim();
|
||||
if (group != null && group.name.equals(groupName)) {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
Backend.instance().configChanged();
|
||||
GroupsFragment groupsFragment = (GroupsFragment) getFragmentManager().getPrimaryNavigationFragment();
|
||||
if (groupsFragment != null) {
|
||||
groupsFragment.populateGroups();
|
||||
if (validated(groupName)) {
|
||||
if (group != null) {
|
||||
group.name = groupName;
|
||||
} else {
|
||||
Group group = new Group(groupName, new ArrayList<Action>());
|
||||
|
||||
Backend.instance().getConfig().getGroups().add(group);
|
||||
}
|
||||
|
||||
Backend.instance().configChanged();
|
||||
GroupsFragment fragment = (GroupsFragment) getFragmentManager().getPrimaryNavigationFragment();
|
||||
if (fragment != null) {
|
||||
fragment.populateGroups();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private boolean validated(String name) {
|
||||
String message = "";
|
||||
Config config = Backend.instance().getConfig();
|
||||
boolean nameUnique = true;
|
||||
|
||||
for (Group g : config.getGroups()) {
|
||||
if (g.name.equals(name)) {
|
||||
nameUnique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nameUnique) {
|
||||
message += "Name is not unique!";
|
||||
|
||||
} else if (name.length() <= 0) {
|
||||
message += "Name cannot be blank!";
|
||||
|
||||
}
|
||||
|
||||
if (message.length() > 0) {
|
||||
nameError.setVisibility(View.VISIBLE);
|
||||
nameError.setText(message);
|
||||
return false;
|
||||
} else {
|
||||
nameError.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ public class PermissionsRequestDialog extends TimeCraftersDialog {
|
||||
|
||||
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
((TextView)root.findViewById(R.id.dialogTitle)).setText("Storage Permission Required");
|
||||
LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||
((TextView)root.findViewById(R.id.dialog_title)).setText("Storage Permission Required");
|
||||
LinearLayout view = root.findViewById(R.id.dialog_content);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_permission_request, null));
|
||||
((TextView)view.findViewById(R.id.message)).setText("Permission is required to write to external storage:\n\n" + TAC.ROOT_PATH);
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ public class ServerDialog extends TimeCraftersDialog {
|
||||
}
|
||||
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||
final TextView title = root.findViewById(R.id.dialog_title);
|
||||
final ConstraintLayout titlebar = root.findViewById(R.id.titlebar);
|
||||
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||
final LinearLayout view = root.findViewById(R.id.dialog_content);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_server, null));
|
||||
new ServerStatsSyncHandler(view, 1_000);
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextThemeWrapper;
|
||||
@@ -21,31 +23,20 @@ import android.widget.TextView;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Action;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Group;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Variable;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.ui.editor.VariablesFragment;
|
||||
|
||||
public class VariableDialog extends TimeCraftersDialog {
|
||||
final String TAG = "VariableDialog";
|
||||
private Action action;
|
||||
private Variable variable;
|
||||
|
||||
private TextView nameTextView, valueTextView;
|
||||
Button variableType;
|
||||
EditText variableName, variableValue;
|
||||
Switch variableValueBoolean;
|
||||
|
||||
public VariableDialog() {
|
||||
}
|
||||
|
||||
public VariableDialog(Action action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public VariableDialog(Variable variable, TextView nameTextView, TextView valueTextView) {
|
||||
this.variable = variable;
|
||||
this.nameTextView = nameTextView;
|
||||
this.valueTextView = valueTextView;
|
||||
}
|
||||
TextView nameError, valueError;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@@ -53,11 +44,22 @@ public class VariableDialog extends TimeCraftersDialog {
|
||||
|
||||
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||
LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||
if (getArguments() != null) {
|
||||
Group group = Backend.instance().getConfig().getGroups().get(getArguments().getInt("group_index"));
|
||||
action = group.getActions().get(getArguments().getInt("action_index"));
|
||||
|
||||
if (getArguments().getInt("variable_index", -1) != -1) {
|
||||
variable = action.getVariables().get(getArguments().getInt("variable_index"));
|
||||
}
|
||||
}
|
||||
|
||||
final TextView title = root.findViewById(R.id.dialog_title);
|
||||
LinearLayout view = root.findViewById(R.id.dialog_content);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_variable, null));
|
||||
variableName = view.findViewById(R.id.variableName);
|
||||
variableType = view.findViewById(R.id.variableType);
|
||||
variableName = view.findViewById(R.id.variable_name);
|
||||
nameError = view.findViewById(R.id.name_error);
|
||||
valueError = view.findViewById(R.id.value_error);
|
||||
variableType = view.findViewById(R.id.variable_type);
|
||||
variableType.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -104,43 +106,135 @@ public class VariableDialog extends TimeCraftersDialog {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
styleSwitch(buttonView, isChecked);
|
||||
validated(variableName.getText().toString().trim(), getValue());
|
||||
}
|
||||
});
|
||||
|
||||
variableName.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
validated(variableName.getText().toString().trim(), getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
variableValue.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
validated(variableName.getText().toString().trim(), getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mutateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String value = "" + variableType.getText().toString().substring(0, 1) + "x";
|
||||
if (variableType.getText().toString().substring(0, 1).equals("B")) {
|
||||
if (variableValueBoolean.isChecked()) {
|
||||
value += "true";
|
||||
String value = getValue();
|
||||
final String variableNameValue = variableName.getText().toString().trim();
|
||||
|
||||
if (validated(variableNameValue, value)) {
|
||||
if (variable != null) {
|
||||
variable.name = variableNameValue;
|
||||
|
||||
Log.d(TAG, "Value: " + value);
|
||||
variable.setValue(value);
|
||||
} else {
|
||||
value += "false";
|
||||
Variable variable = new Variable(variableName.getText().toString(), value);
|
||||
action.getVariables().add(variable);
|
||||
}
|
||||
} else {
|
||||
value += variableValue.getText().toString();
|
||||
|
||||
Backend.instance().configChanged();
|
||||
VariablesFragment fragment = (VariablesFragment) getFragmentManager().getPrimaryNavigationFragment();
|
||||
if (fragment != null) {
|
||||
fragment.populateVariables();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
if (variable != null) {
|
||||
variable.name = variableName.getText().toString();
|
||||
|
||||
Log.d(TAG, "Value: " + value);
|
||||
variable.setValue(value);
|
||||
nameTextView.setText(variable.name);
|
||||
valueTextView.setText(variable.value().toString());
|
||||
} else {
|
||||
Variable variable = new Variable(variableName.getText().toString(), value);
|
||||
action.getVariables().add(variable);
|
||||
}
|
||||
|
||||
Backend.instance().configChanged();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private String getValue() {
|
||||
String value = "" + variableType.getText().toString().substring(0, 1) + "x";
|
||||
|
||||
if (variableType.getText().toString().substring(0, 1).equals("B")) {
|
||||
if (variableValueBoolean.isChecked()) {
|
||||
value += "true";
|
||||
} else {
|
||||
value += "false";
|
||||
}
|
||||
} else {
|
||||
value += variableValue.getText().toString();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private boolean validated(String name, String value) {
|
||||
String nameMessage = "";
|
||||
boolean nameUnique = true, okay = true;
|
||||
|
||||
for (Variable v : action.getVariables()) {
|
||||
if (v.name.equals(name)) {
|
||||
nameUnique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nameUnique) {
|
||||
nameMessage += "Name is not unique!";
|
||||
|
||||
} else if (name.length() <= 0) {
|
||||
nameMessage += "Name cannot be blank!";
|
||||
|
||||
}
|
||||
|
||||
if (nameMessage.length() > 0) {
|
||||
nameError.setVisibility(View.VISIBLE);
|
||||
nameError.setText(nameMessage);
|
||||
okay = false;
|
||||
} else {
|
||||
nameError.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
String varType = Variable.typeOf(value);
|
||||
String varValue = value.split("x", 2)[1];
|
||||
String valueMessage = "";
|
||||
if (!varType.equals("Boolean") && !varType.equals("String") && varValue.length() == 0) {
|
||||
valueMessage += "Value cannot be blank for a numeric type!";
|
||||
}
|
||||
|
||||
if (valueMessage.length() > 0) {
|
||||
valueError.setVisibility(View.VISIBLE);
|
||||
valueError.setText(valueMessage);
|
||||
okay = false;
|
||||
} else {
|
||||
valueError.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return okay;
|
||||
}
|
||||
|
||||
private void showVariableTypeMenu() {
|
||||
Context context = new ContextThemeWrapper(getActivity(), R.style.PopUpMenu);
|
||||
PopupMenu menu = new PopupMenu(context, variableType);
|
||||
@@ -187,6 +281,7 @@ public class VariableDialog extends TimeCraftersDialog {
|
||||
if (_type.equals("boolean")) {
|
||||
variableType.setText("Boolean");
|
||||
variableValue.setVisibility(View.GONE);
|
||||
valueError.setVisibility(View.GONE);
|
||||
variableValueBoolean.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (_type.equals("double")) {
|
||||
@@ -220,6 +315,7 @@ public class VariableDialog extends TimeCraftersDialog {
|
||||
} else if (_type.equals("string")) {
|
||||
variableType.setText("String");
|
||||
variableValue.setVisibility(View.VISIBLE);
|
||||
valueError.setVisibility(View.GONE);
|
||||
variableValueBoolean.setVisibility(View.GONE);
|
||||
|
||||
variableValue.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ActionsFragment extends TimeCraftersFragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final View root = inflater.inflate(R.layout.fragment_actions, container, false);
|
||||
this.container = root.findViewById(R.id.container);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.actionButton);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.action_button);
|
||||
final ScrollView scrollView = root.findViewById(R.id.scrollview);
|
||||
|
||||
this.config = Backend.instance().getConfig();
|
||||
@@ -51,8 +51,11 @@ public class ActionsFragment extends TimeCraftersFragment {
|
||||
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ActionDialog dialog = new ActionDialog(group);
|
||||
dialog.show(getFragmentManager(), null);
|
||||
ActionDialog dialog = new ActionDialog();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("group_index", getArguments().getInt("group_index"));
|
||||
dialog.setArguments(bundle);
|
||||
dialog.show(getFragmentManager(), "add_action");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -95,7 +98,7 @@ public class ActionsFragment extends TimeCraftersFragment {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("group_index", getArguments().getInt("group_index"));
|
||||
bundle.putInt("action_index", group.getActions().indexOf(action));
|
||||
Navigation.findNavController(v).navigate(R.id.variablesFragment, bundle);
|
||||
Navigation.findNavController(v).navigate(R.id.variables_fragment, bundle);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -108,8 +111,12 @@ public class ActionsFragment extends TimeCraftersFragment {
|
||||
rename.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ActionDialog dialog = new ActionDialog(action, name, comment);
|
||||
dialog.show(getFragmentManager(), null);
|
||||
ActionDialog dialog = new ActionDialog();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("group_index", getArguments().getInt("group_index"));
|
||||
bundle.putInt("action_index", group.getActions().indexOf(action));
|
||||
dialog.setArguments(bundle);
|
||||
dialog.show(getFragmentManager(), "edit_action");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GroupsFragment extends TimeCraftersFragment {
|
||||
final View root = inflater.inflate(R.layout.fragment_groups, container, false);
|
||||
this.configName = root.findViewById(R.id.configuration_name);
|
||||
this.container = root.findViewById(R.id.container);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.actionButton);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.action_button);
|
||||
final ScrollView scrollView = root.findViewById(R.id.scrollview);
|
||||
|
||||
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -98,7 +98,7 @@ public class GroupsFragment extends TimeCraftersFragment {
|
||||
public void onClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("group_index", config.getGroups().indexOf(group));
|
||||
Navigation.findNavController(v).navigate(R.id.actionsFragment, bundle);
|
||||
Navigation.findNavController(v).navigate(R.id.actions_fragment, bundle);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.timecrafters.TimeCraftersConfigurationTool.ui.editor;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -36,7 +35,7 @@ public class VariablesFragment extends TimeCraftersFragment {
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
final View root = inflater.inflate(R.layout.fragment_variables, container, false);
|
||||
this.container = root.findViewById(R.id.container);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.actionButton);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.action_button);
|
||||
final ScrollView scrollView = root.findViewById(R.id.scrollview);
|
||||
|
||||
this.config = Backend.instance().getConfig();
|
||||
@@ -53,8 +52,12 @@ public class VariablesFragment extends TimeCraftersFragment {
|
||||
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
VariableDialog dialog = new VariableDialog(action);
|
||||
dialog.show(getFragmentManager(), null);
|
||||
VariableDialog dialog = new VariableDialog();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("group_index", getArguments().getInt("group_index"));
|
||||
bundle.putInt("action_index", getArguments().getInt("action_index"));
|
||||
dialog.setArguments(bundle);
|
||||
dialog.show(getFragmentManager(), "add_variable");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -84,8 +87,13 @@ public class VariablesFragment extends TimeCraftersFragment {
|
||||
rename.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
VariableDialog dialog = new VariableDialog(variable, name, value);
|
||||
dialog.show(getFragmentManager(), null);
|
||||
VariableDialog dialog = new VariableDialog();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("group_index", getArguments().getInt("group_index"));
|
||||
bundle.putInt("action_index", getArguments().getInt("action_index"));
|
||||
bundle.putInt("variable_index", action.getVariables().indexOf(variable));
|
||||
dialog.setArguments(bundle);
|
||||
dialog.show(getFragmentManager(), "edit_variable");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ConfigurationsFragment extends TimeCraftersFragment {
|
||||
this.root = inflater.inflate(R.layout.fragment_configuration, container, false);
|
||||
final ScrollView scrollview = root.findViewById(R.id.scrollview);
|
||||
configsContainer = root.findViewById(R.id.container);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.actionButton);
|
||||
final FloatingActionButton actionButton = root.findViewById(R.id.action_button);
|
||||
|
||||
floatingActionButtonAutoHide(actionButton, scrollview);
|
||||
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialogTitle"
|
||||
android:id="@+id/dialog_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
@@ -45,7 +45,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialogContent"
|
||||
android:id="@+id/dialog_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/dialogBackground"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/variable_name"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name"
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:layout_marginRight="@dimen/button_margin_right"
|
||||
android:textColor="@color/dialogError"
|
||||
android:textColor="@color/dialog_error"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
android:layout_marginRight="@dimen/button_margin_right"
|
||||
android:gravity="center"
|
||||
android:text="TextView"
|
||||
android:textColor="@color/dialogLabel"
|
||||
android:textColor="@color/dialog_label"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|center_horizontal|center_vertical"
|
||||
android:text="@string/variable_name"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name"
|
||||
@@ -20,13 +20,22 @@
|
||||
android:hint="@string/variable_name"
|
||||
android:inputType="textPersonName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_error"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:layout_marginRight="@dimen/button_margin_right"
|
||||
android:textColor="@color/dialog_error"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|center_horizontal|center_vertical"
|
||||
android:text="@string/comment"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/comment"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|center_horizontal|center_vertical"
|
||||
android:text="@string/variable_name"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name"
|
||||
@@ -20,6 +20,15 @@
|
||||
android:hint="@string/variable_name"
|
||||
android:inputType="textPersonName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_error"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:layout_marginRight="@dimen/button_margin_right"
|
||||
android:textColor="@color/dialog_error"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -10,26 +10,35 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|center_horizontal|center_vertical"
|
||||
android:text="@string/variable_name"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/variableName"
|
||||
android:id="@+id/variable_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/variable_name"
|
||||
android:inputType="textPersonName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_error"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:layout_marginRight="@dimen/button_margin_right"
|
||||
android:textColor="@color/dialog_error"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|center_horizontal|center_vertical"
|
||||
android:text="@string/variable_type"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/variableType"
|
||||
android:id="@+id/variable_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
@@ -40,7 +49,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|center_horizontal|center_vertical"
|
||||
android:text="@string/variable_value"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/variableValue"
|
||||
@@ -57,6 +66,15 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/variable_value" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_error"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:layout_marginRight="@dimen/button_margin_right"
|
||||
android:textColor="@color/dialog_error"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Client Status"
|
||||
android:textColor="@color/dialogLabel"
|
||||
android:textColor="@color/dialog_label"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
@@ -30,7 +30,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Total Packets In"
|
||||
android:textColor="@color/dialogLabel"
|
||||
android:textColor="@color/dialog_label"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
@@ -38,7 +38,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Total Packets Out"
|
||||
android:textColor="@color/dialogLabel"
|
||||
android:textColor="@color/dialog_label"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
@@ -46,7 +46,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Total Data In"
|
||||
android:textColor="@color/dialogLabel"
|
||||
android:textColor="@color/dialog_label"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
@@ -54,7 +54,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Total Data Out"
|
||||
android:textColor="@color/dialogLabel"
|
||||
android:textColor="@color/dialog_label"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="0"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/total_packets_in"
|
||||
@@ -79,7 +79,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="0"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/total_packets_out"
|
||||
@@ -87,7 +87,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="0"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/total_data_in"
|
||||
@@ -95,7 +95,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="0"
|
||||
android:textColor="@color/dialogLabel" />
|
||||
android:textColor="@color/dialog_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/total_data_out"
|
||||
@@ -103,7 +103,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="0"
|
||||
android:textColor="@color/dialogLabel"/>
|
||||
android:textColor="@color/dialog_label"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</ScrollView>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/actionButton"
|
||||
android:id="@+id/action_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
tools:layout="@layout/fragment_groups" >
|
||||
<action
|
||||
android:id="@+id/action_navigation_editor_to_actionsFragment"
|
||||
app:destination="@id/actionsFragment" />
|
||||
app:destination="@id/actions_fragment" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
@@ -39,15 +39,15 @@
|
||||
android:label="@string/title_search"
|
||||
tools:layout="@layout/fragment_search" />
|
||||
<fragment
|
||||
android:id="@+id/actionsFragment"
|
||||
android:id="@+id/actions_fragment"
|
||||
android:name="org.timecrafters.TimeCraftersConfigurationTool.ui.editor.ActionsFragment"
|
||||
android:label="Actions" >
|
||||
<action
|
||||
android:id="@+id/action_actionsFragment_to_variablesFragment"
|
||||
app:destination="@id/variablesFragment" />
|
||||
app:destination="@id/variables_fragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/variablesFragment"
|
||||
android:id="@+id/variables_fragment"
|
||||
android:name="org.timecrafters.TimeCraftersConfigurationTool.ui.editor.VariablesFragment"
|
||||
android:label="Variables" />
|
||||
<fragment
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
|
||||
<color name="dialogBackground">#ddd</color>
|
||||
<color name="dialogTitle">#fff</color>
|
||||
<color name="dialogLabel">#222</color>
|
||||
<color name="dialog_label">#222</color>
|
||||
<color name="dialogCloseColor">#222</color>
|
||||
<color name="dialogAlert">#f80</color>
|
||||
<color name="dialogError">@color/colorDanger</color>
|
||||
<color name="dialog_error">@color/colorDanger</color>
|
||||
<color name="dialogNotice">#080</color>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user