diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt index 25ea758f..912e71ee 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt @@ -306,6 +306,11 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage }.execute() } + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + loadSongLyrics() + } + override fun onDestroyView() { super.onDestroyView() if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask!!.isCancelled) { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt index 1fb9f53c..42546517 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt @@ -21,9 +21,12 @@ import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.activities.saf.SAFGuideActivity +import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.SAFUtil +import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog +import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.list.listItems import com.google.android.material.button.MaterialButton import kotlinx.android.synthetic.main.activity_album_tag_editor.* @@ -50,17 +53,18 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() { private var savedArtworkInfo: ArtworkInfo? = null protected val show: MaterialDialog - get() = MaterialDialog(this@AbsTagEditorActivity).show { - title(code.name.monkey.retromusic.R.string.update_image) - listItems(items = items) { _, position, _ -> - when (position) { - 0 -> getImageFromLastFM() - 1 -> startImagePicker() - 2 -> searchImageOnWeb() - 3 -> deleteImage() + get() = MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)) + .show { + cornerRadius(PreferenceUtil.getInstance(this@AbsTagEditorActivity).dialogCorner) + title(R.string.update_image) + listItems(items = items) { _, position, _ -> + when (position) { + 0 -> startImagePicker() + 1 -> searchImageOnWeb() + 2 -> deleteImage() + } + } } - } - } protected abstract val contentViewLayout: Int internal val albumArtist: String? @@ -185,7 +189,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() { super.onCreate(savedInstanceState) setContentView(contentViewLayout) - saveFab = findViewById( R.id.saveTags) + saveFab = findViewById(R.id.saveTags) getIntentExtras() songPaths = getSongPaths() @@ -215,8 +219,8 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() { private fun setUpImageView() { loadCurrentImage() - items = listOf(getString(code.name.monkey.retromusic.R.string.download_from_last_fm), getString(code.name.monkey.retromusic.R.string.pick_from_local_storage), getString(code.name.monkey.retromusic.R.string.web_search), getString(code.name.monkey.retromusic.R.string.remove_cover)) - editorImage.setOnClickListener { show } + items = listOf(getString(code.name.monkey.retromusic.R.string.pick_from_local_storage), getString(code.name.monkey.retromusic.R.string.web_search), getString(code.name.monkey.retromusic.R.string.remove_cover)) + editorImage?.setOnClickListener { show } } private fun startImagePicker() { @@ -227,8 +231,6 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() { protected abstract fun loadCurrentImage() - protected abstract fun getImageFromLastFM() - protected abstract fun searchImageOnWeb() protected abstract fun deleteImage() @@ -273,8 +275,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - val id = item.itemId - when (id) { + when (item.itemId) { android.R.id.home -> { super.onBackPressed() return true @@ -285,9 +286,9 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() { protected fun setNoImageMode() { isInNoImageMode = true - imageContainer!!.visibility = View.GONE - editorImage.visibility = View.GONE - editorImage.isEnabled = false + imageContainer?.visibility = View.GONE + editorImage?.visibility = View.GONE + editorImage?.isEnabled = false setColors(intent.getIntExtra(EXTRA_PALETTE, ATHUtil.resolveColor(this, R.attr.colorPrimary))) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt index 94117c2a..54e8c304 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt @@ -14,8 +14,6 @@ import android.text.TextWatcher import android.widget.Toast import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.MaterialUtil -import code.name.monkey.appthemehelper.util.TintHelper -import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.extensions.appHandleColor import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder @@ -25,16 +23,13 @@ import code.name.monkey.retromusic.rest.LastFMRestClient import code.name.monkey.retromusic.rest.model.LastFmAlbum import code.name.monkey.retromusic.util.ImageUtil import code.name.monkey.retromusic.util.LastFMUtil -import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroColorUtil.generatePalette import code.name.monkey.retromusic.util.RetroColorUtil.getColor import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.request.animation.GlideAnimation import com.bumptech.glide.request.target.SimpleTarget -import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable -import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.activity_album_tag_editor.* import org.jaudiotagger.tag.FieldKey import java.util.* @@ -54,9 +49,9 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { .skipMemoryCache(true) .into(object : SimpleTarget() { override fun onResourceReady(resource: BitmapPaletteWrapper?, glideAnimation: GlideAnimation?) { - RetroColorUtil.getColor(resource?.palette, Color.TRANSPARENT); + getColor(resource?.palette, Color.TRANSPARENT) albumArtBitmap = resource?.bitmap?.let { ImageUtil.resizeBitmap(it, 2048) } - setImageBitmap(albumArtBitmap, RetroColorUtil.getColor(resource?.palette, ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor))) + setImageBitmap(albumArtBitmap, getColor(resource?.palette, ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor))) deleteAlbumArt = false dataChanged() setResult(Activity.RESULT_OK) @@ -67,31 +62,6 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { Toast.makeText(this@AlbumTagEditorActivity, e.toString(), Toast.LENGTH_LONG).show() } }) - - /*Glide.with(AlbumTagEditorActivity.this) - .load(selectedFileUri) - .asBitmap() - .transcode(new BitmapPaletteTranscoder(AlbumTagEditorActivity.this), BitmapPaletteWrapper.class) - .diskCacheStrategy(DiskCacheStrategy.NONE) - .skipMemoryCache(true) - .into(new SimpleTarget() { - @Override - public void onLoadFailed(Exception e, Drawable errorDrawable) { - super.onLoadFailed(e, errorDrawable); - e.printStackTrace(); - Toast.makeText(AlbumTagEditorActivity.this, e.toString(), Toast.LENGTH_LONG).show(); - } - - @Override - public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation glideAnimation) { - PhonographColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT); - albumArtBitmap = ImageUtil.resizeBitmap(resource.getBitmap(), 2048); - setImageBitmap(albumArtBitmap, PhonographColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor))); - deleteAlbumArt = false; - dataChanged(); - setResult(RESULT_OK); - } - });*/ } private var albumArtBitmap: Bitmap? = null @@ -100,11 +70,9 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { private val disposable = CompositeDisposable() private fun setupToolbar() { - toolbar.setNavigationOnClickListener { onBackPressed() } - ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(this, toolbar, Color.TRANSPARENT) - title = null + toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary)) setSupportActionBar(toolbar) - TintHelper.setTintAuto(content, ATHUtil.resolveColor(this, R.attr.colorPrimary), true) + supportActionBar?.setDisplayShowHomeEnabled(true) } override fun onCreate(savedInstanceState: Bundle?) { @@ -144,21 +112,6 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { deleteAlbumArt = false } - override fun getImageFromLastFM() { - val albumTitleStr = albumText.text.toString() - val albumArtistNameStr = albumArtistText.text.toString() - if (albumArtistNameStr.trim { it <= ' ' } == "" || albumTitleStr.trim { it <= ' ' } == "") { - Toast.makeText(this, resources.getString(R.string.album_or_artist_empty), Toast.LENGTH_SHORT).show() - return - } - - disposable.add(lastFMRestClient!!.apiService - .getAlbumInfo(albumTitleStr, albumArtistNameStr, null) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.computation()) - .subscribe { this.extractDetails(it) }) - } - override fun onPause() { super.onPause() disposable.clear() @@ -184,12 +137,12 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { override fun onResourceReady(resource: BitmapPaletteWrapper?, glideAnimation: GlideAnimation?) { albumArtBitmap = resource?.bitmap?.let { ImageUtil.resizeBitmap(it, 2048) } - setImageBitmap(albumArtBitmap, RetroColorUtil.getColor(resource?.palette, ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor))) + setImageBitmap(albumArtBitmap, getColor(resource?.palette, ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor))) deleteAlbumArt = false dataChanged() setResult(RESULT_OK) } - }); + }) return } if (lastFmAlbum.album.tags.tag.size > 0) { @@ -223,8 +176,8 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { fieldKeyValueMap[FieldKey.GENRE] = genreTitle.text.toString() fieldKeyValueMap[FieldKey.YEAR] = yearTitle.text.toString() - writeValuesToFiles(fieldKeyValueMap, if (deleteAlbumArt) AbsTagEditorActivity.ArtworkInfo(id, null) - else if (albumArtBitmap == null) null else AbsTagEditorActivity.ArtworkInfo(id, albumArtBitmap!!)) + writeValuesToFiles(fieldKeyValueMap, if (deleteAlbumArt) ArtworkInfo(id, null) + else if (albumArtBitmap == null) null else ArtworkInfo(id, albumArtBitmap!!)) } override fun getSongPaths(): List { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt index 30a0ecb3..a52277d6 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt @@ -81,10 +81,6 @@ class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher { } - override fun getImageFromLastFM() { - - } - override fun searchImageOnWeb() { } diff --git a/app/src/main/res/layout-land/activity_album_tag_editor.xml b/app/src/main/res/layout-land/activity_album_tag_editor.xml index 5a1f6b01..1f9e0ac8 100644 --- a/app/src/main/res/layout-land/activity_album_tag_editor.xml +++ b/app/src/main/res/layout-land/activity_album_tag_editor.xml @@ -21,26 +21,29 @@ android:id="@+id/toolbar" style="@style/Toolbar" app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp" - app:title="@string/action_tag_editor" - tools:ignore="UnusedAttribute" /> + app:title="@string/action_tag_editor" /> - + android:layout_height="match_parent" + android:layout_margin="16dp" + android:layout_weight="1" + android:transitionName="@string/transition_album_art" + app:cardCornerRadius="24dp" + app:cardElevation="8dp"> + tools:srcCompat="@tools:sample/backgrounds/scenic[5]" /> - + - + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> - + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> diff --git a/app/src/main/res/layout-xlarge-land/activity_album.xml b/app/src/main/res/layout-xlarge-land/activity_album.xml index 2fb0ef98..61d575bd 100644 --- a/app/src/main/res/layout-xlarge-land/activity_album.xml +++ b/app/src/main/res/layout-xlarge-land/activity_album.xml @@ -51,7 +51,7 @@ android:background="@drawable/bg_bottom_sheet_dialog_fragment" android:fillViewport="true" android:overScrollMode="never" - app:layout_behavior="@string/appbar_scrolling_view_behavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> diff --git a/app/src/main/res/layout-xlarge/activity_album.xml b/app/src/main/res/layout-xlarge/activity_album.xml index 5377d90b..228498ef 100644 --- a/app/src/main/res/layout-xlarge/activity_album.xml +++ b/app/src/main/res/layout-xlarge/activity_album.xml @@ -52,7 +52,7 @@ android:layout_marginEnd="96dp" android:fillViewport="true" android:overScrollMode="never" - app:layout_behavior="@string/appbar_scrolling_view_behavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 696445cc..b4045ac2 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -24,7 +24,7 @@ + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> diff --git a/app/src/main/res/layout/activity_album.xml b/app/src/main/res/layout/activity_album.xml index 0f9b47cb..26e3b6b1 100755 --- a/app/src/main/res/layout/activity_album.xml +++ b/app/src/main/res/layout/activity_album.xml @@ -34,7 +34,7 @@ + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + android:layout_height="match_parent" + android:orientation="vertical" + tools:ignore="UnusedAttribute"> + + + + + + + app:liftOnScroll="true"> - + + + + + + + android:orientation="vertical"> - + android:layout_height="wrap_content" + android:transitionName="@string/transition_album_art" + app:cardCornerRadius="24dp" + app:cardElevation="8dp" + app:cardUseCompatPadding="true" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + tools:srcCompat="@tools:sample/backgrounds/scenic[5]" /> - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_artist_details.xml b/app/src/main/res/layout/activity_artist_details.xml index ed0c9a0c..d02b0813 100755 --- a/app/src/main/res/layout/activity_artist_details.xml +++ b/app/src/main/res/layout/activity_artist_details.xml @@ -35,7 +35,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:overScrollMode="never" - app:layout_behavior="@string/appbar_scrolling_view_behavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_license.xml b/app/src/main/res/layout/activity_license.xml index 2e1bfd05..dac51f10 100644 --- a/app/src/main/res/layout/activity_license.xml +++ b/app/src/main/res/layout/activity_license.xml @@ -28,7 +28,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="fill_vertical" - app:layout_behavior="@string/appbar_scrolling_view_behavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:liftOnScroll="true"> - - - - - - - - - + + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> diff --git a/app/src/main/res/layout/fragment_folder.xml b/app/src/main/res/layout/fragment_folder.xml index e5fd2f20..4de47498 100644 --- a/app/src/main/res/layout/fragment_folder.xml +++ b/app/src/main/res/layout/fragment_folder.xml @@ -88,7 +88,7 @@ android:clipToPadding="false" android:layoutAnimation="@anim/layout_animation_fall_down" android:scrollbars="none" - app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">