Skip to content

Commit

Permalink
Fix or ignore deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
frknkrc44 committed Sep 9, 2024
1 parent df32457 commit a23b991
Show file tree
Hide file tree
Showing 24 changed files with 182 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ImageDecoder;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
Expand All @@ -36,6 +37,7 @@
import java.io.File;
import java.util.concurrent.Executors;

@SuppressWarnings("deprecation")
public final class AppSettingsV2 extends Activity {
private LinearLayout main;
public SuperBoard kbdPreview;
Expand Down Expand Up @@ -172,9 +174,15 @@ public void execute(Object... args) {
});
}

@SuppressWarnings("deprecation")
protected Bitmap doInBackground(Object[] p1) {
try {
return MediaStore.Images.Media.getBitmap((ContentResolver) p1[0], (Uri) p1[1]);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ImageDecoder.Source decoder = ImageDecoder.createSource((ContentResolver) p1[0], (Uri) p1[1]);
return ImageDecoder.decodeBitmap(decoder);
} else {
return MediaStore.Images.Media.getBitmap((ContentResolver) p1[0], (Uri) p1[1]);
}
} catch (Throwable ignored) {
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import org.blinksd.board.views.CustomRadioButton;
import org.blinksd.board.views.SettingsCategorizedListAdapter;
import org.blinksd.utils.DensityUtils;
import org.blinksd.utils.DrawableUtils;
import org.blinksd.utils.LayoutCreator;
import org.blinksd.utils.ResourcesUtils;
import org.blinksd.utils.SuperDBHelper;
import org.blinksd.utils.ThemeUtils;
import org.json.JSONException;
Expand All @@ -52,6 +54,7 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

@SuppressWarnings("deprecation")
public final class BackupRestoreActivity extends Activity {
private LinearLayout main;
private TabHost host;
Expand Down Expand Up @@ -384,8 +387,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Drawable doneIcon = getResources().getDrawable(R.drawable.sym_board_return);
doneIcon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
Drawable doneIcon = ResourcesUtils.getDrawable(R.drawable.sym_board_return);
DrawableUtils.setColorFilter(doneIcon, Color.WHITE);
MenuItem done = menu.add(android.R.string.ok).setIcon(doneIcon);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.InputStream;
import java.util.concurrent.Executors;

@SuppressWarnings("deprecation")
public final class DictionaryImportActivity extends Activity {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import org.blinksd.utils.SettingMap;
import org.blinksd.utils.SuperDBHelper;
import org.blinksd.utils.TextUtilsCompat;
import org.blinksd.utils.ViewUtils;
import org.blinksd.utils.superboard.TextType;

@SuppressWarnings("deprecation")
public final class FontSelector extends Activity implements View.OnClickListener {
public static final int FONT_SELECTOR_RESULT = 0xFF;
private String[] fontTypeTranslations;
Expand Down Expand Up @@ -91,7 +93,7 @@ private View createFontItemLayout(TextType value, int i, int j, int rowCount, in
description.setSingleLine();
description.setEllipsize(TextUtils.TruncateAt.END);
btn.addView(description);
btn.setBackgroundDrawable(LayoutUtils.getSelectableItemBg(
ViewUtils.setBackground(btn, LayoutUtils.getSelectableItemBg(
this,
textView.getCurrentTextColor(),
currentFont == currentIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
Expand All @@ -22,16 +21,19 @@
import org.blinksd.board.SuperBoardApplication;
import org.blinksd.board.views.SuperBoard;
import org.blinksd.utils.DensityUtils;
import org.blinksd.utils.DrawableUtils;
import org.blinksd.utils.LayoutCreator;
import org.blinksd.utils.LayoutUtils;
import org.blinksd.utils.SettingMap;
import org.blinksd.utils.SuperDBHelper;
import org.blinksd.utils.ViewUtils;
import org.blinksd.utils.superboard.Language;
import org.blinksd.utils.superboard.RowOptions;

import java.util.Map;
import java.util.Objects;

@SuppressWarnings("deprecation")
public final class KeyboardLayoutSelector extends Activity implements View.OnClickListener {
public static final int KEYBOARD_LAYOUT_SELECTOR_RESULT = 0xFF;
private String currentLayout;
Expand Down Expand Up @@ -122,15 +124,15 @@ private View createItemLayout(Language language) {
View view = new View(this);
view.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
view.setOnClickListener(this);
view.setBackgroundDrawable(LayoutUtils.getSelectableItemBg(
ViewUtils.setBackground(view, LayoutUtils.getSelectableItemBg(
this,
Color.WHITE,
false,
true
));

boolean isSelected = currentLayout.equals(language.language);
btn.setBackgroundDrawable(LayoutUtils.getSelectableItemBg(
ViewUtils.setBackground(btn, LayoutUtils.getSelectableItemBg(
this,
Color.WHITE,
isSelected
Expand All @@ -146,10 +148,10 @@ private View createItemLayout(Language language) {
tick.setLayoutParams(params);
int p = tickSize / 8;
tick.setPadding(p, p, p, p);
tick.setBackgroundDrawable(LayoutUtils.getCircleButtonBackground(false));
ViewUtils.setBackground(tick, LayoutUtils.getCircleButtonBackground(false));
tick.setScaleType(ImageView.ScaleType.FIT_CENTER);
tick.setImageResource(R.drawable.sym_board_return);
tick.getDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
DrawableUtils.setColorFilter(tick.getDrawable(), Color.WHITE);
layers.addView(tick);
}

Expand Down
23 changes: 13 additions & 10 deletions app/src/main/java/org/blinksd/board/activities/SetupActivityV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@

import org.blinksd.board.R;
import org.blinksd.utils.DensityUtils;
import org.blinksd.utils.DrawableUtils;
import org.blinksd.utils.LayoutUtils;
import org.blinksd.utils.ViewUtils;

import java.util.ArrayList;

/** @noinspection NullableProblems*/
@SuppressWarnings("deprecation")
public final class SetupActivityV2 extends Activity {

private final ArrayList<PageContent> pageContents = new ArrayList<>();
Expand Down Expand Up @@ -63,8 +66,8 @@ protected void onCreate(Bundle savedInstanceState) {
));

pageContents.add(new PageContent(
LayoutUtils.getDrawableCompat(
this, R.drawable.sym_keyboard_language, Color.WHITE),
DrawableUtils.getTintedDrawable(
R.drawable.sym_keyboard_language, Color.WHITE),
R.string.wizard_enable,
R.string.wizard_enablebtn,
v -> {
Expand All @@ -76,8 +79,8 @@ protected void onCreate(Bundle savedInstanceState) {
));

pageContents.add(new PageContent(
LayoutUtils.getDrawableCompat(
this, R.drawable.sym_keyboard_language, Color.WHITE),
DrawableUtils.getTintedDrawable(
R.drawable.sym_keyboard_language, Color.WHITE),
R.string.wizard_select,
R.string.wizard_selectbtn,
v -> {
Expand All @@ -93,8 +96,8 @@ protected void onCreate(Bundle savedInstanceState) {
));

pageContents.add(new PageContent(
LayoutUtils.getDrawableCompat(
this, R.drawable.sym_keyboard_language, Color.WHITE),
DrawableUtils.getTintedDrawable(
R.drawable.sym_keyboard_language, Color.WHITE),
R.string.wizard_settings,
R.string.wizard_settingsbtn,
v -> startActivity(new Intent(v.getContext(), AppSettingsV2.class)),
Expand All @@ -103,8 +106,8 @@ protected void onCreate(Bundle savedInstanceState) {
));

pageContents.add(new PageContent(
LayoutUtils.getDrawableCompat(
this, R.drawable.sym_board_return, Color.WHITE),
DrawableUtils.getTintedDrawable(
R.drawable.sym_board_return, Color.WHITE),
R.string.wizard_finish,
R.string.wizard_finishbtn,
v -> finish(),
Expand Down Expand Up @@ -294,7 +297,7 @@ private ImageTextAndButtonView(Context context, PageContent content) {
}
textView.setGravity(Gravity.CENTER);

buttonView.setBackgroundDrawable(
ViewUtils.setBackground(buttonView,
LayoutUtils.getSelectableItemBg(context, buttonView.getCurrentTextColor()));

imageView.setImageDrawable(content.image);
Expand All @@ -308,7 +311,7 @@ private ImageTextAndButtonView(Context context, PageContent content) {
buttonParams = new LayoutParams(buttonParams.width, buttonParams.height);
buttonParams.topMargin = padding;
nextButton.setLayoutParams(buttonParams);
nextButton.setBackgroundDrawable(LayoutUtils.getSelectableItemBg(
ViewUtils.setBackground(nextButton, LayoutUtils.getSelectableItemBg(
context, buttonView.getCurrentTextColor()));
nextButton.setOnClickListener(v -> changePage(currentPage + 1));
nextButton.setText(R.string.wizard_nextbtn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Parcel;
import android.os.Parcelable;

@SuppressWarnings("deprecation")
public final class ResourceParcel implements Parcelable {
public static final Parcelable.Creator<ResourceParcel> CREATOR
= new Parcelable.Creator<ResourceParcel>() {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/org/blinksd/board/views/ClipboardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.blinksd.utils.LayoutUtils;
import org.blinksd.utils.SettingMap;
import org.blinksd.utils.SuperDBHelper;
import org.blinksd.utils.ViewUtils;
import org.frknkrc44.minidb.SuperMiniDB;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -75,7 +76,7 @@ private void init() {
textColor = ColorUtils.convertARGBtoRGB(textColor);

clearAllButton = new ImageButton(getContext());
clearAllButton.setBackgroundDrawable(LayoutUtils.getTransSelectableItemBg(
ViewUtils.setBackground(clearAllButton, LayoutUtils.getTransSelectableItemBg(
getContext(), textColor, false));
LinearLayout.LayoutParams buttonParams =
new LinearLayout.LayoutParams(buttonSize, buttonSize, 0);
Expand Down Expand Up @@ -144,7 +145,7 @@ private void addClipView(String text, boolean addToHistory) {
textView2.setTextColor(ColorUtils.setAlphaForColor(0x88, textColor));

ImageButton button = new ImageButton(getContext());
button.setBackgroundDrawable(LayoutUtils.getTransSelectableItemBg(
ViewUtils.setBackground(button, LayoutUtils.getTransSelectableItemBg(
getContext(), textColor, false));
button.setLayoutParams(new LinearLayout.LayoutParams(buttonSize, buttonSize, 0));
button.setScaleType(ImageView.ScaleType.FIT_CENTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import android.widget.TextView;

Expand Down Expand Up @@ -103,7 +102,7 @@ public ColorSelectorLayout(Context ctx, int colorValue) {
host.setup();

for (int i = 0; i < tabTitles.length; i++) {
TabSpec ts = host.newTabSpec(tabTitles[i]);
TabHost.TabSpec ts = host.newTabSpec(tabTitles[i]);
TextView tv = (TextView) LayoutInflater.from(ctx).inflate(android.R.layout.simple_list_item_1, widget, false);
LinearLayout.LayoutParams pr = (LinearLayout.LayoutParams) LayoutCreator.createLayoutParams(LinearLayout.class, -1, DensityUtils.dpInt(48));
pr.weight = tabTitles.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.widget.RadioButton;

import org.blinksd.utils.DensityUtils;
import org.blinksd.utils.DrawableUtils;

import java.lang.reflect.Field;

Expand All @@ -26,7 +27,7 @@ public CustomRadioButton(Context c) {
return;
}

drw.setColorFilter(0xFFDEDEDE, PorterDuff.Mode.SRC_IN);
DrawableUtils.setColorFilter(drw, 0xFFDEDEDE);

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
setPadding(i + drw.getIntrinsicWidth(), 0, i, 0);
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/org/blinksd/board/views/CustomSeekBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
Expand All @@ -17,6 +16,8 @@

import org.blinksd.board.R;
import org.blinksd.utils.DensityUtils;
import org.blinksd.utils.DrawableUtils;
import org.blinksd.utils.ResourcesUtils;

import java.lang.reflect.Field;

Expand All @@ -42,9 +43,9 @@ void drawSeekBar() {
p.setColor(color);
RectF r = new RectF(0, 0, b.getWidth(), b.getHeight());
c.drawOval(r, p);
setThumb(new BitmapDrawable(b));
Drawable ld = getResources().getDrawable(R.drawable.pbar);
ld.setColorFilter(p.getColor(), PorterDuff.Mode.SRC_ATOP);
setThumb(new BitmapDrawable(getResources(), b));
Drawable ld = ResourcesUtils.getDrawable(R.drawable.pbar);
DrawableUtils.setColorFilter(ld, p.getColor());
setProgressDrawable(ld);
} else {
int color = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/org/blinksd/board/views/EmojiView.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import android.widget.TextView;

Expand Down Expand Up @@ -141,7 +140,7 @@ private void apply() {
th.addView(ll);
th.setup();
for (int i = 0; i < emojis.length; i++) {
TabSpec ts = th.newTabSpec(emojis[i][0]);
TabHost.TabSpec ts = th.newTabSpec(emojis[i][0]);
TextView tv = (TextView) LayoutInflater.from(getContext()).inflate(android.R.layout.simple_list_item_1, tw, false);
tv.setLayoutParams(new LayoutParams(-1, l, 1));
tv.setText(emojis[i][0].trim());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -173,7 +172,7 @@ public void setImageBitmap(Bitmap b) {
host.setup();

for (int i = 0; i < tabTitles.length; i++) {
TabSpec ts = host.newTabSpec(tabTitles[i]);
TabHost.TabSpec ts = host.newTabSpec(tabTitles[i]);
TextView tv = (TextView) LayoutInflater.from(win.getContext())
.inflate(android.R.layout.simple_list_item_1, widget, false);
LinearLayout.LayoutParams pr = (LinearLayout.LayoutParams)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.blinksd.utils.DensityUtils;
import org.blinksd.utils.LayoutCreator;

@SuppressWarnings("deprecation")
public final class NumberSelectorLayout {
private NumberSelectorLayout() {}

Expand All @@ -25,7 +26,11 @@ public static View getNumberSelectorLayout(final AppSettingsV2 ctx, final boolea
lp.bottomMargin = DensityUtils.dpInt(8);
text.setLayoutParams(lp);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
text.setTextAppearance(ctx, android.R.style.TextAppearance_DeviceDefault_Medium);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
text.setTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
} else {
text.setTextAppearance(ctx, android.R.style.TextAppearance_DeviceDefault_Medium);
}
}
text.setText(getProgressString(val, isFloat));
main.addView(text);
Expand Down
Loading

0 comments on commit a23b991

Please sign in to comment.