Compare commits

...

3 Commits

Author SHA1 Message Date
0b0b0410fa fixed stuff 2026-10-02 16:31:25 -04:00
1a5252f48d finsihed generator 2026-10-01 16:20:58 -04:00
e87e2fd85d finsihed generator 2026-10-01 10:59:11 -04:00
3 changed files with 168 additions and 2 deletions

View File

@@ -1,15 +1,38 @@
package com.example.generator;
import android.content.ContentValues;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
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.IOException;
import java.io.OutputStream;
public class EndActivity extends AppCompatActivity {
private String ColorP = "";
private String ColorS = "";
private int mainColorResP = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -20,5 +43,113 @@ public class EndActivity extends AppCompatActivity {
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
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("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);
TextView textView = findViewById(R.id.textView4);
textView.setText(jsonString);
jsonObject.put("Base64", EventsActivity.Data.getBase64());
jsonString = jsonObject.toString(4);
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DISPLAY_NAME, "ScountInfo.json");
values.put(MediaStore.MediaColumns.MIME_TYPE, "json/plain");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
values.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS);
}
Uri externalUri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
externalUri = MediaStore.Downloads.EXTERNAL_CONTENT_URI;
} else {
externalUri = MediaStore.Files.getContentUri("external");
}
Uri fileUri = getContentResolver().insert(externalUri, values);
if (fileUri != null) {
try (OutputStream outputStream = getContentResolver().openOutputStream(fileUri)) {
if (outputStream != null) {
outputStream.write(jsonString.getBytes());
outputStream.flush();
Toast.makeText(this, "File saved to Downloads", Toast.LENGTH_SHORT).show();
}
}
} else {
throw new IOException();
}
} catch (JSONException | IOException e) {
throw new RuntimeException(e);
}
});
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);
}
}
}
}

View File

@@ -40,7 +40,7 @@ public class MainActivity extends AppCompatActivity {
startActivity(intent);
});
Button DebugButton = (Button) findViewById(R.id.Debug);
//DebugButton.setVisibility(View.GONE);
DebugButton.setVisibility(View.GONE);
DebugButton.setOnClickListener((v) -> {
Intent intent = new Intent(this, DebugActivity.class);
startActivity(intent);

View File

@@ -48,5 +48,40 @@
app:layout_constraintEnd_toStartOf="@+id/nextButton"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Preview of file (without base64 image)"
android:textAlignment="center"
android:textColor="@color/white"
app:layout_constraintBottom_toTopOf="@+id/scrollView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textPine4" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="409dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/nextButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white" />
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>