upgrade to minSdkVersion 18, fix some lint warnings

This commit is contained in:
Conny Duck 2018-01-31 21:57:50 +01:00
parent 2eaf727a1d
commit 3c795c6eef
4 changed files with 25 additions and 49 deletions

View file

@ -7,7 +7,7 @@ android {
buildToolsVersion '27.0.1' buildToolsVersion '27.0.1'
defaultConfig { defaultConfig {
applicationId "com.keylesspalace.tusky" applicationId "com.keylesspalace.tusky"
minSdkVersion 15 minSdkVersion 18
targetSdkVersion 27 targetSdkVersion 27
versionCode 31 versionCode 31
versionName "1.4.1" versionName "1.4.1"

View file

@ -1030,8 +1030,7 @@ public final class ComposeActivity extends BaseActivity
} }
private void onMediaPick() { private void onMediaPick() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},

View file

@ -23,7 +23,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -109,7 +108,7 @@ public class EditProfileActivity extends BaseActivity {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
actionBar.setTitle(getString(R.string.title_edit_profile)); actionBar.setTitle(R.string.title_edit_profile);
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowHomeEnabled(true);
} }
@ -130,39 +129,23 @@ public class EditProfileActivity extends BaseActivity {
headerBase64 = null; headerBase64 = null;
} }
avatarButton.setOnClickListener(new View.OnClickListener() { avatarButton.setOnClickListener(v -> onMediaPick(PickType.AVATAR));
@Override headerButton.setOnClickListener(v -> onMediaPick(PickType.HEADER));
public void onClick(View v) {
onMediaPick(PickType.AVATAR);
}
});
headerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMediaPick(PickType.HEADER);
}
});
avatarPreview.setOnClickListener(new View.OnClickListener() { avatarPreview.setOnClickListener(v -> {
@Override
public void onClick(View v) {
avatarPreview.setImageBitmap(null); avatarPreview.setImageBitmap(null);
avatarPreview.setVisibility(View.INVISIBLE); avatarPreview.setVisibility(View.INVISIBLE);
avatarBase64 = null; avatarBase64 = null;
}
}); });
headerPreview.setOnClickListener(new View.OnClickListener() { headerPreview.setOnClickListener(v -> {
@Override
public void onClick(View v) {
headerPreview.setImageBitmap(null); headerPreview.setImageBitmap(null);
headerPreview.setVisibility(View.INVISIBLE); headerPreview.setVisibility(View.INVISIBLE);
headerBase64 = null; headerBase64 = null;
}
}); });
mastodonApi.accountVerifyCredentials().enqueue(new Callback<Account>() { mastodonApi.accountVerifyCredentials().enqueue(new Callback<Account>() {
@Override @Override
public void onResponse(Call<Account> call, Response<Account> response) { public void onResponse(@NonNull Call<Account> call, @NonNull Response<Account> response) {
if (!response.isSuccessful()) { if (!response.isSuccessful()) {
onAccountVerifyCredentialsFailed(); onAccountVerifyCredentialsFailed();
return; return;
@ -187,7 +170,7 @@ public class EditProfileActivity extends BaseActivity {
} }
@Override @Override
public void onFailure(Call<Account> call, Throwable t) { public void onFailure(@NonNull Call<Account> call, @NonNull Throwable t) {
onAccountVerifyCredentialsFailed(); onAccountVerifyCredentialsFailed();
} }
}); });
@ -214,8 +197,7 @@ public class EditProfileActivity extends BaseActivity {
return; return;
} }
currentlyPicking = pickType; currentlyPicking = pickType;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, ActivityCompat.requestPermissions(this,
new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
@ -314,7 +296,7 @@ public class EditProfileActivity extends BaseActivity {
profile.header = headerBase64; profile.header = headerBase64;
mastodonApi.accountUpdateCredentials(profile).enqueue(new Callback<Account>() { mastodonApi.accountUpdateCredentials(profile).enqueue(new Callback<Account>() {
@Override @Override
public void onResponse(Call<Account> call, Response<Account> response) { public void onResponse(@NonNull Call<Account> call, @NonNull Response<Account> response) {
if (!response.isSuccessful()) { if (!response.isSuccessful()) {
onSaveFailure(); onSaveFailure();
return; return;
@ -326,7 +308,7 @@ public class EditProfileActivity extends BaseActivity {
} }
@Override @Override
public void onFailure(Call<Account> call, Throwable t) { public void onFailure(@NonNull Call<Account> call, @NonNull Throwable t) {
onSaveFailure(); onSaveFailure();
} }
}); });

View file

@ -17,7 +17,6 @@ package com.keylesspalace.tusky.util;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
@ -48,7 +47,6 @@ import okhttp3.ConnectionSpec;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response;
public class OkHttpUtils { public class OkHttpUtils {
private static final String TAG = "OkHttpUtils"; // logging tag private static final String TAG = "OkHttpUtils"; // logging tag
@ -108,15 +106,12 @@ public class OkHttpUtils {
*/ */
@NonNull @NonNull
private static Interceptor getUserAgentInterceptor() { private static Interceptor getUserAgentInterceptor() {
return new Interceptor() { return chain -> {
@Override
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request(); Request originalRequest = chain.request();
Request requestWithUserAgent = originalRequest.newBuilder() Request requestWithUserAgent = originalRequest.newBuilder()
.header("User-Agent", "Tusky/"+ BuildConfig.VERSION_NAME+" Android/"+Build.VERSION.RELEASE) .header("User-Agent", "Tusky/"+ BuildConfig.VERSION_NAME+" Android/"+Build.VERSION.RELEASE)
.build(); .build();
return chain.proceed(requestWithUserAgent); return chain.proceed(requestWithUserAgent);
}
}; };
} }
@ -164,7 +159,7 @@ public 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 < 22) {
try { try {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance( TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm()); TrustManagerFactory.getDefaultAlgorithm());