Skip to content

Commit 5dd3662

Browse files
authored
Merge pull request #678 from OpenArchive/feature/next-orbot
feat: renable orbot and use status
2 parents fe1d04e + a330ffe commit 5dd3662

35 files changed

+570
-446
lines changed

app/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ android {
8484
signingConfigs {
8585
getByName("debug") {
8686
val props = loadLocalProperties()
87-
storeFile = file(props["STOREFILE"] as? String ?: "")
87+
storeFile = props["STOREFILE"]?.let { file(it) }
8888
storePassword = props["STOREPASSWORD"] as? String ?: ""
8989
keyAlias = props["KEYALIAS"] as? String ?: ""
9090
keyPassword = props["KEYPASSWORD"] as? String ?: ""
@@ -241,9 +241,9 @@ dependencies {
241241
implementation("com.google.api-client:google-api-client-android:1.26.0")
242242
implementation("com.google.apis:google-api-services-drive:v3-rev136-1.25.0")
243243

244-
// Tor Libraries
245-
implementation(libs.tor.android)
246-
implementation(libs.jtorctl)
244+
// Internal Tor Libraries
245+
//implementation(libs.tor.android)
246+
//implementation(libs.jtorctl)
247247

248248
implementation(libs.bitcoinj.core)
249249
implementation("com.eclipsesource.j2v8:j2v8:6.2.1@aar")
@@ -275,7 +275,7 @@ dependencies {
275275
implementation("com.github.derlio:audio-waveform:v1.0.1")
276276

277277
implementation(libs.clean.insights)
278-
implementation(libs.netcipher)
278+
implementation(fileTree("libs"))
279279

280280
// Mixpanel analytics
281281
implementation(libs.mixpanel)

app/libs/netcipher.aar

43.8 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,6 @@
173173
android:label="@string/folders"
174174
android:theme="@style/SaveAppTheme.NoActionBar" />
175175

176-
<activity
177-
android:name=".features.settings.GeneralSettingsActivity"
178-
android:exported="false"
179-
android:label="@string/general"
180-
android:taskAffinity=""
181-
android:theme="@style/SaveAppTheme.NoActionBar" />
182-
183176
<activity
184177
android:name=".features.settings.ProofModeSettingsActivity"
185178
android:exported="false"
@@ -308,7 +301,7 @@
308301
<service
309302
android:name=".services.snowbird.service.SnowbirdService"
310303
android:exported="false"
311-
android:foregroundServiceType="dataSync"></service>
304+
android:foregroundServiceType="dataSync" />
312305

313306
</application>
314307

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

app/src/main/java/net/opendasharchive/openarchive/features/folders/BrowseFolderScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import net.opendasharchive.openarchive.R
2727
import net.opendasharchive.openarchive.core.presentation.theme.DefaultScaffoldPreview
2828
import org.koin.androidx.compose.koinViewModel
2929
import java.util.Date
30+
import net.opendasharchive.openarchive.features.folders.BrowseFoldersViewModel.Folder
3031

3132
@Composable
3233
fun BrowseFolderScreen(

app/src/main/java/net/opendasharchive/openarchive/features/folders/BrowseFoldersAdapter.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.core.content.ContextCompat
77
import androidx.recyclerview.widget.RecyclerView
88
import net.opendasharchive.openarchive.R
99
import net.opendasharchive.openarchive.databinding.FolderRowBinding
10+
import net.opendasharchive.openarchive.features.folders.BrowseFoldersViewModel.Folder
1011
import java.text.SimpleDateFormat
1112

1213
class BrowseFoldersAdapter(

app/src/main/java/net/opendasharchive/openarchive/features/folders/BrowseFoldersFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.opendasharchive.openarchive.features.folders
22

3-
import android.app.Activity
43
import android.app.Activity.RESULT_OK
54
import android.content.Intent
65
import android.os.Bundle
@@ -19,6 +18,7 @@ import net.opendasharchive.openarchive.db.Project
1918
import net.opendasharchive.openarchive.db.Space
2019
import net.opendasharchive.openarchive.features.core.BaseFragment
2120
import net.opendasharchive.openarchive.features.core.dialog.showSuccessDialog
21+
import net.opendasharchive.openarchive.features.folders.BrowseFoldersViewModel.Folder
2222
import net.opendasharchive.openarchive.util.extensions.toggle
2323
import org.koin.androidx.viewmodel.ext.android.viewModel
2424
import java.util.Date

0 commit comments

Comments
 (0)