Clears out diagnostic code.
This commit is contained in:
parent
48c9b71f92
commit
b9ea3bf185
|
@ -18,15 +18,10 @@ package com.keylesspalace.tusky;
|
||||||
/**A wrapper for android.util.Log that allows for disabling logging, such as for release builds.*/
|
/**A wrapper for android.util.Log that allows for disabling logging, such as for release builds.*/
|
||||||
public class Log {
|
public class Log {
|
||||||
private static final boolean LOGGING_ENABLED = BuildConfig.DEBUG;
|
private static final boolean LOGGING_ENABLED = BuildConfig.DEBUG;
|
||||||
private static String longBoy;
|
|
||||||
private static String watchedTag;
|
|
||||||
|
|
||||||
public static void i(String tag, String string) {
|
public static void i(String tag, String string) {
|
||||||
if (LOGGING_ENABLED) {
|
if (LOGGING_ENABLED) {
|
||||||
android.util.Log.i(tag, string);
|
android.util.Log.i(tag, string);
|
||||||
if (tag.equals(watchedTag)) {
|
|
||||||
longBoy += string + '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +48,4 @@ public class Log {
|
||||||
android.util.Log.w(tag, string);
|
android.util.Log.w(tag, string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void watchTag(String tag) {
|
|
||||||
longBoy = "";
|
|
||||||
watchedTag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getWatchedMessages() {
|
|
||||||
watchedTag = null;
|
|
||||||
return longBoy;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -59,7 +59,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
@BindView(R.id.edit_text_domain) EditText editText;
|
@BindView(R.id.edit_text_domain) EditText editText;
|
||||||
@BindView(R.id.button_login) Button button;
|
@BindView(R.id.button_login) Button button;
|
||||||
@BindView(R.id.whats_an_instance) TextView whatsAnInstance;
|
@BindView(R.id.whats_an_instance) TextView whatsAnInstance;
|
||||||
@BindView(R.id.debug_log_display) TextView debugLogDisplay;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -190,14 +189,11 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
clientSecret = prefClientSecret;
|
clientSecret = prefClientSecret;
|
||||||
redirectUserToAuthorizeAndLogin(editText);
|
redirectUserToAuthorizeAndLogin(editText);
|
||||||
} else {
|
} else {
|
||||||
Log.watchTag(OkHttpUtils.TAG);
|
|
||||||
|
|
||||||
Callback<AppCredentials> callback = new Callback<AppCredentials>() {
|
Callback<AppCredentials> callback = new Callback<AppCredentials>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<AppCredentials> call,
|
public void onResponse(Call<AppCredentials> call,
|
||||||
Response<AppCredentials> response) {
|
Response<AppCredentials> response) {
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
debugLogDisplay.setText(Log.getWatchedMessages());
|
|
||||||
editText.setError(getString(R.string.error_failed_app_registration));
|
editText.setError(getString(R.string.error_failed_app_registration));
|
||||||
Log.e(TAG, "App authentication failed. " + response.message());
|
Log.e(TAG, "App authentication failed. " + response.message());
|
||||||
return;
|
return;
|
||||||
|
@ -209,13 +205,11 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
editor.putString(domain + "/client_id", clientId);
|
editor.putString(domain + "/client_id", clientId);
|
||||||
editor.putString(domain + "/client_secret", clientSecret);
|
editor.putString(domain + "/client_secret", clientSecret);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
Log.watchTag(null);
|
|
||||||
redirectUserToAuthorizeAndLogin(editText);
|
redirectUserToAuthorizeAndLogin(editText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<AppCredentials> call, Throwable t) {
|
public void onFailure(Call<AppCredentials> call, Throwable t) {
|
||||||
debugLogDisplay.setText(Log.getWatchedMessages());
|
|
||||||
editText.setError(getString(R.string.error_failed_app_registration));
|
editText.setError(getString(R.string.error_failed_app_registration));
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.net.ssl.HandshakeCompletedEvent;
|
|
||||||
import javax.net.ssl.HandshakeCompletedListener;
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
@ -77,7 +75,7 @@ class OkHttpUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OkHttpClient.Builder enableHigherTlsOnPreLollipop(OkHttpClient.Builder builder) {
|
private static OkHttpClient.Builder enableHigherTlsOnPreLollipop(OkHttpClient.Builder builder) {
|
||||||
// if (Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT < 22) {
|
if (Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT < 22) {
|
||||||
try {
|
try {
|
||||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
|
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
|
||||||
TrustManagerFactory.getDefaultAlgorithm());
|
TrustManagerFactory.getDefaultAlgorithm());
|
||||||
|
@ -99,7 +97,7 @@ class OkHttpUtils {
|
||||||
} catch (NoSuchAlgorithmException|KeyStoreException|KeyManagementException e) {
|
} catch (NoSuchAlgorithmException|KeyStoreException|KeyManagementException e) {
|
||||||
Log.e(TAG, "Failed enabling TLS 1.1 & 1.2. " + e.getMessage());
|
Log.e(TAG, "Failed enabling TLS 1.1 & 1.2. " + e.getMessage());
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -160,44 +158,12 @@ class OkHttpUtils {
|
||||||
return a.toArray(new String[0]);
|
return a.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private static List<String> getDifferences(String[] wanted, String[] have) {
|
|
||||||
List<String> a = new ArrayList<>(Arrays.asList(wanted));
|
|
||||||
List<String> b = Arrays.asList(have);
|
|
||||||
a.removeAll(b);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Socket patch(Socket socket) {
|
private Socket patch(Socket socket) {
|
||||||
if (socket instanceof SSLSocket) {
|
if (socket instanceof SSLSocket) {
|
||||||
SSLSocket sslSocket = (SSLSocket) socket;
|
SSLSocket sslSocket = (SSLSocket) socket;
|
||||||
String[] protocols = getMatches(DESIRED_TLS_VERSIONS,
|
String[] protocols = getMatches(DESIRED_TLS_VERSIONS,
|
||||||
sslSocket.getSupportedProtocols());
|
sslSocket.getSupportedProtocols());
|
||||||
sslSocket.setEnabledProtocols(protocols);
|
sslSocket.setEnabledProtocols(protocols);
|
||||||
|
|
||||||
// Add a debug listener.
|
|
||||||
String[] enabledProtocols = sslSocket.getEnabledProtocols();
|
|
||||||
List<String> disabledProtocols = getDifferences(sslSocket.getSupportedProtocols(),
|
|
||||||
enabledProtocols);
|
|
||||||
String[] enabledSuites = sslSocket.getEnabledCipherSuites();
|
|
||||||
List<String> disabledSuites = getDifferences(sslSocket.getSupportedCipherSuites(),
|
|
||||||
enabledSuites);
|
|
||||||
Log.i(TAG, "Socket Created-----");
|
|
||||||
Log.i(TAG, "enabled protocols: " + Arrays.toString(enabledProtocols));
|
|
||||||
Log.i(TAG, "disabled protocols: " + disabledProtocols.toString());
|
|
||||||
Log.i(TAG, "enabled cipher suites: " + Arrays.toString(enabledSuites));
|
|
||||||
Log.i(TAG, "disabled cipher suites: " + disabledSuites.toString());
|
|
||||||
|
|
||||||
sslSocket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
|
|
||||||
@Override
|
|
||||||
public void handshakeCompleted(HandshakeCompletedEvent event) {
|
|
||||||
String host = event.getSession().getPeerHost();
|
|
||||||
String protocol = event.getSession().getProtocol();
|
|
||||||
String cipherSuite = event.getCipherSuite();
|
|
||||||
Log.i(TAG, String.format("Handshake: %s %s %s", host, protocol,
|
|
||||||
cipherSuite));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,34 +13,11 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<HorizontalScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="300dp">
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="#000000"
|
|
||||||
android:layout_marginBottom="25dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/debug_log_display"
|
|
||||||
android:textIsSelectable="true"
|
|
||||||
android:textColor="#ffffff" />
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</HorizontalScrollView>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="50dp"
|
android:layout_marginBottom="50dp"
|
||||||
android:src="@drawable/elephant_friend"/>
|
android:src="@drawable/elephant_friend"/>
|
||||||
-->
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
Loading…
Reference in New Issue