Fix crashing

main
h4h13 2019-05-22 09:45:01 +05:30
parent c4513eee9e
commit 88b9111392
7 changed files with 20 additions and 50 deletions

View File

@ -31,7 +31,7 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 323 versionCode 324
versionName '3.1.700' versionName '3.1.700'
multiDexEnabled true multiDexEnabled true

View File

@ -17,7 +17,6 @@ import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper 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.App
import code.name.monkey.retromusic.Constants.USER_BANNER import code.name.monkey.retromusic.Constants.USER_BANNER
import code.name.monkey.retromusic.Constants.USER_PROFILE import code.name.monkey.retromusic.Constants.USER_PROFILE
@ -132,7 +131,7 @@ class UserInfoActivity : AbsBaseActivity() {
if (PreferenceUtil.getInstance().bannerImage.isEmpty()) { if (PreferenceUtil.getInstance().bannerImage.isEmpty()) {
val pickImageIntent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) val pickImageIntent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
pickImageIntent.type = "image/*" pickImageIntent.type = "image/*"
pickImageIntent.putExtra("crop", "true") //pickImageIntent.putExtra("crop", "true")
pickImageIntent.putExtra("outputX", 1290) pickImageIntent.putExtra("outputX", 1290)
pickImageIntent.putExtra("outputY", 720) pickImageIntent.putExtra("outputY", 720)
pickImageIntent.putExtra("aspectX", 16) pickImageIntent.putExtra("aspectX", 16)
@ -162,10 +161,10 @@ class UserInfoActivity : AbsBaseActivity() {
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK && data != null) {
when (requestCode) { when (requestCode) {
PICK_IMAGE_REQUEST -> { PICK_IMAGE_REQUEST -> {
val uri = data!!.data val uri = data.data
try { try {
val bitmap = getResizedBitmap(getBitmap(contentResolver, uri), PROFILE_ICON_SIZE) val bitmap = getResizedBitmap(getBitmap(contentResolver, uri), PROFILE_ICON_SIZE)
val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE) val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE)
@ -176,14 +175,14 @@ class UserInfoActivity : AbsBaseActivity() {
} }
} }
CROP_IMAGE_REQUEST -> { CROP_IMAGE_REQUEST -> {
val extras: Bundle = data?.extras!! val extras: Bundle = data.extras!!
val selectedBitmap: Bitmap = extras.getParcelable("data"); val selectedBitmap: Bitmap = extras.getParcelable("data")
val profileImagePath = saveToInternalStorage(selectedBitmap, USER_PROFILE) val profileImagePath = saveToInternalStorage(selectedBitmap, USER_PROFILE)
PreferenceUtil.getInstance().saveProfileImage(profileImagePath) PreferenceUtil.getInstance().saveProfileImage(profileImagePath)
loadImageFromStorage(profileImagePath) loadImageFromStorage(profileImagePath)
} }
PICK_BANNER_REQUEST -> { PICK_BANNER_REQUEST -> {
val uri = data?.data val uri = data.data
try { try {
val bitmap = getBitmap(contentResolver, uri) val bitmap = getBitmap(contentResolver, uri)
val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER) val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER)
@ -194,40 +193,14 @@ class UserInfoActivity : AbsBaseActivity() {
} }
} }
CROP_BANNER_REQUEST -> { CROP_BANNER_REQUEST -> {
val extras: Bundle = data?.extras!! val extras: Bundle = data.extras!!
val selectedBitmap: Bitmap = extras.getParcelable("data"); val selectedBitmap: Bitmap = extras.getParcelable("data")
val profileImagePath = saveToInternalStorage(selectedBitmap, USER_BANNER) val profileImagePath = saveToInternalStorage(selectedBitmap, USER_BANNER)
PreferenceUtil.getInstance().saveProfileImage(profileImagePath) PreferenceUtil.getInstance().saveProfileImage(profileImagePath)
loadImageFromStorage(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()
}
}*/
} }

View File

@ -49,24 +49,22 @@ public class WhatsNewActivity extends AbsBaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_whats_new); setContentView(R.layout.activity_whats_new);
webView = findViewById(R.id.webView);
toolbar = findViewById(R.id.toolbar);
appBarLayout = findViewById(R.id.appBarLayout);
setStatusbarColorAuto(); setStatusbarColorAuto();
setNavigationbarColorAuto(); setNavigationbarColorAuto();
setTaskDescriptionColorAuto(); setTaskDescriptionColorAuto();
webView = findViewById(R.id.webView);
toolbar = findViewById(R.id.toolbar);
appBarLayout = findViewById(R.id.appBarLayout);
toolbar.setBackgroundColor(ThemeStore.Companion.primaryColor(this)); toolbar.setBackgroundColor(ThemeStore.Companion.primaryColor(this));
appBarLayout.setBackgroundColor(ThemeStore.Companion.primaryColor(this)); appBarLayout.setBackgroundColor(ThemeStore.Companion.primaryColor(this));
setSupportActionBar(toolbar); //setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> onBackPressed()); toolbar.setNavigationOnClickListener(v -> onBackPressed());
ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.Companion.textColorSecondary(this)); ToolbarContentTintHelper.colorBackButton(toolbar, ThemeStore.Companion.textColorSecondary(this));
try { try {
// Load from phonograph-changelog.html in the assets folder
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
InputStream json = getAssets().open("retro-changelog.html"); InputStream json = getAssets().open("retro-changelog.html");
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8)); BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));

View File

@ -135,7 +135,7 @@ object MusicPlayerRemote {
var cursor: Cursor? = null var cursor: Cursor? = null
try { try {
cursor = context.contentResolver.query(uri, projection, null, null, null) cursor = context.contentResolver.query(uri, projection, null, null, null)
cursor.use { it -> cursor.use {
if (it.moveToFirst()) { if (it.moveToFirst()) {
val columnIndex = it.getColumnIndexOrThrow(column) val columnIndex = it.getColumnIndexOrThrow(column)
return it.getString(columnIndex) return it.getString(columnIndex)
@ -405,7 +405,7 @@ object MusicPlayerRemote {
)).blockingFirst() )).blockingFirst()
} }
} }
if (songs != null && !songs.isEmpty()) { if (songs != null && songs.isNotEmpty()) {
openQueue(songs, 0, true) openQueue(songs, 0, true)
} else { } else {
//TODO the file is not listed in the media store //TODO the file is not listed in the media store

View File

@ -89,7 +89,7 @@ object SongLoader {
// Blacklist // Blacklist
val paths = BlacklistStore.getInstance(context).paths val paths = BlacklistStore.getInstance(context).paths
if (!paths.isEmpty()) { if (paths.isNotEmpty()) {
selectionFinal = generateBlacklistSelection(selectionFinal, paths.size) selectionFinal = generateBlacklistSelection(selectionFinal, paths.size)
selectionValuesFinal = addBlacklistSelectionValues(selectionValuesFinal, paths) selectionValuesFinal = addBlacklistSelectionValues(selectionValuesFinal, paths)
} }

View File

@ -90,7 +90,7 @@ public class UserImageView extends CircularImageView implements SharedPreference
@Override @Override
public void getSize(@NonNull SizeReadyCallback cb) { public void getSize(@NonNull SizeReadyCallback cb) {
cb.onSizeReady(32, 32); cb.onSizeReady(96, 96);
} }
@Override @Override

View File

@ -5,13 +5,12 @@
<solid android:color="?android:colorButtonNormal" /> <solid android:color="?android:colorButtonNormal" />
</shape> </shape>
</item> </item>
<item android:id="@android:id/progress"> <item android:id="@android:id/progress">
<scale android:scaleWidth="100%"> <clip>
<shape> <shape>
<corners android:radius="8dp" /> <corners android:radius="8dp" />
<solid android:color="@color/md_black_1000" /> <solid android:color="@color/md_black_1000" />
</shape> </shape>
</scale> </clip>
</item> </item>
</layer-list> </layer-list>