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
3ce7f7e9
Commit
3ce7f7e9
authored
Dec 28, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Plain Diff
Add minidrawer for large screens
parents
dfe469e1
da8a6599
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
7 deletions
+29
-7
build.sbt
build.sbt
+1
-0
src/main/res/layout/layout_main.xml
src/main/res/layout/layout_main.xml
+1
-1
src/main/res/layout/layout_profiles_item.xml
src/main/res/layout/layout_profiles_item.xml
+1
-1
src/main/res/values/dimen.xml
src/main/res/values/dimen.xml
+1
-0
src/main/scala/com/github/shadowsocks/MainActivity.scala
src/main/scala/com/github/shadowsocks/MainActivity.scala
+24
-4
src/main/scala/com/github/shadowsocks/ToolbarFragment.scala
src/main/scala/com/github/shadowsocks/ToolbarFragment.scala
+1
-1
No files found.
build.sbt
View file @
3ce7f7e9
...
@@ -42,6 +42,7 @@ libraryDependencies ++=
...
@@ -42,6 +42,7 @@ libraryDependencies ++=
"com.google.android.gms"
%
"play-services-analytics"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-analytics"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-gcm"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-gcm"
%
"10.0.1"
::
"com.j256.ormlite"
%
"ormlite-android"
%
"5.0"
::
"com.j256.ormlite"
%
"ormlite-android"
%
"5.0"
::
"com.mikepenz"
%
"crossfader"
%
"1.5.0"
::
"com.mikepenz"
%
"fastadapter"
%
"2.1.5"
::
"com.mikepenz"
%
"fastadapter"
%
"2.1.5"
::
"com.mikepenz"
%
"iconics-core"
%
"2.8.2"
::
"com.mikepenz"
%
"iconics-core"
%
"2.8.2"
::
"com.mikepenz"
%
"materialdrawer"
%
"5.8.1"
::
"com.mikepenz"
%
"materialdrawer"
%
"5.8.1"
::
...
...
src/main/res/layout/layout_main.xml
View file @
3ce7f7e9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:ignore=
"UnknownIdInLayout"
android:clipChildren=
"false"
>
tools:ignore=
"UnknownIdInLayout"
android:clipChildren=
"false"
>
<
android.support.design.widget.CoordinatorLayout
android:id=
"@+id/content
"
<
FrameLayout
android:id=
"@+id/fragment_holder
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_above=
"@+id/stat"
/>
android:layout_above=
"@+id/stat"
/>
...
...
src/main/res/layout/layout_profiles_item.xml
View file @
3ce7f7e9
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_gravity=
"center_horizontal"
android:layout_gravity=
"center_horizontal"
app:bounded_width=
"
480dp
"
app:bounded_width=
"
@dimen/profile_item_max_width
"
android:id=
"@+id/indicator"
>
android:id=
"@+id/indicator"
>
<LinearLayout
android:layout_width=
"match_parent"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
src/main/res/values/dimen.xml
View file @
3ce7f7e9
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<dimen
name=
"profile_item_max_width"
>
480dp
</dimen>
<!-- TODO: Remove when this issue is fixed: https://github.com/JorgeCastilloPrz/FABProgressCircle/issues/19 -->
<!-- TODO: Remove when this issue is fixed: https://github.com/JorgeCastilloPrz/FABProgressCircle/issues/19 -->
<dimen
name=
"fab_margin_top"
>
-44dp
</dimen>
<dimen
name=
"fab_margin_top"
>
-44dp
</dimen>
</resources>
</resources>
src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
3ce7f7e9
...
@@ -45,6 +45,9 @@ import com.github.shadowsocks.ShadowsocksApplication.app
...
@@ -45,6 +45,9 @@ import com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.aidl.IShadowsocksServiceCallback
import
com.github.shadowsocks.aidl.IShadowsocksServiceCallback
import
com.github.shadowsocks.utils.CloseUtils.autoDisconnect
import
com.github.shadowsocks.utils.CloseUtils.autoDisconnect
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.utils._
import
com.mikepenz.crossfader.Crossfader
import
com.mikepenz.crossfader.view.CrossFadeSlidingPaneLayout
import
com.mikepenz.materialdrawer.interfaces.ICrossfader
import
com.mikepenz.materialdrawer.model.PrimaryDrawerItem
import
com.mikepenz.materialdrawer.model.PrimaryDrawerItem
import
com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
import
com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
import
com.mikepenz.materialdrawer.
{
Drawer
,
DrawerBuilder
}
import
com.mikepenz.materialdrawer.
{
Drawer
,
DrawerBuilder
}
...
@@ -67,6 +70,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -67,6 +70,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
private
val
handler
=
new
Handler
()
private
val
handler
=
new
Handler
()
private
var
fab
:
FloatingActionButton
=
_
private
var
fab
:
FloatingActionButton
=
_
private
var
fabProgressCircle
:
FABProgressCircle
=
_
private
var
fabProgressCircle
:
FABProgressCircle
=
_
var
crossfader
:
Crossfader
[
CrossFadeSlidingPaneLayout
]
=
_
var
drawer
:
Drawer
=
_
var
drawer
:
Drawer
=
_
private
var
testCount
:
Int
=
_
private
var
testCount
:
Int
=
_
...
@@ -142,7 +146,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -142,7 +146,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
rxText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxTotal
))
rxText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxTotal
))
txRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
txRate
)
+
"/s"
)
txRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
txRate
)
+
"/s"
)
rxRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxRate
)
+
"/s"
)
rxRateText
.
setText
(
TrafficMonitor
.
formatTraffic
(
rxRate
)
+
"/s"
)
val
child
=
getFragmentManager
.
findFragmentById
(
R
.
id
.
content
).
asInstanceOf
[
ToolbarFragment
]
val
child
=
getFragmentManager
.
findFragmentById
(
R
.
id
.
fragment_holder
).
asInstanceOf
[
ToolbarFragment
]
if
(
state
!=
State
.
STOPPING
&&
child
!=
null
)
child
.
onTrafficUpdated
(
txRate
,
rxRate
,
txTotal
,
rxTotal
)
if
(
state
!=
State
.
STOPPING
&&
child
!=
null
)
child
.
onTrafficUpdated
(
txRate
,
rxRate
,
txTotal
,
rxTotal
)
}
}
...
@@ -173,8 +177,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -173,8 +177,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
layout_main
)
setContentView
(
R
.
layout
.
layout_main
)
draw
er
=
new
DrawerBuilder
()
val
drawerBuild
er
=
new
DrawerBuilder
()
.
withActivity
(
this
)
.
withActivity
(
this
)
.
withTranslucentStatusBar
(
true
)
.
withHeader
(
R
.
layout
.
layout_header
)
.
withHeader
(
R
.
layout
.
layout_header
)
.
addDrawerItems
(
.
addDrawerItems
(
new
PrimaryDrawerItem
()
new
PrimaryDrawerItem
()
...
@@ -204,7 +209,21 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -204,7 +209,21 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
.
withOnDrawerItemClickListener
(
this
)
.
withOnDrawerItemClickListener
(
this
)
.
withActionBarDrawerToggle
(
true
)
.
withActionBarDrawerToggle
(
true
)
.
withSavedInstance
(
savedInstanceState
)
.
withSavedInstance
(
savedInstanceState
)
val
miniDrawerWidth
=
getResources
.
getDimension
(
R
.
dimen
.
material_mini_drawer_item
)
if
(
getResources
.
getDisplayMetrics
.
widthPixels
>=
getResources
.
getDimension
(
R
.
dimen
.
profile_item_max_width
)
+
miniDrawerWidth
)
{
drawer
=
drawerBuilder
.
withGenerateMiniDrawer
(
true
).
buildView
()
crossfader
=
new
Crossfader
[
CrossFadeSlidingPaneLayout
]()
crossfader
.
withContent
(
findViewById
(
android
.
R
.
id
.
content
))
.
withFirst
(
drawer
.
getSlider
,
getResources
.
getDimensionPixelSize
(
R
.
dimen
.
material_drawer_width
))
.
withSecond
(
drawer
.
getMiniDrawer
.
build
(
this
),
miniDrawerWidth
.
toInt
)
.
withSavedInstance
(
savedInstanceState
)
.
build
()
.
build
()
drawer
.
getMiniDrawer
.
withCrossFader
(
new
ICrossfader
{
// a wrapper is needed
def
isCrossfaded
:
Boolean
=
crossfader
.
isCrossFaded
def
crossfade
()
:
Unit
=
crossfader
.
crossFade
()
})
}
else
drawer
=
drawerBuilder
.
build
()
val
header
=
drawer
.
getHeader
val
header
=
drawer
.
getHeader
val
title
=
header
.
findViewById
(
R
.
id
.
drawer_title
).
asInstanceOf
[
TextView
]
val
title
=
header
.
findViewById
(
R
.
id
.
drawer_title
).
asInstanceOf
[
TextView
]
...
@@ -318,7 +337,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -318,7 +337,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
private
def
displayFragment
(
fragment
:
ToolbarFragment
)
{
private
def
displayFragment
(
fragment
:
ToolbarFragment
)
{
currentFragment
=
fragment
currentFragment
=
fragment
getFragmentManager
.
beginTransaction
().
replace
(
R
.
id
.
content
,
fragment
).
commitAllowingStateLoss
()
getFragmentManager
.
beginTransaction
().
replace
(
R
.
id
.
fragment_holder
,
fragment
).
commitAllowingStateLoss
()
drawer
.
closeDrawer
()
drawer
.
closeDrawer
()
}
}
...
@@ -368,6 +387,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -368,6 +387,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
override
def
onSaveInstanceState
(
outState
:
Bundle
)
{
override
def
onSaveInstanceState
(
outState
:
Bundle
)
{
super
.
onSaveInstanceState
(
outState
)
super
.
onSaveInstanceState
(
outState
)
drawer
.
saveInstanceState
(
outState
)
drawer
.
saveInstanceState
(
outState
)
if
(
crossfader
!=
null
)
crossfader
.
saveInstanceState
(
outState
)
}
}
override
def
onDestroy
()
{
override
def
onDestroy
()
{
...
...
src/main/scala/com/github/shadowsocks/ToolbarFragment.scala
View file @
3ce7f7e9
...
@@ -32,7 +32,7 @@ class ToolbarFragment extends Fragment {
...
@@ -32,7 +32,7 @@ class ToolbarFragment extends Fragment {
super
.
onViewCreated
(
view
,
savedInstanceState
)
super
.
onViewCreated
(
view
,
savedInstanceState
)
toolbar
=
view
.
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
toolbar
=
view
.
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
val
activity
=
getActivity
.
asInstanceOf
[
MainActivity
]
val
activity
=
getActivity
.
asInstanceOf
[
MainActivity
]
activity
.
drawer
.
setToolbar
(
activity
,
toolbar
,
true
)
if
(
activity
.
crossfader
==
null
)
activity
.
drawer
.
setToolbar
(
activity
,
toolbar
,
true
)
}
}
def
onTrafficUpdated
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
:
Unit
=
()
def
onTrafficUpdated
(
txRate
:
Long
,
rxRate
:
Long
,
txTotal
:
Long
,
rxTotal
:
Long
)
:
Unit
=
()
...
...
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