From a249ac5c1de45cb188aec32010b6097c606e6aed Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sat, 13 May 2023 19:26:02 +0200 Subject: Updated 6 files (automated) --- app/build.gradle.kts | 4 +- .../main/java/dev/equestria/delta/MainActivity.kt | 62 +++++++++++++++------- app/src/main/res/menu/action_bar.xml | 6 +++ app/src/main/res/values-fr/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/values.xml | 3 +- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 13aa09d..fe84909 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,8 +12,8 @@ android { applicationId = "dev.equestria.delta" minSdk = 27 targetSdk = 33 - versionCode = 4 - versionName = "1.11" + versionCode = 6 + versionName = "1.13" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" resConfigs("en", "fr") diff --git a/app/src/main/java/dev/equestria/delta/MainActivity.kt b/app/src/main/java/dev/equestria/delta/MainActivity.kt index 341e1f4..8ac7e99 100644 --- a/app/src/main/java/dev/equestria/delta/MainActivity.kt +++ b/app/src/main/java/dev/equestria/delta/MainActivity.kt @@ -46,6 +46,7 @@ class MainActivity : AppCompatActivity() { private var changedNavItem: Boolean = false private var deltaInformation: JSONObject? = null private var lastRequestLoggedIn: Boolean = false + private var deltaRoot: String = "" override fun onCreateOptionsMenu(menu: Menu?): Boolean { val inflater = menuInflater @@ -59,7 +60,7 @@ class MainActivity : AppCompatActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.user -> { - binding.webView.loadUrl("${getString(R.string.delta_root)}/profile") + binding.webView.loadUrl("${deltaRoot}/profile") return true } @@ -74,7 +75,21 @@ class MainActivity : AppCompatActivity() { } R.id.btn_user_logout -> { - binding.webView.loadUrl("${getString(R.string.delta_root)}/logout") + binding.webView.loadUrl("${deltaRoot}/logout") + return true + } + + R.id.btn_switch -> { + if (deltaRoot === getString(R.string.delta_root_production)) { + deltaRoot = getString(R.string.delta_root_staging) + appMenu.getItem(5).title = getString(R.string.navigation_user_switch_production) + handoffApi31() + } else { + deltaRoot = getString(R.string.delta_root_production) + appMenu.getItem(5).title = getString(R.string.navigation_user_switch_staging) + handoffApi31() + } + return true } @@ -129,6 +144,8 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) DynamicColors.applyToActivitiesIfAvailable(application) + deltaRoot = getString(R.string.delta_root_production) + val name = getString(R.string.channel_name) val descriptionText = getString(R.string.channel_description) val importance = NotificationManager.IMPORTANCE_DEFAULT @@ -154,8 +171,8 @@ class MainActivity : AppCompatActivity() { Log.d("Firebase", token) HTTPRequest.request( - "${getString(R.string.delta_root)}/handoff/fcm/", - getCookie(getString(R.string.delta_root), "DeltaSession") + "||||" + token, + "${deltaRoot}/handoff/fcm/", + getCookie(deltaRoot, "DeltaSession") + "||||" + token, binding.root.context, resources, this, @@ -183,8 +200,8 @@ class MainActivity : AppCompatActivity() { } fun initialCheck() { - HTTPRequest.request("${getString(R.string.delta_root)}/handoff/version/", - getCookie(getString(R.string.delta_root), "DeltaSession"), + HTTPRequest.request("${deltaRoot}/handoff/version/", + getCookie(deltaRoot, "DeltaSession"), binding.root.context, resources, this, @@ -193,6 +210,13 @@ class MainActivity : AppCompatActivity() { { deltaInformation = it appMenu.getItem(3).isEnabled = deltaInformation!!.get("loggedIn") as Boolean + + if (deltaInformation!!.has("admin")) { + appMenu.getItem(5).isVisible = deltaInformation!!.get("admin") as Boolean + } else { + appMenu.getItem(5).isVisible = false + } + initialise() }) { val openURL = Intent(Intent.ACTION_VIEW) @@ -202,8 +226,8 @@ class MainActivity : AppCompatActivity() { } fun routineCheck() { - HTTPRequest.request("${getString(R.string.delta_root)}/handoff/version/", - getCookie(getString(R.string.delta_root), "DeltaSession"), + HTTPRequest.request("${deltaRoot}/handoff/version/", + getCookie(deltaRoot, "DeltaSession"), binding.root.context, resources, this, @@ -250,7 +274,7 @@ class MainActivity : AppCompatActivity() { } Picasso.get().load( - "${getString(R.string.delta_root)}/handoff/avatar/?token=" + deltaInformation.get("session") + "${deltaRoot}/handoff/avatar/?token=" + deltaInformation.get("session") ).into(target) } @@ -331,7 +355,9 @@ class MainActivity : AppCompatActivity() { "/studio/" ) || URL(url).path === "/studio" || URL(url).path.startsWith( "/logout/" - ) || URL(url).path === "/logout" + ) || URL(url).path === "/logout" || URL(url).path.startsWith( + "/pass/" + ) || URL(url).path === "/pass" ) { changedNavItem = true binding.navigationBar.selectedItemId = R.id.navigation_profile @@ -350,7 +376,7 @@ class MainActivity : AppCompatActivity() { ): WebResourceResponse? { request.url.host?.let { Log.i("MainActivity", '"' + it + '"') } - if (request.url.host != getString(R.string.delta_root).split("/")[2]) { + if (request.url.host != deltaRoot.split("/")[2]) { val openURL = Intent(Intent.ACTION_VIEW) openURL.data = request.url startActivity(openURL) @@ -369,7 +395,7 @@ class MainActivity : AppCompatActivity() { if (!changedNavItem) { changedNavItem = true - binding.webView.loadUrl("${getString(R.string.delta_root)}/") + binding.webView.loadUrl("${deltaRoot}/") } true @@ -380,7 +406,7 @@ class MainActivity : AppCompatActivity() { if (!changedNavItem) { changedNavItem = true - binding.webView.loadUrl("${getString(R.string.delta_root)}/search") + binding.webView.loadUrl("${deltaRoot}/search") } true @@ -391,7 +417,7 @@ class MainActivity : AppCompatActivity() { if (!changedNavItem) { changedNavItem = true - binding.webView.loadUrl("${getString(R.string.delta_root)}/content") + binding.webView.loadUrl("${deltaRoot}/content") } true @@ -402,7 +428,7 @@ class MainActivity : AppCompatActivity() { if (!changedNavItem) { changedNavItem = true - binding.webView.loadUrl("${getString(R.string.delta_root)}/profile") + binding.webView.loadUrl("${deltaRoot}/profile") } true @@ -473,20 +499,20 @@ class MainActivity : AppCompatActivity() { if (Intent.ACTION_VIEW == appLinkAction) { if (appLinkData != null) { binding.webView.loadUrl( - "${getString(R.string.delta_root)}/handoff/?version=" + BuildConfig.VERSION_CODE + "&colors=" + colors.joinToString( + "${deltaRoot}/handoff/?version=" + BuildConfig.VERSION_CODE + "&colors=" + colors.joinToString( "," ) + "&return=" + java.net.URLEncoder.encode(appLinkData.path, "utf-8") ) } else { binding.webView.loadUrl( - "${getString(R.string.delta_root)}/handoff/?version=" + BuildConfig.VERSION_CODE + "&colors=" + colors.joinToString( + "${deltaRoot}/handoff/?version=" + BuildConfig.VERSION_CODE + "&colors=" + colors.joinToString( "," ) + "&return=/" ) } } else { binding.webView.loadUrl( - "${getString(R.string.delta_root)}/handoff/?version=" + BuildConfig.VERSION_CODE + "&colors=" + colors.joinToString( + "${deltaRoot}/handoff/?version=" + BuildConfig.VERSION_CODE + "&colors=" + colors.joinToString( "," ) + "&return=/" ) diff --git a/app/src/main/res/menu/action_bar.xml b/app/src/main/res/menu/action_bar.xml index d25a24c..d9e3020 100644 --- a/app/src/main/res/menu/action_bar.xml +++ b/app/src/main/res/menu/action_bar.xml @@ -27,4 +27,10 @@ android:enabled="true" android:title="@string/navigation_user_about" app:showAsAction="never" /> + + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3d882d1..0ea3887 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -6,6 +6,8 @@ Profil Se déconnecter À propos + Utiliser env. dév. + Utiliser env. prod. À propos de %1$s Une application Android pour la plate-forme Delta.\n\nApplication : %1$s\nServeur : %2$s\nAndroid : %3$s\nMàJ : %6$s\nNoyau : %4$s\nAppareil : %5$s\nCarte : %7$s\nAmorceur : %8$s Fermer diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0cbeecc..61d7bf2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,6 +6,8 @@ Profile Log out About + Use dev. env. + Use prod. env. About %1$s An Android app for the Delta platform.\n\nApp: %1$s\nServer: %2$s\nAndroid: %3$s\nSecurity: %6$s\nKernel: %4$s\nDevice: %5$s\nBoard: %7$s\nBootloader: %8$s Close diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index ee1eb49..b942dbc 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -1,5 +1,6 @@ Equestria.dev Delta Delta - https://delta.equestria.dev + https://delta.equestria.dev + https://delta-staging.equestria.dev \ No newline at end of file -- cgit