diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AccountSettingsActivity.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AccountSettingsActivity.kt
index ba7b685..d9447a0 100644
--- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AccountSettingsActivity.kt
+++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AccountSettingsActivity.kt
@@ -1,11 +1,13 @@
package org.foxarmy.barcodescannerforemployees.activities
+import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKeys
import org.foxarmy.barcodescannerforemployees.Net
+import org.foxarmy.barcodescannerforemployees.R
import org.foxarmy.barcodescannerforemployees.databinding.ActivityAccountSettingsBinding
class AccountSettingsActivity : AppCompatActivity() {
@@ -37,12 +39,26 @@ class AccountSettingsActivity : AppCompatActivity() {
binding.saveUsernameButton.setOnClickListener {
val response = net.changeUsername(binding.newUsernameTextEdit.text.toString())
- Toast.makeText(this, response.body!!.string(), Toast.LENGTH_LONG).show()
+ if (response.code == 200) {
+ Toast.makeText(this, getString(R.string.username_changed), Toast.LENGTH_LONG).show()
+ val intent = Intent(this, LoginActivity::class.java)
+ startActivity(intent)
+ finish()
+ } else {
+ Toast.makeText(this, response.body!!.string(), Toast.LENGTH_LONG).show()
+ }
}
binding.savePasswordButton.setOnClickListener {
val response = net.changePassword(binding.newPasswordTextEdit.text.toString())
- Toast.makeText(this, response.body!!.string(), Toast.LENGTH_LONG).show()
+ if (response.code == 200) {
+ Toast.makeText(this, getString(R.string.password_changed), Toast.LENGTH_LONG).show()
+ val intent = Intent(this, LoginActivity::class.java)
+ startActivity(intent)
+ finish()
+ } else {
+ Toast.makeText(this, response.body!!.string(), Toast.LENGTH_LONG).show()
+ }
}
}
}
\ No newline at end of file
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 0a6a8f4..9d1a424 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -118,6 +118,8 @@
Ок
Выйти
Эта возможность доступна только с онлайн аккаунтом
+ Имя пользователя изменено. Пожалуйста, перезайдите
+ Пароль изменён. Пожалуйста, перезайдите
- en-US
- ru-RU
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6c2df16..f782e5e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -116,6 +116,8 @@
OK
Log out
This feature is online only
+ Your username has been changed. Please, relogin
+ You password was changed. Please, relogin
- en-US
- ru-RU