From cbc29b553cbee2c8ed2734e713b97eebae330eee Mon Sep 17 00:00:00 2001 From: Prathamesh More Date: Sun, 28 Nov 2021 12:35:07 +0530 Subject: [PATCH] [Cleanup] Removed unused Classes --- .../retromusic/PeekingLinearLayoutManager.kt | 46 ------ .../retromusic/adapter/TranslatorsAdapter.kt | 66 -------- .../adapter/song/PlaylistSongAdapter.kt | 62 -------- .../misc/AppBarStateChangeListener.kt | 59 ------- .../retromusic/state/NowPlayingPanelState.kt | 8 - .../monkey/retromusic/util/RippleUtils.java | 147 ------------------ .../bottom_navigation_item_background.xml | 5 - ...bottom_navigation_item_background_mask.xml | 19 --- .../bottom_navigation_item_colors.xml | 5 - .../res/layout-sw600dp/item_list_no_image.xml | 64 -------- .../main/res/layout/activity_main_content.xml | 27 ---- .../main/res/layout/dialog_edit_lyrics.xml | 39 ----- .../main/res/layout/item_list_no_image.xml | 49 ------ 13 files changed, 596 deletions(-) delete mode 100644 app/src/main/java/code/name/monkey/retromusic/PeekingLinearLayoutManager.kt delete mode 100644 app/src/main/java/code/name/monkey/retromusic/adapter/TranslatorsAdapter.kt delete mode 100644 app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt delete mode 100644 app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt delete mode 100644 app/src/main/java/code/name/monkey/retromusic/state/NowPlayingPanelState.kt delete mode 100644 app/src/main/java/code/name/monkey/retromusic/util/RippleUtils.java delete mode 100644 app/src/main/res/drawable/bottom_navigation_item_background.xml delete mode 100644 app/src/main/res/drawable/bottom_navigation_item_background_mask.xml delete mode 100644 app/src/main/res/drawable/bottom_navigation_item_colors.xml delete mode 100644 app/src/main/res/layout-sw600dp/item_list_no_image.xml delete mode 100644 app/src/main/res/layout/activity_main_content.xml delete mode 100644 app/src/main/res/layout/dialog_edit_lyrics.xml delete mode 100644 app/src/main/res/layout/item_list_no_image.xml diff --git a/app/src/main/java/code/name/monkey/retromusic/PeekingLinearLayoutManager.kt b/app/src/main/java/code/name/monkey/retromusic/PeekingLinearLayoutManager.kt deleted file mode 100644 index a7961ffd..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/PeekingLinearLayoutManager.kt +++ /dev/null @@ -1,46 +0,0 @@ -package code.name.monkey.retromusic - -import android.content.Context -import android.util.AttributeSet -import android.view.ViewGroup -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView - -class PeekingLinearLayoutManager : LinearLayoutManager { - @JvmOverloads - constructor( - context: Context?, - @RecyclerView.Orientation orientation: Int = RecyclerView.VERTICAL, - reverseLayout: Boolean = false - ) : super(context, orientation, reverseLayout) - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super( - context, - attrs, - defStyleAttr, - defStyleRes - ) - - override fun generateDefaultLayoutParams() = - scaledLayoutParams(super.generateDefaultLayoutParams()) - - override fun generateLayoutParams(lp: ViewGroup.LayoutParams?) = - scaledLayoutParams(super.generateLayoutParams(lp)) - - override fun generateLayoutParams(c: Context?, attrs: AttributeSet?) = - scaledLayoutParams(super.generateLayoutParams(c, attrs)) - - private fun scaledLayoutParams(layoutParams: RecyclerView.LayoutParams) = - layoutParams.apply { - when (orientation) { - HORIZONTAL -> width = (horizontalSpace * ratio).toInt() - VERTICAL -> height = (verticalSpace * ratio).toInt() - } - } - - private val horizontalSpace get() = width - paddingStart - paddingEnd - - private val verticalSpace get() = height - paddingTop - paddingBottom - - private val ratio = 0.8f // change to 0.7f for 70% -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/TranslatorsAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/TranslatorsAdapter.kt deleted file mode 100644 index 9630c25c..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/TranslatorsAdapter.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2020 Hemanth Savarla. - * - * Licensed under the GNU General Public License v3 - * - * This is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - */ -package code.name.monkey.retromusic.adapter - -import android.app.Activity -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView -import code.name.monkey.retromusic.R -import code.name.monkey.retromusic.extensions.hide -import code.name.monkey.retromusic.model.Contributor -import code.name.monkey.retromusic.util.RetroUtil -import code.name.monkey.retromusic.views.RetroShapeableImageView - -class TranslatorsAdapter( - private var contributors: List -) : RecyclerView.Adapter() { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder( - LayoutInflater.from(parent.context).inflate( - R.layout.item_contributor, - parent, - false - ) - ) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val contributor = contributors[position] - holder.bindData(contributor) - holder.itemView.setOnClickListener { - RetroUtil.openUrl(it?.context as Activity, contributors[position].link) - } - } - - override fun getItemCount(): Int { - return contributors.size - } - - inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val title: TextView = itemView.findViewById(R.id.title) - val text: TextView = itemView.findViewById(R.id.text) - val image: RetroShapeableImageView = itemView.findViewById(R.id.icon) - - internal fun bindData(contributor: Contributor) { - title.text = contributor.name - text.text = contributor.summary - image.hide() - } - } -} diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt deleted file mode 100644 index 8f077d8a..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlaylistSongAdapter.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2020 Hemanth Savarla. - * - * Licensed under the GNU General Public License v3 - * - * This is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - */ -package code.name.monkey.retromusic.adapter.song - -import android.view.MenuItem -import android.view.View -import androidx.fragment.app.FragmentActivity -import code.name.monkey.retromusic.R -import code.name.monkey.retromusic.db.PlaylistEntity -import code.name.monkey.retromusic.db.toSongEntity -import code.name.monkey.retromusic.dialogs.RemoveSongFromPlaylistDialog -import code.name.monkey.retromusic.interfaces.ICabHolder -import code.name.monkey.retromusic.model.Song - -class PlaylistSongAdapter( - private val playlist: PlaylistEntity, - activity: FragmentActivity, - dataSet: MutableList, - itemLayoutRes: Int, - iCabHolder: ICabHolder? -) : SongAdapter(activity, dataSet, itemLayoutRes, iCabHolder) { - - init { - this.setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection) - } - - override fun createViewHolder(view: View): SongAdapter.ViewHolder { - return ViewHolder(view) - } - - open inner class ViewHolder(itemView: View) : SongAdapter.ViewHolder(itemView) { - - override var songMenuRes: Int - get() = R.menu.menu_item_playlist_song - set(value) { - super.songMenuRes = value - } - - override fun onSongMenuItemClick(item: MenuItem): Boolean { - when (item.itemId) { - R.id.action_remove_from_playlist -> { - RemoveSongFromPlaylistDialog.create(song.toSongEntity(playlist.playListId)) - .show(activity.supportFragmentManager, "REMOVE_FROM_PLAYLIST") - return true - } - } - return super.onSongMenuItemClick(item) - } - } -} diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt b/app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt deleted file mode 100644 index 6d57337f..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2019 Hemanth Savarala. - * - * Licensed under the GNU General Public License v3 - * - * This is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by - * the Free Software Foundation either version 3 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - */ - -package code.name.monkey.retromusic.misc - -import com.google.android.material.appbar.AppBarLayout -import kotlin.math.abs - -/** - * @author Hemanth S (h4h13). - * https://stackoverflow.com/a/33891727 - */ - -abstract class AppBarStateChangeListener : AppBarLayout.OnOffsetChangedListener { - - private var mCurrentState = State.IDLE - - override fun onOffsetChanged(appBarLayout: AppBarLayout, i: Int) { - when { - i == 0 -> { - if (mCurrentState != State.EXPANDED) { - onStateChanged(appBarLayout, State.EXPANDED) - } - mCurrentState = State.EXPANDED - } - abs(i) >= appBarLayout.totalScrollRange -> { - if (mCurrentState != State.COLLAPSED) { - onStateChanged(appBarLayout, State.COLLAPSED) - } - mCurrentState = State.COLLAPSED - } - else -> { - if (mCurrentState != State.IDLE) { - onStateChanged(appBarLayout, State.IDLE) - } - mCurrentState = State.IDLE - } - } - } - - abstract fun onStateChanged(appBarLayout: AppBarLayout, state: State) - - enum class State { - EXPANDED, - COLLAPSED, - IDLE - } -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/state/NowPlayingPanelState.kt b/app/src/main/java/code/name/monkey/retromusic/state/NowPlayingPanelState.kt deleted file mode 100644 index b142f143..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/state/NowPlayingPanelState.kt +++ /dev/null @@ -1,8 +0,0 @@ -package code.name.monkey.retromusic.state - -enum class NowPlayingPanelState { - EXPAND, - COLLAPSED_WITH, - COLLAPSED_WITHOUT, - HIDE, -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RippleUtils.java b/app/src/main/java/code/name/monkey/retromusic/util/RippleUtils.java deleted file mode 100644 index 335e46ba..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/util/RippleUtils.java +++ /dev/null @@ -1,147 +0,0 @@ -package code.name.monkey.retromusic.util; - -import android.annotation.TargetApi; -import android.content.res.ColorStateList; -import android.graphics.Color; -import android.os.Build; -import android.util.StateSet; - -import androidx.annotation.ColorInt; -import androidx.annotation.Nullable; -import androidx.core.graphics.ColorUtils; - -public class RippleUtils { - public static final boolean USE_FRAMEWORK_RIPPLE = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; - private static final int[] PRESSED_STATE_SET = { - android.R.attr.state_pressed, - }; - private static final int[] HOVERED_FOCUSED_STATE_SET = { - android.R.attr.state_hovered, android.R.attr.state_focused, - }; - private static final int[] FOCUSED_STATE_SET = { - android.R.attr.state_focused, - }; - private static final int[] HOVERED_STATE_SET = { - android.R.attr.state_hovered, - }; - - private static final int[] SELECTED_PRESSED_STATE_SET = { - android.R.attr.state_selected, android.R.attr.state_pressed, - }; - private static final int[] SELECTED_HOVERED_FOCUSED_STATE_SET = { - android.R.attr.state_selected, android.R.attr.state_hovered, android.R.attr.state_focused, - }; - private static final int[] SELECTED_FOCUSED_STATE_SET = { - android.R.attr.state_selected, android.R.attr.state_focused, - }; - private static final int[] SELECTED_HOVERED_STATE_SET = { - android.R.attr.state_selected, android.R.attr.state_hovered, - }; - private static final int[] SELECTED_STATE_SET = { - android.R.attr.state_selected, - }; - - private static final int[] ENABLED_PRESSED_STATE_SET = { - android.R.attr.state_enabled, android.R.attr.state_pressed - }; - - public static ColorStateList convertToRippleDrawableColor(@Nullable ColorStateList rippleColor) { - if (USE_FRAMEWORK_RIPPLE) { - int size = 2; - - final int[][] states = new int[size][]; - final int[] colors = new int[size]; - int i = 0; - - // Ideally we would define a different composite color for each state, but that causes the - // ripple animation to abort prematurely. - // So we only allow two base states: selected, and non-selected. For each base state, we only - // base the ripple composite on its pressed state. - - // Selected base state. - states[i] = SELECTED_STATE_SET; - colors[i] = getColorForState(rippleColor, SELECTED_PRESSED_STATE_SET); - i++; - - // Non-selected base state. - states[i] = StateSet.NOTHING; - colors[i] = getColorForState(rippleColor, PRESSED_STATE_SET); - i++; - - return new ColorStateList(states, colors); - } else { - int size = 10; - - final int[][] states = new int[size][]; - final int[] colors = new int[size]; - int i = 0; - - states[i] = SELECTED_PRESSED_STATE_SET; - colors[i] = getColorForState(rippleColor, SELECTED_PRESSED_STATE_SET); - i++; - - states[i] = SELECTED_HOVERED_FOCUSED_STATE_SET; - colors[i] = getColorForState(rippleColor, SELECTED_HOVERED_FOCUSED_STATE_SET); - i++; - - states[i] = SELECTED_FOCUSED_STATE_SET; - colors[i] = getColorForState(rippleColor, SELECTED_FOCUSED_STATE_SET); - i++; - - states[i] = SELECTED_HOVERED_STATE_SET; - colors[i] = getColorForState(rippleColor, SELECTED_HOVERED_STATE_SET); - i++; - - // Checked state. - states[i] = SELECTED_STATE_SET; - colors[i] = Color.TRANSPARENT; - i++; - - states[i] = PRESSED_STATE_SET; - colors[i] = getColorForState(rippleColor, PRESSED_STATE_SET); - i++; - - states[i] = HOVERED_FOCUSED_STATE_SET; - colors[i] = getColorForState(rippleColor, HOVERED_FOCUSED_STATE_SET); - i++; - - states[i] = FOCUSED_STATE_SET; - colors[i] = getColorForState(rippleColor, FOCUSED_STATE_SET); - i++; - - states[i] = HOVERED_STATE_SET; - colors[i] = getColorForState(rippleColor, HOVERED_STATE_SET); - i++; - - // Default state. - states[i] = StateSet.NOTHING; - colors[i] = Color.TRANSPARENT; - i++; - - return new ColorStateList(states, colors); - } - } - - @ColorInt - private static int getColorForState(@Nullable ColorStateList rippleColor, int[] state) { - int color; - if (rippleColor != null) { - color = rippleColor.getColorForState(state, rippleColor.getDefaultColor()); - } else { - color = Color.TRANSPARENT; - } - return USE_FRAMEWORK_RIPPLE ? doubleAlpha(color) : color; - } - - /** - * On API 21+, the framework composites a ripple color onto the display at about 50% opacity. - * Since we are providing precise ripple colors, cancel that out by doubling the opacity here. - */ - @ColorInt - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static int doubleAlpha(@ColorInt int color) { - int alpha = Math.min(2 * Color.alpha(color), 255); - return ColorUtils.setAlphaComponent(color, alpha); - } -} diff --git a/app/src/main/res/drawable/bottom_navigation_item_background.xml b/app/src/main/res/drawable/bottom_navigation_item_background.xml deleted file mode 100644 index ff7e8135..00000000 --- a/app/src/main/res/drawable/bottom_navigation_item_background.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_navigation_item_background_mask.xml b/app/src/main/res/drawable/bottom_navigation_item_background_mask.xml deleted file mode 100644 index fd8fd117..00000000 --- a/app/src/main/res/drawable/bottom_navigation_item_background_mask.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_navigation_item_colors.xml b/app/src/main/res/drawable/bottom_navigation_item_colors.xml deleted file mode 100644 index 330a0f98..00000000 --- a/app/src/main/res/drawable/bottom_navigation_item_colors.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp/item_list_no_image.xml b/app/src/main/res/layout-sw600dp/item_list_no_image.xml deleted file mode 100644 index dfcbafa8..00000000 --- a/app/src/main/res/layout-sw600dp/item_list_no_image.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main_content.xml b/app/src/main/res/layout/activity_main_content.xml deleted file mode 100644 index cb62073d..00000000 --- a/app/src/main/res/layout/activity_main_content.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - diff --git a/app/src/main/res/layout/dialog_edit_lyrics.xml b/app/src/main/res/layout/dialog_edit_lyrics.xml deleted file mode 100644 index ac767afe..00000000 --- a/app/src/main/res/layout/dialog_edit_lyrics.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - -