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
77d2def9
Commit
77d2def9
authored
Dec 30, 2019
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow importing profiles.json from URL
parent
3f25eace
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
475 additions
and
0 deletions
+475
-0
core/src/main/java/com/github/shadowsocks/subscription/Subscription.kt
.../java/com/github/shadowsocks/subscription/Subscription.kt
+87
-0
core/src/main/res/values/strings.xml
core/src/main/res/values/strings.xml
+6
-0
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
+2
-0
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+1
-0
mobile/src/main/java/com/github/shadowsocks/subscription/SubscriptionFragment.kt
...m/github/shadowsocks/subscription/SubscriptionFragment.kt
+342
-0
mobile/src/main/res/layout/dialog_subscription.xml
mobile/src/main/res/layout/dialog_subscription.xml
+20
-0
mobile/src/main/res/menu/navigation_main.xml
mobile/src/main/res/menu/navigation_main.xml
+3
-0
mobile/src/main/res/menu/subscription_menu.xml
mobile/src/main/res/menu/subscription_menu.xml
+14
-0
No files found.
core/src/main/java/com/github/shadowsocks/subscription/Subscription.kt
0 → 100644
View file @
77d2def9
/*******************************************************************************
* *
* 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.subscription
import
android.content.Context
import
android.util.Log
import
androidx.recyclerview.widget.SortedList
import
com.crashlytics.android.Crashlytics
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.net.Subnet
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.asIterable
import
java.io.File
import
java.io.IOException
import
java.io.Reader
import
java.net.URL
import
java.net.URLConnection
class
Subscription
{
companion
object
{
const
val
SUBSCRIPTION
=
"subscription"
var
instance
:
Subscription
get
()
{
val
sub
=
Subscription
()
val
str
=
DataStore
.
publicStore
.
getString
(
SUBSCRIPTION
)
if
(
str
!=
null
)
sub
.
fromReader
(
str
.
reader
())
return
sub
}
set
(
value
)
=
DataStore
.
publicStore
.
putString
(
SUBSCRIPTION
,
value
.
toString
())
}
private
abstract
class
BaseSorter
<
T
>
:
SortedList
.
Callback
<
T
>()
{
override
fun
onInserted
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
areContentsTheSame
(
oldItem
:
T
?,
newItem
:
T
?):
Boolean
=
oldItem
==
newItem
override
fun
onMoved
(
fromPosition
:
Int
,
toPosition
:
Int
)
{
}
override
fun
onChanged
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
onRemoved
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
areItemsTheSame
(
item1
:
T
?,
item2
:
T
?):
Boolean
=
item1
==
item2
override
fun
compare
(
o1
:
T
?,
o2
:
T
?):
Int
=
if
(
o1
==
null
)
if
(
o2
==
null
)
0
else
1
else
if
(
o2
==
null
)
-
1
else
compareNonNull
(
o1
,
o2
)
abstract
fun
compareNonNull
(
o1
:
T
,
o2
:
T
):
Int
}
private
open
class
DefaultSorter
<
T
:
Comparable
<
T
>>
:
BaseSorter
<
T
>()
{
override
fun
compareNonNull
(
o1
:
T
,
o2
:
T
):
Int
=
o1
.
compareTo
(
o2
)
}
private
object
URLSorter
:
BaseSorter
<
URL
>()
{
private
val
ordering
=
compareBy
<
URL
>({
it
.
host
},
{
it
.
port
},
{
it
.
file
},
{
it
.
protocol
})
override
fun
compareNonNull
(
o1
:
URL
,
o2
:
URL
):
Int
=
ordering
.
compare
(
o1
,
o2
)
}
val
urls
=
SortedList
(
URL
::
class
.
java
,
URLSorter
)
fun
fromReader
(
reader
:
Reader
):
Subscription
{
urls
.
clear
()
reader
.
useLines
{
for
(
line
in
it
)
{
urls
.
add
(
URL
(
line
))
}
}
return
this
}
override
fun
toString
():
String
{
val
result
=
StringBuilder
()
result
.
append
(
urls
.
asIterable
().
joinToString
(
"\n"
))
return
result
.
toString
()
}
}
core/src/main/res/values/strings.xml
View file @
77d2def9
...
@@ -135,6 +135,12 @@
...
@@ -135,6 +135,12 @@
<string
name=
"vpn_connected"
>
Connected, tap to check connection
</string>
<string
name=
"vpn_connected"
>
Connected, tap to check connection
</string>
<string
name=
"not_connected"
>
Not connected
</string>
<string
name=
"not_connected"
>
Not connected
</string>
<!-- subscriptions -->
<string
name=
"subscriptions"
>
Subscriptions
</string>
<string
name=
"add_subscription"
>
Add a subscription
</string>
<string
name=
"edit_subscription"
>
Edit subscription
</string>
<string
name=
"update_subscription"
>
Refresh servers from subscription
</string>
<!-- acl -->
<!-- acl -->
<string
name=
"custom_rules"
>
Custom rules
</string>
<string
name=
"custom_rules"
>
Custom rules
</string>
<string
name=
"action_add_rule"
>
Add rule(s)…
</string>
<string
name=
"action_add_rule"
>
Add rule(s)…
</string>
...
...
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
View file @
77d2def9
...
@@ -48,6 +48,7 @@ import com.github.shadowsocks.aidl.TrafficStats
...
@@ -48,6 +48,7 @@ import com.github.shadowsocks.aidl.TrafficStats
import
com.github.shadowsocks.bg.BaseService
import
com.github.shadowsocks.bg.BaseService
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.preference.OnPreferenceDataStoreChangeListener
import
com.github.shadowsocks.preference.OnPreferenceDataStoreChangeListener
import
com.github.shadowsocks.subscription.SubscriptionFragment
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.SingleInstanceActivity
import
com.github.shadowsocks.utils.SingleInstanceActivity
import
com.github.shadowsocks.widget.ListHolderListener
import
com.github.shadowsocks.widget.ListHolderListener
...
@@ -215,6 +216,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
...
@@ -215,6 +216,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
return
true
return
true
}
}
R
.
id
.
customRules
->
displayFragment
(
CustomRulesFragment
())
R
.
id
.
customRules
->
displayFragment
(
CustomRulesFragment
())
R
.
id
.
subscriptions
->
displayFragment
(
SubscriptionFragment
())
else
->
return
false
else
->
return
false
}
}
item
.
isChecked
=
true
item
.
isChecked
=
true
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
77d2def9
...
@@ -257,6 +257,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
...
@@ -257,6 +257,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
}.
build
().
loadAd
(
AdRequest
.
Builder
().
apply
{
}.
build
().
loadAd
(
AdRequest
.
Builder
().
apply
{
addTestDevice
(
"B08FC1764A7B250E91EA9D0D5EBEB208"
)
addTestDevice
(
"B08FC1764A7B250E91EA9D0D5EBEB208"
)
addTestDevice
(
"7509D18EB8AF82F915874FEF53877A64"
)
addTestDevice
(
"7509D18EB8AF82F915874FEF53877A64"
)
addTestDevice
(
"F58907F28184A828DD0DB6F8E38189C6"
)
}.
build
())
}.
build
())
}
else
if
(
nativeAd
!=
null
)
populateUnifiedNativeAdView
(
nativeAd
!!
,
nativeAdView
!!
)
}
else
if
(
nativeAd
!=
null
)
populateUnifiedNativeAdView
(
nativeAd
!!
,
nativeAdView
!!
)
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/subscription/SubscriptionFragment.kt
0 → 100644
View file @
77d2def9
This diff is collapsed.
Click to expand it.
mobile/src/main/res/layout/dialog_subscription.xml
0 → 100644
View file @
77d2def9
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"16dp"
>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/content_layout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:errorEnabled=
"true"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/content"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingTop=
"12dp"
android:inputType=
"textNoSuggestions|textMultiLine"
/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
mobile/src/main/res/menu/navigation_main.xml
View file @
77d2def9
...
@@ -5,6 +5,9 @@
...
@@ -5,6 +5,9 @@
<item
android:id=
"@+id/profiles"
<item
android:id=
"@+id/profiles"
android:title=
"@string/profiles"
android:title=
"@string/profiles"
android:icon=
"@drawable/ic_action_description"
/>
android:icon=
"@drawable/ic_action_description"
/>
<item
android:id=
"@+id/subscriptions"
android:title=
"@string/subscriptions"
android:icon=
"@drawable/ic_action_description"
/>
<item
android:id=
"@+id/customRules"
<item
android:id=
"@+id/customRules"
android:title=
"@string/custom_rules"
android:title=
"@string/custom_rules"
android:icon=
"@drawable/ic_action_assignment"
/>
android:icon=
"@drawable/ic_action_assignment"
/>
...
...
mobile/src/main/res/menu/subscription_menu.xml
0 → 100644
View file @
77d2def9
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:title=
"@string/add_subscription"
android:id=
"@+id/action_manual_settings"
android:icon=
"@drawable/ic_av_playlist_add"
android:alphabeticShortcut=
"n"
app:showAsAction=
"always"
/>
<item
android:title=
"@string/update_subscription"
android:id=
"@+id/action_update_subscription"
android:icon=
"@drawable/ic_action_done"
android:alphabeticShortcut=
"r"
app:showAsAction=
"ifRoom"
/>
</menu>
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