logging out on user data changes
This commit is contained in:
parent
58a7ea7357
commit
abe2a850d6
|
@ -1,11 +1,13 @@
|
||||||
package org.foxarmy.barcodescannerforemployees.activities
|
package org.foxarmy.barcodescannerforemployees.activities
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
import androidx.security.crypto.EncryptedSharedPreferences
|
||||||
import androidx.security.crypto.MasterKeys
|
import androidx.security.crypto.MasterKeys
|
||||||
import org.foxarmy.barcodescannerforemployees.Net
|
import org.foxarmy.barcodescannerforemployees.Net
|
||||||
|
import org.foxarmy.barcodescannerforemployees.R
|
||||||
import org.foxarmy.barcodescannerforemployees.databinding.ActivityAccountSettingsBinding
|
import org.foxarmy.barcodescannerforemployees.databinding.ActivityAccountSettingsBinding
|
||||||
|
|
||||||
class AccountSettingsActivity : AppCompatActivity() {
|
class AccountSettingsActivity : AppCompatActivity() {
|
||||||
|
@ -37,12 +39,26 @@ class AccountSettingsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
binding.saveUsernameButton.setOnClickListener {
|
binding.saveUsernameButton.setOnClickListener {
|
||||||
val response = net.changeUsername(binding.newUsernameTextEdit.text.toString())
|
val response = net.changeUsername(binding.newUsernameTextEdit.text.toString())
|
||||||
|
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()
|
Toast.makeText(this, response.body!!.string(), Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binding.savePasswordButton.setOnClickListener {
|
binding.savePasswordButton.setOnClickListener {
|
||||||
val response = net.changePassword(binding.newPasswordTextEdit.text.toString())
|
val response = net.changePassword(binding.newPasswordTextEdit.text.toString())
|
||||||
|
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()
|
Toast.makeText(this, response.body!!.string(), Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -118,6 +118,8 @@
|
||||||
<string name="ok">Ок</string>
|
<string name="ok">Ок</string>
|
||||||
<string name="logout">Выйти</string>
|
<string name="logout">Выйти</string>
|
||||||
<string name="online_only_feature">Эта возможность доступна только с онлайн аккаунтом</string>
|
<string name="online_only_feature">Эта возможность доступна только с онлайн аккаунтом</string>
|
||||||
|
<string name="username_changed">Имя пользователя изменено. Пожалуйста, перезайдите</string>
|
||||||
|
<string name="password_changed">Пароль изменён. Пожалуйста, перезайдите</string>
|
||||||
<string-array name="languages">
|
<string-array name="languages">
|
||||||
<item>en-US</item>
|
<item>en-US</item>
|
||||||
<item>ru-RU</item>
|
<item>ru-RU</item>
|
||||||
|
|
|
@ -116,6 +116,8 @@
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="logout">Log out</string>
|
<string name="logout">Log out</string>
|
||||||
<string name="online_only_feature">This feature is online only</string>
|
<string name="online_only_feature">This feature is online only</string>
|
||||||
|
<string name="username_changed">Your username has been changed. Please, relogin</string>
|
||||||
|
<string name="password_changed">You password was changed. Please, relogin</string>
|
||||||
<string-array name="languages">
|
<string-array name="languages">
|
||||||
<item>en-US</item>
|
<item>en-US</item>
|
||||||
<item>ru-RU</item>
|
<item>ru-RU</item>
|
||||||
|
|
Loading…
Reference in New Issue