Fix crash when drawing icon on older devices

Julien LepillerThu Jun 04 20:43:21+0200 2020

ebf8b66

Fix crash when drawing icon on older devices

CHANGELOG.md

88
99
* Do not highlight dictionaries that have not been downloaded, even if there is
1010
  a new version.
11+
* Fix a crash on older devices that was caused by incorrect handling of dictionary
12+
  icons.
1113
1214
Changes In 0.2.2.1
1315
------------------

app/src/main/java/eu/lepiller/nani/DictionaryDownloadActivity.java

66
import android.os.Build;
77
88
import androidx.core.app.NotificationCompat;
9-
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
109
import androidx.appcompat.app.AppCompatActivity;
1110
import android.os.Bundle;
1211
import android.util.Log;

156155
        if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
157156
            drawable = getResources().getDrawable(drawableResId, getTheme());
158157
        } else {
159-
            drawable = VectorDrawableCompat.create(getResources(), drawableResId, getTheme());
158+
            drawable = getResources().getDrawable(drawableResId);
160159
        }
161160
        download_button.setImageDrawable(drawable);
162161
    }

app/src/main/java/eu/lepiller/nani/dictionary/Dictionary.java

55
import android.os.Build;
66
import android.util.Pair;
77
8-
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
9-
108
import java.io.File;
119
import java.io.FileInputStream;
1210
import java.io.FileNotFoundException;

7876
        if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
7977
            drawable = context.getResources().getDrawable(drawableResId, context.getTheme());
8078
        } else {
81-
            drawable = VectorDrawableCompat.create(context.getResources(), drawableResId, context.getTheme());
79+
            drawable = context.getResources().getDrawable(drawableResId);
8280
        }
8381
        return drawable;
8482
    }