Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
.externalNativeBuild
.cxx
local.properties
keystore.properties
*.jks
*.keystore
13 changes: 13 additions & 0 deletions .idea/planningMode.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
id("base")
Expand All @@ -7,6 +10,13 @@ var versionMajor = 4
var versionMinor = 0
var versionPatch = 0

val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties().apply {
if (keystorePropertiesFile.exists()) {
load (FileInputStream(keystorePropertiesFile))
}
}

configure<com.android.build.api.dsl.ApplicationExtension> {
namespace = "com.team3663.scouting_app"
compileSdk = 37
Expand All @@ -25,6 +35,17 @@ configure<com.android.build.api.dsl.ApplicationExtension> {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
create("release") {
if (keystorePropertiesFile.exists()) {
storeFile = file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
}
}
}

buildTypes {
getByName("release") {
isMinifyEnabled = true
Expand All @@ -33,13 +54,22 @@ configure<com.android.build.api.dsl.ApplicationExtension> {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
if (keystorePropertiesFile.exists()) {
signingConfig = signingConfigs.getByName("release")
}
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

packaging {
resources {
excludes += "META-INF/INDEX.LIST"
excludes += "META-INF/DEPENDENCIES"
}
}
}

base {
Expand All @@ -48,11 +78,16 @@ base {

dependencies {
implementation(libs.appcompat)
implementation(libs.documentfile)
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
implementation(libs.qr.generator)
implementation(libs.preference)
implementation(libs.google.api.client)
implementation(libs.google.drive.services)
implementation(libs.play.services.auth)
implementation(libs.mssql)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
Expand Down
20 changes: 19 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,22 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep class net.sourceforge.jtds.** { *; }
-dontwarn net.sourceforge.jtds.**

# Google API/Drive client (google-api-client ships no consumer rules and maps JSON via
# reflection on @Key-annotated fields; R8 would otherwise strip/rename them and break uploads).
-keepattributes Signature,*Annotation*,EnclosingMethod
-keep class com.google.api.client.** { *; }
-keep class com.google.api.services.drive.** { *; }
-keepclassmembers class * { @com.google.api.client.util.Key <fields>; }
-dontwarn com.google.api.client.**
-dontwarn com.google.api.services.drive.**
-dontwarn org.apache.http.**
-dontwarn javax.**

# Gson (used by GsonFactory to (de)serialize the Drive model classes)
-keep class com.google.gson.** { *; }
-dontwarn com.google.gson.**
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<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.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public class AppLaunch extends AppCompatActivity {
// There are no request codes
Intent data = result.getData();
if (Objects.requireNonNull(data).getIntExtra(Constants.Settings.RELOAD_DATA_KEY, 0) == 1) {
Globals.MatchList.clearList();
Globals.MatchList.LoadDataFile(appLaunchBinding.textStatusFile, appLaunchBinding.progressBarFile, appLaunchBinding.textPercentFile, appLaunchBinding.progressBarOverall, appLaunchBinding.textStatusOverall);
appLaunchBinding.textStatusFile.setText("");
loadDataFiles();
}
}
});
Expand Down Expand Up @@ -259,6 +257,18 @@ private void initDataFiles() {
// Output: void
// =============================================================================================
private void loadDataFiles() {
// Ensure the loading file objects are visible
appLaunchBinding.progressBarOverall.setVisibility(View.VISIBLE);
appLaunchBinding.progressBarFile.setVisibility(View.VISIBLE);
appLaunchBinding.textStatusOverall.setVisibility(View.VISIBLE);
appLaunchBinding.textPercentOverall.setVisibility(View.VISIBLE);
appLaunchBinding.textStatusFile.setVisibility(View.VISIBLE);
appLaunchBinding.textPercentFile.setVisibility(View.VISIBLE);
appLaunchBinding.butStartScouting.setVisibility(View.INVISIBLE);
appLaunchBinding.imgButSettings.setVisibility(View.INVISIBLE);
appLaunchBinding.butStartScouting.setClickable(false);
appLaunchBinding.imgButSettings.setClickable(false);

// Clear out the lists, just in case
_DataFile.clearAllLists();

Expand Down Expand Up @@ -291,6 +301,7 @@ public void run() {
throw new RuntimeException(e);
}

// Hide the loading file objects
appLaunchBinding.progressBarOverall.setVisibility(View.INVISIBLE);
appLaunchBinding.progressBarFile.setVisibility(View.INVISIBLE);
appLaunchBinding.textStatusOverall.setVisibility(View.INVISIBLE);
Expand All @@ -301,8 +312,6 @@ public void run() {
appLaunchBinding.imgButSettings.setVisibility(View.VISIBLE);
appLaunchBinding.butStartScouting.setClickable(true);
appLaunchBinding.imgButSettings.setClickable(true);
appLaunchBinding.butStartScouting.setVisibility(View.VISIBLE);
appLaunchBinding.imgButSettings.setVisibility(View.VISIBLE);

// Erase the status text
appLaunchBinding.textStatusFile.setText("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.team3663.scouting_app.databinding.SettingsBinding;
import com.team3663.scouting_app.fragments.*;
import com.google.android.material.tabs.TabLayoutMediator;
import com.team3663.scouting_app.utility.CPR_Network;

public class Settings extends AppCompatActivity {
// =============================================================================================
Expand All @@ -42,6 +43,9 @@ protected void onCreate(Bundle in_savedInstanceState) {
if (Globals.sp == null) Globals.sp = this.getSharedPreferences(getString(R.string.preference_setting_file_key), Context.MODE_PRIVATE);
if (Globals.spe == null) Globals.spe = Globals.sp.edit();

// Set the files downloaded to false when we first get into settings.
CPR_Network.filesDownloaded = false;

adapter = new SettingsPagerAdapter(this);
settingsBinding.viewPager.setAdapter(adapter);

Expand All @@ -53,12 +57,28 @@ protected void onCreate(Bundle in_savedInstanceState) {
).attach();

// Define a Cancel Button
settingsBinding.butCancel.setOnClickListener(view -> finish());
settingsBinding.butCancel.setOnClickListener(view -> CancelSettings());

// Define a Save Button
settingsBinding.butSave.setOnClickListener(view -> SaveSettings());
}

// =============================================================================================
// Function: CancelSettings
// Description: Cancel any changes made (ignore them) but set the intent to reload the data
// if new files were downloaded.
// Parameters: void
// Output: void
// =============================================================================================
private void CancelSettings() {
Intent intent = new Intent();

if (CPR_Network.filesDownloaded) intent.putExtra(Constants.Settings.RELOAD_DATA_KEY, 1);

setResult(RESULT_OK, intent);
finish();
}

// =============================================================================================
// Function: SaveSettings
// Description: Save off the settings before closing this activity
Expand All @@ -70,6 +90,7 @@ private void SaveSettings() {
SettingsPage1 fragmentPage1 = adapter.getFragmentPage1();
SettingsPage2 fragmentPage2 = adapter.getFragmentPage2();
SettingsPage3 fragmentPage3 = adapter.getFragmentPage3();
SettingsPage4 fragmentPage4 = adapter.getFragmentPage4();

// Page1 Settings
if (fragmentPage1 != null && fragmentPage1.binding != null) {
Expand All @@ -92,9 +113,11 @@ private void SaveSettings() {
Globals.spe.putString(Constants.Prefs.SCOUTING_TEAM, ScoutingTeam);
}

int NumMatches = Integer.parseInt(fragmentPage1.binding.editNumMatches.getText().toString());
if (NumMatches < 1) NumMatches = 1;
Globals.spe.putInt(Constants.Prefs.NUM_MATCHES, NumMatches);
Globals.CurrentPrefTeamPos = fragmentPage1.binding.spinnerPrefTeamPos.getSelectedItemPosition();
Globals.spe.putInt(Constants.Prefs.PREF_TEAM_POS, Globals.CurrentPrefTeamPos);

Globals.CurrentFieldOrientationPos = fragmentPage1.binding.spinnerOrientation.getSelectedItemPosition();
Globals.spe.putInt(Constants.Prefs.PREF_ORIENTATION, Globals.CurrentFieldOrientationPos);
}

// Page2 Settings
Expand All @@ -104,23 +127,18 @@ private void SaveSettings() {
Globals.spe.putInt(Constants.Prefs.COLOR_CONTEXT_MENU, ColorId);
}

Globals.CurrentPrefTeamPos = fragmentPage2.binding.spinnerPrefTeamPos.getSelectedItemPosition();
Globals.spe.putInt(Constants.Prefs.PREF_TEAM_POS, Globals.CurrentPrefTeamPos);

int CurrentQRSize = Integer.parseInt(fragmentPage2.binding.editQRSize.getText().toString());
Globals.spe.putInt(Constants.Prefs.QR_SIZE, CurrentQRSize);

Globals.CurrentFieldOrientationPos = fragmentPage2.binding.spinnerOrientation.getSelectedItemPosition();
Globals.spe.putInt(Constants.Prefs.PREF_ORIENTATION, Globals.CurrentFieldOrientationPos);
int NumMatches = Integer.parseInt(fragmentPage2.binding.editNumMatches.getText().toString());
if (NumMatches < 1) NumMatches = 1;
Globals.spe.putInt(Constants.Prefs.NUM_MATCHES, NumMatches);
}

// Page3 Settings
if (fragmentPage3 != null && fragmentPage3.binding != null) {
Editable userField;

userField = fragmentPage3.binding.editGoogleDrive.getText();
Globals.spe.putString(Constants.Prefs.GOOGLE_DRIVE, (userField != null) ? userField.toString() : "");

userField = fragmentPage3.binding.editServer.getText();
Globals.spe.putString(Constants.Prefs.SQL_SERVER, (userField != null) ? userField.toString() : "");

Expand All @@ -134,6 +152,19 @@ private void SaveSettings() {
Globals.spe.putString(Constants.Prefs.SQL_PASSWORD, (userField != null) ? userField.toString() : "");
}

// Page4 Settings
if (fragmentPage4 != null && fragmentPage4.binding != null) {
Editable userField;

userField = fragmentPage4.binding.editGoogleUpload.getText();
Globals.spe.putString(Constants.Prefs.GOOGLE_DRIVE_UPLOAD, (userField != null) ? userField.toString() : "");

userField = fragmentPage4.binding.editGoogleDownload.getText();
Globals.spe.putString(Constants.Prefs.GOOGLE_DRIVE_DOWNLOAD, (userField != null) ? userField.toString() : "");

if (CPR_Network.filesDownloaded) intent.putExtra(Constants.Settings.RELOAD_DATA_KEY, 1);
}

Globals.spe.apply();
setResult(RESULT_OK, intent);
finish();
Expand Down
Loading