Skip to content

Commit

Permalink
Merge pull request #1176 from prathameshmm02/dev
Browse files Browse the repository at this point in the history
Bug Fixes & Improvements
  • Loading branch information
Daksh777 committed Dec 1, 2021
2 parents be46012 + b6509de commit 6924e5d
Show file tree
Hide file tree
Showing 137 changed files with 1,042 additions and 1,836 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {

defaultConfig {
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31

renderscriptTargetApi 29//must match target sdk and build tools
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -126,7 +126,7 @@ dependencies {
def retrofit_version = '2.9.0'
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.3'

def material_dialog_version = "3.3.0"
implementation "com.afollestad.material-dialogs:core:$material_dialog_version"
Expand All @@ -142,7 +142,7 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"

def koin_version = '3.1.3'
def koin_version = '3.1.4'
implementation "io.insert-koin:koin-core:$koin_version"
implementation "io.insert-koin:koin-android:$koin_version"

Expand All @@ -157,7 +157,7 @@ dependencies {
implementation 'com.anjlab.android.iab.v3:library:2.0.3'
implementation 'com.r0adkll:slidableactivity:2.1.0'
implementation 'com.heinrichreimersoftware:material-intro:2.0.0'
implementation 'com.github.dhaval2404:imagepicker:1.7.1'
implementation 'com.github.dhaval2404:imagepicker:2.1'
implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
implementation 'cat.ereza:customactivityoncrash:2.3.0'
debugImplementation 'com.github.amitshekhariitbhu:Android-Debug-Database:1.0.6'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
android:enabled="true"
android:exported="true"
android:label="@string/app_name"
android:foregroundServiceType="mediaPlayback"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/code/name/monkey/retromusic/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ object Constants {
const val IS_MUSIC =
MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"

@Suppress("Deprecation")
val baseProjection = arrayOf(
BaseColumns._ID, // 0
MediaStore.Audio.AudioColumns.TITLE, // 1
Expand Down Expand Up @@ -118,6 +119,8 @@ const val ALBUM_GRID_SIZE_LAND = "album_grid_size_land"
const val SONG_GRID_SIZE_LAND = "song_grid_size_land"
const val ARTIST_GRID_SIZE = "artist_grid_size"
const val ARTIST_GRID_SIZE_LAND = "artist_grid_size_land"
const val PLAYLIST_GRID_SIZE = "playlist_grid_size"
const val PLAYLIST_GRID_SIZE_LAND = "playlist_grid_size_land"
const val COLORED_APP_SHORTCUTS = "colored_app_shortcuts"
const val AUDIO_DUCKING = "audio_ducking"
const val LAST_ADDED_CUTOFF = "last_added_interval"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,10 @@ public static LanguageContextWrapper wrap(Context context, Locale newLocale) {
LocaleList localeList = new LocaleList(newLocale);
LocaleList.setDefault(localeList);
configuration.setLocales(localeList);

context = context.createConfigurationContext(configuration);

} else if (VersionUtils.INSTANCE.hasLollipop()) {
configuration.setLocale(newLocale);
context = context.createConfigurationContext(configuration);

} else {
configuration.locale = newLocale;
res.updateConfiguration(configuration, res.getDisplayMetrics());
configuration.setLocale(newLocale);
}

context = context.createConfigurationContext(configuration);
return new LanguageContextWrapper(context);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
}
}

@Suppress("Deprecation")
private fun lockScreenInit() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
permissionDeniedMessage!!,
Snackbar.LENGTH_INDEFINITE
)
.setAction(code.name.monkey.retromusic.R.string.action_grant) { requestPermissions() }
.setAction(R.string.action_grant) { requestPermissions() }
.setActionTextColor(ThemeStore.accentColor(this)).show()
} else {
// User has deny permission and checked never show permission dialog so you can redirect to Application settings page
Snackbar.make(
snackBarContainer,
permissionDeniedMessage!!,
Snackbar.LENGTH_INDEFINITE
).setAction(code.name.monkey.retromusic.R.string.action_settings) {
).setAction(R.string.action_settings) {
val intent = Intent()
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
val uri = Uri.fromParts(
Expand Down Expand Up @@ -172,7 +172,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
v.getGlobalVisibleRect(outRect)
if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
v.clearFocus()
val imm = getSystemService<InputMethodManager>()?.hideSoftInputFromWindow(v.windowToken, 0)
getSystemService<InputMethodManager>()?.hideSoftInputFromWindow(v.windowToken, 0)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import android.view.WindowManager
import androidx.annotation.ColorInt
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
import androidx.core.os.ConfigurationCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import code.name.monkey.appthemehelper.ATH
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
Expand Down Expand Up @@ -118,12 +120,11 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
if (statusBar != null) {
when {
VersionUtils.hasMarshmallow() -> statusBar.setBackgroundColor(color)
VersionUtils.hasLollipop() -> statusBar.setBackgroundColor(
else -> statusBar.setBackgroundColor(
ColorUtil.darkenColor(
color
)
)
else -> statusBar.setBackgroundColor(color)
}
} else {
when {
Expand Down Expand Up @@ -193,16 +194,20 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
}

private fun setImmersiveFullscreen() {
val flags =
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)

if (PreferenceUtil.isFullScreenMode) {
window.decorView.systemUiVisibility = flags
WindowInsetsControllerCompat(window, window.decorView).apply {
systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
hide(WindowInsetsCompat.Type.systemBars())
}
}
}

private fun exitFullscreen() {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
WindowInsetsControllerCompat(window, window.decorView).apply {
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
show(WindowInsetsCompat.Type.systemBars())
}
}

override fun run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.os.Build;

import androidx.annotation.IntRange;
import androidx.annotation.NonNull;

import java.util.Arrays;
import java.util.Locale;
Expand All @@ -16,19 +17,16 @@
public class DeviceInfo {

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private final String[] abis =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
? Build.SUPPORTED_ABIS
: new String[] {Build.CPU_ABI, Build.CPU_ABI2};
Build.SUPPORTED_ABIS;

@SuppressLint("NewApi")
private final String[] abis32Bits =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_32_BIT_ABIS : null;
Build.SUPPORTED_32_BIT_ABIS;

@SuppressLint("NewApi")
private final String[] abis64Bits =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_64_BIT_ABIS : null;
Build.SUPPORTED_64_BIT_ABIS;

private final String baseTheme;

Expand Down Expand Up @@ -138,6 +136,7 @@ public String toMarkdown() {
+ "</table>\n";
}

@NonNull
@Override
public String toString() {
return "App version: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class TagWriter {
)
}

suspend fun writeTagsToFiles(context: Context, info: AudioTagInfo) =
suspend fun writeTagsToFiles(context: Context, info: AudioTagInfo) {
withContext(Dispatchers.IO) {
try {
kotlin.runCatching {
var artwork: Artwork? = null
var albumArtFile: File? = null
if (info.artworkInfo?.artwork != null) {
Expand Down Expand Up @@ -113,18 +113,18 @@ class TagWriter {
deleteAlbumArt(context, info.artworkInfo!!.albumId)
}
scan(context, info.filePaths)
} catch (e: Exception) {
e.printStackTrace()
scan(context, null)
}.onFailure {
it.printStackTrace()
}
}
}


@RequiresApi(Build.VERSION_CODES.R)
suspend fun writeTagsToFilesR(context: Context, info: AudioTagInfo) =
suspend fun writeTagsToFilesR(context: Context, info: AudioTagInfo): List<File> =
withContext(Dispatchers.IO) {
val cacheFiles = mutableListOf<File>()
try {
kotlin.runCatching {
var artwork: Artwork? = null
var albumArtFile: File? = null
if (info.artworkInfo?.artwork != null) {
Expand Down Expand Up @@ -193,11 +193,10 @@ class TagWriter {
} else if (deletedArtwork) {
deleteAlbumArt(context, info.artworkInfo!!.albumId)
}
cacheFiles
} catch (e: Exception) {
e.printStackTrace()
listOf()
}.onFailure {
it.printStackTrace()
}
cacheFiles
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package code.name.monkey.retromusic.adapter

import android.os.SystemClock
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -51,6 +52,8 @@ class HomeAdapter(
) : RecyclerView.Adapter<RecyclerView.ViewHolder>(), IArtistClickListener, IAlbumClickListener,
IGenreClickListener {

private var mLastClickTime: Long = 0

private var list = listOf<Home>()

override fun getItemViewType(position: Int): Int {
Expand Down Expand Up @@ -194,6 +197,10 @@ class HomeAdapter(
itemView.findViewById<TextView>(R.id.message).apply {
setTextColor(color)
setOnClickListener {
if (SystemClock.elapsedRealtime() - mLastClickTime < 1000){
return@setOnClickListener
}
mLastClickTime = SystemClock.elapsedRealtime()
MusicPlayerRemote.playNext((home.arrayList as List<Song>).subList(0, 8))
if (!MusicPlayerRemote.isPlaying) {
MusicPlayerRemote.playNextSong()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,6 @@ class SearchAdapter(
}
}

private fun getSongs(playlist: Playlist): List<Song> {
val songs = mutableListOf<Song>()
if (playlist is AbsSmartPlaylist) {
songs.addAll(playlist.getSongs())
} else {
songs.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id))
}
return songs
}

override fun getItemCount(): Int {
return dataSet.size
}
Expand Down
Loading

0 comments on commit 6924e5d

Please sign in to comment.