Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Oct 28, 2021
2 parents dc02097 + ea6657a commit e3d9d73
Show file tree
Hide file tree
Showing 36 changed files with 150 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public AddressPicker(@NonNull Activity activity, @StyleRes int themeResId) {
@Override
protected void initData() {
super.initData();
titleView.setText("地址选择");
if (addressLoader == null || addressParser == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import androidx.annotation.StyleRes;

import com.github.gzuliyujiang.calendarpicker.core.CalendarAdapter;
import com.github.gzuliyujiang.calendarpicker.core.CalendarView;
import com.github.gzuliyujiang.calendarpicker.core.ColorScheme;
import com.github.gzuliyujiang.calendarpicker.core.OnDateSelectedListener;
import com.github.gzuliyujiang.calendarpicker.core.DateUtils;
import com.github.gzuliyujiang.calendarpicker.core.CalendarView;
import com.github.gzuliyujiang.calendarpicker.core.OnDateSelectedListener;
import com.github.gzuliyujiang.dialog.DialogConfig;
import com.github.gzuliyujiang.dialog.DialogStyle;
import com.github.gzuliyujiang.dialog.ModalDialog;
Expand Down Expand Up @@ -68,8 +68,9 @@ protected View createBodyView() {
}

@Override
protected void initView(@NonNull View contentView) {
super.initView(contentView);
protected void initView() {
super.initView();
setHeight((int) (activity.getResources().getDisplayMetrics().heightPixels * 0.6f));
switch (DialogConfig.getDialogStyle()) {
case DialogStyle.Default:
headerView.setVisibility(View.VISIBLE);
Expand All @@ -89,7 +90,6 @@ protected void initView(@NonNull View contentView) {
protected void initData() {
super.initData();
initialized = true;
setHeight((int) (activity.getResources().getDisplayMetrics().heightPixels * 0.6f));
if (minDate == null && maxDate == null) {
Date currentDate = new Date(System.currentTimeMillis());
Calendar minCalendar = DateUtils.calendar(currentDate);
Expand Down
6 changes: 5 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# 更新日志

## 4.0.1 - 2021.10.28
## 4.0.2 - 2021.10.28

- 基于最新版本的 Android Studio Arctic Fox 构建,Gradle 升级到最新的 7.x 版本;
- 文本国际化,支持定制多语言(默认为中文及英文);
- 手机号码前缀选择器数据完善,支持全球的国家及地区;

## 4.0.1 - 2021.09.26

- 优化选择器标题设置,避免设置不生效问题;

## 4.0.0 - 2021.09.18

- 支持设置弹窗样式,内置四种弹窗模式,支持全局弹窗配色,效果请运行Demo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ protected View createBodyView() {

@CallSuper
@Override
protected void initView(@NonNull View contentView) {
super.initView(contentView);
protected void initView() {
super.initView();
colorGradientView = contentView.findViewById(R.id.color_picker_panel);
brightnessGradientView = contentView.findViewById(R.id.color_picker_bright);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
Expand All @@ -40,7 +39,6 @@
import androidx.annotation.FloatRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.annotation.StyleRes;

/**
Expand Down Expand Up @@ -87,7 +85,7 @@ private void init(Activity activity) {
window.setGravity(Gravity.CENTER);
window.getDecorView().setPadding(0, 0, 0, 0);
}
onInit(activity, null);
onInit(null);
// 调用create或show才能触发onCreate
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
super.create();
Expand All @@ -96,11 +94,21 @@ private void init(Activity activity) {
}
}

/**
* @deprecated 使用 {@link #onInit(Bundle)} 代替
*/
@Deprecated
@CallSuper
protected void onInit(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
DialogLog.print("dialog onInit");
}

@CallSuper
protected void onInit(@Nullable Bundle savedInstanceState) {
//noinspection deprecation
onInit(activity, savedInstanceState);
}

@Override
protected final void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -115,17 +123,28 @@ private void readyView() {
contentView.setFocusable(true);
contentView.setFocusableInTouchMode(true);
setContentView(contentView);
initView(contentView);
initView();
}

@NonNull
protected abstract View createContentView();

/**
* @deprecated 使用 {@link #initView()} 代替
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
@CallSuper
protected void initView(View contentView) {
DialogLog.print("dialog initView");
}

@CallSuper
protected void initView() {
//noinspection deprecation
initView(contentView);
}

public final void disableCancel() {
setCancelable(false);
setCanceledOnTouchOutside(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public BottomDialog(@NonNull Activity activity, @StyleRes int themeResId) {
}

@Override
public void onInit(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
super.onInit(activity, savedInstanceState);
public void onInit(@Nullable Bundle savedInstanceState) {
super.onInit(savedInstanceState);
setCancelable(true);
setCanceledOnTouchOutside(true);
setWidth(activity.getResources().getDisplayMetrics().widthPixels);
Expand All @@ -66,7 +66,7 @@ protected boolean enableMaskView() {
return true;
}

private void addMaskView() {
protected void addMaskView() {
// 通过自定义遮罩层视图解决自带弹窗遮罩致使系统导航栏背景过暗不一体问题
try {
// 取消弹窗遮罩效果 android:backgroundDimEnabled=false
Expand Down Expand Up @@ -111,7 +111,7 @@ public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
}

private void removeMaskView() {
protected void removeMaskView() {
if (maskView == null) {
DialogLog.print("mask view is null");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.core.graphics.ColorUtils;

Expand Down Expand Up @@ -58,8 +57,8 @@ public ModalDialog(@NonNull Activity activity, @StyleRes int themeResId) {
}

@Override
public void onInit(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
super.onInit(activity, savedInstanceState);
public void onInit(@Nullable Bundle savedInstanceState) {
super.onInit(savedInstanceState);
if (DialogConfig.getDialogStyle() == DialogStyle.Three) {
setWidth((int) (activity.getResources().getDisplayMetrics().widthPixels * 0.8f));
setGravity(Gravity.CENTER);
Expand Down Expand Up @@ -146,8 +145,8 @@ protected View createFooterView() {

@CallSuper
@Override
protected void initView(@NonNull View contentView) {
super.initView(contentView);
protected void initView() {
super.initView();
int color = DialogConfig.getDialogColor().contentBackgroundColor();
switch (DialogConfig.getDialogStyle()) {
case DialogStyle.One:
Expand All @@ -173,12 +172,6 @@ protected void initView(@NonNull View contentView) {
if (okView == null) {
throw new IllegalArgumentException("Ok view id not found");
}
}

@CallSuper
@Override
protected void initData() {
super.initData();
titleView.setTextColor(DialogConfig.getDialogColor().titleTextColor());
cancelView.setTextColor(DialogConfig.getDialogColor().cancelTextColor());
okView.setTextColor(DialogConfig.getDialogColor().okTextColor());
Expand Down Expand Up @@ -221,6 +214,34 @@ private void maybeBuildEllipseButton() {
}
}

@Override
public void setTitle(final @Nullable CharSequence title) {
if (titleView != null) {
titleView.post(new Runnable() {
@Override
public void run() {
titleView.setText(title);
}
});
} else {
super.setTitle(title);
}
}

@Override
public void setTitle(final int titleId) {
if (titleView != null) {
titleView.post(new Runnable() {
@Override
public void run() {
titleView.setText(titleId);
}
});
} else {
super.setTitle(titleId);
}
}

@CallSuper
@Override
public void onClick(View v) {
Expand All @@ -240,24 +261,6 @@ public void onClick(View v) {

protected abstract void onOk();

@Override
public void setTitle(@Nullable CharSequence title) {
if (titleView == null) {
return;
}
titleView.post(new Runnable() {
@Override
public void run() {
titleView.setText(title);
}
});
}

@Override
public void setTitle(@StringRes int titleId) {
setTitle(activity.getString(titleId));
}

public final void setBodyWidth(@Dimension(unit = Dimension.DP) @IntRange(from = 50) int bodyWidth) {
ViewGroup.LayoutParams layoutParams = bodyView.getLayoutParams();
int width = WRAP_CONTENT;
Expand Down
4 changes: 2 additions & 2 deletions Common/src/main/res/layout/dialog_footer_style_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
android:paddingTop="13dp"
android:paddingBottom="13dp"
android:singleLine="true"
android:text="@string/dialog_modal_cancel"
android:text="@android:string/cancel"
android:textColor="#FF333333"
android:textSize="15sp" />

Expand All @@ -46,7 +46,7 @@
android:paddingTop="13dp"
android:paddingBottom="13dp"
android:singleLine="true"
android:text="@string/dialog_modal_ok"
android:text="@android:string/ok"
android:textColor="#FF333333"
android:textSize="15sp" />

Expand Down
2 changes: 1 addition & 1 deletion Common/src/main/res/layout/dialog_footer_style_2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
android:paddingTop="13dp"
android:paddingBottom="13dp"
android:singleLine="true"
android:text="@string/dialog_modal_ok"
android:text="@android:string/ok"
android:textColor="#FF333333"
android:textSize="15sp" />

Expand Down
4 changes: 2 additions & 2 deletions Common/src/main/res/layout/dialog_footer_style_3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:gravity="center"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:text="@string/dialog_modal_cancel"
android:text="@android:string/cancel"
android:textColor="#FF333333"
android:textSize="14sp" />

Expand All @@ -37,7 +37,7 @@
android:gravity="center"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:text="@string/dialog_modal_ok"
android:text="@android:string/ok"
android:textColor="#FF333333"
android:textSize="14sp" />

Expand Down
5 changes: 3 additions & 2 deletions Common/src/main/res/layout/dialog_header_style_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-->

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dialog_modal_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -22,7 +23,7 @@
android:paddingEnd="25dp"
android:paddingBottom="15dp"
android:singleLine="true"
android:text="@string/dialog_modal_title"
android:textColor="#FF666666"
android:textSize="15sp"
android:textStyle="bold" />
android:textStyle="bold"
tools:text="@android:string/untitled" />
5 changes: 3 additions & 2 deletions Common/src/main/res/layout/dialog_header_style_2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand All @@ -27,10 +28,10 @@
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:singleLine="true"
android:text="@string/dialog_modal_title"
android:textColor="#FF666666"
android:textSize="15sp"
android:textStyle="bold" />
android:textStyle="bold"
tools:text="@android:string/untitled" />

<TextView
android:id="@+id/dialog_modal_cancel"
Expand Down
5 changes: 3 additions & 2 deletions Common/src/main/res/layout/dialog_header_style_3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-->

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dialog_modal_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -22,7 +23,7 @@
android:paddingEnd="25dp"
android:paddingBottom="15dp"
android:singleLine="true"
android:text="@string/dialog_modal_title"
android:textColor="#FF666666"
android:textSize="15sp"
android:textStyle="bold" />
android:textStyle="bold"
tools:text="@android:string/untitled" />
4 changes: 2 additions & 2 deletions Common/src/main/res/layout/dialog_header_style_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:paddingTop="15dp"
android:paddingEnd="20dp"
android:paddingBottom="15dp"
android:text="@string/dialog_modal_cancel"
android:text="@android:string/cancel"
android:textColor="#FF333333"
android:textSize="15sp" />

Expand Down Expand Up @@ -54,7 +54,7 @@
android:paddingTop="15dp"
android:paddingEnd="20dp"
android:paddingBottom="15dp"
android:text="@string/dialog_modal_ok"
android:text="@android:string/ok"
android:textColor="#FF0081FF"
android:textSize="15sp" />

Expand Down
Loading

0 comments on commit e3d9d73

Please sign in to comment.