mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
CS logo in QR image
This commit is contained in:
parent
b459126f58
commit
e25603d63a
2 changed files with 35 additions and 8 deletions
|
@ -8,6 +8,8 @@ import android.view.inputmethod.EditorInfo
|
|||
import android.widget.TextView
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.drawable.toBitmapOrNull
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
|
@ -60,8 +62,10 @@ import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
|||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||
import kotlinx.coroutines.delay
|
||||
import qrcode.QRCode
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
class SettingsAccount : PreferenceFragmentCompat(), BiometricAuthenticator.BiometricAuthCallback {
|
||||
companion object {
|
||||
|
@ -149,10 +153,13 @@ class SettingsAccount : PreferenceFragmentCompat(), BiometricAuthenticator.Biome
|
|||
AlertDialog.Builder(activity)
|
||||
.setView(binding.root)
|
||||
|
||||
builder.setNegativeButton(R.string.cancel) { _, _ -> }
|
||||
builder.setPositiveButton(R.string.auth_locally) { _, _ ->
|
||||
builder.apply {
|
||||
setNegativeButton(R.string.cancel) { _, _ -> }
|
||||
setPositiveButton(R.string.auth_locally) { _, _ ->
|
||||
api.authenticate(activity)
|
||||
}
|
||||
}
|
||||
|
||||
val dialog = builder.create()
|
||||
|
||||
ioSafe {
|
||||
|
@ -168,19 +175,31 @@ class SettingsAccount : PreferenceFragmentCompat(), BiometricAuthenticator.Biome
|
|||
return@ioSafe
|
||||
}
|
||||
|
||||
val logoBytes = ContextCompat.getDrawable(
|
||||
activity,
|
||||
R.drawable.cloud_2_solid
|
||||
)?.toBitmapOrNull()?.let { bitmap ->
|
||||
val csLogo = ByteArrayOutputStream()
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, csLogo)
|
||||
csLogo.toByteArray()
|
||||
}
|
||||
|
||||
val qrCodeImage = QRCode.ofRoundedSquares()
|
||||
.withColor(activity.colorFromAttribute(R.attr.colorPrimary))
|
||||
.withLogo(logoBytes, 200.toPx, 200.toPx)
|
||||
.build(pinCodeData.verificationUrl)
|
||||
.render().nativeImage() as Bitmap
|
||||
|
||||
activity.runOnUiThread {
|
||||
dialog.show()
|
||||
binding.devicePinCode.setText(txt(pinCodeData.userCode))
|
||||
binding.deviceAuthMessage.setText(txt(R.string.device_pin_url_message, pinCodeData.verificationUrl))
|
||||
binding.deviceAuthQrcode.setImage(
|
||||
binding.apply {
|
||||
devicePinCode.setText(txt(pinCodeData.userCode))
|
||||
deviceAuthMessage.setText(txt(R.string.device_pin_url_message, pinCodeData.verificationUrl))
|
||||
deviceAuthQrcode.setImage(
|
||||
img(qrCodeImage)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var expirationCounter = pinCodeData.expiresIn
|
||||
|
||||
|
|
8
app/src/main/res/drawable/cloud_2_solid.xml
Normal file
8
app/src/main/res/drawable/cloud_2_solid.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<vector xmlns:tools="http://schemas.android.com/tools" android:name="vector"
|
||||
android:width="200dp" android:height="200dp" android:viewportWidth="283"
|
||||
android:viewportHeight="283" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:name="path"
|
||||
android:pathData="M 245.05 148.63 C 242.249 148.627 239.463 149.052 236.79 149.89 C 235.151 141.364 230.698 133.63 224.147 127.931 C 217.597 122.233 209.321 118.893 200.65 118.45 C 195.913 105.431 186.788 94.458 174.851 87.427 C 162.914 80.396 148.893 77.735 135.21 79.905 C 121.527 82.074 109.017 88.941 99.84 99.32 C 89.871 95.945 79.051 96.024 69.133 99.545 C 59.215 103.065 50.765 109.826 45.155 118.73 C 39.545 127.634 37.094 138.174 38.2 148.64 L 37.94 148.64 C 30.615 148.64 23.582 151.553 18.403 156.733 C 13.223 161.912 10.31 168.945 10.31 176.27 C 10.31 183.595 13.223 190.628 18.403 195.807 C 23.582 200.987 30.615 203.9 37.94 203.9 L 245.05 203.9 C 252.375 203.9 259.408 200.987 264.587 195.807 C 269.767 190.628 272.68 183.595 272.68 176.27 C 272.68 168.945 269.767 161.912 264.587 156.733 C 259.408 151.553 252.375 148.64 245.05 148.64 Z"
|
||||
android:fillColor="?attr/colorPrimary" android:strokeWidth="1"
|
||||
tools:ignore="VectorPath"/>
|
||||
</vector>
|
Loading…
Add table
Add a link
Reference in a new issue