mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
Add fields displayed within field editor
This commit is contained in:
@@ -15,8 +15,11 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
import com.ridgebotics.ridgescout.R;
|
import com.ridgebotics.ridgescout.R;
|
||||||
|
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class FieldDisplay extends ConstraintLayout {
|
public class FieldDisplay extends ConstraintLayout {
|
||||||
public FieldDisplay(Context context, @Nullable AttributeSet attrs) {
|
public FieldDisplay(Context context, @Nullable AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -32,33 +35,42 @@ public class FieldDisplay extends ConstraintLayout {
|
|||||||
|
|
||||||
public Button editButton;
|
public Button editButton;
|
||||||
|
|
||||||
private TextView titleText;
|
|
||||||
private TextView typeText;
|
|
||||||
|
|
||||||
// private View fieldView;
|
// private View fieldView;
|
||||||
private LinearLayout buttonBox;
|
private LinearLayout buttonBox;
|
||||||
private ConstraintLayout box;
|
private ConstraintLayout box;
|
||||||
private View coloredBackground;
|
public View coloredBackground;
|
||||||
|
private LinearLayout fieldDisplayBox;
|
||||||
|
|
||||||
public void init(Context context) {
|
public void init(Context context) {
|
||||||
LayoutInflater.from(context).inflate(R.layout.view_field_display, this, true);
|
LayoutInflater.from(context).inflate(R.layout.view_field_display, this, true);
|
||||||
|
|
||||||
box = findViewById(R.id.field_box);
|
box = findViewById(R.id.field_box);
|
||||||
|
fieldDisplayBox = findViewById(R.id.field_display_box);
|
||||||
coloredBackground = findViewById(R.id.field_background);
|
coloredBackground = findViewById(R.id.field_background);
|
||||||
|
|
||||||
editButton = findViewById(R.id.button_edit);
|
editButton = findViewById(R.id.button_edit);
|
||||||
|
|
||||||
titleText = findViewById(R.id.field_title);
|
|
||||||
typeText = findViewById(R.id.field_description);
|
|
||||||
|
|
||||||
buttonBox = findViewById(R.id.buttons);
|
buttonBox = findViewById(R.id.buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInputType(FieldType field){
|
private ToggleTitleView toggleTitleView;
|
||||||
|
private View fieldView;
|
||||||
|
|
||||||
|
public void setField(FieldType field){
|
||||||
this.field = field;
|
this.field = field;
|
||||||
|
|
||||||
titleText.setText(field.name);
|
// titleText.setText(field.name);
|
||||||
typeText.setText(field.get_type_name());
|
// typeText.setText(field.get_type_name());
|
||||||
|
|
||||||
|
toggleTitleView = new ToggleTitleView(getContext());
|
||||||
|
toggleTitleView.setTitle(field.name);
|
||||||
|
toggleTitleView.setDescription(field.description);
|
||||||
|
fieldView = field.createView(getContext(), dataType -> 0);
|
||||||
|
|
||||||
|
fieldDisplayBox.removeAllViews();
|
||||||
|
fieldDisplayBox.addView(toggleTitleView);
|
||||||
|
fieldDisplayBox.addView(fieldView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setField(View newView){
|
// public void setField(View newView){
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public class ToggleTitleView extends ConstraintLayout {
|
|||||||
else
|
else
|
||||||
disable();
|
disable();
|
||||||
|
|
||||||
onToggleListener.onToggle(!checked);
|
if(onToggleListener != null)
|
||||||
|
onToggleListener.onToggle(!checked);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.ridgebotics.ridgescout.ui.settings;
|
package com.ridgebotics.ridgescout.ui.settings;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -132,16 +134,23 @@ public class FieldsFragment extends Fragment {
|
|||||||
|
|
||||||
binding.saveButton.setOnClickListener(l -> save());
|
binding.saveButton.setOnClickListener(l -> save());
|
||||||
|
|
||||||
|
// binding.previewButton.setOnClickListener(v -> startPreview());
|
||||||
|
|
||||||
|
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private void createFieldDisplay(FieldType field){
|
private void createFieldDisplay(FieldType field){
|
||||||
final FieldDisplay fd = new FieldDisplay(getContext());
|
final FieldDisplay fd = new FieldDisplay(getContext());
|
||||||
views.add(fd);
|
views.add(fd);
|
||||||
|
|
||||||
fd.setInputType(field);
|
fd.setField(field);
|
||||||
fd.setColor(unfocused_background_color);
|
fd.setColor(unfocused_background_color);
|
||||||
fd.setOnClickListener(v -> setFocus(fd,false));
|
fd.coloredBackground.setOnTouchListener((view, motionEvent) -> {
|
||||||
|
FieldsFragment.this.setFocus(fd, false);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
fd.editButton.setOnClickListener(v -> openEditor(fd));
|
fd.editButton.setOnClickListener(v -> openEditor(fd));
|
||||||
|
|
||||||
binding.fieldsArea.addView(fd);
|
binding.fieldsArea.addView(fd);
|
||||||
@@ -196,7 +205,7 @@ public class FieldsFragment extends Fragment {
|
|||||||
alert.setNeutralButton("Cancel", (dialogInterface, i) -> {});
|
alert.setNeutralButton("Cancel", (dialogInterface, i) -> {});
|
||||||
alert.setPositiveButton("Save", (dialogInterface, i) -> {
|
alert.setPositiveButton("Save", (dialogInterface, i) -> {
|
||||||
f.save();
|
f.save();
|
||||||
fd.setInputType(field);
|
fd.setField(field);
|
||||||
enableSaving();
|
enableSaving();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -276,521 +285,7 @@ public class FieldsFragment extends Fragment {
|
|||||||
alert.create().show();
|
alert.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void revertPopup(){
|
||||||
|
|
||||||
// @SuppressLint("ClickableViewAccessibility")
|
}
|
||||||
// public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
|
||||||
// @Nullable Bundle savedInstanceState) {
|
|
||||||
// binding = FragmentSettingsFieldsBinding.inflate(inflater, container, false);
|
|
||||||
//
|
|
||||||
// binding.valueEditScrollview.setOnTouchListener((v, event) -> true);
|
|
||||||
//
|
|
||||||
// binding.saveButton.setVisibility(View.GONE);
|
|
||||||
// binding.cancelEditButton.setVisibility(View.GONE);
|
|
||||||
// binding.editButton.setVisibility(View.GONE);
|
|
||||||
// binding.upButton.setVisibility(View.GONE);
|
|
||||||
// binding.addButton.setVisibility(View.GONE);
|
|
||||||
// binding.downButton.setVisibility(View.GONE);
|
|
||||||
// binding.deleteButton.setVisibility(View.GONE);
|
|
||||||
//
|
|
||||||
// binding.valueEditContainer.setVisibility(View.GONE);
|
|
||||||
//
|
|
||||||
// load_field_menu();
|
|
||||||
//
|
|
||||||
// ((MainActivity) getActivity()).setOnBackPressed(() -> {
|
|
||||||
// if(binding.saveButton.getVisibility() == View.GONE) return true;
|
|
||||||
//
|
|
||||||
// AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
|
||||||
// alert.setTitle("Warning!");
|
|
||||||
// alert.setMessage("You have not saved your progress!");
|
|
||||||
// alert.setPositiveButton("Return", null);
|
|
||||||
// alert.setNeutralButton("Quit without saving", (dialogInterface, i) -> {
|
|
||||||
// binding.saveButton.setVisibility(View.GONE);
|
|
||||||
// if(getActivity() != null)
|
|
||||||
// getActivity().onBackPressed();
|
|
||||||
// });
|
|
||||||
// alert.setCancelable(true);
|
|
||||||
//
|
|
||||||
// alert.create().show();
|
|
||||||
//
|
|
||||||
// return false;
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// return binding.getRoot();
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
|
||||||
// inputType[][] values;
|
|
||||||
//
|
|
||||||
// private void load_field_menu() {
|
|
||||||
//
|
|
||||||
// values = fields.load(filename);
|
|
||||||
//
|
|
||||||
// binding.fieldsArea.bringToFront();
|
|
||||||
// binding.fieldsArea.setStretchAllColumns(true);
|
|
||||||
// binding.fieldsArea.removeAllViews();
|
|
||||||
// binding.fieldsArea.setReorderingEnabled(false);
|
|
||||||
//
|
|
||||||
// if(values == null) return;
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < values.length; i++){
|
|
||||||
//
|
|
||||||
// TableRow tr = new TableRow(getContext());
|
|
||||||
// TableLayout.LayoutParams rowParams = new TableLayout.LayoutParams(
|
|
||||||
// FrameLayout.LayoutParams.WRAP_CONTENT,
|
|
||||||
// FrameLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// rowParams.setMargins(20,20,20,20);
|
|
||||||
// tr.setLayoutParams(rowParams);
|
|
||||||
// tr.setPadding(20,20,20,20);
|
|
||||||
//
|
|
||||||
// TextView tv = new TextView(getContext());
|
|
||||||
// tv.setText("v" + i);
|
|
||||||
// tv.setTextSize(20);
|
|
||||||
// tr.addView(tv);
|
|
||||||
//
|
|
||||||
// tv = new TextView(getContext());
|
|
||||||
// tv.setText(values[i].length + " Fields");
|
|
||||||
// tv.setTextSize(16);
|
|
||||||
// tr.addView(tv);
|
|
||||||
//
|
|
||||||
// binding.fieldsArea.addView(tr);
|
|
||||||
//
|
|
||||||
// if(i == values.length-1) {
|
|
||||||
// tr.setBackgroundColor(background_color);
|
|
||||||
// int fi = i;
|
|
||||||
// tr.setOnClickListener(v -> {
|
|
||||||
// display_fields(values[fi]);
|
|
||||||
// });
|
|
||||||
// }else{
|
|
||||||
// tr.setBackgroundColor(unfocused_background_color);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(values.length > 1) {
|
|
||||||
// binding.revertVersionButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.revertVersionButton.setOnClickListener(v -> {
|
|
||||||
// AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
|
||||||
// alert.setTitle("Warning!");
|
|
||||||
// alert.setMessage("If there is any data set this version, it will be deleted!");
|
|
||||||
// alert.setPositiveButton("OK", (dialog, which) -> {
|
|
||||||
// inputType[][] newArr = new inputType[values.length - 1][];
|
|
||||||
// System.arraycopy(values, 0, newArr, 0, values.length - 1);
|
|
||||||
// if(fields.save(filename, newArr))
|
|
||||||
// AlertManager.toast("Saved");
|
|
||||||
// load_field_menu();
|
|
||||||
// });
|
|
||||||
// alert.setNegativeButton("Cancel", null);
|
|
||||||
// alert.setCancelable(true);
|
|
||||||
// alert.create().show();
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void display_fields(inputType[] version_values) {
|
|
||||||
// binding.fieldsArea.removeAllViews();
|
|
||||||
// binding.fieldsArea.setReorderingEnabled(false);
|
|
||||||
//
|
|
||||||
// binding.revertVersionButton.setVisibility(View.GONE);
|
|
||||||
//
|
|
||||||
// binding.saveButton.setVisibility(View.GONE);
|
|
||||||
// binding.editButton.setVisibility(View.GONE);
|
|
||||||
// binding.upButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.addButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.downButton.setVisibility(View.VISIBLE);
|
|
||||||
//
|
|
||||||
// updateUpDownAvailability();
|
|
||||||
//
|
|
||||||
// binding.valueEditContainer.setVisibility(View.GONE);
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < version_values.length; i++){
|
|
||||||
// addRow(version_values[i]);
|
|
||||||
// }
|
|
||||||
// selindex = -1;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// binding.addButton.setOnClickListener(this::addField);
|
|
||||||
// binding.saveButton.setOnClickListener(this::buttonfunc);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Make sure the user cannot move fields when they shouldn't
|
|
||||||
// private void updateUpDownAvailability(){
|
|
||||||
// binding.upButton.setEnabled(selindex != -1 && selindex != 0);
|
|
||||||
// binding.downButton.setEnabled(selindex != -1 && selindex != values[values.length-1].length-1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void addRow(inputType field){
|
|
||||||
// View tr = getTableRow(field);
|
|
||||||
//
|
|
||||||
// binding.fieldsArea.addView(tr);
|
|
||||||
//
|
|
||||||
// tr.setOnClickListener(v -> {
|
|
||||||
// binding.editButton.setVisibility(View.VISIBLE);
|
|
||||||
// trOnClick(values[values.length-1], tr);
|
|
||||||
// updateUpDownAvailability();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// binding.upButton.setOnClickListener(v -> {
|
|
||||||
// if(selindex != 0) {
|
|
||||||
// binding.saveButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.fieldsArea.updateRowOrder(selindex, selindex - 1);
|
|
||||||
// selindex -= 1;
|
|
||||||
// }
|
|
||||||
// updateUpDownAvailability();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// binding.downButton.setOnClickListener(v -> {
|
|
||||||
// if(selindex != values[values.length-1].length-1) {
|
|
||||||
// binding.saveButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.fieldsArea.updateRowOrder(selindex, selindex + 1);
|
|
||||||
// selindex += 1;
|
|
||||||
// }
|
|
||||||
// updateUpDownAvailability();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void buttonfunc(View v){
|
|
||||||
// AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
|
||||||
// alert.setTitle("Warning!");
|
|
||||||
// alert.setMessage("Changing or removing some values will result in lost data!\nBut this will create a new field version, and you can revert at any time.");
|
|
||||||
// alert.setPositiveButton("OK", (dialog, which) -> {
|
|
||||||
// inputType[][] currentValues = fields.load(filename);
|
|
||||||
// assert currentValues != null;
|
|
||||||
// inputType[][] newValues = new inputType[currentValues.length+1][];
|
|
||||||
// System.arraycopy(currentValues, 0, newValues, 0, currentValues.length);
|
|
||||||
//
|
|
||||||
// newValues[newValues.length-1] = new inputType[values[values.length-1].length];
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < values[values.length-1].length; i++){
|
|
||||||
// newValues[newValues.length-1][i] = values[values.length-1][binding.fieldsArea.getReorderedIndexes().get(i)];
|
|
||||||
// }
|
|
||||||
//// newValues[newValues.length-1] = values[values.length-1];
|
|
||||||
//
|
|
||||||
// if(fields.save(filename, newValues))
|
|
||||||
// AlertManager.toast("Saved");
|
|
||||||
//
|
|
||||||
// Navigation.findNavController((Activity) getContext(), R.id.nav_host_fragment_activity_main).navigate(R.id.action_navigation_data_fields_to_navigation_settings);
|
|
||||||
// });
|
|
||||||
// alert.setNegativeButton("Cancel", null);
|
|
||||||
// alert.setCancelable(true);
|
|
||||||
// alert.create().show();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private int selindex = -1;
|
|
||||||
//
|
|
||||||
// private void trOnClick(inputType[] version_values, View tr){
|
|
||||||
// selindex = -1;
|
|
||||||
// for(int i = 0; i < binding.fieldsArea.getChildCount(); i++){
|
|
||||||
// View v = binding.fieldsArea.getChildAt(i);
|
|
||||||
//
|
|
||||||
// if(v.equals(tr)) {
|
|
||||||
// tr.setBackgroundColor(background_color);
|
|
||||||
// selindex = i;
|
|
||||||
// } else
|
|
||||||
// binding.fieldsArea.getChildAt(i).setBackgroundColor(unfocused_background_color);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// onFieldSelect(version_values[binding.fieldsArea.getReorderedIndexes().get(selindex)]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void onFieldSelect(inputType field){
|
|
||||||
// //System.out.println(field.name);
|
|
||||||
//
|
|
||||||
// binding.editButton.setOnClickListener(v -> {
|
|
||||||
// binding.editButton.setVisibility(View.GONE);
|
|
||||||
// binding.addButton.setVisibility(View.GONE);
|
|
||||||
// binding.upButton.setVisibility(View.GONE);
|
|
||||||
// binding.downButton.setVisibility(View.GONE);
|
|
||||||
//
|
|
||||||
// binding.ValueEditTable.removeAllViews();
|
|
||||||
// binding.valueEditContainer.setVisibility(View.VISIBLE);
|
|
||||||
// TextView tv = new TextView(getContext());
|
|
||||||
//
|
|
||||||
// tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
|
||||||
// tv.setText(field.name);
|
|
||||||
// tv.setPadding(8,8,8,8);
|
|
||||||
// tv.setTextSize(24);
|
|
||||||
//
|
|
||||||
// binding.ValueEditTable.addView(tv);
|
|
||||||
//
|
|
||||||
// final FieldEditorHelper fe = new FieldEditorHelper(
|
|
||||||
// getContext(),
|
|
||||||
// field,
|
|
||||||
// binding.ValueEditTable
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// binding.saveButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.saveButton.setOnClickListener(a -> {
|
|
||||||
// System.out.println(fe.save());
|
|
||||||
// defaultVisibility();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// binding.cancelEditButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.cancelEditButton.setOnClickListener(a -> {
|
|
||||||
// defaultVisibility();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// binding.deleteButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.deleteButton.setOnClickListener(a -> {
|
|
||||||
// deleteField(field);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void deleteField(inputType field){
|
|
||||||
// AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
|
||||||
// alert.setTitle("Warning!");
|
|
||||||
// alert.setMessage("Removing a value will result in data being deleted in subsequent field versions!");
|
|
||||||
// alert.setNegativeButton("Cancel", null);
|
|
||||||
// alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// defaultVisibility();
|
|
||||||
//
|
|
||||||
// int oldindex = -1;
|
|
||||||
// for(int i = 0; i < values[values.length - 1].length; i++){
|
|
||||||
// if(values[values.length - 1][i].equals(field)){
|
|
||||||
// oldindex = i;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(oldindex != -1) {
|
|
||||||
// System.out.println(Arrays.toString(values[values.length - 1]));
|
|
||||||
// binding.fieldsArea.removeViewAt(selindex);
|
|
||||||
// binding.fieldsArea.removeElement(oldindex);
|
|
||||||
// values[values.length - 1] = removeElement(values[values.length - 1], oldindex);
|
|
||||||
// selindex = -1;
|
|
||||||
// AlertManager.toast("Removed!");
|
|
||||||
// binding.editButton.setVisibility(View.GONE);
|
|
||||||
// System.out.println(Arrays.toString(values[values.length - 1]));
|
|
||||||
// //System.out.println(values[values.length-1].length);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// alert.setCancelable(true);
|
|
||||||
// alert.create().show();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public inputType[] removeElement(inputType[] src, int i) {
|
|
||||||
// inputType[] newArray = new inputType[src.length - 1];
|
|
||||||
// if (i > 0){
|
|
||||||
// System.arraycopy(src, 0, newArray, 0, i);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (newArray.length > i){
|
|
||||||
// System.arraycopy(src, i + 1, newArray, i, newArray.length - i);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return newArray;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private void defaultVisibility() {
|
|
||||||
// binding.editButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.addButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.upButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.downButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.ValueEditTable.removeAllViews();
|
|
||||||
// binding.valueEditContainer.setVisibility(View.GONE);
|
|
||||||
// binding.cancelEditButton.setVisibility(View.GONE);
|
|
||||||
// binding.deleteButton.setVisibility(View.GONE);
|
|
||||||
// binding.saveButton.setOnClickListener(this::buttonfunc);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private void addField(View v) {
|
|
||||||
// AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
// builder.setTitle("Title");
|
|
||||||
//
|
|
||||||
// final EditText input = new EditText(getContext());
|
|
||||||
// input.setInputType(InputType.TYPE_CLASS_TEXT);
|
|
||||||
//
|
|
||||||
// builder.setView(input);
|
|
||||||
//
|
|
||||||
// builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// dialog.cancel();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// String title = input.getText().toString();
|
|
||||||
// if(title.isEmpty() || title.isBlank()) {
|
|
||||||
// AlertManager.addSimpleError("Title cannot be blank!");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// addField_Part_2(title);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// builder.show();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void addField_Part_2(String title) {
|
|
||||||
// AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
// builder.setTitle("Select Type");
|
|
||||||
//
|
|
||||||
// final CustomSpinnerView dropdown = new CustomSpinnerView(getContext());
|
|
||||||
// List<String> options = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// options.add("Slider");
|
|
||||||
// options.add("Text");
|
|
||||||
// options.add("Dropdown");
|
|
||||||
// options.add("Tally");
|
|
||||||
// options.add("Number");
|
|
||||||
// options.add("Checkbox");
|
|
||||||
// options.add("Field Position");
|
|
||||||
//
|
|
||||||
// dropdown.setOptions(options, 0);
|
|
||||||
// dropdown.setTitle("Type");
|
|
||||||
//
|
|
||||||
// builder.setView(dropdown);
|
|
||||||
//
|
|
||||||
// builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
|
|
||||||
// builder.setPositiveButton("OK", (dialog, which) -> addField_Part_3(title, dropdown.getIndex()));
|
|
||||||
//
|
|
||||||
// builder.show();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void addField_Part_3(String title, int typeIndex) {
|
|
||||||
// switch (typeIndex){
|
|
||||||
// case 0:
|
|
||||||
// SliderType slider = new SliderType();
|
|
||||||
// slider.name = title;
|
|
||||||
// FieldEditorHelper.setSliderParams(slider, FieldEditorHelper.defaultSliderParams);
|
|
||||||
// addField_Part_4(slider);
|
|
||||||
// break;
|
|
||||||
// case 1:
|
|
||||||
// textType text = new textType();
|
|
||||||
// text.name = title;
|
|
||||||
// FieldEditorHelper.setTextParams(text, FieldEditorHelper.defaultTextParams);
|
|
||||||
// addField_Part_4(text);
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// dropdownType dropdown = new dropdownType();
|
|
||||||
// dropdown.name = title;
|
|
||||||
// FieldEditorHelper.setDropdownParams(dropdown, FieldEditorHelper.defaultDropdownParams);
|
|
||||||
// addField_Part_4(dropdown);
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// tallyType tally = new tallyType();
|
|
||||||
// tally.name = title;
|
|
||||||
// FieldEditorHelper.setTallyParams(tally, FieldEditorHelper.defaultTallyParams);
|
|
||||||
// addField_Part_4(tally);
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// numberType num = new numberType();
|
|
||||||
// num.name = title;
|
|
||||||
// FieldEditorHelper.setNumberParams(num, FieldEditorHelper.defaultNumberParams);
|
|
||||||
// addField_Part_4(num);
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// checkboxType cb = new checkboxType();
|
|
||||||
// cb.name = title;
|
|
||||||
// FieldEditorHelper.setCheckboxParam(cb, FieldEditorHelper.defaultCheckboxParam);
|
|
||||||
// addField_Part_4(cb);
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// fieldposType fp = new fieldposType();
|
|
||||||
// fp.name = title;
|
|
||||||
// FieldEditorHelper.setFieldPosParam(fp, FieldEditorHelper.defaultFieldPosParam);
|
|
||||||
// addField_Part_4(fp);
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// private void addField_Part_4(inputType field) {
|
|
||||||
// binding.editButton.setVisibility(View.GONE);
|
|
||||||
// binding.addButton.setVisibility(View.GONE);
|
|
||||||
// binding.upButton.setVisibility(View.GONE);
|
|
||||||
// binding.downButton.setVisibility(View.GONE);
|
|
||||||
//
|
|
||||||
// binding.ValueEditTable.removeAllViews();
|
|
||||||
// binding.valueEditContainer.setVisibility(View.VISIBLE);
|
|
||||||
// TextView tv = new TextView(getContext());
|
|
||||||
//
|
|
||||||
// tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
|
||||||
// tv.setText(field.name);
|
|
||||||
// tv.setPadding(8,8,8,8);
|
|
||||||
// tv.setTextSize(24);
|
|
||||||
//
|
|
||||||
// binding.ValueEditTable.addView(tv);
|
|
||||||
//
|
|
||||||
// final FieldEditorHelper fe = new FieldEditorHelper(
|
|
||||||
// getContext(),
|
|
||||||
// field,
|
|
||||||
// binding.ValueEditTable
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// binding.saveButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.saveButton.setOnClickListener(a -> {
|
|
||||||
// inputType[] newValues = new inputType[values[values.length-1].length+1];
|
|
||||||
// System.arraycopy(values[values.length-1], 0, newValues, 0, values[values.length-1].length);
|
|
||||||
// newValues[newValues.length-1] = field;
|
|
||||||
// values[values.length-1] = newValues;
|
|
||||||
//
|
|
||||||
//// AlertManager.alert("Test", String.valueOf(binding.fieldsArea.getReorderedIndexes()));
|
|
||||||
//
|
|
||||||
// //TableRow tr = getTableRow(field);
|
|
||||||
// //binding.fieldsArea.addView(tr);
|
|
||||||
// addRow(field);
|
|
||||||
//
|
|
||||||
// System.out.println(fe.save());
|
|
||||||
// defaultVisibility();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// binding.cancelEditButton.setVisibility(View.VISIBLE);
|
|
||||||
// binding.cancelEditButton.setOnClickListener(a -> {
|
|
||||||
// defaultVisibility();
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private @NonNull View getTableRow(inputType field) {
|
|
||||||
//// TableRow tr = new TableRow(getContext());
|
|
||||||
//// TableLayout.LayoutParams rowParams = new TableLayout.LayoutParams(
|
|
||||||
//// FrameLayout.LayoutParams.WRAP_CONTENT,
|
|
||||||
//// FrameLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
//// );
|
|
||||||
////
|
|
||||||
//// rowParams.setMargins(20,20,20,20);
|
|
||||||
//// tr.setLayoutParams(rowParams);
|
|
||||||
//// tr.setPadding(20,20,20,20);
|
|
||||||
//// tr.setBackgroundColor(unfocused_background_color);
|
|
||||||
////
|
|
||||||
//// TextView tv = new TextView(getContext());
|
|
||||||
//// tv.setText(field.get_type_name());
|
|
||||||
//// tv.setTextSize(12);
|
|
||||||
//// tr.addView(tv);
|
|
||||||
////
|
|
||||||
//// tv = new TextView(getContext());
|
|
||||||
//// tv.setText(field.name);
|
|
||||||
//// tv.setTextSize(20);
|
|
||||||
//// tr.addView(tv);
|
|
||||||
// FieldDisplay fd = new FieldDisplay(getContext());
|
|
||||||
//
|
|
||||||
// fd.setField(field.createView(getContext(), dataType -> 0));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return fd;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,15 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/revert_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Revert"
|
||||||
|
android:textSize="20sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/up_button"
|
android:id="@+id/up_button"
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
@@ -67,5 +76,22 @@
|
|||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/preview_scout_scroll"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/preview_scout_area"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="48dp">
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -44,36 +44,20 @@
|
|||||||
app:layout_constraintVertical_bias="0.6"
|
app:layout_constraintVertical_bias="0.6"
|
||||||
tools:ignore="UselessParent">
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/field_title"
|
android:id="@+id/field_display_box"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Example dropdown"
|
android:orientation="vertical"
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
|
android:layout_margin="5dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
</TextView>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/field_description"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:text="Dropdown"
|
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/field_background"
|
android:id="@+id/field_background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user