finsihed generator

This commit is contained in:
2026-10-01 10:59:11 -04:00
parent f37db4ace0
commit e87e2fd85d

View File

@@ -1,15 +1,34 @@
package com.example.generator; package com.example.generator;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets; import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.button.MaterialButton;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class EndActivity extends AppCompatActivity { public class EndActivity extends AppCompatActivity {
private String ColorP = "";
private String ColorS = "";
private int mainColorResP = 0;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -20,5 +39,99 @@ public class EndActivity extends AppCompatActivity {
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets; return insets;
}); });
if (EventsActivity.Data.getColorS() != null) {
ColorS = EventsActivity.Data.getColorS();
}
if (EventsActivity.Data.getColorP() != null) {
ColorP = EventsActivity.Data.getColorP();
}
MaterialButton backButton = findViewById(R.id.backButton);
MaterialButton nextButton = findViewById(R.id.nextButton);
backButton.setOnClickListener((v) -> {
Intent intent = new Intent(this, MakeAutoActivity.class);
startActivity(intent);
});
nextButton.setOnClickListener((v) -> {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("ColorP", ColorP);
jsonObject.put("ColorS", ColorS);
jsonObject.put("startingPositions", EventsActivity.Data.getNumPos());
jsonObject.put("Base64", EventsActivity.Data.getBase64());
jsonObject.put("eventn1", EventsActivity.Data.getEventn1());
jsonObject.put("eventa1", EventsActivity.Data.getEventa1());
jsonObject.put("eventn2", EventsActivity.Data.getEventn2());
jsonObject.put("eventa2", EventsActivity.Data.getEventa2());
jsonObject.put("eventn3", EventsActivity.Data.getEventn3());
jsonObject.put("eventa3", EventsActivity.Data.getEventa3());
jsonObject.put("eventn4", EventsActivity.Data.getEventn4());
jsonObject.put("eventa4", EventsActivity.Data.getEventa4());
jsonObject.put("numScoreObjects", EventsActivity.Data.getNumScoreOb());
jsonObject.put("ScoreOb1", EventsActivity.Data.getScoreOb1());
jsonObject.put("ScoreOb2", EventsActivity.Data.getScoreOb2());
jsonObject.put("ScoreOb3", EventsActivity.Data.getScoreOb3());
jsonObject.put("ScoreOb4", EventsActivity.Data.getScoreOb4());
jsonObject.put("ScoreOb5", EventsActivity.Data.getScoreOb5());
jsonObject.put("ScoreOb6", EventsActivity.Data.getScoreOb6());
jsonObject.put("ScoreOb7", EventsActivity.Data.getScoreOb7());
jsonObject.put("ScoreOb8", EventsActivity.Data.getScoreOb8());
jsonObject.put("ScoreOb9", EventsActivity.Data.getScoreOb9());
jsonObject.put("NumButtonObAuto", new JSONArray(EventsActivity.Data.getNumButtonObAuto()));
jsonObject.put("NumButtonObTeleop", new JSONArray(EventsActivity.Data.getNumButtonObTeleop()));
jsonObject.put("valueButtonsAuto", new JSONArray(EventsActivity.Data.getValueButtonsAuto()));
jsonObject.put("valueButtonsTele", new JSONArray(EventsActivity.Data.getValueButtonsTele()));
jsonObject.put("numCheckBoxes", EventsActivity.Data.getNumCheckBoxes());
jsonObject.put("CheckBox1", EventsActivity.Data.getCheckBox1());
jsonObject.put("CheckBox2", EventsActivity.Data.getCheckBox2());
jsonObject.put("CheckBox3", EventsActivity.Data.getCheckBox3());
jsonObject.put("CheckBox4", EventsActivity.Data.getCheckBox4());
jsonObject.put("climbLevels", EventsActivity.Data.getClimbLevels());
String jsonString = jsonObject.toString(4);
File downloadDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File(downloadDir, "ScountInfo.json");
FileWriter fileWriter = new FileWriter(file);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.write(jsonString);
bufferedWriter.close();
} catch (JSONException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
Intent intent = new Intent(this, MakeCheckActivity.class);
startActivity(intent);
});
switch (ColorP) {
case "Green": mainColorResP = R.color.greenMain; break;
case "Blue": mainColorResP = R.color.blueMain; break;
case "Pink": mainColorResP = R.color.pinkMain; break;
case "Purple": mainColorResP = R.color.purpleMain; break;
case "Red": mainColorResP = R.color.redMain; break;
case "Yellow": mainColorResP = R.color.yellowMain; break;
default: mainColorResP = R.color.orangeMain; break;
}
if (mainColorResP != 0) {
int actualColor = ContextCompat.getColor(this, mainColorResP);
ColorStateList tintList = ColorStateList.valueOf(actualColor);
ViewCompat.setBackgroundTintList(nextButton, tintList);
ViewCompat.setBackgroundTintList(backButton, tintList);
nextButton.setStrokeWidth(0);
backButton.setStrokeWidth(0);
}
} }
} }