Skip to content

Commit

Permalink
* versions updated
Browse files Browse the repository at this point in the history
* small UI changes
  • Loading branch information
MFlisar committed Mar 25, 2020
2 parents 24a1d69 + 1bf8650 commit 7cf1f16
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
Expand Down
25 changes: 16 additions & 9 deletions library/src/main/java/com/michaelflisar/gdprdialog/GDPRDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand All @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -165,4 +172,4 @@ private void onSaveConsentAndCloseDialog() {
}
mViewManager.reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/layout-land/gdpr_dialog_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<Button
android:id="@+id/btAgree"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
Expand Down
54 changes: 27 additions & 27 deletions library/src/main/res/layout/gdpr_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="?dialogPreferredPadding">
android:paddingLeft="?dialogPreferredPadding"
android:paddingTop="18dp"
android:paddingRight="?dialogPreferredPadding"
android:paddingBottom="18dp">

<!-- 0 - general page -->

Expand All @@ -29,7 +32,6 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_weight="1">

<LinearLayout
Expand All @@ -39,42 +41,39 @@

<TextView
android:id="@+id/tvText1"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/gdpr_big_padding"
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:text="@string/gdpr_dialog_text1_part1"
android:textAlignment="center"
android:textSize="@dimen/gdpr_text_size_small"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2"
android:textStyle="bold"/>

<TextView
android:id="@+id/tvText2"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:text="@string/gdpr_dialog_text2_singular"
android:textSize="@dimen/gdpr_text_size_normal"/>
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>

<TextView
android:id="@+id/tvQuestion"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/gdpr_big_padding"
android:layout_marginTop="@dimen/gdpr_big_padding"
android:text="@string/gdpr_dialog_question"
android:textAlignment="center"
android:textSize="@dimen/gdpr_text_size_big"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
android:textStyle="bold"/>

<TextView
android:id="@+id/tvText3"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gdpr_small_padding"
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:text="@string/gdpr_dialog_text3"
android:textSize="@dimen/gdpr_text_size_normal"/>
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>

</LinearLayout>

Expand All @@ -84,8 +83,9 @@
android:id="@+id/cbAge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:text="@string/gdpr_dialog_confirm_age"/>
android:minHeight="48dp"
android:text="@string/gdpr_dialog_confirm_age"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>

<include
layout="@layout/gdpr_dialog_bottom"
Expand All @@ -104,39 +104,39 @@

<TextView
android:id="@+id/tvServiceInfo1"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gdpr_dialog_text_info1"/>
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:text="@string/gdpr_dialog_text_info1"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>

<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:layout_marginTop="@dimen/gdpr_small_padding"
android:layout_weight="1"
android:scrollbars="vertical">

<TextView
android:id="@+id/tvServiceInfo2"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""/>
android:text=""
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>

</ScrollView>

<TextView
android:id="@+id/tvServiceInfo3"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:text="@string/gdpr_dialog_text_info3"/>
android:text="@string/gdpr_dialog_text_info3"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>

<Button
android:id="@+id/btBack"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gdpr_dialog_back"/>
Expand All @@ -153,15 +153,15 @@

<TextView
android:id="@+id/tvNonPersonalisedInfo1"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/gdpr_small_padding"
android:text="@string/gdpr_dialog_text_explicit_non_personalised_info1"/>
android:text="@string/gdpr_dialog_text_explicit_non_personalised_info1"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"/>

<Button
android:id="@+id/btAgreeNonPersonalised"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gdpr_dialog_agree"/>
Expand Down
8 changes: 5 additions & 3 deletions library/src/main/res/layout/gdpr_dialog_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<Button
android:id="@+id/btAgree"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gdpr_dialog_agree"/>
Expand All @@ -13,13 +13,15 @@
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gdpr_dialog_disagree_no_thanks"/>
android:text="@string/gdpr_dialog_disagree_no_thanks"
android:textStyle="bold"/>

<Button
android:id="@+id/btNoConsentAtAll"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gdpr_dialog_disagree_no_ads"/>
android:text="@string/gdpr_dialog_disagree_no_ads"
android:textStyle="bold"/>

</merge>
5 changes: 0 additions & 5 deletions library/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="gdpr_big_padding">12dp</dimen>
<dimen name="gdpr_small_padding">8dp</dimen>

<dimen name="gdpr_text_size_small">12sp</dimen>
<dimen name="gdpr_text_size_normal">14sp</dimen>
<dimen name="gdpr_text_size_big">16sp</dimen>
</resources>

0 comments on commit 7cf1f16

Please sign in to comment.