Compare commits
5 Commits
f1bb8d28b4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b0b0410fa | |||
| 1a5252f48d | |||
| e87e2fd85d | |||
| f37db4ace0 | |||
| 64208bef11 |
@@ -2,8 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="29" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -64,6 +66,10 @@
|
||||
android:name=".MakeCheckActivity"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".EndActivity"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,155 @@
|
||||
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);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_end);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MakeCheckActivity extends AppCompatActivity {
|
||||
EventsActivity.Data.setClimbLevels(levelsStr.isEmpty() ? 0 : Integer.parseInt(levelsStr));
|
||||
String checkBoxesStr = CheckBoxObjects.getText().toString().trim();
|
||||
EventsActivity.Data.setNumCheckBoxes(checkBoxesStr.isEmpty() ? 0 : Integer.parseInt(checkBoxesStr));
|
||||
Intent intent = new Intent(this, MakeAutoActivity2.class);
|
||||
Intent intent = new Intent(this, EndActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
|
||||
87
Generator/app/src/main/res/layout/activity_end.xml
Normal file
87
Generator/app/src/main/res/layout/activity_end.xml
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black"
|
||||
tools:context=".EndActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textPine4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="32dp"
|
||||
android:ems="10"
|
||||
android:text="generate config file"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/nextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:backgroundTint="@color/orangeMain"
|
||||
android:text="Make file"
|
||||
app:cornerRadius="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/backButton" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/backButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:backgroundTint="@color/orangeMain"
|
||||
android:text="Back"
|
||||
app:cornerRadius="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
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>
|
||||
Reference in New Issue
Block a user