diff options
author | Chris Koying Browet <cbro@semperpax.com> | 2016-09-14 13:21:26 +0200 |
---|---|---|
committer | Chris Koying Browet <cbro@semperpax.com> | 2016-10-26 10:54:29 +0200 |
commit | 52b22ba7d6eed3da9b1c03aeb5597fefaef5ce96 (patch) | |
tree | df56786ebef51fde5c4a30b801352ecb3a361ab6 | |
parent | 9a7fc35b4c4a9db124d9659e8b34b695e68af100 (diff) |
FIX: [droid;apps] handles missing res icon
-rw-r--r-- | xbmc/filesystem/AndroidAppFile.cpp | 35 | ||||
-rw-r--r-- | xbmc/platform/android/jni/Bitmap.h | 6 | ||||
-rw-r--r-- | xbmc/platform/android/jni/JNIBase.h | 1 |
3 files changed, 26 insertions, 16 deletions
diff --git a/xbmc/filesystem/AndroidAppFile.cpp b/xbmc/filesystem/AndroidAppFile.cpp index 14819ea2a3..3905689cbf 100644 --- a/xbmc/filesystem/AndroidAppFile.cpp +++ b/xbmc/filesystem/AndroidAppFile.cpp @@ -88,25 +88,34 @@ unsigned int CFileAndroidApp::ReadIcon(unsigned char** lpBuf, unsigned int* widt { JNIEnv* env = xbmc_jnienv(); void *bitmapBuf = NULL; + int densities[] = { CJNIDisplayMetrics::DENSITY_XXXHIGH, CJNIDisplayMetrics::DENSITY_XXHIGH, CJNIDisplayMetrics::DENSITY_XHIGH, -1 }; - CJNIBitmapDrawable bmp; + CJNIBitmap bmp; if (CJNIBuild::SDK_INT >= 15 && m_icon) { - int density = CJNIDisplayMetrics::DENSITY_XHIGH; - if (CJNIBuild::SDK_INT >= 18) - density = CJNIDisplayMetrics::DENSITY_XXXHIGH; - else if (CJNIBuild::SDK_INT >= 16) - density = CJNIDisplayMetrics::DENSITY_XXHIGH; CJNIResources res = CJNIContext::GetPackageManager().getResourcesForApplication(m_packageName); if (res) - bmp = res.getDrawableForDensity(m_icon, density); + { + for (int i=0; densities[i] != -1 && !bmp; ++i) + { + int density = densities[i]; + CJNIBitmapDrawable resbmp = res.getDrawableForDensity(m_icon, density); + if (xbmc_jnienv()->ExceptionCheck()) + xbmc_jnienv()->ExceptionClear(); + else + if (resbmp.getBitmap()) + bmp = resbmp.getBitmap(); + } + } } - else - bmp = (CJNIBitmapDrawable)CJNIContext::GetPackageManager().getApplicationIcon(m_packageName); - CJNIBitmap bitmap(bmp.getBitmap()); + if (!bmp) + bmp = ((CJNIBitmapDrawable)(CJNIContext::GetPackageManager().getApplicationIcon(m_packageName))).getBitmap(); + if (!bmp) + return 0; + AndroidBitmapInfo info; - AndroidBitmap_getInfo(env, bitmap.get_raw(), &info); + AndroidBitmap_getInfo(env, bmp.get_raw(), &info); if (!info.width || !info.height) return 0; @@ -116,11 +125,11 @@ unsigned int CFileAndroidApp::ReadIcon(unsigned char** lpBuf, unsigned int* widt int imgsize = *width * *height * 4; *lpBuf = new unsigned char[imgsize]; - AndroidBitmap_lockPixels(env, bitmap.get_raw(), &bitmapBuf); + AndroidBitmap_lockPixels(env, bmp.get_raw(), &bitmapBuf); if (bitmapBuf) { memcpy(*lpBuf, bitmapBuf, imgsize); - AndroidBitmap_unlockPixels(env, bitmap.get_raw()); + AndroidBitmap_unlockPixels(env, bmp.get_raw()); return imgsize; } return 0; diff --git a/xbmc/platform/android/jni/Bitmap.h b/xbmc/platform/android/jni/Bitmap.h index 81b4d0880f..bf047d714a 100644 --- a/xbmc/platform/android/jni/Bitmap.h +++ b/xbmc/platform/android/jni/Bitmap.h @@ -24,7 +24,7 @@ class CJNIBitmap : public CJNIBase { public: - CJNIBitmap(); - CJNIBitmap(const jni::jhobject &object) : CJNIBase(object) {}; - ~CJNIBitmap() {}; + CJNIBitmap() {} + CJNIBitmap(const jni::jhobject &object) : CJNIBase(object) {} + ~CJNIBitmap() {} }; diff --git a/xbmc/platform/android/jni/JNIBase.h b/xbmc/platform/android/jni/JNIBase.h index 3f567202a5..f60939333e 100644 --- a/xbmc/platform/android/jni/JNIBase.h +++ b/xbmc/platform/android/jni/JNIBase.h @@ -33,6 +33,7 @@ public: static int GetSDKVersion(); protected: + CJNIBase() {} CJNIBase(jni::jhobject const& object); CJNIBase(std::string classname); ~CJNIBase(); |