Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
580ce148
Commit
580ce148
authored
Jan 15, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine animations
parent
d4213e8e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
74 deletions
+14
-74
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
+0
-6
mobile/src/main/java/com/github/shadowsocks/widget/BottomMarginBehavior.kt
...ava/com/github/shadowsocks/widget/BottomMarginBehavior.kt
+0
-40
mobile/src/main/java/com/github/shadowsocks/widget/ShrinkUpwardBehavior.kt
...ava/com/github/shadowsocks/widget/ShrinkUpwardBehavior.kt
+13
-27
mobile/src/main/res/layout/layout_main.xml
mobile/src/main/res/layout/layout_main.xml
+1
-1
No files found.
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
View file @
580ce148
...
...
@@ -9,7 +9,6 @@ import android.support.annotation.AttrRes
import
android.support.v4.app.Fragment
import
android.support.v4.app.FragmentManager
import
android.support.v7.util.SortedList
import
android.view.accessibility.AccessibilityManager
import
android.util.TypedValue
import
com.github.shadowsocks.App.Companion.app
import
com.github.shadowsocks.JniHelper
...
...
@@ -22,11 +21,6 @@ private val fieldChildFragmentManager by lazy {
field
}
fun
isAccessibilityEnabled
(
context
:
Context
):
Boolean
{
val
am
=
context
.
getSystemService
(
Context
.
ACCESSIBILITY_SERVICE
)
as
AccessibilityManager
return
am
.
isEnabled
()
}
fun
String
.
isNumericAddress
()
=
JniHelper
.
parseNumericAddress
(
this
)
!=
null
fun
String
.
parseNumericAddress
():
InetAddress
?
{
val
addr
=
JniHelper
.
parseNumericAddress
(
this
)
...
...
mobile/src/main/java/com/github/shadowsocks/widget/BottomMarginBehavior.kt
deleted
100644 → 0
View file @
d4213e8e
/*******************************************************************************
* *
* Copyright (C) 2017 by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 2017 by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
package
com.github.shadowsocks.widget
import
android.content.Context
import
android.support.design.widget.CoordinatorLayout
import
android.util.AttributeSet
import
android.view.View
import
com.github.shadowsocks.R
class
BottomMarginBehavior
:
CoordinatorLayout
.
Behavior
<
View
>
{
constructor
()
:
super
()
constructor
(
context
:
Context
,
attrs
:
AttributeSet
)
:
super
(
context
,
attrs
)
override
fun
layoutDependsOn
(
parent
:
CoordinatorLayout
,
child
:
View
,
dependency
:
View
):
Boolean
=
dependency
.
id
==
R
.
id
.
stat
// sorry I'm too lazy to write an attribute
override
fun
onDependentViewChanged
(
parent
:
CoordinatorLayout
,
child
:
View
,
dependency
:
View
):
Boolean
{
(
child
.
layoutParams
as
CoordinatorLayout
.
LayoutParams
).
bottomMargin
=
(
parent
.
height
-
dependency
.
y
).
toInt
()
return
true
}
}
mobile/src/main/java/com/github/shadowsocks/widget/
Move
UpwardBehavior.kt
→
mobile/src/main/java/com/github/shadowsocks/widget/
Shrink
UpwardBehavior.kt
View file @
580ce148
...
...
@@ -20,34 +20,27 @@
package
com.github.shadowsocks.widget
import
android.animation.Animator
import
android.animation.AnimatorListenerAdapter
import
android.animation.ValueAnimator
import
android.content.Context
import
android.os.Build
import
android.support.design.widget.CoordinatorLayout
import
android.support.design.widget.SnackbarAnimation
import
android.support.design.widget.Snackbar
import
android.support.
v4.view.ViewCompat
import
android.support.
design.widget.SnackbarAnimation
import
android.util.AttributeSet
import
android.view.View
import
com.github.shadowsocks.utils.isAccessibilityEnabled
import
android.view.accessibility.AccessibilityManager
/**
* Full credits go to: https://stackoverflow.com/a/35904421/2245107
*/
class
MoveUpwardBehavior
:
CoordinatorLayout
.
Behavior
<
View
>
{
constructor
()
:
super
()
constructor
(
context
:
Context
,
attrs
:
AttributeSet
)
:
super
(
context
,
attrs
)
class
ShrinkUpwardBehavior
(
context
:
Context
,
attrs
:
AttributeSet
)
:
CoordinatorLayout
.
Behavior
<
View
>(
context
,
attrs
)
{
private
val
accessibility
=
context
.
getSystemService
(
Context
.
ACCESSIBILITY_SERVICE
)
as
AccessibilityManager
override
fun
layoutDependsOn
(
parent
:
CoordinatorLayout
,
child
:
View
,
dependency
:
View
):
Boolean
=
dependency
is
Snackbar
.
SnackbarLayout
override
fun
onDependentViewChanged
(
parent
:
CoordinatorLayout
,
child
:
View
,
dependency
:
View
):
Boolean
{
val
params
=
child
.
layoutParams
params
.
height
=
parent
.
height
-
dependency
.
height
child
.
layoutParams
=
params
child
.
layoutParams
.
height
=
dependency
.
y
.
toInt
()
child
.
requestLayout
()
return
true
}
...
...
@@ -55,25 +48,18 @@ class MoveUpwardBehavior : CoordinatorLayout.Behavior<View> {
* Based on BaseTransientBottomBar.animateViewOut (support lib 27.0.2).
*/
override
fun
onDependentViewRemoved
(
parent
:
CoordinatorLayout
,
child
:
View
,
dependency
:
View
)
{
if
(
!
isAccessibilityEnabled
(
parent
.
getContext
()))
{
if
(
accessibility
.
isEnabled
)
child
.
layoutParams
.
height
=
parent
.
height
else
{
val
animator
=
ValueAnimator
()
val
start
=
child
.
height
animator
.
setIntValues
(
start
,
parent
.
height
)
animator
.
interpolator
=
SnackbarAnimation
.
FAST_OUT_SLOW_IN_INTERPOLATOR
animator
.
duration
=
SnackbarAnimation
.
ANIMATION_DURATION
animator
.
addUpdateListener
(
object
:
ValueAnimator
.
AnimatorUpdateListener
{
override
fun
onAnimationUpdate
(
animator
:
ValueAnimator
)
{
val
currentValue
=
animator
.
animatedValue
as
Int
val
params
=
child
.
layoutParams
params
.
height
=
currentValue
child
.
layoutParams
=
params
@Suppress
(
"NAME_SHADOWING"
)
animator
.
addUpdateListener
{
animator
->
child
.
layoutParams
.
height
=
animator
.
animatedValue
as
Int
child
.
requestLayout
()
}
})
animator
.
start
()
}
else
{
val
params
=
child
.
layoutParams
params
.
height
=
parent
.
height
child
.
layoutParams
=
params
}
}
}
mobile/src/main/res/layout/layout_main.xml
View file @
580ce148
...
...
@@ -12,7 +12,7 @@
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layout_behavior=
"com.github.shadowsocks.widget.
Move
UpwardBehavior"
>
app:layout_behavior=
"com.github.shadowsocks.widget.
Shrink
UpwardBehavior"
>
<FrameLayout
android:id=
"@+id/fragment_holder"
...
...
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