Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mmm-rain
AndroidUtilCode
提交
340e8c95
A
AndroidUtilCode
项目概览
mmm-rain
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
340e8c95
编写于
3月 18, 2019
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 08/18 log
上级
2679130d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
16 deletion
+48
-16
utilcode/lib/src/main/java/com/blankj/utilcode/util/ScreenUtils.java
...b/src/main/java/com/blankj/utilcode/util/ScreenUtils.java
+28
-4
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/screen/ScreenActivity.kt
.../com/blankj/utilcode/pkg/feature/screen/ScreenActivity.kt
+2
-0
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/helper/DialogHelper.kt
.../main/java/com/blankj/utilcode/pkg/helper/DialogHelper.kt
+17
-12
utilcode/pkg/src/main/res/layout/dialog_keyboard.xml
utilcode/pkg/src/main/res/layout/dialog_keyboard.xml
+1
-0
未找到文件。
utilcode/lib/src/main/java/com/blankj/utilcode/util/ScreenUtils.java
浏览文件 @
340e8c95
...
...
@@ -41,12 +41,11 @@ public final class ScreenUtils {
*/
public
static
int
getScreenWidth
()
{
WindowManager
wm
=
(
WindowManager
)
Utils
.
getApp
().
getSystemService
(
Context
.
WINDOW_SERVICE
);
if
(
wm
==
null
)
return
-
1
;
Point
point
=
new
Point
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
//noinspection ConstantConditions
wm
.
getDefaultDisplay
().
getRealSize
(
point
);
}
else
{
//noinspection ConstantConditions
wm
.
getDefaultDisplay
().
getSize
(
point
);
}
return
point
.
x
;
...
...
@@ -59,17 +58,42 @@ public final class ScreenUtils {
*/
public
static
int
getScreenHeight
()
{
WindowManager
wm
=
(
WindowManager
)
Utils
.
getApp
().
getSystemService
(
Context
.
WINDOW_SERVICE
);
if
(
wm
==
null
)
return
-
1
;
Point
point
=
new
Point
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
//noinspection ConstantConditions
wm
.
getDefaultDisplay
().
getRealSize
(
point
);
}
else
{
//noinspection ConstantConditions
wm
.
getDefaultDisplay
().
getSize
(
point
);
}
return
point
.
y
;
}
/**
* Return the application's width of screen, in pixel.
*
* @return the application's width of screen, in pixel
*/
public
static
int
getAppScreenWidth
()
{
WindowManager
wm
=
(
WindowManager
)
Utils
.
getApp
().
getSystemService
(
Context
.
WINDOW_SERVICE
);
if
(
wm
==
null
)
return
-
1
;
Point
point
=
new
Point
();
wm
.
getDefaultDisplay
().
getSize
(
point
);
return
point
.
x
;
}
/**
* Return the application's height of screen, in pixel.
*
* @return the application's height of screen, in pixel
*/
public
static
int
getAppScreenHeight
()
{
WindowManager
wm
=
(
WindowManager
)
Utils
.
getApp
().
getSystemService
(
Context
.
WINDOW_SERVICE
);
if
(
wm
==
null
)
return
-
1
;
Point
point
=
new
Point
();
wm
.
getDefaultDisplay
().
getSize
(
point
);
return
point
.
y
;
}
/**
* Return the density of screen.
*
...
...
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/screen/ScreenActivity.kt
浏览文件 @
340e8c95
...
...
@@ -95,6 +95,8 @@ class ScreenActivity : BaseTitleActivity() {
SpanUtils
.
with
(
screenAboutTv
)
.
appendLine
(
"getScreenWidth: "
+
ScreenUtils
.
getScreenWidth
())
.
appendLine
(
"getScreenHeight: "
+
ScreenUtils
.
getScreenHeight
())
.
appendLine
(
"getAppScreenWidth: "
+
ScreenUtils
.
getAppScreenWidth
())
.
appendLine
(
"getAppScreenHeight: "
+
ScreenUtils
.
getAppScreenHeight
())
.
appendLine
(
"getScreenDensity: "
+
ScreenUtils
.
getScreenDensity
())
.
appendLine
(
"getScreenDensityDpi: "
+
ScreenUtils
.
getScreenDensityDpi
())
.
appendLine
(
"isFullScreen: "
+
ScreenUtils
.
isFullScreen
(
this
))
...
...
utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/helper/DialogHelper.kt
浏览文件 @
340e8c95
package
com.blankj.utilcode.pkg.helper
import
android.graphics.Bitmap
import
android.graphics.drawable.ColorDrawable
import
android.support.v7.app.AlertDialog
import
android.text.method.ScrollingMovementMethod
import
android.view.Gravity
import
android.view.LayoutInflater
import
android.view.View
import
android.view.Window
import
android.widget.Button
import
android.widget.EditText
import
android.widget.ImageView
import
android.widget.TextView
import
com.blankj.utilcode.pkg.R
import
com.blankj.utilcode.util.ActivityUtils
import
com.blankj.utilcode.util.KeyboardUtils
import
com.blankj.utilcode.util.PermissionUtils
import
com.blankj.utilcode.util.*
import
com.blankj.utilcode.util.PermissionUtils.OnRationaleListener.ShouldRequest
import
com.blankj.utilcode.util.ToastUtils
/**
* ```
...
...
@@ -56,7 +56,9 @@ object DialogHelper {
val
topActivity
=
ActivityUtils
.
getTopActivity
()
if
(!
ActivityUtils
.
isActivityAlive
(
topActivity
))
return
val
dialogView
=
LayoutInflater
.
from
(
topActivity
).
inflate
(
R
.
layout
.
dialog_keyboard
,
null
)
val
dialog
=
AlertDialog
.
Builder
(
topActivity
).
setView
(
dialogView
).
create
()
val
dialog
=
AlertDialog
.
Builder
(
topActivity
)
.
setView
(
dialogView
)
.
create
()
dialog
.
setCanceledOnTouchOutside
(
false
)
val
keyboardDialogEt
=
dialogView
.
findViewById
<
EditText
>(
R
.
id
.
keyboardDialogEt
)
val
listener
=
View
.
OnClickListener
{
v
->
...
...
@@ -74,15 +76,18 @@ object DialogHelper {
dialogView
.
findViewById
<
View
>(
R
.
id
.
keyboardDialogShowSoftInputBtn
).
setOnClickListener
(
listener
)
dialogView
.
findViewById
<
View
>(
R
.
id
.
keyboardDialogToggleSoftInputBtn
).
setOnClickListener
(
listener
)
dialogView
.
findViewById
<
View
>(
R
.
id
.
keyboardDialogCloseBtn
).
setOnClickListener
(
listener
)
dialog
.
show
()
// val attributes = dialog.window.attributes
// attributes.y = SizeUtils.dp2px(300f)
// attributes.height = ScreenUtils.getScreenHeight() / 2
// dialog.window.attributes = attributes
// dialog.window.decorView.setPadding(0, 0, 0, 0)
val
window
=
dialog
.
window
window
.
requestFeature
(
Window
.
FEATURE_NO_TITLE
)
dialog
.
show
()
KeyboardUtils
.
fixAndroidBug5497
(
dialog
.
window
)
window
.
setBackgroundDrawable
(
ColorDrawable
(
0
))
val
attributes
=
dialog
.
window
.
attributes
attributes
.
gravity
=
Gravity
.
BOTTOM
attributes
.
width
=
ScreenUtils
.
getAppScreenWidth
()
attributes
.
height
=
ScreenUtils
.
getAppScreenHeight
()
//* 2 / 5
dialog
.
window
.
attributes
=
attributes
}
fun
showFragmentDialog
(
info
:
CharSequence
)
{
...
...
utilcode/pkg/src/main/res/layout/dialog_keyboard.xml
浏览文件 @
340e8c95
...
...
@@ -3,6 +3,7 @@
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/mediumGray"
android:fillViewport=
"true"
>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录