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 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) { 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 @@