mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Fixed formatting.
This commit is contained in:
parent
2b6d22ed94
commit
e1ccb4e404
@ -21,7 +21,6 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import com.tooltip.Tooltip;
|
import com.tooltip.Tooltip;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
@ -455,9 +454,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NotNull Throwable throwable) {
|
public void onFailure(@NonNull Call<GiteaVersion> callVersion, Throwable t) {
|
||||||
Log.e("onFailure-version", throwable.toString());
|
Log.e("onFailure-version", t.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -481,6 +481,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
|
||||||
if (response.code() == 200) {
|
if (response.code() == 200) {
|
||||||
|
|
||||||
tinyDb.putBoolean("loggedInMode", true);
|
tinyDb.putBoolean("loggedInMode", true);
|
||||||
assert userDetails != null;
|
assert userDetails != null;
|
||||||
tinyDb.putString(userDetails.getLogin() + "-token", loginToken_);
|
tinyDb.putString(userDetails.getLogin() + "-token", loginToken_);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.mian.gitnex.clients;
|
package org.mian.gitnex.clients;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import org.mian.gitnex.ssl.MemorizingTrustManager;
|
import org.mian.gitnex.ssl.MemorizingTrustManager;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
@ -25,10 +26,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||||||
|
|
||||||
public class IssuesService {
|
public class IssuesService {
|
||||||
|
|
||||||
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context context) {
|
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||||
|
|
||||||
final boolean connToInternet = AppUtil.haveNetworkConnection(context);
|
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||||
File httpCacheDirectory = new File(context.getCacheDir(), "responses");
|
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||||
int cacheSize = 50 * 1024 * 1024; // 50MB
|
int cacheSize = 50 * 1024 * 1024; // 50MB
|
||||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ public class IssuesService {
|
|||||||
try {
|
try {
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
|
|
||||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(context);
|
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||||
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
||||||
|
|
||||||
OkHttpClient okHttpClient = new OkHttpClient.Builder().cache(cache).sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager).hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())).addInterceptor(new Interceptor() {
|
OkHttpClient okHttpClient = new OkHttpClient.Builder().cache(cache).sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager).hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())).addInterceptor(new Interceptor() {
|
||||||
@ -62,8 +63,9 @@ public class IssuesService {
|
|||||||
|
|
||||||
Retrofit retrofit = builder.build();
|
Retrofit retrofit = builder.build();
|
||||||
return retrofit.create(serviceClass);
|
return retrofit.create(serviceClass);
|
||||||
} catch(Exception e) {
|
}
|
||||||
e.printStackTrace();
|
catch(Exception e) {
|
||||||
|
Log.e("onFailure", e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.mian.gitnex.clients;
|
package org.mian.gitnex.clients;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import org.mian.gitnex.ssl.MemorizingTrustManager;
|
import org.mian.gitnex.ssl.MemorizingTrustManager;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
@ -25,10 +26,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||||||
|
|
||||||
public class PullRequestsService {
|
public class PullRequestsService {
|
||||||
|
|
||||||
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context context) {
|
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||||
|
|
||||||
final boolean connToInternet = AppUtil.haveNetworkConnection(context);
|
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||||
File httpCacheDirectory = new File(context.getCacheDir(), "responses");
|
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||||
int cacheSize = 50 * 1024 * 1024; // 50MB
|
int cacheSize = 50 * 1024 * 1024; // 50MB
|
||||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ public class PullRequestsService {
|
|||||||
try {
|
try {
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
|
|
||||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(context);
|
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||||
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
sslContext.init(null, new X509TrustManager[]{memorizingTrustManager}, new SecureRandom());
|
||||||
|
|
||||||
OkHttpClient okHttpClient = new OkHttpClient.Builder().cache(cache).sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager).hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())).addInterceptor(new Interceptor() {
|
OkHttpClient okHttpClient = new OkHttpClient.Builder().cache(cache).sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager).hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())).addInterceptor(new Interceptor() {
|
||||||
@ -62,8 +63,9 @@ public class PullRequestsService {
|
|||||||
|
|
||||||
Retrofit retrofit = builder.build();
|
Retrofit retrofit = builder.build();
|
||||||
return retrofit.create(serviceClass);
|
return retrofit.create(serviceClass);
|
||||||
} catch(Exception e) {
|
}
|
||||||
e.printStackTrace();
|
catch(Exception e) {
|
||||||
|
Log.e("onFailure", e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.mian.gitnex.clients;
|
package org.mian.gitnex.clients;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import org.mian.gitnex.interfaces.ApiInterface;
|
import org.mian.gitnex.interfaces.ApiInterface;
|
||||||
import org.mian.gitnex.ssl.MemorizingTrustManager;
|
import org.mian.gitnex.ssl.MemorizingTrustManager;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
@ -25,10 +26,10 @@ public class RetrofitClient {
|
|||||||
|
|
||||||
private Retrofit retrofit;
|
private Retrofit retrofit;
|
||||||
|
|
||||||
private RetrofitClient(String instanceUrl, Context context) {
|
private RetrofitClient(String instanceUrl, Context ctx) {
|
||||||
final boolean connToInternet = AppUtil.haveNetworkConnection(context);
|
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||||
int cacheSize = 50 * 1024 * 1024; // 50MB
|
int cacheSize = 50 * 1024 * 1024; // 50MB
|
||||||
File httpCacheDirectory = new File(context.getCacheDir(), "responses");
|
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||||
|
|
||||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||||
@ -37,21 +38,23 @@ public class RetrofitClient {
|
|||||||
try {
|
try {
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
|
|
||||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(context);
|
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||||
sslContext.init(null, new X509TrustManager[] { memorizingTrustManager }, new SecureRandom());
|
sslContext.init(null, new X509TrustManager[] { memorizingTrustManager }, new SecureRandom());
|
||||||
|
|
||||||
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder()
|
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder()
|
||||||
.cache(cache)
|
.cache(cache)
|
||||||
|
//.addInterceptor(logging)
|
||||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||||
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
||||||
.addInterceptor(chain -> {
|
.addInterceptor(chain -> {
|
||||||
|
|
||||||
Request request = chain.request();
|
Request request = chain.request();
|
||||||
|
if(connToInternet) {
|
||||||
request = (connToInternet) ?
|
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||||
request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build() :
|
}
|
||||||
request.newBuilder().header("Cache-Control",
|
else {
|
||||||
"public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||||
|
}
|
||||||
return chain.proceed(request);
|
return chain.proceed(request);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -63,8 +66,9 @@ public class RetrofitClient {
|
|||||||
|
|
||||||
retrofit = builder.build();
|
retrofit = builder.build();
|
||||||
|
|
||||||
} catch(Exception e) {
|
}
|
||||||
e.printStackTrace();
|
catch(Exception e) {
|
||||||
|
Log.e("onFailure", e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ import javax.net.ssl.X509TrustManager;
|
|||||||
/**
|
/**
|
||||||
* Author Georg Lukas, modified by anonTree1417
|
* Author Georg Lukas, modified by anonTree1417
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MemorizingTrustManager implements X509TrustManager {
|
public class MemorizingTrustManager implements X509TrustManager {
|
||||||
private final static String DECISION_INTENT = "de.duenndns.ssl.DECISION";
|
private final static String DECISION_INTENT = "de.duenndns.ssl.DECISION";
|
||||||
final static String DECISION_INTENT_ID = DECISION_INTENT + ".decisionId";
|
final static String DECISION_INTENT_ID = DECISION_INTENT + ".decisionId";
|
||||||
|
@ -567,18 +567,16 @@
|
|||||||
<string name="changelogTitle" translatable="false">Changelog</string>
|
<string name="changelogTitle" translatable="false">Changelog</string>
|
||||||
|
|
||||||
<!-- Memorizing Trust Manager -->
|
<!-- Memorizing Trust Manager -->
|
||||||
|
<string name="mtm_notification">Certificate Verification</string>
|
||||||
<string name="mtm_accept_cert">Accept Unknown Certificate?</string>
|
<string name="mtm_accept_cert">Accept Unknown Certificate?</string>
|
||||||
<string name="mtm_trust_anchor">The server certificate is not signed by a known Certificate Authority.</string>
|
<string name="mtm_trust_anchor">The server certificate is not signed by a known Certificate Authority.</string>
|
||||||
<string name="mtm_cert_expired">The server certificate is expired.</string>
|
<string name="mtm_cert_expired">The server certificate is expired.</string>
|
||||||
<string name="mtm_accept_servername">Accept Mismatching Server Name?</string>
|
<string name="mtm_accept_servername">Accept Mismatching Server Name?</string>
|
||||||
<string name="mtm_hostname_mismatch">Server could not authenticate as \"%s\". The certificate is only valid for:</string>
|
<string name="mtm_hostname_mismatch">Server could not authenticate as \"%s\". The certificate is only valid for:</string>
|
||||||
|
|
||||||
<string name="mtm_connect_anyway">Do you want to connect anyway?</string>
|
<string name="mtm_connect_anyway">Do you want to connect anyway?</string>
|
||||||
<string name="mtm_cert_details">Certificate details:</string>
|
<string name="mtm_cert_details">Certificate details:</string>
|
||||||
|
|
||||||
<string name="mtm_decision_always">Always</string>
|
<string name="mtm_decision_always">Always</string>
|
||||||
<string name="mtm_decision_once">Once</string>
|
<string name="mtm_decision_once">Once</string>
|
||||||
<string name="mtm_decision_abort">Abort</string>
|
<string name="mtm_decision_abort">Abort</string>
|
||||||
|
|
||||||
<string name="mtm_notification">Certificate Verification</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user