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
e5db0f63
Commit
e5db0f63
authored
Dec 23, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a header layout
parent
aa1e052b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
src/main/res/drawable/background_header.png
src/main/res/drawable/background_header.png
+0
-0
src/main/res/layout/layout_header.xml
src/main/res/layout/layout_header.xml
+10
-0
src/main/scala/com/github/shadowsocks/MainActivity.scala
src/main/scala/com/github/shadowsocks/MainActivity.scala
+31
-2
No files found.
src/main/res/drawable/background_header.png
0 → 100644
View file @
e5db0f63
18.3 KB
src/main/res/layout/layout_header.xml
0 → 100644
View file @
e5db0f63
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/drawer_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"shadowsocks"
android:gravity=
"center"
android:background=
"@drawable/background_header"
android:textSize=
"32sp"
android:textColor=
"@android:color/white"
/>
src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
e5db0f63
...
@@ -22,12 +22,13 @@ package com.github.shadowsocks
...
@@ -22,12 +22,13 @@ package com.github.shadowsocks
import
java.lang.System.currentTimeMillis
import
java.lang.System.currentTimeMillis
import
java.net.
{
HttpURLConnection
,
URL
}
import
java.net.
{
HttpURLConnection
,
URL
}
import
java.util.
Locale
import
java.util.
{
Locale
,
Hashtable
}
import
android.app.Activity
import
android.app.Activity
import
android.app.backup.BackupManager
import
android.app.backup.BackupManager
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
import
android.content.SharedPreferences.OnSharedPreferenceChangeListener
import
android.content._
import
android.content._
import
android.graphics.Typeface
import
android.net.
{
Uri
,
VpnService
}
import
android.net.
{
Uri
,
VpnService
}
import
android.nfc.
{
NdefMessage
,
NfcAdapter
}
import
android.nfc.
{
NdefMessage
,
NfcAdapter
}
import
android.os.
{
Build
,
Bundle
,
Handler
}
import
android.os.
{
Build
,
Bundle
,
Handler
}
...
@@ -40,6 +41,7 @@ import android.util.Log
...
@@ -40,6 +41,7 @@ import android.util.Log
import
android.view.View
import
android.view.View
import
android.webkit.
{
WebView
,
WebViewClient
}
import
android.webkit.
{
WebView
,
WebViewClient
}
import
android.widget.
{
TextView
,
Toast
}
import
android.widget.
{
TextView
,
Toast
}
import
com.github.jorgecastilloprz.FABProgressCircle
import
com.github.jorgecastilloprz.FABProgressCircle
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.aidl.IShadowsocksServiceCallback
import
com.github.shadowsocks.aidl.IShadowsocksServiceCallback
...
@@ -51,6 +53,27 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
...
@@ -51,6 +53,27 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
import
com.mikepenz.materialdrawer.model.
{
PrimaryDrawerItem
,
SecondaryDrawerItem
}
import
com.mikepenz.materialdrawer.model.
{
PrimaryDrawerItem
,
SecondaryDrawerItem
}
import
com.mikepenz.materialdrawer.
{
Drawer
,
DrawerBuilder
}
import
com.mikepenz.materialdrawer.
{
Drawer
,
DrawerBuilder
}
object
Typefaces
{
def
get
(
c
:
Context
,
assetPath
:
String
)
:
Typeface
=
{
cache
synchronized
{
if
(!
cache
.
containsKey
(
assetPath
))
{
try
{
cache
.
put
(
assetPath
,
Typeface
.
createFromAsset
(
c
.
getAssets
,
assetPath
))
}
catch
{
case
e
:
Exception
=>
Log
.
e
(
TAG
,
"Could not get typeface '"
+
assetPath
+
"' because "
+
e
.
getMessage
)
app
.
track
(
e
)
return
null
}
}
return
cache
.
get
(
assetPath
)
}
}
private
final
val
TAG
=
"Typefaces"
private
final
val
cache
=
new
Hashtable
[
String
,
Typeface
]
}
object
MainActivity
{
object
MainActivity
{
private
final
val
TAG
=
"ShadowsocksMainActivity"
private
final
val
TAG
=
"ShadowsocksMainActivity"
private
final
val
REQUEST_CONNECT
=
1
private
final
val
REQUEST_CONNECT
=
1
...
@@ -209,7 +232,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -209,7 +232,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
setContentView
(
R
.
layout
.
layout_main
)
setContentView
(
R
.
layout
.
layout_main
)
drawer
=
new
DrawerBuilder
()
drawer
=
new
DrawerBuilder
()
.
withActivity
(
this
)
.
withActivity
(
this
)
// TODO: .withHeader(R.drawable.some
_header)
.
withHeader
(
R
.
layout
.
layout
_header
)
.
addDrawerItems
(
.
addDrawerItems
(
new
PrimaryDrawerItem
()
new
PrimaryDrawerItem
()
.
withIdentifier
(
DRAWER_PROFILES
)
.
withIdentifier
(
DRAWER_PROFILES
)
...
@@ -228,6 +251,12 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
...
@@ -228,6 +251,12 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
.
withOnDrawerItemClickListener
(
this
)
.
withOnDrawerItemClickListener
(
this
)
.
withActionBarDrawerToggle
(
true
)
.
withActionBarDrawerToggle
(
true
)
.
build
()
.
build
()
val
header
=
drawer
.
getHeader
val
title
=
header
.
findViewById
(
R
.
id
.
drawer_title
).
asInstanceOf
[
TextView
]
val
tf
=
Typefaces
.
get
(
this
,
"fonts/Iceland.ttf"
)
if
(
tf
!=
null
)
title
.
setTypeface
(
tf
)
if
(
savedInstanceState
==
null
)
displayFragment
(
profilesFragment
)
if
(
savedInstanceState
==
null
)
displayFragment
(
profilesFragment
)
stat
=
findViewById
(
R
.
id
.
stat
)
stat
=
findViewById
(
R
.
id
.
stat
)
connectionTestText
=
findViewById
(
R
.
id
.
connection_test
).
asInstanceOf
[
TextView
]
connectionTestText
=
findViewById
(
R
.
id
.
connection_test
).
asInstanceOf
[
TextView
]
...
...
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