Skip to content

Commit

Permalink
调整宽度比例约束的默认值, 发布1.1.3版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Jan 20, 2020
1 parent bc46466 commit 6138c74
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ allprojects {
```
dependencies {
...
implementation 'com.github.xuexiangjys:XUpdate:1.1.2'
implementation 'com.github.xuexiangjys:XUpdate:1.1.3'
}
```

Expand Down Expand Up @@ -300,7 +300,7 @@ XUpdate.newBuild(getActivity())

* promptThemeColor: 设置主题颜色(升级/安装按钮的背景色)
* promptTopResId: 弹窗的标题背景的资源图片
* promptWidthRatio: 弹窗宽度占屏幕宽度的比例,默认是0.8
* promptWidthRatio: 弹窗宽度占屏幕宽度的比例,默认是-1,不做约束
* promptHeightRatio: 弹窗高度占屏幕高度的比例,默认是-1,不做约束

```
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
androidTestImplementation deps.espresso.core
implementation project(':xupdate-lib')

// implementation 'com.github.xuexiangjys:XUpdate:1.1.1'
// implementation 'com.github.xuexiangjys:XUpdate:1.1.2'

implementation 'com.github.xuexiangjys.XUtil:xutil-core:1.1.6'
implementation 'com.github.xuexiangjys.XUtil:xutil-sub:1.1.6'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,12 @@ public Builder supportBackgroundUpdate(boolean supportBackgroundUpdate) {
}

/**
* 设置版本更新提示器宽度占屏幕的比例,默认是0.8
* 设置版本更新提示器宽度占屏幕的比例,默认是-1,不做约束
*
* @param widthRatio
* @return
*/
public Builder promptWidthRatio(@FloatRange(from = 0.5F, to = 1F) float widthRatio) {
public Builder promptWidthRatio(float widthRatio) {
promptEntity.setWidthRatio(widthRatio);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public PromptEntity() {
mThemeColor = -1;
mTopResId = -1;
mSupportBackgroundUpdate = false;
mWidthRatio = 0.8F;
mWidthRatio = -1;
mHeightRatio = -1;
}

Expand Down Expand Up @@ -92,7 +92,7 @@ public PromptEntity setSupportBackgroundUpdate(boolean supportBackgroundUpdate)
return this;
}

public PromptEntity setWidthRatio(@FloatRange(from = 0.5F, to = 1F) float widthRatio) {
public PromptEntity setWidthRatio(float widthRatio) {
mWidthRatio = widthRatio;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ private void setDialogTheme(int themeColor, int topResId, float widthRatio, floa
if (window != null) {
WindowManager.LayoutParams lp = window.getAttributes();
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
lp.width = (int) (displayMetrics.widthPixels * widthRatio);
if (heightRatio > 0) {
if (widthRatio > 0 && widthRatio < 1) {
lp.width = (int) (displayMetrics.widthPixels * widthRatio);
}
if (heightRatio > 0 && heightRatio < 1) {
lp.height = (int) (displayMetrics.heightPixels * heightRatio);
}
window.setAttributes(lp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
window.setGravity(Gravity.CENTER);
WindowManager.LayoutParams lp = window.getAttributes();
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
lp.width = (int) (displayMetrics.widthPixels * mPromptEntity.getWidthRatio());
if (mPromptEntity.getHeightRatio() > 0) {
if (mPromptEntity.getWidthRatio() > 0 && mPromptEntity.getWidthRatio() < 1) {
lp.width = (int) (displayMetrics.widthPixels * mPromptEntity.getWidthRatio());
}
if (mPromptEntity.getHeightRatio() > 0 && mPromptEntity.getHeightRatio() < 1) {
lp.height = (int) (displayMetrics.heightPixels * mPromptEntity.getHeightRatio());
}
window.setAttributes(lp);
Expand Down

0 comments on commit 6138c74

Please sign in to comment.