Initial goodbye google dialog

This commit is contained in:
Patrick Schneider 2025-06-09 16:09:45 +02:00
commit f3bfabc3d1
3 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,38 @@
package org.secuso.privacyfriendlyboardgameclock
import android.content.Context
import android.graphics.text.LineBreaker
import android.os.Build
import android.preference.PreferenceManager
import android.text.method.LinkMovementMethod
import android.view.LayoutInflater
import android.widget.CheckBox
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
fun checkGoodbyeGoogle(context: Context, layoutInflater: LayoutInflater) {
val showNotice = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("show_goodbye_google_notice", true);
if (showNotice) {
val view = layoutInflater.inflate(R.layout.dialog_goodbye_google, null, false)
view.findViewById<CheckBox>(R.id.show_notice_checkbox).apply {
setOnClickListener {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("show_goodbye_google_notice", !isChecked).apply()
}
}
val dialog = AlertDialog.Builder(context)
.setView(view)
.setNeutralButton(android.R.string.ok) { _, _ -> }
.setCancelable(false)
.create()
dialog.show()
dialog.findViewById<TextView>(R.id.text)?.apply {
movementMethod = LinkMovementMethod.getInstance()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
justificationMode = LineBreaker.JUSTIFICATION_MODE_INTER_WORD
}
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
<stroke android:width="4dp" android:color="#880000"/>
</shape>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="32dp"
android:background="@drawable/dialog_border"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@android:drawable/ic_dialog_alert"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:tint="@color/red"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_goodbye_google_title"
android:textStyle="bold"
android:textSize="16dp"
android:layout_gravity="center"
android:padding="8dp"
/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_goodbye_google_desc"
/>
</ScrollView>
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/show_notice_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_goodbye_google_deactivate_notice"
/>
</LinearLayout>