Skip to content

Commit 1bd0fd2

Browse files
committed
Merge remote-tracking branch 'origin/next' into bugFix/cleanup-next
# Conflicts: # app/build.gradle.kts # app/src/main/AndroidManifest.xml # app/src/main/java/net/opendasharchive/openarchive/features/settings/SettingsFragment.kt
2 parents ce8ee29 + 5dd3662 commit 1bd0fd2

38 files changed

+831
-357
lines changed

app/build.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ android {
4545
minSdk = 29
4646
//noinspection OldTargetApi
4747
targetSdk = 34
48-
versionCode = 30006
48+
versionCode = 30007
4949
versionName = "0.7.8"
5050
multiDexEnabled = true
5151
vectorDrawables.useSupportLibrary = true
@@ -76,6 +76,7 @@ android {
7676
getByName("debug") {
7777
val props = loadLocalProperties()
7878
storeFile = file(props["STOREFILE"] as? String ?: "")
79+
storeFile = props["STOREFILE"]?.let { file(it) }
7980
storePassword = props["STOREPASSWORD"] as? String ?: ""
8081
keyAlias = props["KEYALIAS"] as? String ?: ""
8182
keyPassword = props["KEYPASSWORD"] as? String ?: ""
@@ -250,9 +251,9 @@ dependencies {
250251
implementation("com.google.api-client:google-api-client-android:1.26.0")
251252
implementation("com.google.apis:google-api-services-drive:v3-rev136-1.25.0")
252253

253-
// Tor Libraries
254-
implementation(libs.tor.android)
255-
implementation(libs.jtorctl)
254+
// Internal Tor Libraries
255+
//implementation(libs.tor.android)
256+
//implementation(libs.jtorctl)
256257

257258
implementation(libs.bitcoinj.core)
258259
implementation("com.eclipsesource.j2v8:j2v8:6.2.1@aar")
@@ -284,7 +285,7 @@ dependencies {
284285
implementation("com.github.derlio:audio-waveform:v1.0.1")
285286

286287
implementation(libs.clean.insights)
287-
implementation(libs.netcipher)
288+
implementation(fileTree("libs"))
288289

289290
// Mixpanel analytics
290291
implementation(libs.mixpanel)

app/libs/netcipher.aar

43.8 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
<service
260260
android:name=".services.snowbird.service.SnowbirdService"
261261
android:exported="false"
262-
android:foregroundServiceType="dataSync"></service>
262+
android:foregroundServiceType="dataSync" />
263263

264264
</application>
265265

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright 2012-2016 Nathan Freitas
3+
* Copyright 2015 str4d
4+
* Portions Copyright (c) 2016 CommonsWare, LLC
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package info.guardianproject.netcipher.client;
20+
21+
import android.content.Context;
22+
import android.content.Intent;
23+
import javax.net.ssl.SSLSocketFactory;
24+
25+
import okhttp3.OkHttpClient;
26+
import okhttp3.Request;
27+
28+
/**
29+
* Creates an OkHttpClient using NetCipher configuration. Use
30+
* build() if you have no other OkHttpClient configuration
31+
* that you need to perform. Or, use applyTo() to augment an
32+
* existing OkHttpClient.Builder with NetCipher.
33+
*/
34+
public class StrongOkHttpClientBuilder extends
35+
StrongBuilderBase<StrongOkHttpClientBuilder, OkHttpClient> {
36+
/**
37+
* Creates a StrongOkHttpClientBuilder using the strongest set
38+
* of options for security. Use this if the strongest set of
39+
* options is what you want; otherwise, create a
40+
* builder via the constructor and configure it as you see fit.
41+
*
42+
* @param context any Context will do
43+
* @return a configured StrongOkHttpClientBuilder
44+
* @throws Exception
45+
*/
46+
static public StrongOkHttpClientBuilder forMaxSecurity(Context context)
47+
throws Exception {
48+
return(new StrongOkHttpClientBuilder(context)
49+
.withBestProxy());
50+
}
51+
52+
/**
53+
* Creates a builder instance.
54+
*
55+
* @param context any Context will do; builder will hold onto
56+
* Application context
57+
*/
58+
public StrongOkHttpClientBuilder(Context context) {
59+
super(context);
60+
}
61+
62+
/**
63+
* Copy constructor.
64+
*
65+
* @param original builder to clone
66+
*/
67+
public StrongOkHttpClientBuilder(StrongOkHttpClientBuilder original) {
68+
super(original);
69+
}
70+
71+
/**
72+
* OkHttp3 does not support SOCKS proxies:
73+
* https://github.com/square/okhttp/issues/2315
74+
*
75+
* @return false
76+
*/
77+
@Override
78+
public boolean supportsSocksProxy() {
79+
return(false);
80+
}
81+
82+
/**
83+
* {@inheritDoc}
84+
*/
85+
@Override
86+
public OkHttpClient build(Intent status) {
87+
return(applyTo(new OkHttpClient.Builder(), status).build());
88+
}
89+
90+
/**
91+
* Adds NetCipher configuration to an existing OkHttpClient.Builder,
92+
* in case you have additional configuration that you wish to
93+
* perform.
94+
*
95+
* @param builder a new or partially-configured OkHttpClient.Builder
96+
* @return the same builder
97+
*/
98+
public OkHttpClient.Builder applyTo(OkHttpClient.Builder builder, Intent status) {
99+
SSLSocketFactory factory=buildSocketFactory();
100+
101+
if (factory!=null) {
102+
builder.sslSocketFactory(factory);
103+
}
104+
105+
return(builder
106+
.proxy(buildProxy(status)));
107+
}
108+
109+
@Override
110+
protected String get(Intent status, OkHttpClient connection,
111+
String url) throws Exception {
112+
Request request=new Request.Builder().url(TOR_CHECK_URL).build();
113+
114+
return(connection.newCall(request).execute().body().string());
115+
}
116+
}

app/src/main/java/net/opendasharchive/openarchive/SaveApp.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import net.opendasharchive.openarchive.core.logger.AppLogger
2222
import net.opendasharchive.openarchive.features.settings.passcode.PasscodeManager
2323
import net.opendasharchive.openarchive.util.Analytics
2424
import net.opendasharchive.openarchive.util.Prefs
25-
import net.opendasharchive.openarchive.util.Theme
2625
import org.koin.android.ext.koin.androidContext
2726
import org.koin.android.ext.koin.androidLogger
2827
import org.koin.core.context.startKoin
@@ -69,7 +68,7 @@ class SaveApp : SugarApp(), SingletonImageLoader.Factory {
6968
Prefs.load(this)
7069
applyTheme()
7170

72-
if (Prefs.useTor) initNetCipher()
71+
initNetCipher()
7372

7473
CleanInsightsManager.init(this)
7574

@@ -78,13 +77,17 @@ class SaveApp : SugarApp(), SingletonImageLoader.Factory {
7877

7978
private fun initNetCipher() {
8079
AppLogger.d("Initializing NetCipher client")
81-
val oh = OrbotHelper.get(this)
8280

83-
if (BuildConfig.DEBUG) {
84-
oh.skipOrbotValidation()
81+
OrbotHelper.get(this).apply {
82+
if (BuildConfig.DEBUG) {
83+
skipOrbotValidation()
84+
}
85+
init()
8586
}
8687

87-
// oh.init()
88+
if (Prefs.useTor) {
89+
OrbotHelper.requestStartTor(this@SaveApp)
90+
}
8891
}
8992

9093
private fun createSnowbirdNotificationChannel() {

app/src/main/java/net/opendasharchive/openarchive/core/di/CoreModule.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package net.opendasharchive.openarchive.core.di
22

3-
import android.content.Context
4-
import com.google.api.services.drive.Drive
5-
import com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine
6-
import net.opendasharchive.openarchive.features.core.dialog.DefaultResourceProvider
73
import net.opendasharchive.openarchive.features.core.dialog.DialogStateManager
84
import net.opendasharchive.openarchive.features.core.dialog.ResourceProvider
5+
import net.opendasharchive.openarchive.features.core.dialog.DefaultResourceProvider
96
import net.opendasharchive.openarchive.features.folders.BrowseFoldersViewModel
10-
import net.opendasharchive.openarchive.features.main.MainViewModel
117
import net.opendasharchive.openarchive.features.main.ui.HomeViewModel
8+
import net.opendasharchive.openarchive.features.main.MainViewModel
9+
import net.opendasharchive.openarchive.services.servicesModule
1210
import org.koin.android.ext.koin.androidApplication
1311
import org.koin.core.module.dsl.viewModel
1412
import org.koin.dsl.module
@@ -27,10 +25,9 @@ val coreModule = module {
2725
}
2826

2927
viewModel {
30-
BrowseFoldersViewModel(
31-
context = get<Context>()
32-
)
28+
BrowseFoldersViewModel(get())
3329
}
30+
includes(servicesModule)
3431
}
3532

3633

app/src/main/java/net/opendasharchive/openarchive/core/infrastructure/client/ClientResult.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ import java.io.IOException
1010
import kotlin.coroutines.resume
1111
import kotlin.coroutines.resumeWithException
1212

13-
suspend fun <T> OkHttpClient.enqueueResult(
14-
request: Request,
15-
onResume: (Response) -> T
16-
) = suspendCancellableCoroutine { continuation ->
13+
suspend fun OkHttpClient.enqueueResult(
14+
request: Request
15+
): Result<Response> = suspendCancellableCoroutine { continuation ->
1716
newCall(request).enqueue(object : Callback {
1817
override fun onFailure(call: Call, e: IOException) {
1918
continuation.resumeWithException(e)
2019
}
2120

2221
override fun onResponse(call: Call, response: Response) {
23-
continuation.resume(onResume(response))
22+
continuation.resume(Result.success(response))
2423
}
2524
})
2625

0 commit comments

Comments
 (0)