mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
replace lovelyDialog with MaterialAlert
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
53f0779a44
commit
9298de0d43
@ -27,8 +27,10 @@ import android.os.Bundle
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.webkit.SslErrorHandler
|
import android.webkit.SslErrorHandler
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||||
import com.nextcloud.talk.events.CertificateEvent
|
import com.nextcloud.talk.events.CertificateEvent
|
||||||
@ -36,7 +38,6 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
|||||||
import com.nextcloud.talk.utils.SecurityUtils
|
import com.nextcloud.talk.utils.SecurityUtils
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
import com.nextcloud.talk.utils.ssl.MagicTrustManager
|
import com.nextcloud.talk.utils.ssl.MagicTrustManager
|
||||||
import com.yarolegovich.lovelydialog.LovelyStandardDialog
|
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
@ -114,21 +115,26 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
issuedBy, issuedFor, validFrom, validUntil
|
issuedBy, issuedFor, validFrom, validUntil
|
||||||
)
|
)
|
||||||
|
|
||||||
LovelyStandardDialog(this)
|
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
||||||
.setTopColorRes(R.color.nc_darkRed)
|
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_security_white_24dp))
|
||||||
.setNegativeButtonColorRes(R.color.nc_darkRed)
|
|
||||||
.setPositiveButtonColor(viewThemeUtils.getScheme(this).primary)
|
|
||||||
.setIcon(R.drawable.ic_security_white_24dp)
|
|
||||||
.setTitle(R.string.nc_certificate_dialog_title)
|
.setTitle(R.string.nc_certificate_dialog_title)
|
||||||
.setMessage(dialogText)
|
.setMessage(dialogText)
|
||||||
.setPositiveButton(R.string.nc_yes) { v ->
|
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
||||||
magicTrustManager.addCertInTrustStore(cert)
|
magicTrustManager.addCertInTrustStore(cert)
|
||||||
sslErrorHandler?.proceed()
|
sslErrorHandler?.proceed()
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_no) { view1 ->
|
.setNegativeButton(R.string.nc_no) { _, _ ->
|
||||||
sslErrorHandler?.cancel()
|
sslErrorHandler?.cancel()
|
||||||
}
|
}
|
||||||
.show()
|
|
||||||
|
viewThemeUtils.colorMaterialAlertDialogBackground(context, dialogBuilder)
|
||||||
|
|
||||||
|
val dialog = dialogBuilder.show()
|
||||||
|
|
||||||
|
viewThemeUtils.colorTextButtons(
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
||||||
|
)
|
||||||
} catch (e: CertificateParsingException) {
|
} catch (e: CertificateParsingException) {
|
||||||
Log.d(TAG, "Failed to parse the certificate")
|
Log.d(TAG, "Failed to parse the certificate")
|
||||||
}
|
}
|
||||||
|
@ -801,6 +801,14 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
return spannable
|
return spannable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun colorMaterialAlertDialogIcon(context: Context, drawableId: Int): Drawable {
|
||||||
|
val drawable = AppCompatResources.getDrawable(context, drawableId)!!
|
||||||
|
withScheme(context) { scheme ->
|
||||||
|
DrawableCompat.setTint(drawable, scheme.secondary)
|
||||||
|
}
|
||||||
|
return drawable
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
|
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
|
||||||
R.drawable.ic_mimetype_package_x_generic,
|
R.drawable.ic_mimetype_package_x_generic,
|
||||||
|
Loading…
Reference in New Issue
Block a user