GCM: Fix confirm dialog in dark theme

This commit is contained in:
Marvin W 2021-03-18 01:19:54 +01:00
parent 5eb04b44db
commit 91b0f6893f
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
3 changed files with 74 additions and 64 deletions

View File

@ -4,9 +4,16 @@ import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.SpannedString;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.TextView;
@ -58,9 +65,12 @@ public class AskPushPermission extends FragmentActivity {
try {
PackageManager pm = getPackageManager();
final ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
CharSequence label = pm.getApplicationLabel(info);
String label = pm.getApplicationLabel(info).toString();
String raw = getString(R.string.gcm_allow_app_popup, label);
SpannableString s = new SpannableString(raw);
s.setSpan(new StyleSpan(Typeface.BOLD), raw.indexOf(label), raw.indexOf(label) + label.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
((TextView) findViewById(R.id.permission_message)).setText(Html.fromHtml("Allow <b>" + label + "</b> to register for push notifications?"));
((TextView) findViewById(R.id.permission_message)).setText(s);
findViewById(R.id.permission_allow_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -14,88 +14,87 @@
limitations under the License.
-->
<FrameLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:clipChildren="false"
android:clipToPadding="false">
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/dialog_container"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorBackground"
android:orientation="vertical">
<FrameLayout
android:id="@+id/desc_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="20dip"
android:paddingLeft="20dip"
android:paddingTop="18dip"
android:paddingEnd="16dip"
android:paddingRight="16dip">
<LinearLayout
android:id="@+id/perm_desc_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/permission_icon"
android:layout_width="36dip"
android:layout_height="36dip"
android:scaleType="fitCenter"
android:src="@drawable/ic_cloud_bell"
app:tint="?attr/colorAccent">
</ImageView>
<TextView
android:id="@+id/permission_message"
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dip"
android:paddingLeft="16dip"
android:text="Allow {appName} to register for push notifications?"
android:textSize="20sp">
</TextView>
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal"
android:paddingStart="20dip"
android:paddingLeft="20dip"
android:paddingEnd="16dip"
android:paddingRight="16dip">
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="24dp"
android:paddingTop="18dp"
android:paddingRight="24dp"
android:paddingBottom="24dp">
<Button
android:id="@+id/permission_deny_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
<ImageView
android:id="@+id/permission_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginBottom="12dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_cloud_bell"
app:tint="?attr/colorAccent">
</ImageView>
<TextView
android:id="@+id/permission_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/deny">
</Button>
android:gravity="center"
android:text="@string/gcm_allow_app_popup"
android:textSize="18sp">
</TextView>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.25dp"
android:background="?android:attr/textColorSecondary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/permission_allow_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?android:attr/selectableItemBackground"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/allow">
</Button>
<View
android:layout_width="match_parent"
android:layout_height="0.25dp"
android:background="?android:attr/textColorSecondary" />
<Button
android:id="@+id/permission_deny_button"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?android:attr/selectableItemBackground"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/deny">
</Button>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</ScrollView>

View File

@ -171,6 +171,7 @@ This can take a couple of minutes."</string>
<string name="gcm_network_state_disconnected">Disconnected</string>
<string name="gcm_network_state_connected">Connected since <xliff:g example="2 hours ago">%1$s</xliff:g></string>
<string name="gcm_enable_switch">Receive push notifications</string>
<string name="gcm_allow_app_popup">Allow <xliff:g example="F-Droid">%1$s</xliff:g> to register for push notifications?</string>
<string name="pref_push_app_allow_register_title">Allow registration</string>
<string name="pref_push_app_allow_register_summary">Allow the app to register for push notifications.</string>