From 3eb8b6d4644a4774f1e1f1cc8c26fd78588ff04d Mon Sep 17 00:00:00 2001 From: Miku Nyan Date: Mon, 7 Dec 2015 23:34:49 +0300 Subject: [PATCH] switch to api 23 (Android 6.0) --- AndroidManifest.xml | 2 +- build.gradle | 7 ++- gradle.properties | 1 + project.properties | 2 +- .../http/recaptcha/Recaptcha2fallback.java | 3 +- .../DrawerArrowDrawable.java | 3 +- .../FixedSubsamplingScaleImageView.java | 3 +- .../lib/pullable_layout/CircleImageView.java | 3 +- .../pullable_layout/SwipeRefreshLayout.java | 5 +- .../miku/wishmaster/ui/CompatibilityImpl.java | 17 ++++++ .../miku/wishmaster/ui/ResourcesCompat23.java | 54 +++++++++++++++++++ .../ui/presentation/BoardFragment.java | 9 ++-- .../ui/presentation/HtmlParser.java | 3 +- 13 files changed, 94 insertions(+), 18 deletions(-) create mode 100644 gradle.properties create mode 100644 src/nya/miku/wishmaster/ui/ResourcesCompat23.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f0d7549a0..b27d04f2a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -31,7 +31,7 @@ along with this program. If not, see . + android:targetSdkVersion="23" /> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package nya.miku.wishmaster.ui; + +import android.content.res.ColorStateList; +import android.content.res.Resources; +import android.os.Build; +import android.widget.TextView; + +public class ResourcesCompat23 { + + @SuppressWarnings("deprecation") + public static int getColor(Resources resources, int id) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + return resources.getColor(id); + } else { + return CompatibilityImpl.getColor(resources, id); + } + } + + @SuppressWarnings("deprecation") + public static ColorStateList getColorStateList(Resources resources, int id) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + return resources.getColorStateList(id); + } else { + return CompatibilityImpl.getColorStateList(resources, id); + } + } + + @SuppressWarnings("deprecation") + public static void setTextAppearance(TextView textView, int resId) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + textView.setTextAppearance(textView.getContext(), resId); + } else { + CompatibilityImpl.setTextAppearance(textView, resId); + } + } +} diff --git a/src/nya/miku/wishmaster/ui/presentation/BoardFragment.java b/src/nya/miku/wishmaster/ui/presentation/BoardFragment.java index d05e99b98..3fa246895 100644 --- a/src/nya/miku/wishmaster/ui/presentation/BoardFragment.java +++ b/src/nya/miku/wishmaster/ui/presentation/BoardFragment.java @@ -66,6 +66,7 @@ import nya.miku.wishmaster.ui.GalleryActivity; import nya.miku.wishmaster.ui.MainActivity; import nya.miku.wishmaster.ui.QuickAccess; +import nya.miku.wishmaster.ui.ResourcesCompat23; import nya.miku.wishmaster.ui.downloading.DownloadingService; import nya.miku.wishmaster.ui.downloading.BackgroundThumbDownloader; import nya.miku.wishmaster.ui.posting.PostFormActivity; @@ -3303,7 +3304,7 @@ public void run() { final Button btnToSelecting = new Button(activity); btnToSelecting.setText(R.string.grid_gallery_select); - btnToSelecting.setTextAppearance(activity, android.R.style.TextAppearance_Small); + ResourcesCompat23.setTextAppearance(btnToSelecting, android.R.style.TextAppearance_Small); btnToSelecting.setSingleLine(); btnToSelecting.setVisibility(View.VISIBLE); btnToSelecting.setLayoutParams( @@ -3315,17 +3316,17 @@ public void run() { Button btnDownload = new Button(activity); btnDownload.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3.25f)); btnDownload.setText(R.string.grid_gallery_download); - btnDownload.setTextAppearance(activity, android.R.style.TextAppearance_Small); + ResourcesCompat23.setTextAppearance(btnDownload, android.R.style.TextAppearance_Small); btnDownload.setSingleLine(); Button btnSelectAll = new Button(activity); btnSelectAll.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3.75f)); btnSelectAll.setText(android.R.string.selectAll); - btnSelectAll.setTextAppearance(activity, android.R.style.TextAppearance_Small); + ResourcesCompat23.setTextAppearance(btnSelectAll, android.R.style.TextAppearance_Small); btnSelectAll.setSingleLine(); Button btnCancel = new Button(activity); btnCancel.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3f)); btnCancel.setText(android.R.string.cancel); - btnCancel.setTextAppearance(activity, android.R.style.TextAppearance_Small); + ResourcesCompat23.setTextAppearance(btnCancel, android.R.style.TextAppearance_Small); btnCancel.setSingleLine(); layoutSelectingButtons.addView(btnDownload); layoutSelectingButtons.addView(btnSelectAll); diff --git a/src/nya/miku/wishmaster/ui/presentation/HtmlParser.java b/src/nya/miku/wishmaster/ui/presentation/HtmlParser.java index e890ee4ae..f4945e63e 100644 --- a/src/nya/miku/wishmaster/ui/presentation/HtmlParser.java +++ b/src/nya/miku/wishmaster/ui/presentation/HtmlParser.java @@ -21,6 +21,7 @@ package nya.miku.wishmaster.ui.presentation; import android.graphics.Color; +import nya.miku.wishmaster.ui.ResourcesCompat23; import nya.miku.wishmaster.ui.presentation.ClickableURLSpan.URLSpanClickListener; import nya.miku.wishmaster.ui.presentation.ThemeUtils.ThemeColors; @@ -537,7 +538,7 @@ private static void endFont(SpannableStringBuilder text) { String name = f.mColor.substring(1); int colorRes = res.getIdentifier(name, "color", "android"); if (colorRes != 0) { - ColorStateList colors = res.getColorStateList(colorRes); + ColorStateList colors = ResourcesCompat23.getColorStateList(res, colorRes); text.setSpan(new TextAppearanceSpan(null, 0, 0, colors, null), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } else {