mirror of
https://github.com/TimeCrafters/TimeCraftersConfigurationTool.git
synced 2025-12-16 05:22:35 +00:00
Refactored Config inner classes into their own classes, added a dialogs for Groups, Actions, Server, and confirmations
This commit is contained in:
@@ -2,8 +2,6 @@ package org.timecrafters.TimeCraftersConfigurationTool;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
@@ -16,7 +14,6 @@ import androidx.navigation.ui.AppBarConfiguration;
|
|||||||
import androidx.navigation.ui.NavigationUI;
|
import androidx.navigation.ui.NavigationUI;
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.Dialog;
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.PermissionsRequestDialog;
|
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.PermissionsRequestDialog;
|
||||||
|
|
||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package org.timecrafters.TimeCraftersConfigurationTool.backend;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import java.io.Reader;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Configuration;
|
||||||
import java.nio.file.Files;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Group;
|
||||||
import java.nio.file.Paths;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Action;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Variable;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Preset;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -24,11 +27,12 @@ public class Config {
|
|||||||
ArrayList<Action> actions = new ArrayList<>();
|
ArrayList<Action> actions = new ArrayList<>();
|
||||||
ArrayList<Variable> variables = new ArrayList<>();
|
ArrayList<Variable> variables = new ArrayList<>();
|
||||||
variables.add(new Variable("VarName", "Dx90.45"));
|
variables.add(new Variable("VarName", "Dx90.45"));
|
||||||
variables.add(new Variable("VarName2", "FxFx90.45"));
|
variables.add(new Variable("VarName2", "Fx90.45"));
|
||||||
variables.add(new Variable("VarName3", "Dx90.45"));
|
variables.add(new Variable("VarName3", "Dx90.45"));
|
||||||
variables.add(new Variable("distance", "Ix90"));
|
variables.add(new Variable("distance", "Ix90"));
|
||||||
variables.add(new Variable("variable", "Dx90.45"));
|
variables.add(new Variable("variable", "Dx90.45"));
|
||||||
variables.add(new Variable("tea_time", "SxThe Tea Party was quite enjoyable."));
|
variables.add(new Variable("tea_time", "SxThe Tea Party was quite enjoyable."));
|
||||||
|
variables.add(new Variable("tea_time", "SxThe x Tea x Party was x quite x enjoyable."));
|
||||||
|
|
||||||
actions.add(new Action("DriverOne", "This is a comment", true, variables));
|
actions.add(new Action("DriverOne", "This is a comment", true, variables));
|
||||||
actions.add(new Action("DriverTwo", "", true, variables));
|
actions.add(new Action("DriverTwo", "", true, variables));
|
||||||
@@ -96,129 +100,4 @@ public class Config {
|
|||||||
this.groups = config.groups;
|
this.groups = config.groups;
|
||||||
this.presets = config.presets;
|
this.presets = config.presets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Configuration {
|
|
||||||
public Date createdAt, updatedAt;
|
|
||||||
private int specVersion;
|
|
||||||
public int revision;
|
|
||||||
|
|
||||||
public Configuration(Date createdAt, Date updatedAt, int specVersion, int revision) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
this.updatedAt = updatedAt;
|
|
||||||
this.specVersion = specVersion;
|
|
||||||
this.revision = revision;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSpecVersion() { return specVersion; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Preset {
|
|
||||||
private ArrayList<Group> groups;
|
|
||||||
private ArrayList<Action> actions;
|
|
||||||
|
|
||||||
public Preset(ArrayList<Group> groups, ArrayList<Action> actions) {
|
|
||||||
this.groups = groups;
|
|
||||||
this.actions = actions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Group {
|
|
||||||
public String name;
|
|
||||||
private ArrayList<Action> actions;
|
|
||||||
|
|
||||||
public Group(String name, ArrayList<Action> actions) {
|
|
||||||
this.name = name;
|
|
||||||
this.actions = actions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Action> getActions() {
|
|
||||||
return actions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Action {
|
|
||||||
public String name, comment;
|
|
||||||
public boolean enabled;
|
|
||||||
private ArrayList<Variable> variables;
|
|
||||||
|
|
||||||
public Action(String name, String comment, boolean enabled, ArrayList<Variable> variables) {
|
|
||||||
this.name = name;
|
|
||||||
this.comment = comment;
|
|
||||||
this.enabled = enabled;
|
|
||||||
this.variables = variables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Variable> getVariables() { return variables; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Variable {
|
|
||||||
public String name;
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
public Variable(String name, String value) {
|
|
||||||
this.name = name;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> T value() {
|
|
||||||
return valueOf();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T> T valueOf() {
|
|
||||||
String[] split = value.split("x");
|
|
||||||
|
|
||||||
switch (split[0]) {
|
|
||||||
case "B": {
|
|
||||||
return (T) Boolean.valueOf(split[(split.length-1)]);
|
|
||||||
}
|
|
||||||
case "D": {
|
|
||||||
return (T) Double.valueOf(split[(split.length-1)]);
|
|
||||||
}
|
|
||||||
case "F": {
|
|
||||||
return (T) Float.valueOf(split[(split.length-1)]);
|
|
||||||
}
|
|
||||||
case "I": {
|
|
||||||
return (T) Integer.valueOf(split[(split.length-1)]);
|
|
||||||
}
|
|
||||||
case "L": {
|
|
||||||
return (T) Long.valueOf(split[(split.length-1)]);
|
|
||||||
}
|
|
||||||
case "S": {
|
|
||||||
return (T) String.valueOf(split[(split.length-1)]);
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String typeOf(String value) {
|
|
||||||
String[] split = value.split("x");
|
|
||||||
|
|
||||||
switch (split[0]) {
|
|
||||||
case "B": {
|
|
||||||
return "Boolean";
|
|
||||||
}
|
|
||||||
case "D": {
|
|
||||||
return "Double";
|
|
||||||
}
|
|
||||||
case "F": {
|
|
||||||
return "Float";
|
|
||||||
}
|
|
||||||
case "I": {
|
|
||||||
return "Integer";
|
|
||||||
}
|
|
||||||
case "L": {
|
|
||||||
return "Long";
|
|
||||||
}
|
|
||||||
case "S": {
|
|
||||||
return "String";
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return "=!UNKNOWN!=";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.backend.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Action {
|
||||||
|
public String name, comment;
|
||||||
|
public boolean enabled;
|
||||||
|
private ArrayList<Variable> variables;
|
||||||
|
|
||||||
|
public Action(String name, String comment, boolean enabled, ArrayList<Variable> variables) {
|
||||||
|
this.name = name;
|
||||||
|
this.comment = comment;
|
||||||
|
this.enabled = enabled;
|
||||||
|
this.variables = variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Variable> getVariables() { return variables; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.backend.config;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class Configuration {
|
||||||
|
public Date createdAt, updatedAt;
|
||||||
|
private int specVersion;
|
||||||
|
public int revision;
|
||||||
|
|
||||||
|
public Configuration(Date createdAt, Date updatedAt, int specVersion, int revision) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
this.specVersion = specVersion;
|
||||||
|
this.revision = revision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSpecVersion() { return specVersion; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.backend.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Group {
|
||||||
|
public String name;
|
||||||
|
private ArrayList<Action> actions;
|
||||||
|
|
||||||
|
public Group(String name, ArrayList<Action> actions) {
|
||||||
|
this.name = name;
|
||||||
|
this.actions = actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Action> getActions() {
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.backend.config;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Preset {
|
||||||
|
private ArrayList<Group> groups;
|
||||||
|
private ArrayList<Action> actions;
|
||||||
|
|
||||||
|
public Preset(ArrayList<Group> groups, ArrayList<Action> actions) {
|
||||||
|
this.groups = groups;
|
||||||
|
this.actions = actions;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.backend.config;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Variable {
|
||||||
|
public String name;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public Variable(String name, String value) {
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String rawValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T value() {
|
||||||
|
return valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
static public <T> T valueOf(String value) {
|
||||||
|
String[] split = value.split("x", 2);
|
||||||
|
// Log.d("Variable", "valueOf split: " + Arrays.toString(split));
|
||||||
|
|
||||||
|
switch (split[0]) {
|
||||||
|
case "B": {
|
||||||
|
return (T) Boolean.valueOf(split[(split.length-1)]);
|
||||||
|
}
|
||||||
|
case "D": {
|
||||||
|
return (T) Double.valueOf(split[(split.length-1)]);
|
||||||
|
}
|
||||||
|
case "F": {
|
||||||
|
return (T) Float.valueOf(split[(split.length-1)]);
|
||||||
|
}
|
||||||
|
case "I": {
|
||||||
|
return (T) Integer.valueOf(split[(split.length-1)]);
|
||||||
|
}
|
||||||
|
case "L": {
|
||||||
|
return (T) Long.valueOf(split[(split.length-1)]);
|
||||||
|
}
|
||||||
|
case "S": {
|
||||||
|
String string = "";
|
||||||
|
int i = 0;
|
||||||
|
for(String str : split) {
|
||||||
|
if (i == 0) { i++; continue; }
|
||||||
|
|
||||||
|
string += str;
|
||||||
|
}
|
||||||
|
return (T) string;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public String typeOf(String value) {
|
||||||
|
String[] split = value.split("x");
|
||||||
|
|
||||||
|
switch (split[0]) {
|
||||||
|
case "B": {
|
||||||
|
return "Boolean";
|
||||||
|
}
|
||||||
|
case "D": {
|
||||||
|
return "Double";
|
||||||
|
}
|
||||||
|
case "F": {
|
||||||
|
return "Float";
|
||||||
|
}
|
||||||
|
case "I": {
|
||||||
|
return "Integer";
|
||||||
|
}
|
||||||
|
case "L": {
|
||||||
|
return "Long";
|
||||||
|
}
|
||||||
|
case "S": {
|
||||||
|
return "String";
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return "=!UNKNOWN!=";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Switch;
|
||||||
|
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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
setCancelable(false);
|
||||||
|
|
||||||
|
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||||
|
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||||
|
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_action, null));
|
||||||
|
final EditText name = view.findViewById(R.id.name);
|
||||||
|
final EditText comment = view.findViewById(R.id.comment);
|
||||||
|
|
||||||
|
final Button cancel = view.findViewById(R.id.cancel);
|
||||||
|
final Button mutate = view.findViewById(R.id.mutate);
|
||||||
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (action != null) {
|
||||||
|
title.setText("Editing " + action.name);
|
||||||
|
name.setText(action.name);
|
||||||
|
comment.setText(action.comment);
|
||||||
|
|
||||||
|
mutate.setText("Update");
|
||||||
|
} else {
|
||||||
|
title.setText("Add Action");
|
||||||
|
}
|
||||||
|
|
||||||
|
mutate.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (action != null) {
|
||||||
|
action.name = name.getText().toString();
|
||||||
|
|
||||||
|
nameSwitch.setText(name.getText().toString());
|
||||||
|
commentTextView.setText(comment.getText().toString());
|
||||||
|
|
||||||
|
if (comment.getText().toString().length() > 0) {
|
||||||
|
commentTextView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
commentTextView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Action action = new Action(name.getText().toString(), comment.getText().toString(), true, new ArrayList<Variable>());
|
||||||
|
|
||||||
|
group.getActions().add(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
Backend.instance().configChanged();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||||
|
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||||
|
|
||||||
|
public class ConfigurationDialog extends TimeCraftersDialog {
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||||
|
|
||||||
|
public class ConfirmationDialog extends TimeCraftersDialog {
|
||||||
|
private String title, message;
|
||||||
|
private Runnable action;
|
||||||
|
|
||||||
|
public ConfirmationDialog() {}
|
||||||
|
|
||||||
|
public ConfirmationDialog(String title, String message, Runnable action) {
|
||||||
|
this.title = title;
|
||||||
|
this.message = message;
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||||
|
final ConstraintLayout titlebar = root.findViewById(R.id.titlebar);
|
||||||
|
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||||
|
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);
|
||||||
|
|
||||||
|
titlebar.setBackgroundColor(getResources().getColor(R.color.dialogAlert));
|
||||||
|
title.setText(this.title);
|
||||||
|
messageView.setText(message);
|
||||||
|
|
||||||
|
confirm.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
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.library.TimeCraftersDialog;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class GroupDialog extends TimeCraftersDialog {
|
||||||
|
final String TAG = "GroupDialog";
|
||||||
|
private Group group;
|
||||||
|
|
||||||
|
public GroupDialog() {}
|
||||||
|
|
||||||
|
public GroupDialog(Group group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
setCancelable(false);
|
||||||
|
|
||||||
|
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||||
|
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||||
|
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_group, null));
|
||||||
|
final EditText name = view.findViewById(R.id.name);
|
||||||
|
|
||||||
|
final Button cancel = view.findViewById(R.id.cancel);
|
||||||
|
final Button mutate = view.findViewById(R.id.mutate);
|
||||||
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (group != null) {
|
||||||
|
title.setText("Editing " + group.name);
|
||||||
|
name.setText(group.name);
|
||||||
|
mutate.setText(getResources().getString(R.string.dialog_update));
|
||||||
|
} else {
|
||||||
|
title.setText("Add Group");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
Backend.instance().configChanged();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -9,22 +8,20 @@ import android.widget.Button;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.MainActivity;
|
import org.timecrafters.TimeCraftersConfigurationTool.MainActivity;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.TAC;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.TAC;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||||
|
|
||||||
public class PermissionsRequestDialog extends Dialog {
|
public class PermissionsRequestDialog extends TimeCraftersDialog {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
setCancelable(false);
|
setCancelable(false);
|
||||||
|
|
||||||
View v = super.onCreateView(inflater, container, savedInstanceState);
|
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
((TextView)v.findViewById(R.id.dialogTitle)).setText("Storage Permission Required");
|
((TextView)root.findViewById(R.id.dialogTitle)).setText("Storage Permission Required");
|
||||||
LinearLayout view = v.findViewById(R.id.dialogContent);
|
LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_permission_request, null));
|
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);
|
((TextView)view.findViewById(R.id.message)).setText("Permission is required to write to external storage:\n\n" + TAC.ROOT_PATH);
|
||||||
|
|
||||||
@@ -48,6 +45,6 @@ public class PermissionsRequestDialog extends Dialog {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return v;
|
return root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||||
|
|
||||||
|
public class ServerDialog extends TimeCraftersDialog {
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
setCancelable(false);
|
||||||
|
|
||||||
|
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||||
|
final ConstraintLayout titlebar = root.findViewById(R.id.titlebar);
|
||||||
|
final LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||||
|
view.addView(getLayoutInflater().inflate(R.layout.dialog_server, null));
|
||||||
|
|
||||||
|
title.setText(getResources().getString(R.string.tacnet_server_status));
|
||||||
|
|
||||||
|
final Button stopServer = root.findViewById(R.id.stop_server);
|
||||||
|
stopServer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
@@ -18,22 +19,44 @@ import android.widget.Switch;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Action;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Variable;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
|
||||||
|
|
||||||
public class VariableDialog extends Dialog {
|
public class VariableDialog extends TimeCraftersDialog {
|
||||||
final String TAG = "VariableDialog";
|
final String TAG = "VariableDialog";
|
||||||
|
private Action action;
|
||||||
|
private Variable variable;
|
||||||
|
|
||||||
|
private TextView nameTextView, valueTextView;
|
||||||
Button variableType;
|
Button variableType;
|
||||||
EditText variableValue;
|
EditText variableName, variableValue;
|
||||||
Switch variableValueBoolean;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
setCancelable(false);
|
setCancelable(false);
|
||||||
|
|
||||||
View v = super.onCreateView(inflater, container, savedInstanceState);
|
View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
((TextView)v.findViewById(R.id.dialogTitle)).setText("Add Variable");
|
final TextView title = root.findViewById(R.id.dialogTitle);
|
||||||
LinearLayout view = v.findViewById(R.id.dialogContent);
|
LinearLayout view = root.findViewById(R.id.dialogContent);
|
||||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_variable, null));
|
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_variable, null));
|
||||||
|
variableName = view.findViewById(R.id.variableName);
|
||||||
variableType = view.findViewById(R.id.variableType);
|
variableType = view.findViewById(R.id.variableType);
|
||||||
variableType.setOnClickListener(new View.OnClickListener() {
|
variableType.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -48,10 +71,8 @@ public class VariableDialog extends Dialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
variableValue = v.findViewById(R.id.variableValue);
|
variableValue = root.findViewById(R.id.variableValue);
|
||||||
variableValueBoolean = v.findViewById(R.id.variableValueBoolean);
|
variableValueBoolean = root.findViewById(R.id.variableValueBoolean);
|
||||||
|
|
||||||
setVariableType("Double");
|
|
||||||
|
|
||||||
Button cancelButton = view.findViewById(R.id.cancel);
|
Button cancelButton = view.findViewById(R.id.cancel);
|
||||||
Button mutateButton = view.findViewById(R.id.mutate);
|
Button mutateButton = view.findViewById(R.id.mutate);
|
||||||
@@ -62,14 +83,62 @@ public class VariableDialog extends Dialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (variable != null) {
|
||||||
|
title.setText("Editing " + variable.name);
|
||||||
|
mutateButton.setText(getResources().getString(R.string.dialog_update));
|
||||||
|
variableName.setText(variable.name);
|
||||||
|
setVariableType(Variable.typeOf(variable.rawValue()));
|
||||||
|
|
||||||
|
if (variableType.getText().toString().toLowerCase().equals("boolean")) {
|
||||||
|
variableValueBoolean.setChecked((boolean)variable.value());
|
||||||
|
} else {
|
||||||
|
variableValue.setText(variable.value().toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
title.setText("Add Variable");
|
||||||
|
setVariableType("Double");
|
||||||
|
}
|
||||||
|
|
||||||
|
styleSwitch(variableValueBoolean, variableValueBoolean.isChecked());
|
||||||
|
variableValueBoolean.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
styleSwitch(buttonView, isChecked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mutateButton.setOnClickListener(new View.OnClickListener() {
|
mutateButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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";
|
||||||
|
} else {
|
||||||
|
value += "false";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value += variableValue.getText().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return v;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showVariableTypeMenu() {
|
private void showVariableTypeMenu() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
package org.timecrafters.TimeCraftersConfigurationTool.library;
|
||||||
|
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -6,6 +6,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -13,7 +14,7 @@ import androidx.fragment.app.DialogFragment;
|
|||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
|
||||||
public class Dialog extends DialogFragment {
|
public class TimeCraftersDialog extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -49,4 +50,12 @@ public class Dialog extends DialogFragment {
|
|||||||
getActivity().getWindowManager().getDefaultDisplay().getSize(point);
|
getActivity().getWindowManager().getDefaultDisplay().getSize(point);
|
||||||
getDialog().getWindow().setLayout((int) (point.x * 0.8), ViewGroup.LayoutParams.WRAP_CONTENT);
|
getDialog().getWindow().setLayout((int) (point.x * 0.8), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void styleSwitch(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if (isChecked) {
|
||||||
|
buttonView.setBackground(getResources().getDrawable(R.drawable.button));
|
||||||
|
} else {
|
||||||
|
buttonView.setBackground(getResources().getDrawable(R.drawable.dangerous_button));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.timecrafters.TimeCraftersConfigurationTool.library;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
|
||||||
|
public class TimeCraftersFragment extends androidx.fragment.app.Fragment {
|
||||||
|
public void floatingActionButtonAutoHide(final FloatingActionButton button, final ScrollView view) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // API Level 23 (Android 6)
|
||||||
|
view.setOnScrollChangeListener(new View.OnScrollChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
||||||
|
final int dy = scrollY - oldScrollY;
|
||||||
|
if (dy > 0 && button.getVisibility() == View.VISIBLE) {
|
||||||
|
button.hide();
|
||||||
|
} else if (dy < 0 && button.getVisibility() == View.GONE) {
|
||||||
|
button.show();
|
||||||
|
} else if (!view.canScrollVertically(1)) {
|
||||||
|
button.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void styleSwitch(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if (isChecked) {
|
||||||
|
buttonView.setBackground(getResources().getDrawable(R.drawable.button));
|
||||||
|
} else {
|
||||||
|
buttonView.setBackground(getResources().getDrawable(R.drawable.dangerous_button));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,26 +4,31 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Action;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Group;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.ActionDialog;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class ActionsFragment extends Fragment {
|
public class ActionsFragment extends TimeCraftersFragment {
|
||||||
private Config config;
|
private Config config;
|
||||||
private Config.Group group;
|
private Group group;
|
||||||
private LinearLayout container;
|
private LinearLayout container;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -31,6 +36,8 @@ public class ActionsFragment extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
final View root = inflater.inflate(R.layout.fragment_actions, container, false);
|
final View root = inflater.inflate(R.layout.fragment_actions, container, false);
|
||||||
this.container = root.findViewById(R.id.container);
|
this.container = root.findViewById(R.id.container);
|
||||||
|
final FloatingActionButton actionButton = root.findViewById(R.id.actionButton);
|
||||||
|
final ScrollView scrollView = root.findViewById(R.id.scrollview);
|
||||||
|
|
||||||
this.config = Backend.instance().getConfig();
|
this.config = Backend.instance().getConfig();
|
||||||
this.group = config.getGroups().get(0);
|
this.group = config.getGroups().get(0);
|
||||||
@@ -39,18 +46,28 @@ public class ActionsFragment extends Fragment {
|
|||||||
|
|
||||||
populateActions();
|
populateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
floatingActionButtonAutoHide(actionButton, scrollView);
|
||||||
|
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ActionDialog dialog = new ActionDialog(group);
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateActions() {
|
private void populateActions() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final Config.Action action : group.getActions()) {
|
for (final Action action : group.getActions()) {
|
||||||
View view = View.inflate(getContext(), R.layout.fragment_part_actions, null);
|
final View view = View.inflate(getContext(), R.layout.fragment_part_actions, null);
|
||||||
Switch name = view.findViewById(R.id.name);
|
final Switch name = view.findViewById(R.id.name);
|
||||||
ImageButton edit = view.findViewById(R.id.edit);
|
final ImageButton edit = view.findViewById(R.id.edit);
|
||||||
ImageButton rename = view.findViewById(R.id.rename);
|
final ImageButton rename = view.findViewById(R.id.rename);
|
||||||
ImageButton delete = view.findViewById(R.id.delete);
|
final ImageButton delete = view.findViewById(R.id.delete);
|
||||||
TextView comment = view.findViewById(R.id.comment);
|
final TextView comment = view.findViewById(R.id.comment);
|
||||||
|
|
||||||
if (i % 2 == 0) { // even
|
if (i % 2 == 0) { // even
|
||||||
view.setBackgroundColor(getResources().getColor(R.color.list_even));
|
view.setBackgroundColor(getResources().getColor(R.color.list_even));
|
||||||
@@ -83,16 +100,16 @@ public class ActionsFragment extends Fragment {
|
|||||||
comment.setVisibility(View.GONE);
|
comment.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rename.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ActionDialog dialog = new ActionDialog(action, name, comment);
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void styleSwitch(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
buttonView.setBackground(getResources().getDrawable(R.drawable.button));
|
|
||||||
} else {
|
|
||||||
buttonView.setBackground(getResources().getDrawable(R.drawable.dangerous_button));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,20 +8,25 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config.Group;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.config.Group;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.ConfirmationDialog;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.GroupDialog;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class EditorFragment extends Fragment {
|
public class GroupsFragment extends TimeCraftersFragment {
|
||||||
|
|
||||||
final private String TAG = "EditorFragment";
|
final private String TAG = "EditorFragment";
|
||||||
|
|
||||||
@@ -34,11 +39,24 @@ public class EditorFragment extends Fragment {
|
|||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
editorViewModel =
|
editorViewModel =
|
||||||
ViewModelProviders.of(this).get(EditorViewModel.class);
|
ViewModelProviders.of(this).get(EditorViewModel.class);
|
||||||
final View root = inflater.inflate(R.layout.fragment_editor, container, false);
|
final View root = inflater.inflate(R.layout.fragment_groups, container, false);
|
||||||
this.configName = root.findViewById(R.id.configuration_name);
|
this.configName = root.findViewById(R.id.configuration_name);
|
||||||
this.container = root.findViewById(R.id.container);
|
this.container = root.findViewById(R.id.container);
|
||||||
|
final FloatingActionButton actionButton = root.findViewById(R.id.actionButton);
|
||||||
|
final ScrollView scrollView = root.findViewById(R.id.scrollview);
|
||||||
|
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
GroupDialog dialog = new GroupDialog();
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
floatingActionButtonAutoHide(actionButton, scrollView);
|
||||||
|
|
||||||
|
if (Backend.instance() != null)
|
||||||
this.config = Backend.instance().getConfig();
|
this.config = Backend.instance().getConfig();
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
configName.setVisibility(View.GONE);
|
configName.setVisibility(View.GONE);
|
||||||
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle("Config: " + config.getName());
|
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle("Config: " + config.getName());
|
||||||
@@ -53,7 +71,7 @@ public class EditorFragment extends Fragment {
|
|||||||
|
|
||||||
private void populateGroups() {
|
private void populateGroups() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Group group : config.getGroups()) {
|
for (final Group group : config.getGroups()) {
|
||||||
View view = View.inflate(getContext(), R.layout.fragment_part_groups, null);
|
View view = View.inflate(getContext(), R.layout.fragment_part_groups, null);
|
||||||
Button name = view.findViewById(R.id.name);
|
Button name = view.findViewById(R.id.name);
|
||||||
ImageButton rename = view.findViewById(R.id.rename);
|
ImageButton rename = view.findViewById(R.id.rename);
|
||||||
@@ -73,6 +91,22 @@ public class EditorFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rename.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
GroupDialog dialog = new GroupDialog(group);
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
delete.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ConfirmationDialog dialog = new ConfirmationDialog("Are you sure?", "Really delete " + group.name + "?", null);
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
}
|
}
|
||||||
@@ -4,32 +4,37 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.navigation.NavAction;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import androidx.navigation.Navigation;
|
|
||||||
import androidx.navigation.ui.NavigationUI;
|
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Config;
|
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.dialogs.VariableDialog;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class VariablesFragment extends Fragment {
|
public class VariablesFragment extends TimeCraftersFragment {
|
||||||
private Config config;
|
private Config config;
|
||||||
private LinearLayout container;
|
private LinearLayout container;
|
||||||
private Config.Group group;
|
private Group group;
|
||||||
private Config.Action action;
|
private Action action;
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View root = inflater.inflate(R.layout.fragment_variables, container, false);
|
final View root = inflater.inflate(R.layout.fragment_variables, container, false);
|
||||||
this.container = root.findViewById(R.id.container);
|
this.container = root.findViewById(R.id.container);
|
||||||
|
final FloatingActionButton actionButton = root.findViewById(R.id.actionButton);
|
||||||
|
final ScrollView scrollView = root.findViewById(R.id.scrollview);
|
||||||
|
|
||||||
this.config = Backend.instance().getConfig();
|
this.config = Backend.instance().getConfig();
|
||||||
this.group = config.getGroups().get(0);
|
this.group = config.getGroups().get(0);
|
||||||
@@ -40,15 +45,24 @@ public class VariablesFragment extends Fragment {
|
|||||||
populateVariables();
|
populateVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
floatingActionButtonAutoHide(actionButton, scrollView);
|
||||||
|
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
VariableDialog dialog = new VariableDialog(action);
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateVariables() {
|
private void populateVariables() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Config.Variable variable : action.getVariables()) {
|
for (final Variable variable : action.getVariables()) {
|
||||||
View view = View.inflate(getContext(), R.layout.fragment_part_variables, null);
|
View view = View.inflate(getContext(), R.layout.fragment_part_variables, null);
|
||||||
TextView name = view.findViewById(R.id.name);
|
final TextView name = view.findViewById(R.id.name);
|
||||||
TextView value = view.findViewById(R.id.value);
|
final TextView value = view.findViewById(R.id.value);
|
||||||
ImageButton rename = view.findViewById(R.id.rename);
|
ImageButton rename = view.findViewById(R.id.rename);
|
||||||
ImageButton delete = view.findViewById(R.id.delete);
|
ImageButton delete = view.findViewById(R.id.delete);
|
||||||
|
|
||||||
@@ -61,6 +75,14 @@ public class VariablesFragment extends Fragment {
|
|||||||
name.setText(variable.name);
|
name.setText(variable.name);
|
||||||
value.setText("" + variable.value());
|
value.setText("" + variable.value());
|
||||||
|
|
||||||
|
rename.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
VariableDialog dialog = new VariableDialog(variable, name, value);
|
||||||
|
dialog.show(getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,16 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class SearchFragment extends Fragment {
|
public class SearchFragment extends TimeCraftersFragment {
|
||||||
|
|
||||||
private SearchViewModel searchViewModel;
|
private SearchViewModel searchViewModel;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.timecrafters.TimeCraftersConfigurationTool.ui.settings;
|
package org.timecrafters.TimeCraftersConfigurationTool.ui.settings;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -9,14 +8,14 @@ import android.widget.Button;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class SettingsFragment extends Fragment {
|
public class SettingsFragment extends TimeCraftersFragment {
|
||||||
|
|
||||||
private SettingsViewModel settingsViewModel;
|
private SettingsViewModel settingsViewModel;
|
||||||
|
|
||||||
|
|||||||
@@ -7,23 +7,14 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class ConfigurationsFragment extends Fragment {
|
public class ConfigurationsFragment extends TimeCraftersFragment {
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View root = inflater.inflate(R.layout.activity_manage_configurations, container, false);
|
final View root = inflater.inflate(R.layout.fragment_configuration, container, false);
|
||||||
|
|
||||||
|
|
||||||
LinearLayout v = root.findViewById(R.id.configurations);
|
|
||||||
v.setBackgroundColor(getResources().getColor(R.color.list_even));
|
|
||||||
|
|
||||||
View vv = v.inflate(getContext(), R.layout.fragment_configuration, null);
|
|
||||||
v.addView(vv);
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.timecrafters.TimeCraftersConfigurationTool.ui.settings.presets;
|
package org.timecrafters.TimeCraftersConfigurationTool.ui.settings.presets;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class PresetsFragment extends Fragment {
|
public class PresetsFragment extends TimeCraftersFragment {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import android.widget.EditText;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
|
||||||
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.VariableDialog;
|
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.ServerDialog;
|
||||||
|
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersFragment;
|
||||||
|
|
||||||
public class TACNETFragment extends Fragment {
|
public class TACNETFragment extends TimeCraftersFragment {
|
||||||
|
|
||||||
private static final String TAG = "TACNETFragment";
|
private static final String TAG = "TACNETFragment";
|
||||||
private TACNETViewModel TACNETViewModel;
|
private TACNETViewModel TACNETViewModel;
|
||||||
@@ -69,8 +69,8 @@ public class TACNETFragment extends Fragment {
|
|||||||
connectButton.setOnClickListener(new View.OnClickListener() {
|
connectButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
VariableDialog dialog = new VariableDialog();
|
// ConnectDialog dialog = new ConnectDialog();
|
||||||
dialog.show(getFragmentManager(), null);
|
// dialog.show(getFragmentManager(), null);
|
||||||
Backend.instance().saveSettings();
|
Backend.instance().saveSettings();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -78,7 +78,7 @@ public class TACNETFragment extends Fragment {
|
|||||||
startServerButton.setOnClickListener(new View.OnClickListener() {
|
startServerButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
VariableDialog dialog = new VariableDialog();
|
ServerDialog dialog = new ServerDialog();
|
||||||
dialog.show(getFragmentManager(), null);
|
dialog.show(getFragmentManager(), null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
BIN
app/src/main/res/drawable-hdpi/plus.png
Normal file
BIN
app/src/main/res/drawable-hdpi/plus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 241 B |
BIN
app/src/main/res/drawable-mdpi/plus.png
Normal file
BIN
app/src/main/res/drawable-mdpi/plus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 199 B |
BIN
app/src/main/res/drawable-xhdpi/plus.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/plus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 276 B |
BIN
app/src/main/res/drawable-xxhdpi/plus.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/plus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 388 B |
BIN
app/src/main/res/drawable-xxxhdpi/plus.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/plus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 498 B |
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/configurations"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
</ScrollView>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -30,9 +30,10 @@
|
|||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/dialogCloseButton"
|
android:id="@+id/dialogCloseButton"
|
||||||
android:layout_width="wrap_content"
|
style="Da"
|
||||||
|
android:layout_width="56dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:backgroundTint="@color/colorDanger"
|
android:background="@drawable/dangerous_button"
|
||||||
android:contentDescription="@string/dialog_close"
|
android:contentDescription="@string/dialog_close"
|
||||||
android:src="@drawable/cross"
|
android:src="@drawable/cross"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|||||||
43
app/src/main/res/layout/dialog_confirmation.xml
Normal file
43
app/src/main/res/layout/dialog_confirmation.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/message"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginLeft="@dimen/button_margin_left"
|
||||||
|
android:layout_marginTop="@dimen/button_margin_top"
|
||||||
|
android:layout_marginRight="@dimen/button_margin_right"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="TextView"
|
||||||
|
android:textColor="@color/dialogLabel"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/dialog_button_margin"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/dialog_cancel" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/confirm"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/dialog_okay"
|
||||||
|
android:background="@drawable/dangerous_button" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
59
app/src/main/res/layout/dialog_edit_action.xml
Normal file
59
app/src/main/res/layout/dialog_edit_action.xml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView5"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center|center_horizontal|center_vertical"
|
||||||
|
android:text="@string/variable_name"
|
||||||
|
android:textColor="@color/dialogLabel" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/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/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" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/comment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="@string/comment"
|
||||||
|
android:inputType="textPersonName" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/dialog_button_margin"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/dialog_cancel" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/mutate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/dialog_add" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
43
app/src/main/res/layout/dialog_edit_group.xml
Normal file
43
app/src/main/res/layout/dialog_edit_group.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView5"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center|center_horizontal|center_vertical"
|
||||||
|
android:text="@string/variable_name"
|
||||||
|
android:textColor="@color/dialogLabel" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="@string/variable_name"
|
||||||
|
android:inputType="textPersonName" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/dialog_button_margin"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/dialog_cancel" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/mutate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/dialog_add" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
126
app/src/main/res/layout/dialog_server.xml
Normal file
126
app/src/main/res/layout/dialog_server.xml
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
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:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- labels -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Client Status"
|
||||||
|
android:textColor="@color/dialogLabel"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Total Packets In"
|
||||||
|
android:textColor="@color/dialogLabel"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Total Packets Out"
|
||||||
|
android:textColor="@color/dialogLabel"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Total Data In"
|
||||||
|
android:textColor="@color/dialogLabel"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Total Data Out"
|
||||||
|
android:textColor="@color/dialogLabel"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- values -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/button_margin_left"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/total_data_out"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="@color/dialogLabel"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/total_packets_in"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="@color/dialogLabel"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/total_data_in"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="@color/dialogLabel"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/client_status"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="@color/dialogLabel"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/total_packets_out"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="@color/dialogLabel"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/dialog_button_margin"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/stop_server"
|
||||||
|
style="@style/DangerousButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/tacnet_stop_server" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
@@ -5,16 +5,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.editor.EditorFragment">
|
tools:context=".ui.editor.GroupsFragment">
|
||||||
|
|
||||||
<ScrollView
|
<include layout="@layout/partial_editor"/>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
</ScrollView>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -3,19 +3,9 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ScrollView
|
<include layout="@layout/partial_editor"/>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/configuration"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"></LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -5,25 +5,18 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.editor.EditorFragment">
|
tools:context=".ui.editor.GroupsFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/configuration_name"
|
android:id="@+id/configuration_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/list_even"
|
android:background="@color/list_even"
|
||||||
android:text="No configuration active"
|
android:text="@string/warning_no_config_active"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
|
|
||||||
<ScrollView
|
<include layout="@layout/partial_editor"/>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
</ScrollView>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -5,16 +5,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.editor.EditorFragment">
|
tools:context=".ui.editor.GroupsFragment">
|
||||||
|
|
||||||
<ScrollView
|
<include layout="@layout/partial_editor"/>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
</ScrollView>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
31
app/src/main/res/layout/partial_editor.xml
Normal file
31
app/src/main/res/layout/partial_editor.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/scrollview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/actionButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/activity_vertical_margin"
|
||||||
|
android:clickable="true"
|
||||||
|
android:src="@drawable/plus"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/navigation_editor"
|
android:id="@+id/navigation_editor"
|
||||||
android:name="org.timecrafters.TimeCraftersConfigurationTool.ui.editor.EditorFragment"
|
android:name="org.timecrafters.TimeCraftersConfigurationTool.ui.editor.GroupsFragment"
|
||||||
android:label="@string/title_editor"
|
android:label="@string/title_editor"
|
||||||
tools:layout="@layout/fragment_editor" >
|
tools:layout="@layout/fragment_groups" >
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_navigation_editor_to_actionsFragment"
|
android:id="@+id/action_navigation_editor_to_actionsFragment"
|
||||||
app:destination="@id/actionsFragment" />
|
app:destination="@id/actionsFragment" />
|
||||||
|
|||||||
@@ -32,4 +32,8 @@
|
|||||||
<string name="variable_name">Name</string>
|
<string name="variable_name">Name</string>
|
||||||
<string name="variable_type">Type</string>
|
<string name="variable_type">Type</string>
|
||||||
<string name="variable_value">Value</string>
|
<string name="variable_value">Value</string>
|
||||||
|
<string name="comment">Comment</string>
|
||||||
|
<string name="warning_no_config_active">No active configuration set</string>
|
||||||
|
<string name="tacnet_stop_server">Stop Server</string>
|
||||||
|
<string name="tacnet_server_status">Server Status</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user