From 28a85639ed76335719f1335535b9662e5c964036 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sat, 14 Apr 2018 13:56:48 +0200 Subject: [PATCH] upgrade minSdkVersion to 19 --- app/build.gradle | 2 +- .../keylesspalace/tusky/ComposeActivity.java | 21 ++++++------------- .../tusky/adapter/StatusViewHolder.java | 8 ++----- .../tusky/util/NotificationHelper.java | 9 +++----- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 667380c4..adb24550 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ android { buildToolsVersion '27.0.3' defaultConfig { applicationId "com.keylesspalace.tusky" - minSdkVersion 18 + minSdkVersion 19 targetSdkVersion 27 versionCode 34 versionName "1.5.2" diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 151e82ff..d6529c8d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -31,7 +31,6 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Parcel; @@ -972,20 +971,12 @@ public final class ComposeActivity } private void initiateMediaPicking() { - Intent intent; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); - } else { - intent = new Intent(Intent.ACTION_GET_CONTENT); - } + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - intent.setType("image/* video/*"); - } else { - String[] mimeTypes = new String[]{"image/*", "video/*"}; - intent.setType("*/*"); - intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); - } + + String[] mimeTypes = new String[]{"image/*", "video/*"}; + intent.setType("*/*"); + intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); startActivityForResult(intent, MEDIA_PICK_RESULT); } @@ -1283,7 +1274,7 @@ public final class ComposeActivity super.onActivityResult(requestCode, resultCode, intent); if (resultCode == RESULT_OK && requestCode == MEDIA_PICK_RESULT && intent != null) { Uri uri = intent.getData(); - if (uri != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (uri != null) { // this is necessary so the SendTootService can access the uri later final int takeFlags = intent.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION; getContentResolver().takePersistableUriPermission(uri, takeFlags); diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java index db5c80f7..f18e3c7b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java @@ -17,7 +17,6 @@ package com.keylesspalace.tusky.adapter; import android.content.Context; import android.graphics.drawable.Drawable; -import android.os.Build; import android.support.annotation.Nullable; import android.view.View; import android.widget.ImageView; @@ -52,11 +51,8 @@ public class StatusViewHolder extends StatusBaseViewHolder { Context context = avatar.getContext(); boolean hasReblog = rebloggedUrl != null && !rebloggedUrl.isEmpty(); int padding = hasReblog ? Utils.dpToPx(context, 12) : 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - avatar.setPaddingRelative(0, 0, padding, padding); - } else { - avatar.setPadding(0, 0, padding, padding); - } + + avatar.setPaddingRelative(0, 0, padding, padding); if (hasReblog) { avatarReblog.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java b/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java index 5c4530df..858dc6e1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java @@ -89,21 +89,18 @@ public class NotificationHelper { currentNotifications = new JSONArray(); } - boolean alreadyContains = false; - for (int i = 0; i < currentNotifications.length(); i++) { try { if (currentNotifications.getString(i).equals(body.getAccount().getName())) { - alreadyContains = true; + currentNotifications.remove(i); + break; } } catch (JSONException e) { Log.d(TAG, Log.getStackTraceString(e)); } } - if (!alreadyContains) { - currentNotifications.put(body.getAccount().getName()); - } + currentNotifications.put(body.getAccount().getName()); account.setActiveNotifications(currentNotifications.toString());