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 {