|
@@ -3,6 +3,7 @@ package com.swago.login
|
|
|
import android.Manifest
|
|
|
import android.app.Activity
|
|
|
import android.content.Intent
|
|
|
+import android.os.Build
|
|
|
import android.view.View
|
|
|
import android.widget.Toast
|
|
|
import androidx.activity.viewModels
|
|
@@ -52,22 +53,41 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
|
|
|
binding.clFaceBook.setOnClickListener(object : NoDoubleClickListener() {
|
|
|
override fun onClick() {
|
|
|
if (SwagoShareUtils.isInstall(this@LoginActivity,FACEBOOK)){
|
|
|
- PermissionX.init(this@LoginActivity)
|
|
|
- .permissions(
|
|
|
- Manifest.permission.READ_EXTERNAL_STORAGE
|
|
|
- )
|
|
|
- .request { allGranted, grantedList, deniedList ->
|
|
|
- if (allGranted) {
|
|
|
- FBLogin.login(this@LoginActivity)
|
|
|
- } else {
|
|
|
- FBLogin.login(this@LoginActivity)
|
|
|
- Toast.makeText(
|
|
|
- this@LoginActivity,
|
|
|
- "These permissions are denied: $deniedList",
|
|
|
- Toast.LENGTH_LONG
|
|
|
- ).show()
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
|
|
|
+ PermissionX.init(this@LoginActivity)
|
|
|
+ .permissions(
|
|
|
+ Manifest.permission.READ_MEDIA_IMAGES
|
|
|
+ )
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ FBLogin.login(this@LoginActivity)
|
|
|
+ } else {
|
|
|
+ FBLogin.login(this@LoginActivity)
|
|
|
+ Toast.makeText(
|
|
|
+ this@LoginActivity,
|
|
|
+ "These permissions are denied: $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }else{
|
|
|
+ PermissionX.init(this@LoginActivity)
|
|
|
+ .permissions(
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE
|
|
|
+ )
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ FBLogin.login(this@LoginActivity)
|
|
|
+ } else {
|
|
|
+ FBLogin.login(this@LoginActivity)
|
|
|
+ Toast.makeText(
|
|
|
+ this@LoginActivity,
|
|
|
+ "These permissions are denied: $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}else{
|
|
|
Toast.makeText(AppContext.getContext(), AppContext.getContext().resources.getString(R.string.install_facebook), Toast.LENGTH_SHORT).show()
|
|
|
}
|
|
@@ -77,22 +97,41 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
|
|
|
binding.clGoogle.setOnClickListener(object : NoDoubleClickListener() {
|
|
|
override fun onClick() {
|
|
|
if (SwagoShareUtils.isInstall(this@LoginActivity,GOOGLE)) {
|
|
|
- PermissionX.init(this@LoginActivity)
|
|
|
- .permissions(
|
|
|
- Manifest.permission.READ_EXTERNAL_STORAGE
|
|
|
- )
|
|
|
- .request { allGranted, grantedList, deniedList ->
|
|
|
- if (allGranted) {
|
|
|
- GoogleLogin.login(this@LoginActivity)
|
|
|
- } else {
|
|
|
- GoogleLogin.login(this@LoginActivity)
|
|
|
- Toast.makeText(
|
|
|
- this@LoginActivity,
|
|
|
- "These permissions are denied: $deniedList",
|
|
|
- Toast.LENGTH_LONG
|
|
|
- ).show()
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
|
|
|
+ PermissionX.init(this@LoginActivity)
|
|
|
+ .permissions(
|
|
|
+ Manifest.permission.READ_MEDIA_IMAGES
|
|
|
+ )
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ GoogleLogin.login(this@LoginActivity)
|
|
|
+ } else {
|
|
|
+ GoogleLogin.login(this@LoginActivity)
|
|
|
+ Toast.makeText(
|
|
|
+ this@LoginActivity,
|
|
|
+ "These permissions are denied: $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }else{
|
|
|
+ PermissionX.init(this@LoginActivity)
|
|
|
+ .permissions(
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE
|
|
|
+ )
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ GoogleLogin.login(this@LoginActivity)
|
|
|
+ } else {
|
|
|
+ GoogleLogin.login(this@LoginActivity)
|
|
|
+ Toast.makeText(
|
|
|
+ this@LoginActivity,
|
|
|
+ "These permissions are denied: $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}else{
|
|
|
Toast.makeText(AppContext.getContext(), "", Toast.LENGTH_SHORT).show()
|
|
|
}
|
|
@@ -139,28 +178,53 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
|
|
|
|
|
|
binding.ivAccountLogin.setOnClickListener(object:NoDoubleClickListener(){
|
|
|
override fun onClick() {
|
|
|
- PermissionX.init(this@LoginActivity)
|
|
|
- .permissions(
|
|
|
- Manifest.permission.READ_EXTERNAL_STORAGE
|
|
|
- )
|
|
|
- .request { allGranted, grantedList, deniedList ->
|
|
|
- if (allGranted) {
|
|
|
- SwagoLoading.showLoadingDialog(this@LoginActivity)
|
|
|
- val account = binding.etAccount.text.toString()
|
|
|
- val secret = binding.etSecret.text.toString()
|
|
|
- loginVm.loginByAccount(account, secret)
|
|
|
- } else {
|
|
|
- SwagoLoading.showLoadingDialog(this@LoginActivity)
|
|
|
- val account = binding.etAccount.text.toString()
|
|
|
- val secret = binding.etSecret.text.toString()
|
|
|
- loginVm.loginByAccount(account, secret)
|
|
|
- Toast.makeText(
|
|
|
- this@LoginActivity,
|
|
|
- "These permissions are denied: $deniedList",
|
|
|
- Toast.LENGTH_LONG
|
|
|
- ).show()
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
|
|
|
+ PermissionX.init(this@LoginActivity)
|
|
|
+ .permissions(
|
|
|
+ Manifest.permission.READ_MEDIA_IMAGES
|
|
|
+ )
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ SwagoLoading.showLoadingDialog(this@LoginActivity)
|
|
|
+ val account = binding.etAccount.text.toString()
|
|
|
+ val secret = binding.etSecret.text.toString()
|
|
|
+ loginVm.loginByAccount(account, secret)
|
|
|
+ } else {
|
|
|
+ SwagoLoading.showLoadingDialog(this@LoginActivity)
|
|
|
+ val account = binding.etAccount.text.toString()
|
|
|
+ val secret = binding.etSecret.text.toString()
|
|
|
+ loginVm.loginByAccount(account, secret)
|
|
|
+ Toast.makeText(
|
|
|
+ this@LoginActivity,
|
|
|
+ "These permissions are denied: $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }else{
|
|
|
+ PermissionX.init(this@LoginActivity)
|
|
|
+ .permissions(
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE
|
|
|
+ )
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ SwagoLoading.showLoadingDialog(this@LoginActivity)
|
|
|
+ val account = binding.etAccount.text.toString()
|
|
|
+ val secret = binding.etSecret.text.toString()
|
|
|
+ loginVm.loginByAccount(account, secret)
|
|
|
+ } else {
|
|
|
+ SwagoLoading.showLoadingDialog(this@LoginActivity)
|
|
|
+ val account = binding.etAccount.text.toString()
|
|
|
+ val secret = binding.etSecret.text.toString()
|
|
|
+ loginVm.loginByAccount(account, secret)
|
|
|
+ Toast.makeText(
|
|
|
+ this@LoginActivity,
|
|
|
+ "These permissions are denied: $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|