Skip to content

Commit 8e17e4f

Browse files
committed
Clean up and bump version
1 parent 36576a6 commit 8e17e4f

File tree

11 files changed

+9
-367
lines changed

11 files changed

+9
-367
lines changed

buildSrc/src/main/kotlin/Helpers.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ fun Project.setupCore() {
5656
setupCommon()
5757
android.apply {
5858
defaultConfig {
59-
versionCode = 5010450
60-
versionName = "5.1.4-nightly"
59+
versionCode = 5010550
60+
versionName = "5.1.5-nightly"
6161
}
6262
compileOptions.isCoreLibraryDesugaringEnabled = true
6363
lintOptions {

core/build.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ dependencies {
7373

7474
api(project(":plugin"))
7575
api("androidx.appcompat:appcompat:1.2.0")
76-
api("androidx.core:core-ktx:1.4.0-alpha01")
76+
api("androidx.core:core-ktx:1.5.0-alpha05")
7777

7878
api("androidx.fragment:fragment-ktx:1.3.0-beta01")
7979
api("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion")
@@ -84,9 +84,8 @@ dependencies {
8484
api("androidx.work:work-gcm:$workVersion")
8585
api("com.google.android.gms:play-services-oss-licenses:17.0.0")
8686
api("com.google.code.gson:gson:2.8.6")
87-
api("com.google.firebase:firebase-analytics-ktx:17.5.0")
88-
api("com.google.firebase:firebase-config-ktx:19.2.0")
89-
api("com.google.firebase:firebase-crashlytics:17.2.2")
87+
api("com.google.firebase:firebase-analytics-ktx:18.0.0")
88+
api("com.google.firebase:firebase-crashlytics:17.3.0")
9089
api("com.jakewharton.timber:timber:4.7.1")
9190
api("dnsjava:dnsjava:3.3.0")
9291
api("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")

core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import com.github.shadowsocks.preference.DataStore
3232
import com.github.shadowsocks.utils.parseNumericAddress
3333
import com.github.shadowsocks.utils.signaturesCompat
3434
import com.github.shadowsocks.utils.useCancellable
35-
import com.google.firebase.remoteconfig.ktx.get
3635
import kotlinx.coroutines.CoroutineScope
3736
import kotlinx.coroutines.Dispatchers
3837
import kotlinx.coroutines.withContext
@@ -52,37 +51,6 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
5251
private var scheduleConfigUpdate = false
5352

5453
suspend fun init(service: BaseService.Interface) {
55-
if (profile.isSponsored) {
56-
scheduleConfigUpdate = true
57-
val mdg = MessageDigest.getInstance("SHA-1")
58-
mdg.update(Core.packageInfo.signaturesCompat.first().toByteArray())
59-
val (config, success) = RemoteConfig.fetch()
60-
scheduleConfigUpdate = !success
61-
val conn = withContext(Dispatchers.IO) {
62-
// Network.openConnection might use networking, see https://issuetracker.google.com/issues/135242093
63-
service.openConnection(URL(config["proxy_url"].asString())) as HttpURLConnection
64-
}
65-
conn.requestMethod = "POST"
66-
conn.doOutput = true
67-
68-
val proxies = conn.useCancellable {
69-
try {
70-
outputStream.bufferedWriter().use {
71-
it.write("sig=" + Base64.encodeToString(mdg.digest(), Base64.DEFAULT))
72-
}
73-
inputStream.bufferedReader().readText()
74-
} catch (e: IOException) {
75-
throw BaseService.ExpectedExceptionWrapper(e)
76-
}
77-
}.split('|').toMutableList()
78-
proxies.shuffle()
79-
val proxy = proxies.first().split(':')
80-
profile.host = proxy[0].trim()
81-
profile.remotePort = proxy[1].trim().toInt()
82-
profile.password = proxy[2].trim()
83-
profile.method = proxy[3].trim()
84-
}
85-
8654
// it's hard to resolve DNS on a specific interface so we'll do it here
8755
if (profile.host.parseNumericAddress() == null) {
8856
profile.host = try {
@@ -139,7 +107,6 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
139107

140108
fun scheduleUpdate() {
141109
if (route !in arrayOf(Acl.ALL, Acl.CUSTOM_RULES)) AclSyncer.schedule(route)
142-
if (scheduleConfigUpdate) RemoteConfig.fetchAsync()
143110
}
144111

145112
fun shutdown(scope: CoroutineScope) {

core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt

Lines changed: 0 additions & 51 deletions
This file was deleted.

core/src/main/java/com/github/shadowsocks/database/Profile.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ data class Profile(
101101

102102
companion object {
103103
private const val serialVersionUID = 1L
104-
private const val sponsored = "198.199.101.152"
104+
private const val sponsored = "example.shadowsocks.org"
105105
private val pattern =
106106
"""(?i)ss://[-a-zA-Z0-9+&@#/%?=.~*'()|!:,;_\[\]]*[-a-zA-Z0-9+&@#/%=.~*'()|\[\]]""".toRegex()
107107
private val userInfoPattern = "^(.+?):(.*)$".toRegex()

mobile/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ dependencies {
1717
implementation("androidx.browser:browser:1.2.0")
1818
implementation("androidx.camera:camera-camera2:$cameraxVersion")
1919
implementation("androidx.camera:camera-lifecycle:$cameraxVersion")
20-
implementation("androidx.camera:camera-view:1.0.0-alpha17")
21-
implementation("androidx.constraintlayout:constraintlayout:2.0.1")
20+
implementation("androidx.camera:camera-view:1.0.0-alpha19")
21+
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
2222
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
23-
implementation("com.google.firebase:firebase-ads:19.4.0")
2423
implementation("com.google.mlkit:barcode-scanning:16.0.3")
2524
implementation("com.google.zxing:core:3.4.1")
2625
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0")

mobile/src/main/java/com/github/shadowsocks/AdsManager.kt

Lines changed: 0 additions & 41 deletions
This file was deleted.

mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ import com.github.shadowsocks.utils.readableMessage
5656
import com.github.shadowsocks.widget.ListHolderListener
5757
import com.github.shadowsocks.widget.MainListListener
5858
import com.github.shadowsocks.widget.UndoSnackbarManager
59-
import com.google.android.gms.ads.VideoOptions
60-
import com.google.android.gms.ads.formats.NativeAdOptions
61-
import com.google.android.gms.ads.formats.UnifiedNativeAd
62-
import com.google.android.gms.ads.formats.UnifiedNativeAdView
6359
import com.google.zxing.BarcodeFormat
6460
import com.google.zxing.EncodeHintType
6561
import com.google.zxing.MultiFormatWriter
@@ -89,32 +85,6 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
8985
private fun isProfileEditable(id: Long) =
9086
(activity as MainActivity).state == BaseService.State.Stopped || id !in Core.activeProfileIds
9187

92-
private var nativeAd: UnifiedNativeAd? = null
93-
private var nativeAdView: UnifiedNativeAdView? = null
94-
private var adHost: ProfileViewHolder? = null
95-
private fun tryBindAd() = lifecycleScope.launchWhenStarted {
96-
val fp = layoutManager.findFirstVisibleItemPosition()
97-
if (fp < 0) return@launchWhenStarted
98-
for (i in object : Iterator<Int> {
99-
var first = fp
100-
var last = layoutManager.findLastCompletelyVisibleItemPosition()
101-
var flipper = false
102-
override fun hasNext() = first <= last
103-
override fun next(): Int {
104-
flipper = !flipper
105-
return if (flipper) first++ else last--
106-
}
107-
}.asSequence().toList().reversed()) {
108-
val viewHolder = profilesList.findViewHolderForAdapterPosition(i) as? ProfileViewHolder
109-
if (viewHolder?.item?.isSponsored == true) {
110-
viewHolder.populateUnifiedNativeAdView(nativeAd!!, nativeAdView!!)
111-
// might be in the middle of a layout after scrolling, need to wait
112-
withContext(Dispatchers.Main) { profilesAdapter.notifyItemChanged(i) }
113-
break
114-
}
115-
}
116-
}
117-
11888
@SuppressLint("ValidFragment")
11989
class QRCodeDialog() : DialogFragment() {
12090
constructor(url: String) : this() {
@@ -157,7 +127,6 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
157127
private val traffic = itemView.findViewById<TextView>(R.id.traffic)
158128
private val edit = itemView.findViewById<View>(R.id.edit)
159129
private val subscription = itemView.findViewById<View>(R.id.subscription)
160-
private val adContainer = itemView.findViewById<LinearLayout>(R.id.ad_container)
161130

162131
init {
163132
edit.setOnClickListener {
@@ -181,92 +150,6 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
181150
TooltipCompat.setTooltipText(share, share.contentDescription)
182151
}
183152

184-
fun populateUnifiedNativeAdView(nativeAd: UnifiedNativeAd, adView: UnifiedNativeAdView) {
185-
// Set other ad assets.
186-
adView.headlineView = adView.findViewById(R.id.ad_headline)
187-
adView.bodyView = adView.findViewById(R.id.ad_body)
188-
adView.callToActionView = adView.findViewById(R.id.ad_call_to_action)
189-
adView.iconView = adView.findViewById(R.id.ad_app_icon)
190-
adView.starRatingView = adView.findViewById(R.id.ad_stars)
191-
adView.advertiserView = adView.findViewById(R.id.ad_advertiser)
192-
193-
// The headline and media content are guaranteed to be in every UnifiedNativeAd.
194-
(adView.headlineView as TextView).text = nativeAd.headline
195-
196-
// These assets aren't guaranteed to be in every UnifiedNativeAd, so it's important to
197-
// check before trying to display them.
198-
if (nativeAd.body == null) {
199-
adView.bodyView.visibility = View.INVISIBLE
200-
} else {
201-
adView.bodyView.visibility = View.VISIBLE
202-
(adView.bodyView as TextView).text = nativeAd.body
203-
}
204-
205-
if (nativeAd.callToAction == null) {
206-
adView.callToActionView.visibility = View.INVISIBLE
207-
} else {
208-
adView.callToActionView.visibility = View.VISIBLE
209-
(adView.callToActionView as Button).text = nativeAd.callToAction
210-
}
211-
212-
if (nativeAd.icon == null) {
213-
adView.iconView.visibility = View.GONE
214-
} else {
215-
(adView.iconView as ImageView).setImageDrawable(
216-
nativeAd.icon.drawable)
217-
adView.iconView.visibility = View.VISIBLE
218-
}
219-
220-
if (nativeAd.starRating == null) {
221-
adView.starRatingView.visibility = View.INVISIBLE
222-
} else {
223-
(adView.starRatingView as RatingBar).rating = nativeAd.starRating!!.toFloat()
224-
adView.starRatingView.visibility = View.VISIBLE
225-
}
226-
227-
if (nativeAd.advertiser == null) {
228-
adView.advertiserView.visibility = View.INVISIBLE
229-
} else {
230-
(adView.advertiserView as TextView).text = nativeAd.advertiser
231-
adView.advertiserView.visibility = View.VISIBLE
232-
}
233-
234-
// This method tells the Google Mobile Ads SDK that you have finished populating your
235-
// native ad view with this native ad.
236-
adView.setNativeAd(nativeAd)
237-
adContainer.addView(adView)
238-
adHost = this
239-
}
240-
241-
fun attach() {
242-
if (adHost != null || !item.isSponsored) return
243-
if (nativeAdView == null) {
244-
nativeAdView = layoutInflater.inflate(R.layout.ad_unified, adContainer, false) as UnifiedNativeAdView
245-
AdsManager.load(context) {
246-
forUnifiedNativeAd { unifiedNativeAd ->
247-
// You must call destroy on old ads when you are done with them,
248-
// otherwise you will have a memory leak.
249-
nativeAd?.destroy()
250-
nativeAd = unifiedNativeAd
251-
tryBindAd()
252-
}
253-
withNativeAdOptions(NativeAdOptions.Builder().apply {
254-
setVideoOptions(VideoOptions.Builder().apply {
255-
setStartMuted(true)
256-
}.build())
257-
}.build())
258-
}
259-
} else if (nativeAd != null) populateUnifiedNativeAdView(nativeAd!!, nativeAdView!!)
260-
}
261-
262-
fun detach() {
263-
if (adHost == this) {
264-
adHost = null
265-
adContainer.removeAllViews()
266-
tryBindAd()
267-
}
268-
}
269-
270153
fun bind(item: Profile) {
271154
this.item = item
272155
val editable = isProfileEditable(item.id)
@@ -341,8 +224,6 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
341224
setHasStableIds(true) // see: http://stackoverflow.com/a/32488059/2245107
342225
}
343226

344-
override fun onViewAttachedToWindow(holder: ProfileViewHolder) = holder.attach()
345-
override fun onViewDetachedFromWindow(holder: ProfileViewHolder) = holder.detach()
346227
override fun onBindViewHolder(holder: ProfileViewHolder, position: Int) = holder.bind(profiles[position])
347228
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProfileViewHolder = ProfileViewHolder(
348229
LayoutInflater.from(parent.context).inflate(R.layout.layout_profile, parent, false))
@@ -594,7 +475,6 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
594475

595476
override fun onDestroyView() {
596477
undoManager.flush()
597-
nativeAd?.destroy()
598478
super.onDestroyView()
599479
}
600480

0 commit comments

Comments
 (0)