Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
Widget
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Android Widget
Widget
Commits
b74a2abd
Commit
b74a2abd
authored
Jul 01, 2020
by
王韦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[new]修改 tool背景
parent
530ce747
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
191 additions
and
35 deletions
+191
-35
build.gradle
KeyBoardView/build.gradle
+1
-1
NumberKeyBoard.kt
...src/main/java/com/qmai/android/keyboard/NumberKeyBoard.kt
+2
-4
QmKeyboard.java
...w/src/main/java/com/qmai/android/keyboard/QmKeyboard.java
+3
-10
QmKeyboardView.java
...c/main/java/com/qmai/android/keyboard/QmKeyboardView.java
+1
-2
styles.xml
KeyBoardView/src/main/res/values/styles.xml
+1
-1
numkeyboard.xml
KeyBoardView/src/main/res/xml/numkeyboard.xml
+9
-1
build.gradle
app/build.gradle
+4
-1
DemoDialogFragmemt.kt
.../main/java/com/qimai/android/widget/DemoDialogFragmemt.kt
+86
-6
MainActivity.kt
app/src/main/java/com/qimai/android/widget/MainActivity.kt
+1
-1
activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-0
one_flow.xml
app/src/main/res/layout/one_flow.xml
+8
-0
build.gradle
widgetlib/build.gradle
+1
-0
QmTipOverlayDrawable.kt
...com/qimai/android/widgetlib/popup/QmTipOverlayDrawable.kt
+60
-5
QmToolTip.kt
.../main/java/com/qimai/android/widgetlib/popup/QmToolTip.kt
+13
-3
No files found.
KeyBoardView/build.gradle
View file @
b74a2abd
...
@@ -37,7 +37,7 @@ repositories {
...
@@ -37,7 +37,7 @@ repositories {
}
}
group
'com.qmai.android.widget'
group
'com.qmai.android.widget'
version
'1.1.
2
-SNAPSHOT'
version
'1.1.
4
-SNAPSHOT'
gradlePublish
{
gradlePublish
{
...
...
KeyBoardView/src/main/java/com/qmai/android/keyboard/NumberKeyBoard.kt
View file @
b74a2abd
...
@@ -3,7 +3,6 @@ package com.qmai.android.keyboard;
...
@@ -3,7 +3,6 @@ package com.qmai.android.keyboard;
import
android.content.Context
import
android.content.Context
import
android.util.AttributeSet
import
android.util.AttributeSet
import
android.widget.EditText
import
android.widget.EditText
import
android.widget.TextView
import
com.qmai.android.keyboardview.R
import
com.qmai.android.keyboardview.R
/**
/**
...
@@ -12,11 +11,10 @@ import com.qmai.android.keyboardview.R
...
@@ -12,11 +11,10 @@ import com.qmai.android.keyboardview.R
**/
**/
class
NumberKeyBoard
:
QmKeyboardView
{
class
NumberKeyBoard
:
QmKeyboardView
{
private
lateinit
var
editWidget
:
TextView
private
lateinit
var
editWidget
:
EditText
enum
class
Code
constructor
(
var
code
:
Int
)
{
enum
class
Code
constructor
(
var
code
:
Int
)
{
ZERO
(
0
),
ONE
(
1
),
TWO
(
2
),
THREE
(
3
),
FOUR
(
4
),
FIVE
(
5
),
DELETE
(
10
),
CLEAR
(
11
)
SIX
(
6
),
SEVEN
(
7
),
EIGHT
(
8
),
NINE
(
9
),
DELETE
(
10
),
CLEAR
(
11
)
}
}
...
...
KeyBoardView/src/main/java/com/qmai/android/keyboard/QmKeyboard.java
View file @
b74a2abd
...
@@ -694,9 +694,7 @@ public class QmKeyboard {
...
@@ -694,9 +694,7 @@ public class QmKeyboard {
return
mShifted
;
return
mShifted
;
}
}
/**
* @hide
*/
public
int
[]
getShiftKeyIndices
()
{
public
int
[]
getShiftKeyIndices
()
{
return
mShiftKeyIndices
;
return
mShiftKeyIndices
;
}
}
...
@@ -763,14 +761,12 @@ public class QmKeyboard {
...
@@ -763,14 +761,12 @@ public class QmKeyboard {
private
void
loadKeyboard
(
Context
context
,
XmlResourceParser
parser
)
{
private
void
loadKeyboard
(
Context
context
,
XmlResourceParser
parser
)
{
boolean
inKey
=
false
;
boolean
inKey
=
false
;
boolean
inRow
=
false
;
boolean
inRow
=
false
;
boolean
leftMostKey
=
false
;
int
row
=
0
;
int
x
=
0
;
int
x
=
0
;
int
y
=
0
;
int
y
=
0
;
Key
key
=
null
;
Key
key
=
null
;
Row
currentRow
=
null
;
Row
currentRow
=
null
;
Resources
res
=
context
.
getResources
();
Resources
res
=
context
.
getResources
();
boolean
skipRow
=
false
;
boolean
skipRow
;
try
{
try
{
int
event
;
int
event
;
...
@@ -811,7 +807,7 @@ public class QmKeyboard {
...
@@ -811,7 +807,7 @@ public class QmKeyboard {
}
else
if
(
event
==
XmlResourceParser
.
END_TAG
)
{
}
else
if
(
event
==
XmlResourceParser
.
END_TAG
)
{
if
(
inKey
)
{
if
(
inKey
)
{
inKey
=
false
;
inKey
=
false
;
x
+=
key
.
gap
+
key
.
width
;
x
+=
2
*
key
.
gap
+
key
.
width
;
if
(
x
>
mTotalWidth
)
{
if
(
x
>
mTotalWidth
)
{
mTotalWidth
=
x
;
mTotalWidth
=
x
;
}
}
...
@@ -819,7 +815,6 @@ public class QmKeyboard {
...
@@ -819,7 +815,6 @@ public class QmKeyboard {
inRow
=
false
;
inRow
=
false
;
y
+=
currentRow
.
verticalGap
;
y
+=
currentRow
.
verticalGap
;
y
+=
currentRow
.
defaultHeight
;
y
+=
currentRow
.
defaultHeight
;
row
++;
}
else
{
}
else
{
// TODO: error or extend?
// TODO: error or extend?
}
}
...
@@ -848,8 +843,6 @@ public class QmKeyboard {
...
@@ -848,8 +843,6 @@ public class QmKeyboard {
TypedArray
a
=
res
.
obtainAttributes
(
attributeSet
,
TypedArray
a
=
res
.
obtainAttributes
(
attributeSet
,
R
.
styleable
.
CKeyBoard
);
R
.
styleable
.
CKeyBoard
);
Log
.
v
(
"keyBoard"
,
"index Count == "
+
a
.
getIndexCount
());
mDefaultWidth
=
getDimensionOrFraction
(
a
,
mDefaultWidth
=
getDimensionOrFraction
(
a
,
R
.
styleable
.
CKeyBoard_cKeyWidth
,
R
.
styleable
.
CKeyBoard_cKeyWidth
,
...
...
KeyBoardView/src/main/java/com/qmai/android/keyboard/QmKeyboardView.java
View file @
b74a2abd
...
@@ -680,8 +680,7 @@ public class QmKeyboardView extends View implements View.OnClickListener {
...
@@ -680,8 +680,7 @@ public class QmKeyboardView extends View implements View.OnClickListener {
}
}
canvas
.
drawColor
(
0x00000000
,
PorterDuff
.
Mode
.
CLEAR
);
canvas
.
drawColor
(
0x00000000
,
PorterDuff
.
Mode
.
CLEAR
);
final
int
keyCount
=
keys
.
length
;
final
int
keyCount
=
keys
.
length
;
for
(
int
i
=
0
;
i
<
keyCount
;
i
++)
{
for
(
final
Key
key
:
keys
)
{
final
Key
key
=
keys
[
i
];
if
(
drawSingleKey
&&
invalidKey
!=
key
)
{
if
(
drawSingleKey
&&
invalidKey
!=
key
)
{
continue
;
continue
;
}
}
...
...
KeyBoardView/src/main/res/values/styles.xml
View file @
b74a2abd
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<item
name=
"keyPreviewHeight"
>
80dp
</item>
<item
name=
"keyPreviewHeight"
>
80dp
</item>
<item
name=
"labelTextSize"
>
15sp
</item>
<item
name=
"labelTextSize"
>
15sp
</item>
<item
name=
"popupLayout"
>
@layout/keyboard_popup_keyboard
</item>
<item
name=
"popupLayout"
>
@layout/keyboard_popup_keyboard
</item>
<item
name=
"verticalCorrection"
>
-1
0dip
</item>
<item
name=
"verticalCorrection"
>
0dip
</item>
<item
name=
"shadowColor"
>
#333333
</item>
<item
name=
"shadowColor"
>
#333333
</item>
<item
name=
"shadowRadius"
>
0
</item>
<item
name=
"shadowRadius"
>
0
</item>
</style>
</style>
...
...
KeyBoardView/src/main/res/xml/numkeyboard.xml
View file @
b74a2abd
...
@@ -2,45 +2,52 @@
...
@@ -2,45 +2,52 @@
<KeyBoard
<KeyBoard
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
app:cKeyHeight =
"60dp"
app:cKeyHeight =
"60dp"
app:CHorizontalGap=
"
48
dp"
app:CHorizontalGap=
"
24
dp"
app:CVerticalGap =
"13dp"
app:CVerticalGap =
"13dp"
app:cKeyWidth=
"60dp"
>
app:cKeyWidth=
"60dp"
>
<Row>
<Row>
<Key
<Key
app:codes=
"1"
app:codes=
"1"
app:keyEdgeFlags=
"left"
app:keyLabel=
"1"
/>
app:keyLabel=
"1"
/>
<Key
<Key
app:codes=
"2"
app:codes=
"2"
app:keyLabel=
"2"
/>
app:keyLabel=
"2"
/>
<Key
<Key
app:codes=
"3"
app:codes=
"3"
app:keyEdgeFlags=
"right"
app:keyLabel=
"3"
/>
app:keyLabel=
"3"
/>
</Row>
</Row>
<Row>
<Row>
<Key
<Key
app:codes=
"4"
app:codes=
"4"
app:keyEdgeFlags=
"left"
app:keyLabel=
"4"
/>
app:keyLabel=
"4"
/>
<Key
<Key
app:codes=
"5"
app:codes=
"5"
app:keyLabel=
"5"
/>
app:keyLabel=
"5"
/>
<Key
<Key
app:codes=
"6"
app:codes=
"6"
app:keyEdgeFlags=
"right"
app:keyLabel=
"6"
/>
app:keyLabel=
"6"
/>
</Row>
</Row>
<Row>
<Row>
<Key
<Key
app:codes=
"7"
app:codes=
"7"
app:keyEdgeFlags=
"left"
app:keyLabel=
"7"
/>
app:keyLabel=
"7"
/>
<Key
<Key
app:codes=
"8"
app:codes=
"8"
app:keyLabel=
"8"
/>
app:keyLabel=
"8"
/>
<Key
<Key
app:codes=
"9"
app:codes=
"9"
app:keyEdgeFlags=
"right"
app:keyLabel=
"9"
/>
app:keyLabel=
"9"
/>
</Row>
</Row>
<Row>
<Row>
<Key
<Key
app:codes=
"11"
app:codes=
"11"
app:keyEdgeFlags=
"left"
app:keyLabel=
"清空"
/>
app:keyLabel=
"清空"
/>
<Key
<Key
app:codes=
"0"
app:codes=
"0"
...
@@ -48,6 +55,7 @@
...
@@ -48,6 +55,7 @@
<Key
<Key
app:codes=
"10"
app:codes=
"10"
app:isRepeatable=
"true"
app:isRepeatable=
"true"
app:keyEdgeFlags=
"right"
app:keyIcon =
"@drawable/keyboard_delete"
app:keyIcon =
"@drawable/keyboard_delete"
/>
/>
</Row>
</Row>
...
...
app/build.gradle
View file @
b74a2abd
...
@@ -24,6 +24,7 @@ android {
...
@@ -24,6 +24,7 @@ android {
}
}
dependencies
{
dependencies
{
implementation
'com.hyman:flowlayout-lib:1.1.2'
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation
'androidx.appcompat:appcompat:1.0.2'
implementation
'androidx.appcompat:appcompat:1.0.2'
...
@@ -38,7 +39,9 @@ dependencies {
...
@@ -38,7 +39,9 @@ dependencies {
implementation
project
(
path:
':tools'
)
implementation
project
(
path:
':tools'
)
implementation
'androidx.recyclerview:recyclerview:1.0.0'
implementation
'androidx.recyclerview:recyclerview:1.0.0'
implementation
'com.github.sebdomdev:android-drawer-sheet:1.0'
implementation
'com.github.sebdomdev:android-drawer-sheet:1.0'
implementation
'com.lxj:xpopup:2.0.6-rc1'
implementation
'com.google.android.material:material:1.3.0-alpha01'
implementation
'androidx.recyclerview:recyclerview:1.1.0'
// todo test
// todo test
// implementation 'com.android.tools.build:gradle:3.1.1'
// implementation 'com.android.tools.build:gradle:3.1.1'
...
...
app/src/main/java/com/qimai/android/widget/DemoDialogFragmemt.kt
View file @
b74a2abd
...
@@ -3,35 +3,115 @@ package com.qimai.android.widget
...
@@ -3,35 +3,115 @@ package com.qimai.android.widget
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.TextView
import
com.lxj.xpopup.XPopup
import
com.lxj.xpopup.core.AttachPopupView
import
com.qimai.android.tools.dpTopx
import
com.qimai.android.tools.dpTopx
import
com.qimai.android.tools.getScreenWidth
import
com.qimai.android.tools.getScreenWidth
import
com.qimai.android.widgetlib.popup.AbsQMBaseDialogFragment
import
com.qimai.android.widgetlib.popup.AbsQMBaseDialogFragment
import
com.zhy.view.flowlayout.FlowLayout
import
com.zhy.view.flowlayout.TagAdapter
import
com.zhy.view.flowlayout.TagFlowLayout
/**
/**
* created by wangwei ON 2019-11-06 email:wangwei_5521@163.com
* created by wangwei ON 2019-11-06 email:wangwei_5521@163.com
* @version 1.1.1
* @version 1.1.1
* @Description
* @Description
**/
**/
class
DemoDialogFragmemt
:
class
DemoDialogFragmemt
:
AbsQMBaseDialogFragment
()
{
AbsQMBaseDialogFragment
()
{
override
fun
prepareView
(
override
fun
prepareView
(
inflater
:
LayoutInflater
?,
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?
container
:
ViewGroup
?
):
View
{
):
View
{
val
view
=
inflater
?.
inflate
(
R
.
layout
.
qm_alert_content
,
container
,
false
)
val
view
=
inflater
?.
inflate
(
R
.
layout
.
one_flow
,
container
,
false
)
as
TagFlowLayout
val
oneAdaptr
=
object
:
TagAdapter
<
String
>(
listOf
(
"老乡鸡"
,
"香肠"
,
"发Joe"
,
"发Joe房间诶哦"
))
{
override
fun
getView
(
parent
:
FlowLayout
?,
position
:
Int
,
t
:
String
?):
View
{
return
view
!!
val
textView
=
TextView
(
context
)
}
textView
.
text
=
t
!!
return
textView
}
override
fun
onSelected
(
position
:
Int
,
view
:
View
?)
{
super
.
onSelected
(
position
,
view
)
XPopup
.
Builder
(
context
)
.
atView
(
view
)
.
hasShadowBg
(
false
)
.
isCenterHorizontal
(
true
)
.
asCustom
(
object
:
AttachPopupView
(
context
!!
)
{
override
fun
getImplLayoutId
():
Int
{
return
R
.
layout
.
one_flow
}
override
fun
initPopupContent
()
{
super
.
initPopupContent
()
val
flow
=
attachPopupContainer
.
findViewById
<
TagFlowLayout
>(
R
.
id
.
flowLayout
)
val
subAapter
=
object
:
TagAdapter
<
String
>(
listOf
(
"老乡鸡"
,
"香肠"
,
"发Joe"
,
"发Joe房间诶哦"
))
{
override
fun
getView
(
parent
:
FlowLayout
?,
position
:
Int
,
t
:
String
?
):
View
{
val
textView
=
TextView
(
context
)
textView
.
text
=
t
!!
return
textView
}
override
fun
onSelected
(
position
:
Int
,
view
:
View
?)
{
super
.
onSelected
(
position
,
view
)
}
}
flow
.
adapter
=
subAapter
}
})
.
show
();
//
//
}
}
view
.
adapter
=
oneAdaptr
// val sub = view!!.findViewById<TextView>(R.id.alert_confirm)
// sub.setOnClickListener{
// XPopup.Builder(context)
// .atView(sub)
// .isCenterHorizontal(true)
// .hasShadowBg(false)
// .asCustom(object : AttachPopupView(context!!){
// override fun getImplLayoutId(): Int {
// return R.layout.tip
// }
// })
// .show();
//
//
// }
return
view
!!
}
override
fun
config
():
DialogFramgentConfig
{
override
fun
config
():
DialogFramgentConfig
{
return
DialogFramgentConfig
().
apply
{
return
DialogFramgentConfig
().
apply
{
context
?.
let
{
context
?.
let
{
c
->
c
->
mWindowWidth
=
getScreenWidth
(
c
)
-
c
.
dpTopx
(
30.0f
)
mWindowWidth
=
getScreenWidth
(
c
)
-
c
.
dpTopx
(
30.0f
)
}
}
...
...
app/src/main/java/com/qimai/android/widget/MainActivity.kt
View file @
b74a2abd
...
@@ -33,7 +33,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -33,7 +33,7 @@ class MainActivity : AppCompatActivity() {
}
}
keyboard
.
bindEditText
(
inputText
)
keyboard
.
bindEditText
(
inputText
)
findViewById
<
TextView
>(
R
.
id
.
drawer
).
setOnClickListener
{
findViewById
<
TextView
>(
R
.
id
.
drawer
).
setOnClickListener
{
startActivity
(
Intent
(
MainActivity
@
this
,
Drawer
Activity
::
class
.
java
))
startActivity
(
Intent
(
MainActivity
@
this
,
CommomPop
Activity
::
class
.
java
))
}
}
findViewById
<
Button
>(
R
.
id
.
tip
).
setOnClickListener
{
findViewById
<
Button
>(
R
.
id
.
tip
).
setOnClickListener
{
...
...
app/src/main/res/layout/activity_main.xml
View file @
b74a2abd
...
@@ -70,6 +70,7 @@
...
@@ -70,6 +70,7 @@
<com.qmai.android.keyboard.NumberKeyBoard
<com.qmai.android.keyboard.NumberKeyBoard
android:id=
"@+id/keyboard"
android:id=
"@+id/keyboard"
android:background=
"#444444"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</LinearLayout>
...
...
app/src/main/res/layout/one_flow.xml
0 → 100644
View file @
b74a2abd
<?xml version="1.0" encoding="utf-8"?>
<com.zhy.view.flowlayout.TagFlowLayout
android:id=
"@+id/flowLayout"
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
</com.zhy.view.flowlayout.TagFlowLayout>
\ No newline at end of file
widgetlib/build.gradle
View file @
b74a2abd
...
@@ -40,6 +40,7 @@ dependencies {
...
@@ -40,6 +40,7 @@ dependencies {
implementation
'androidx.recyclerview:recyclerview:1.0.0'
implementation
'androidx.recyclerview:recyclerview:1.0.0'
implementation
'com.github.ybq:Android-SpinKit:1.4.0'
implementation
'com.github.ybq:Android-SpinKit:1.4.0'
// implementation 'com.qmai.android.tools:tools:1.1.1-SNAPSHOT'
// implementation 'com.qmai.android.tools:tools:1.1.1-SNAPSHOT'
}
}
repositories
{
repositories
{
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/QmTipOverlayDrawable.kt
View file @
b74a2abd
package
com.qimai.android.widgetlib.popup
package
com.qimai.android.widgetlib.popup
import
android.content.Context
import
android.graphics.*
import
android.graphics.*
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.os.Build
import
android.os.Build
import
android.view.Gravity
import
android.view.Gravity
import
androidx.annotation.IntDef
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
com.qimai.android.tools.dpTopx
import
com.qimai.android.tools.dpTopx
import
com.qimai.android.widgetlib.R
import
com.qimai.android.widgetlib.R
...
@@ -14,7 +16,7 @@ import com.qimai.android.widgetlib.R
...
@@ -14,7 +16,7 @@ import com.qimai.android.widgetlib.R
* @Description
* @Description
**/
**/
@Suppress
(
"unused"
)
@Suppress
(
"unused"
)
internal
class
QmTipOverlayDrawable
(
builder
:
QmToolTip
.
Builder
)
:
Drawable
()
{
class
QmTipOverlayDrawable
(
builder
:
Builder
)
:
Drawable
()
{
private
val
outlineRect
=
Rect
()
private
val
outlineRect
=
Rect
()
private
val
radius
:
Float
private
val
radius
:
Float
...
@@ -32,14 +34,67 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
...
@@ -32,14 +34,67 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
private
var
showArrow
=
true
private
var
showArrow
=
true
class
Builder
{
@IntDef
(
Gravity
.
TOP
,
Gravity
.
BOTTOM
,
Gravity
.
NO_GRAVITY
)
@Retention
(
AnnotationRetention
.
SOURCE
)
annotation
class
GravityRange
var
defaultOverlayStyle
:
Int
=
R
.
style
.
QmToolTipOverlayDefault
@GravityRange
internal
var
gravity
=
Gravity
.
NO_GRAVITY
var
showArrow
=
true
var
arrowWeight
=
0.5f
var
offset
=
0
var
conetxt
:
Context
?
=
null
fun
withContext
(
ctx
:
Context
)
=
apply
{
this
.
conetxt
=
ctx
}
fun
withArrowWeight
(
arrowWeight
:
Float
)
=
apply
{
this
.
arrowWeight
=
arrowWeight
}
fun
withGravity
(
@GravityRange
gravity
:
Int
)
=
apply
{
this
.
gravity
=
gravity
}
fun
withArrowShow
(
showArrow
:
Boolean
)
=
apply
{
this
.
showArrow
=
showArrow
}
fun
withDefaultOverlayStyle
(
defaultOverlayStyle
:
Int
)
=
apply
{
this
.
defaultOverlayStyle
=
defaultOverlayStyle
}
fun
withOffset
(
offset
:
Int
)
=
apply
{
this
.
offset
=
offset
}
}
/**
/**
* 0-1
* 0-1
*/
*/
private
var
arrowWeight
=
0.5f
private
var
arrowWeight
=
0.5f
init
{
init
{
val
context
=
builder
.
con
tentView
!!
.
conte
xt
val
context
=
builder
.
con
et
xt
val
theme
=
context
.
theme
.
obtainStyledAttributes
(
val
theme
=
context
!!
.
theme
.
obtainStyledAttributes
(
null
,
null
,
R
.
styleable
.
QmToolTipOverlay
,
R
.
styleable
.
QmToolTipOverlay
,
0
,
0
,
...
@@ -48,7 +103,7 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
...
@@ -48,7 +103,7 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
this
.
radius
=
this
.
radius
=
theme
.
getDimensionPixelSize
(
theme
.
getDimensionPixelSize
(
R
.
styleable
.
QmToolTipOverlay_overlay_radius
,
R
.
styleable
.
QmToolTipOverlay_overlay_radius
,
context
.
dpTopx
(
5f
)
context
!!
.
dpTopx
(
5f
)
).
toFloat
()
).
toFloat
()
this
.
bgColor
=
theme
.
getColor
(
this
.
bgColor
=
theme
.
getColor
(
R
.
styleable
.
QmToolTipOverlay_overlay_bgColor
,
R
.
styleable
.
QmToolTipOverlay_overlay_bgColor
,
...
@@ -68,7 +123,7 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
...
@@ -68,7 +123,7 @@ internal class QmTipOverlayDrawable(builder: QmToolTip.Builder) : Drawable() {
this
.
showArrow
=
builder
.
showArrow
this
.
showArrow
=
builder
.
showArrow
this
.
rectF
=
RectF
()
this
.
rectF
=
RectF
()
bgPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
bgPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
bgPaint
.
color
=
bgColor
bgPaint
.
color
=
bgColor
bgPaint
.
style
=
Paint
.
Style
.
FILL
bgPaint
.
style
=
Paint
.
Style
.
FILL
if
(
borderColor
!=
0
)
{
if
(
borderColor
!=
0
)
{
borderPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
borderPaint
=
Paint
(
Paint
.
ANTI_ALIAS_FLAG
)
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/QmToolTip.kt
View file @
b74a2abd
...
@@ -29,6 +29,7 @@ class QmToolTip private constructor(
...
@@ -29,6 +29,7 @@ class QmToolTip private constructor(
private
val
mWindow
=
PopupWindow
()
private
val
mWindow
=
PopupWindow
()
private
val
attachedViewLocation
=
IntArray
(
2
)
private
val
attachedViewLocation
=
IntArray
(
2
)
/**
/**
* 箭头离 anchor的距离
* 箭头离 anchor的距离
*/
*/
...
@@ -47,7 +48,7 @@ class QmToolTip private constructor(
...
@@ -47,7 +48,7 @@ class QmToolTip private constructor(
private
var
containerMeasureHeight
=
0
private
var
containerMeasureHeight
=
0
private
var
arrowWeight
=
0f
private
var
arrowWeight
=
0f
private
var
offset
=
0
private
var
offset
=
0
private
constructor
(
builder
:
Builder
)
:
this
(
private
constructor
(
builder
:
Builder
)
:
this
(
builder
.
attachedView
,
builder
.
attachedView
,
...
@@ -141,7 +142,16 @@ class QmToolTip private constructor(
...
@@ -141,7 +142,16 @@ class QmToolTip private constructor(
}
}
}
}
container
.
background
=
QmTipOverlayDrawable
(
builder
=
builder
)
container
.
background
=
QmTipOverlayDrawable
(
QmTipOverlayDrawable
.
Builder
()
.
withContext
(
builder
.
contentView
!!
.
context
)
.
withGravity
(
builder
.
gravity
)
.
withOffset
(
builder
.
offset
)
.
withArrowShow
(
builder
.
showArrow
)
.
withDefaultOverlayStyle
(
builder
.
defaultOverlayStyle
)
.
withArrowWeight
(
builder
.
arrowWeight
)
)
mWindow
.
contentView
=
container
mWindow
.
contentView
=
container
mWindow
.
setBackgroundDrawable
(
ColorDrawable
(
Color
.
TRANSPARENT
))
mWindow
.
setBackgroundDrawable
(
ColorDrawable
(
Color
.
TRANSPARENT
))
...
@@ -220,7 +230,7 @@ class QmToolTip private constructor(
...
@@ -220,7 +230,7 @@ class QmToolTip private constructor(
point
=
calculateBottomOffset
(
anchorView
)
point
=
calculateBottomOffset
(
anchorView
)
}
}
}
}
return
Point
(
point
.
x
,
point
.
y
+
offset
)
return
Point
(
point
.
x
,
point
.
y
+
offset
)
}
}
private
fun
calculateTopOffset
(
anchorView
:
View
):
Point
{
private
fun
calculateTopOffset
(
anchorView
:
View
):
Point
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment