From 88b911139247915c6cde62d1ab515926c27cd919 Mon Sep 17 00:00:00 2001 From: h4h13 Date: Wed, 22 May 2019 09:45:01 +0530 Subject: [PATCH] Fix crashing --- app/build.gradle | 2 +- .../retromusic/activities/UserInfoActivity.kt | 43 ++++--------------- .../activities/WhatsNewActivity.java | 12 +++--- .../retromusic/helper/MusicPlayerRemote.kt | 4 +- .../monkey/retromusic/loaders/SongLoader.kt | 2 +- .../retromusic/views/UserImageView.java | 2 +- .../main/res/drawable/color_progress_seek.xml | 5 +-- 7 files changed, 20 insertions(+), 50 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2924be6e..3b70fa18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,7 +31,7 @@ android { vectorDrawables.useSupportLibrary = true applicationId "code.name.monkey.retromusic" - versionCode 323 + versionCode 324 versionName '3.1.700' multiDexEnabled true diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt index 108bf6f4..8c36a911 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt @@ -17,7 +17,6 @@ import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialValueHelper -import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.App import code.name.monkey.retromusic.Constants.USER_BANNER import code.name.monkey.retromusic.Constants.USER_PROFILE @@ -132,7 +131,7 @@ class UserInfoActivity : AbsBaseActivity() { if (PreferenceUtil.getInstance().bannerImage.isEmpty()) { val pickImageIntent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) pickImageIntent.type = "image/*" - pickImageIntent.putExtra("crop", "true") + //pickImageIntent.putExtra("crop", "true") pickImageIntent.putExtra("outputX", 1290) pickImageIntent.putExtra("outputY", 720) pickImageIntent.putExtra("aspectX", 16) @@ -162,10 +161,10 @@ class UserInfoActivity : AbsBaseActivity() { public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) - if (resultCode == Activity.RESULT_OK) { + if (resultCode == Activity.RESULT_OK && data != null) { when (requestCode) { PICK_IMAGE_REQUEST -> { - val uri = data!!.data + val uri = data.data try { val bitmap = getResizedBitmap(getBitmap(contentResolver, uri), PROFILE_ICON_SIZE) val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE) @@ -176,14 +175,14 @@ class UserInfoActivity : AbsBaseActivity() { } } CROP_IMAGE_REQUEST -> { - val extras: Bundle = data?.extras!! - val selectedBitmap: Bitmap = extras.getParcelable("data"); + val extras: Bundle = data.extras!! + val selectedBitmap: Bitmap = extras.getParcelable("data") val profileImagePath = saveToInternalStorage(selectedBitmap, USER_PROFILE) PreferenceUtil.getInstance().saveProfileImage(profileImagePath) loadImageFromStorage(profileImagePath) } PICK_BANNER_REQUEST -> { - val uri = data?.data + val uri = data.data try { val bitmap = getBitmap(contentResolver, uri) val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER) @@ -194,40 +193,14 @@ class UserInfoActivity : AbsBaseActivity() { } } CROP_BANNER_REQUEST -> { - val extras: Bundle = data?.extras!! - val selectedBitmap: Bitmap = extras.getParcelable("data"); + val extras: Bundle = data.extras!! + val selectedBitmap: Bitmap = extras.getParcelable("data") val profileImagePath = saveToInternalStorage(selectedBitmap, USER_BANNER) PreferenceUtil.getInstance().saveProfileImage(profileImagePath) loadImageFromStorage(profileImagePath) } } } - /*if (requestCode == PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK && data != null && data.data != null) { - val picturePath = data.data - performCrop(picturePath) - } else if (requestCode == CROP_IMAGE_REQUEST && resultCode == Activity.RESULT_OK && data != null && data.data != null) { - val uri = data.data - try { - val bitmap = ImageUtil.getResizedBitmap(Media.getBitmap(contentResolver, uri), PROFILE_ICON_SIZE) - val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE) - PreferenceUtil.getInstance().saveProfileImage(profileImagePath) - loadImageFromStorage(profileImagePath) - } catch (e: IOException) { - e.printStackTrace() - } - } else if (requestCode == PICK_BANNER_REQUEST && resultCode == Activity.RESULT_OK && data != null && - data.data != null) { - val uri = data.data - try { - val bitmap = Media.getBitmap(contentResolver, uri) - val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER) - PreferenceUtil.getInstance().setBannerImagePath(profileImagePath) - loadBannerFromStorage(profileImagePath) - } catch (e: IOException) { - e.printStackTrace() - } - - }*/ } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java index 8323aa98..42a3887e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java @@ -49,24 +49,22 @@ public class WhatsNewActivity extends AbsBaseActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_whats_new); - webView = findViewById(R.id.webView); - toolbar = findViewById(R.id.toolbar); - appBarLayout = findViewById(R.id.appBarLayout); - - setStatusbarColorAuto(); setNavigationbarColorAuto(); setTaskDescriptionColorAuto(); + webView = findViewById(R.id.webView); + toolbar = findViewById(R.id.toolbar); + appBarLayout = findViewById(R.id.appBarLayout); + toolbar.setBackgroundColor(ThemeStore.Companion.primaryColor(this)); appBarLayout.setBackgroundColor(ThemeStore.Companion.primaryColor(this)); - setSupportActionBar(toolbar); + //setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(v -> onBackPressed()); ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.Companion.textColorSecondary(this)); try { - // Load from phonograph-changelog.html in the assets folder StringBuilder buf = new StringBuilder(); InputStream json = getAssets().open("retro-changelog.html"); BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8)); diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt index cf3e33f8..3b65f126 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt @@ -135,7 +135,7 @@ object MusicPlayerRemote { var cursor: Cursor? = null try { cursor = context.contentResolver.query(uri, projection, null, null, null) - cursor.use { it -> + cursor.use { if (it.moveToFirst()) { val columnIndex = it.getColumnIndexOrThrow(column) return it.getString(columnIndex) @@ -405,7 +405,7 @@ object MusicPlayerRemote { )).blockingFirst() } } - if (songs != null && !songs.isEmpty()) { + if (songs != null && songs.isNotEmpty()) { openQueue(songs, 0, true) } else { //TODO the file is not listed in the media store diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt index 2d693a81..6649fb3b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt @@ -89,7 +89,7 @@ object SongLoader { // Blacklist val paths = BlacklistStore.getInstance(context).paths - if (!paths.isEmpty()) { + if (paths.isNotEmpty()) { selectionFinal = generateBlacklistSelection(selectionFinal, paths.size) selectionValuesFinal = addBlacklistSelectionValues(selectionValuesFinal, paths) } diff --git a/app/src/main/java/code/name/monkey/retromusic/views/UserImageView.java b/app/src/main/java/code/name/monkey/retromusic/views/UserImageView.java index 8c7a3f63..51df25eb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/UserImageView.java +++ b/app/src/main/java/code/name/monkey/retromusic/views/UserImageView.java @@ -90,7 +90,7 @@ public class UserImageView extends CircularImageView implements SharedPreference @Override public void getSize(@NonNull SizeReadyCallback cb) { - cb.onSizeReady(32, 32); + cb.onSizeReady(96, 96); } @Override diff --git a/app/src/main/res/drawable/color_progress_seek.xml b/app/src/main/res/drawable/color_progress_seek.xml index 314913b8..5386ffb4 100755 --- a/app/src/main/res/drawable/color_progress_seek.xml +++ b/app/src/main/res/drawable/color_progress_seek.xml @@ -5,13 +5,12 @@ - - + - + \ No newline at end of file