diff options
author | RaindropsSys <contact@minteck.org> | 2023-05-13 19:26:02 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-05-13 19:26:02 +0200 |
commit | a249ac5c1de45cb188aec32010b6097c606e6aed (patch) | |
tree | 434cc865014b06a8ff58dd5752f95164b99ea2a0 | |
parent | d1d855bed901003a4dd3bb5f3da49f477786f83a (diff) | |
download | delta-android-a249ac5c1de45cb188aec32010b6097c606e6aed.tar.gz delta-android-a249ac5c1de45cb188aec32010b6097c606e6aed.tar.bz2 delta-android-a249ac5c1de45cb188aec32010b6097c606e6aed.zip |
Updated 6 files (automated)
-rw-r--r-- | app/build.gradle.kts | 4 | ||||
-rw-r--r-- | app/src/main/java/dev/equestria/delta/MainActivity.kt | 62 | ||||
-rw-r--r-- | app/src/main/res/menu/action_bar.xml | 6 | ||||
-rw-r--r-- | app/src/main/res/values-fr/strings.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | 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" /> + + <item + android:id="@+id/btn_switch" + android:enabled="true" + android:title="@string/navigation_user_switch_staging" + app:showAsAction="never" /> </menu>
\ 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 @@ <string name="navigation_user_profile">Profil</string> <string name="navigation_user_logout">Se déconnecter</string> <string name="navigation_user_about">À propos</string> + <string name="navigation_user_switch_staging">Utiliser env. dév.</string> + <string name="navigation_user_switch_production">Utiliser env. prod.</string> <string name="about_title">À propos de %1$s</string> <string name="about_message">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</string> <string name="about_close">Fermer</string> 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 @@ <string name="navigation_user_profile">Profile</string> <string name="navigation_user_logout">Log out</string> <string name="navigation_user_about">About</string> + <string name="navigation_user_switch_staging">Use dev. env.</string> + <string name="navigation_user_switch_production">Use prod. env.</string> <string name="about_title">About %1$s</string> <string name="about_message">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</string> <string name="about_close">Close</string> 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 @@ <resources> <string name="app_name" translatable="false">Equestria.dev Delta</string> <string name="app_launch_name" translatable="false">Delta</string> - <string name="delta_root" translatable="false">https://delta.equestria.dev</string> + <string name="delta_root_production" translatable="false">https://delta.equestria.dev</string> + <string name="delta_root_staging" translatable="false">https://delta-staging.equestria.dev</string> </resources>
\ No newline at end of file |