From d1b601ef963f8a55e7605b74a5e0faddd8e9046e Mon Sep 17 00:00:00 2001 From: 1951FDG <1951FDG@users.noreply.github.com> Date: Fri, 18 Oct 2019 17:22:12 +0200 Subject: [PATCH 1/4] fix title of dialog not getting set due to double negative ((!mViewManager.getSetup().noToolbarTheme()) --- README.md | 2 +- .../michaelflisar/gdprdialog/GDPRDialog.java | 25 ++++++++++++------- .../michaelflisar/gdprdialog/GDPRSetup.java | 3 ++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5c9ef97..78955fe 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ GDPRSetup setup = new GDPRSetup(GDPRDefinitions.ADMOB) // add all networks you u .withCustomDialogTheme(theme) .withShortQuestion(true) .withLoadAdMobNetworks(publisherId(s)) // e.g. "pub-0123456789012345" - .withNoToolbarTheme(noToolbarTheme) + .withNoToolbarTheme(noToolbarTheme) // true, if you use a theme without a toolbar, false otherwise .withShowPaidOrFreeInfoText(true) // show the info that this app is cheap/free based on the networks or hide it .withCustomTexts(customTexts) // provide custom texts (title, top message, main message, question text, age confirmation text) by resource or string ; diff --git a/library/src/main/java/com/michaelflisar/gdprdialog/GDPRDialog.java b/library/src/main/java/com/michaelflisar/gdprdialog/GDPRDialog.java index f93a6bb..1b2cf37 100644 --- a/library/src/main/java/com/michaelflisar/gdprdialog/GDPRDialog.java +++ b/library/src/main/java/com/michaelflisar/gdprdialog/GDPRDialog.java @@ -10,6 +10,8 @@ import androidx.core.app.ActivityCompat; import androidx.appcompat.app.AppCompatDialog; import androidx.appcompat.app.AppCompatDialogFragment; +import androidx.fragment.app.DialogFragment; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -48,6 +50,12 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewManager = new GDPRViewManager(getArguments(), savedInstanceState); mForceActivityToImplementCallback = getArguments().getBoolean(ARG_PARENT_MUST_IMPLEMENT_CALLBACK); + GDPRCustomTexts customTexts = mViewManager.getSetup().getCustomTexts(); + if (customTexts.hasTitle() && customTexts.getTitle(getContext()).isEmpty()) { + setStyle(DialogFragment.STYLE_NO_TITLE, mViewManager.getSetup().customDialogTheme()); + } else { + setStyle(DialogFragment.STYLE_NORMAL, mViewManager.getSetup().customDialogTheme()); + } } @Override @@ -71,12 +79,11 @@ public void onSaveInstanceState(Bundle outState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = initView(inflater, container); - if (!mViewManager.getSetup().noToolbarTheme()) { - if (mViewManager.getSetup().getCustomTexts().hasTitle()) - getDialog().setTitle(mViewManager.getSetup().getCustomTexts().getTitle(view.getContext())); - else - getDialog().setTitle(R.string.gdpr_dialog_title); - } + GDPRCustomTexts customTexts = mViewManager.getSetup().getCustomTexts(); + if (customTexts.hasTitle()) + getDialog().setTitle(customTexts.getTitle(getContext())); + else + getDialog().setTitle(R.string.gdpr_dialog_title); return view; } @@ -90,7 +97,7 @@ public void onDestroy() { public Dialog onCreateDialog(Bundle savedInstanceState) { if (mViewManager.shouldUseBottomSheet()) { - BottomSheetDialog dlg = new BottomSheetDialog(getContext(), mViewManager.getSetup().customDialogTheme()){ + BottomSheetDialog dlg = new BottomSheetDialog(getContext(), getTheme()){ @Override public void onBackPressed() { if (mViewManager.handleBackPress()) { @@ -131,7 +138,7 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) { }); return dlg; } else { - return new AppCompatDialog(getContext(), mViewManager.getSetup().customDialogTheme()) { + return new AppCompatDialog(getContext(), getTheme()) { @Override public void onBackPressed() { if (mViewManager.handleBackPress()) { @@ -165,4 +172,4 @@ private void onSaveConsentAndCloseDialog() { } mViewManager.reset(); } -} \ No newline at end of file +} diff --git a/library/src/main/java/com/michaelflisar/gdprdialog/GDPRSetup.java b/library/src/main/java/com/michaelflisar/gdprdialog/GDPRSetup.java index cce95fe..9dc7a1a 100644 --- a/library/src/main/java/com/michaelflisar/gdprdialog/GDPRSetup.java +++ b/library/src/main/java/com/michaelflisar/gdprdialog/GDPRSetup.java @@ -112,7 +112,8 @@ public GDPRSetup withExplicitNonPersonalisedConfirmation(boolean explicitNonPers } /** - * use this if you use an app theme without a toolbar as actionbar + * use this if you use an app theme without a toolbar as actionbar only! + * use this to show a toolbar when launching {@link GDPRActivity} * * @param noToolbarTheme true, if you use a theme without a toolbar, false otherwise * @return this From c6ebc33279ba15442081cfb3308b512f75cd0848 Mon Sep 17 00:00:00 2001 From: 1951FDG <1951FDG@users.noreply.github.com> Date: Fri, 18 Oct 2019 17:23:26 +0200 Subject: [PATCH 2/4] fix null pointer exception when (getSupportActionBar() == null) --- .../michaelflisar/gdprdialog/helper/GDPRViewManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/michaelflisar/gdprdialog/helper/GDPRViewManager.java b/library/src/main/java/com/michaelflisar/gdprdialog/helper/GDPRViewManager.java index 7c1737f..5f3a2a9 100644 --- a/library/src/main/java/com/michaelflisar/gdprdialog/helper/GDPRViewManager.java +++ b/library/src/main/java/com/michaelflisar/gdprdialog/helper/GDPRViewManager.java @@ -234,10 +234,11 @@ public void init(Activity activity, View view, IOnFinishView onFinishViewListene } public void initActionBar(Activity activity, ActionBar supportActionBar) { - if (mSetup.getCustomTexts().hasTitle()) - supportActionBar.setTitle(mSetup.getCustomTexts().getTitle(activity)); - else - supportActionBar.setTitle(R.string.gdpr_dialog_title); + if (supportActionBar != null) + if (mSetup.getCustomTexts().hasTitle()) + supportActionBar.setTitle(mSetup.getCustomTexts().getTitle(activity)); + else + supportActionBar.setTitle(R.string.gdpr_dialog_title); } private void initButtons(Activity activity, Button btAgree, Button btDisagree, Button btNoConsentAtAll) { From 2fde29a3d02aeb47bbdc8081c03b2f3f99877f64 Mon Sep 17 00:00:00 2001 From: 1951FDG <1951FDG@users.noreply.github.com> Date: Fri, 18 Oct 2019 18:22:34 +0200 Subject: [PATCH 3/4] fix padding, fix accessibility issue (height of `Checkbox` touch target), remove mentions of textSize and use typographic styles instead, bold style for all secondary actions, unelevated style for primary action --- .../res/layout-land/gdpr_dialog_bottom.xml | 2 +- library/src/main/res/layout/gdpr_dialog.xml | 54 +++++++++---------- .../main/res/layout/gdpr_dialog_bottom.xml | 8 +-- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/library/src/main/res/layout-land/gdpr_dialog_bottom.xml b/library/src/main/res/layout-land/gdpr_dialog_bottom.xml index 48ab586..a953ea4 100644 --- a/library/src/main/res/layout-land/gdpr_dialog_bottom.xml +++ b/library/src/main/res/layout-land/gdpr_dialog_bottom.xml @@ -23,7 +23,7 @@