|
@@ -1,7 +1,6 @@
|
|
package com.afollestad.materialdialogs;
|
|
package com.afollestad.materialdialogs;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.annotation.SuppressLint;
|
|
-import android.annotation.TargetApi;
|
|
|
|
import android.app.AlertDialog;
|
|
import android.app.AlertDialog;
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
@@ -168,12 +167,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
content.setLinkTextColor(mBuilder.positiveColor);
|
|
content.setLinkTextColor(mBuilder.positiveColor);
|
|
}
|
|
}
|
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
|
- //noinspection ResourceType
|
|
|
|
- title.setTextAlignment(gravityToAlignment(builder.titleGravity));
|
|
|
|
- } else {
|
|
|
|
- title.setGravity(gravityIntToGravity(builder.titleGravity));
|
|
|
|
- }
|
|
|
|
|
|
+ title.setGravity(gravityIntToGravity(builder.titleGravity));
|
|
|
|
|
|
if (builder.contentColorSet) {
|
|
if (builder.contentColorSet) {
|
|
content.setTextColor(builder.contentColor);
|
|
content.setTextColor(builder.contentColor);
|
|
@@ -283,13 +277,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
final int fallback = DialogUtils.resolveColor(getContext(), android.R.attr.textColorPrimary);
|
|
final int fallback = DialogUtils.resolveColor(getContext(), android.R.attr.textColorPrimary);
|
|
title.setTextColor(DialogUtils.resolveColor(getContext(), R.attr.md_title_color, fallback));
|
|
title.setTextColor(DialogUtils.resolveColor(getContext(), R.attr.md_title_color, fallback));
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
|
- //noinspection ResourceType
|
|
|
|
- content.setTextAlignment(gravityToAlignment(builder.contentGravity));
|
|
|
|
- } else {
|
|
|
|
- content.setGravity(gravityIntToGravity(builder.contentGravity));
|
|
|
|
- }
|
|
|
|
|
|
+ content.setGravity(gravityIntToGravity(builder.contentGravity));
|
|
}
|
|
}
|
|
|
|
|
|
if (builder.showListener != null) {
|
|
if (builder.showListener != null) {
|
|
@@ -340,18 +328,6 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
|
|
|
- private static int gravityToAlignment(GravityEnum gravity) {
|
|
|
|
- switch (gravity) {
|
|
|
|
- case CENTER:
|
|
|
|
- return View.TEXT_ALIGNMENT_CENTER;
|
|
|
|
- case END:
|
|
|
|
- return View.TEXT_ALIGNMENT_VIEW_END;
|
|
|
|
- default:
|
|
|
|
- return View.TEXT_ALIGNMENT_VIEW_START;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void onShow(DialogInterface dialog) {
|
|
public void onShow(DialogInterface dialog) {
|
|
super.onShow(dialog); // calls any external show listeners
|
|
super.onShow(dialog); // calls any external show listeners
|
|
@@ -751,15 +727,8 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
setBackgroundCompat(positiveButton, getButtonSelector(DialogAction.POSITIVE));
|
|
setBackgroundCompat(positiveButton, getButtonSelector(DialogAction.POSITIVE));
|
|
positiveButton.setTag(POSITIVE);
|
|
positiveButton.setTag(POSITIVE);
|
|
positiveButton.setOnClickListener(this);
|
|
positiveButton.setOnClickListener(this);
|
|
-
|
|
|
|
- if (isStacked) {
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
|
- //noinspection ResourceType
|
|
|
|
- positiveTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
|
|
|
|
- } else {
|
|
|
|
- positiveTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (isStacked)
|
|
|
|
+ positiveTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
|
|
} else {
|
|
} else {
|
|
positiveButton.setVisibility(View.GONE);
|
|
positiveButton.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
@@ -775,15 +744,8 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
neutralTextView.setText(mBuilder.neutralText);
|
|
neutralTextView.setText(mBuilder.neutralText);
|
|
neutralButton.setTag(NEUTRAL);
|
|
neutralButton.setTag(NEUTRAL);
|
|
neutralButton.setOnClickListener(this);
|
|
neutralButton.setOnClickListener(this);
|
|
-
|
|
|
|
- if (isStacked) {
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
|
- //noinspection ResourceType
|
|
|
|
- neutralTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
|
|
|
|
- } else {
|
|
|
|
- neutralTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (isStacked)
|
|
|
|
+ neutralTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
|
|
} else {
|
|
} else {
|
|
neutralButton.setVisibility(View.GONE);
|
|
neutralButton.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
@@ -818,12 +780,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
}
|
|
}
|
|
negativeButton.setLayoutParams(params);
|
|
negativeButton.setLayoutParams(params);
|
|
} else {
|
|
} else {
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
|
- //noinspection ResourceType
|
|
|
|
- negativeTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
|
|
|
|
- } else {
|
|
|
|
- negativeTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
|
|
|
|
- }
|
|
|
|
|
|
+ negativeTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
negativeButton.setVisibility(View.GONE);
|
|
negativeButton.setVisibility(View.GONE);
|