Skip to content

Commit

Permalink
sync: new server check fail popup (fixes #3412) (#3414)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Apr 29, 2024
1 parent 9a5a635 commit e3674bd
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1500
versionName "0.15.0"
versionCode 1501
versionName "0.15.1"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/java/org/ole/planet/myplanet/datamanager/Service.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.ole.planet.myplanet.datamanager

import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.content.SharedPreferences
import android.net.Uri
import android.text.TextUtils
Expand All @@ -18,6 +20,7 @@ import org.ole.planet.myplanet.model.RealmCommunity
import org.ole.planet.myplanet.model.RealmUserModel.Companion.isUserExists
import org.ole.planet.myplanet.model.RealmUserModel.Companion.populateUsersTable
import org.ole.planet.myplanet.service.UploadToShelfService
import org.ole.planet.myplanet.ui.sync.ProcessUserDataActivity
import org.ole.planet.myplanet.utilities.AndroidDecrypter.Companion.generateIv
import org.ole.planet.myplanet.utilities.AndroidDecrypter.Companion.generateKey
import org.ole.planet.myplanet.utilities.Constants.KEY_UPGRADE_MAX
Expand Down Expand Up @@ -324,18 +327,28 @@ class Service(private val context: Context) {
customProgressDialog.dismiss()
}
} else {
Utilities.log("Failed to get id")
customProgressDialog.dismiss()
showAlertDialog(context.getString(R.string.failed_to_get_configuration_id))
}
}

override fun onFailure(call: Call<JsonObject?>, t: Throwable) {
t.message?.let { Utilities.log(it) }
customProgressDialog.dismiss()
showAlertDialog(context.getString(R.string.device_couldn_t_reach_server_check_and_try_again))
}
})
}

fun showAlertDialog(message: String?) {
val builder = AlertDialog.Builder(context)
builder.setMessage(message)
builder.setCancelable(true)
builder.setNegativeButton(R.string.okay) { dialog: DialogInterface, _: Int -> dialog.cancel() }
val alert = builder.create()
alert.show()
}

private fun getUrl(couchdbURL: String): String {
var url = couchdbURL

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,5 +1031,6 @@
<string name="location_colon">الموقع:</string>
<string name="recurring_colon">متكرر:</string>
<string name="created_by_colon">تم إنشاؤه بواسطة:</string>
<string name="failed_to_get_configuration_id">فشل في الحصول على معرف التكوين. يرجى الاتصال بالمسؤول</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,5 +1031,6 @@
<string name="location_colon">ubicación:</string>
<string name="recurring_colon">recurrente:</string>
<string name="created_by_colon">creado por:</string>
<string name="failed_to_get_configuration_id">No se pudo obtener el ID de configuración. Por favor, contacte al administrador</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,5 +1031,6 @@
<string name="location_colon">emplacement:</string>
<string name="recurring_colon">récurrent:</string>
<string name="created_by_colon">créé par:</string>
<string name="failed_to_get_configuration_id">Impossible de récupérer l\'identifiant de configuration. Veuillez contacter l\'administrateur</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ne/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,5 +1031,6 @@
<string name="location_colon">स्थान:</string>
<string name="recurring_colon">आवर्तमान:</string>
<string name="created_by_colon">बनाएको:</string>
<string name="failed_to_get_configuration_id">बनावट आईडी प्राप्त गर्न असफल भयो। कृपया व्यवस्थापकसँग सम्पर्क गर्नुहोस्।</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-so/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,5 +1031,6 @@
<string name="location_colon">goobta:</string>
<string name="recurring_colon">ku dhaqan:</string>
<string name="created_by_colon">lagu sameeyay:</string>
<string name="failed_to_get_configuration_id">Ma jirin ID-ka qaababka. Fadlan la xiriir maamulaha</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,5 +1031,6 @@
<string name="location_colon">location:</string>
<string name="recurring_colon">recurring:</string>
<string name="created_by_colon">created by:</string>
<string name="failed_to_get_configuration_id">failed to get configuration id. kindly contact admin</string>

</resources>

0 comments on commit e3674bd

Please sign in to comment.