diff --git a/app/build.gradle b/app/build.gradle index 01395eae..cb2d4ecc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,7 +22,7 @@ android { vectorDrawables.useSupportLibrary = true applicationId "code.name.monkey.retromusic" - versionCode 399 + versionCode 400 versionName '3.4.850' multiDexEnabled true @@ -116,6 +116,7 @@ static def getDate() { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation project(':appthemehelper') + implementation project(':liboverscroll') implementation 'androidx.multidex:multidex:2.0.1' implementation "androidx.gridlayout:gridlayout:1.0.0" diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt index 21e44354..41645390 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt @@ -32,6 +32,7 @@ import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.list.listItems import com.google.gson.Gson import com.google.gson.reflect.TypeToken +import kotlinx.android.synthetic.main.activity_about.container import kotlinx.android.synthetic.main.activity_about.toolbar import kotlinx.android.synthetic.main.card_credit.recyclerView import kotlinx.android.synthetic.main.card_other.changelog @@ -48,6 +49,7 @@ import kotlinx.android.synthetic.main.card_social.instagramLink import kotlinx.android.synthetic.main.card_social.pinterestLink import kotlinx.android.synthetic.main.card_social.telegramLink import kotlinx.android.synthetic.main.card_social.twitterLink +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper import java.io.IOException import java.nio.charset.StandardCharsets @@ -86,6 +88,7 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener { version.setSummary(getAppVersion()) setUpView() loadContributors() + OverScrollDecoratorHelper.setUpOverScroll(container) } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt index 3a5327d5..f7d95e1c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt @@ -46,6 +46,7 @@ import com.bumptech.glide.Glide import kotlinx.android.synthetic.main.activity_album.albumCoverContainer import kotlinx.android.synthetic.main.activity_album.albumText import kotlinx.android.synthetic.main.activity_album.albumTitle +import kotlinx.android.synthetic.main.activity_album.container import kotlinx.android.synthetic.main.activity_album.image import kotlinx.android.synthetic.main.activity_album.toolbar import kotlinx.android.synthetic.main.activity_album_content.moreRecyclerView @@ -54,6 +55,7 @@ import kotlinx.android.synthetic.main.activity_album_content.playAction import kotlinx.android.synthetic.main.activity_album_content.recyclerView import kotlinx.android.synthetic.main.activity_album_content.shuffleAction import kotlinx.android.synthetic.main.activity_album_content.songTitle +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper import java.util.ArrayList import javax.inject.Inject import android.util.Pair as UtilPair @@ -158,6 +160,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C isNestedScrollingEnabled = false adapter = simpleSongAdapter } + + OverScrollDecoratorHelper.setUpOverScroll(container) } override fun onDestroy() { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt index da589fdb..319d6579 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt @@ -42,6 +42,7 @@ import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroUtil import com.afollestad.materialcab.MaterialCab import com.bumptech.glide.Glide +import kotlinx.android.synthetic.main.activity_album.container import kotlinx.android.synthetic.main.activity_artist_content.albumRecyclerView import kotlinx.android.synthetic.main.activity_artist_content.albumTitle import kotlinx.android.synthetic.main.activity_artist_content.biographyText @@ -56,6 +57,7 @@ import kotlinx.android.synthetic.main.activity_artist_details.image import kotlinx.android.synthetic.main.activity_artist_details.imageContainer import kotlinx.android.synthetic.main.activity_artist_details.text import kotlinx.android.synthetic.main.activity_artist_details.toolbar +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper import java.util.Locale import javax.inject.Inject @@ -177,6 +179,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, layoutManager = LinearLayoutManager(this.context) adapter = songAdapter } + OverScrollDecoratorHelper.setUpOverScroll(container) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt index 7377fd93..bcae9801 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt @@ -24,6 +24,7 @@ import kotlinx.android.synthetic.main.activity_playing_queue.clearQueue import kotlinx.android.synthetic.main.activity_playing_queue.playerQueueSubHeader import kotlinx.android.synthetic.main.activity_playing_queue.recyclerView import kotlinx.android.synthetic.main.activity_playing_queue.toolbar +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper open class PlayingQueueActivity : AbsMusicServiceActivity() { @@ -108,6 +109,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() { } }) ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView) + OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL) } private fun checkForPadding() { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt index 82a57bd4..faf0a6f9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt @@ -34,6 +34,7 @@ import kotlinx.android.synthetic.main.activity_playlist_detail.emptyEmoji import kotlinx.android.synthetic.main.activity_playlist_detail.emptyText import kotlinx.android.synthetic.main.activity_playlist_detail.recyclerView import kotlinx.android.synthetic.main.activity_playlist_detail.toolbar +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper import javax.inject.Inject class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, PlaylistSongsView { @@ -75,6 +76,8 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli private fun setUpRecyclerView() { ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView) + OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL) + recyclerView.layoutManager = LinearLayoutManager(this) if (playlist is AbsCustomPlaylist) { adapter = PlaylistSongAdapter(this, ArrayList(), R.layout.item_list, false, this) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt index 850aaae3..f12ad699 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt @@ -38,6 +38,7 @@ import kotlinx.android.synthetic.main.activity_search.recyclerView import kotlinx.android.synthetic.main.activity_search.searchContainer import kotlinx.android.synthetic.main.activity_search.searchView import kotlinx.android.synthetic.main.activity_search.voiceSearch +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper import java.util.Locale import javax.inject.Inject @@ -112,6 +113,8 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch } } }) + + OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL) } private fun setupSearchView() { 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 176114cb..b08e4c0c 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 @@ -1,51 +1,37 @@ package code.name.monkey.retromusic.activities; +import static code.name.monkey.appthemehelper.util.ATHUtil.INSTANCE; + import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.Color; import android.os.Bundle; import android.webkit.WebView; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; - -import com.google.android.material.appbar.AppBarLayout; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; - +import androidx.core.widget.NestedScrollView; import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.activities.base.AbsBaseActivity; import code.name.monkey.retromusic.util.PreferenceUtil; - -import static code.name.monkey.appthemehelper.util.ATHUtil.INSTANCE; +import com.google.android.material.appbar.AppBarLayout; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper; public class WhatsNewActivity extends AbsBaseActivity { - WebView webView; - Toolbar toolbar; + AppBarLayout appBarLayout; + Toolbar toolbar; - private static void setChangelogRead(@NonNull Context context) { - try { - PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); - int currentVersion = pInfo.versionCode; - PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion); - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - } - - private static String colorToCSS(int color) { - return String.format("rgb(%d, %d, %d)", Color.red(color), Color.green(color), Color.blue(color)); // on API 29, WebView doesn't load with hex colors - } + WebView webView; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -65,24 +51,30 @@ public class WhatsNewActivity extends AbsBaseActivity { toolbar.setNavigationOnClickListener(v -> onBackPressed()); ToolbarContentTintHelper.colorBackButton(toolbar); - + NestedScrollView nestedScrollView = findViewById(R.id.container); + OverScrollDecoratorHelper.setUpOverScroll(nestedScrollView); + try { StringBuilder buf = new StringBuilder(); InputStream json = getAssets().open("retro-changelog.html"); BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8)); String str; - while ((str = in.readLine()) != null) + while ((str = in.readLine()) != null) { buf.append(str); + } in.close(); // Inject color values for WebView body background and links final boolean isDark = INSTANCE.isWindowBackgroundDark(this); - final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff"))); + final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface, + Color.parseColor(isDark ? "#424242" : "#ffffff"))); final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000")); final String changeLog = buf.toString() - .replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor)) + .replace("{style-placeholder}", + String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor)) .replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this))) - .replace("{link-color-active}", colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this)))); + .replace("{link-color-active}", + colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this)))); webView.loadData(changeLog, "text/html", "UTF-8"); } catch (Throwable e) { @@ -90,4 +82,19 @@ public class WhatsNewActivity extends AbsBaseActivity { } setChangelogRead(this); } + + private static String colorToCSS(int color) { + return String.format("rgb(%d, %d, %d)", Color.red(color), Color.green(color), + Color.blue(color)); // on API 29, WebView doesn't load with hex colors + } + + private static void setChangelogRead(@NonNull Context context) { + try { + PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); + int currentVersion = pInfo.versionCode; + PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt index ed5d2c92..b1134f39 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt @@ -13,15 +13,21 @@ import code.name.monkey.retromusic.util.DensityUtil import code.name.monkey.retromusic.util.ViewUtil import com.google.android.material.appbar.AppBarLayout import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView -import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.* +import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.container +import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.empty +import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.emptyEmoji +import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.emptyText +import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.recyclerView +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper -abstract class AbsLibraryPagerRecyclerViewFragment, LM : RecyclerView.LayoutManager> : AbsLibraryPagerFragment(), AppBarLayout.OnOffsetChangedListener { +abstract class AbsLibraryPagerRecyclerViewFragment, LM : RecyclerView.LayoutManager> : + AbsLibraryPagerFragment(), AppBarLayout.OnOffsetChangedListener { protected var adapter: A? = null protected var layoutManager: LM? = null override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { return inflater.inflate(R.layout.fragment_main_activity_recycler_view, container, false) } @@ -40,6 +46,8 @@ abstract class AbsLibraryPagerRecyclerViewFragment, } recyclerView.layoutManager = layoutManager recyclerView.adapter = adapter + + OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL) } private fun initAdapter() { @@ -89,10 +97,11 @@ abstract class AbsLibraryPagerRecyclerViewFragment, override fun onOffsetChanged(p0: AppBarLayout?, i: Int) { container.setPadding( - container.paddingLeft, - container.paddingTop, - container.paddingRight, - libraryFragment.totalAppBarScrollingRange + i) + container.paddingLeft, + container.paddingTop, + container.paddingRight, + libraryFragment.totalAppBarScrollingRange + i + ) } override fun onQueueChanged() { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt index ef80c892..f0731d1f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt @@ -4,12 +4,16 @@ import android.app.ActivityOptions import android.content.res.ColorStateList import android.os.Bundle import android.util.DisplayMetrics -import android.view.* +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup import androidx.appcompat.widget.Toolbar import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.appthemehelper.common.ATHToolbarActivity import code.name.monkey.appthemehelper.util.ATHUtil -import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.App import code.name.monkey.retromusic.Constants @@ -30,14 +34,24 @@ import code.name.monkey.retromusic.mvp.presenter.HomePresenter import code.name.monkey.retromusic.mvp.presenter.HomeView import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.PreferenceUtil -import code.name.monkey.retromusic.util.RetroColorUtil import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy -import kotlinx.android.synthetic.main.abs_playlists.* -import kotlinx.android.synthetic.main.fragment_banner_home.* -import kotlinx.android.synthetic.main.home_content.* +import kotlinx.android.synthetic.main.abs_playlists.actionShuffle +import kotlinx.android.synthetic.main.abs_playlists.history +import kotlinx.android.synthetic.main.abs_playlists.lastAdded +import kotlinx.android.synthetic.main.abs_playlists.topPlayed +import kotlinx.android.synthetic.main.fragment_banner_home.bannerImage +import kotlinx.android.synthetic.main.fragment_banner_home.titleWelcome +import kotlinx.android.synthetic.main.fragment_banner_home.toolbarContainer +import kotlinx.android.synthetic.main.fragment_banner_home.userImage +import kotlinx.android.synthetic.main.fragment_home.container +import kotlinx.android.synthetic.main.home_content.emptyContainer +import kotlinx.android.synthetic.main.home_content.recyclerView +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper import java.io.File -import java.util.* +import java.util.ArrayList +import java.util.Calendar +import java.util.Random import javax.inject.Inject class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeView { @@ -53,18 +67,22 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba } override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? { - return inflater.inflate(if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, viewGroup, false) + return inflater.inflate( + if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, + viewGroup, + false + ) } private fun loadImageFromStorage() { Glide.with(requireContext()) - .load(File(PreferenceUtil.getInstance(requireContext()).profileImage, Constants.USER_PROFILE)) - .asBitmap() - .diskCacheStrategy(DiskCacheStrategy.NONE) - .skipMemoryCache(true) - .placeholder(R.drawable.ic_person_flat) - .error(R.drawable.ic_person_flat) - .into(userImage) + .load(File(PreferenceUtil.getInstance(requireContext()).profileImage, Constants.USER_PROFILE)) + .asBitmap() + .diskCacheStrategy(DiskCacheStrategy.NONE) + .skipMemoryCache(true) + .placeholder(R.drawable.ic_person_flat) + .error(R.drawable.ic_person_flat) + .into(userImage) } private val displayMetrics: DisplayMetrics @@ -81,7 +99,11 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba toolbar = view.findViewById(R.id.toolbar) bannerImage?.setOnClickListener { - val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, userImage, getString(R.string.transition_user_image)) + val options = ActivityOptions.makeSceneTransitionAnimation( + mainActivity, + userImage, + getString(R.string.transition_user_image) + ) NavigationUtil.goToUserInfo(requireActivity(), options) } @@ -104,7 +126,11 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba setupToolbar() userImage?.setOnClickListener { - val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, userImage, getString(R.string.transition_user_image)) + val options = ActivityOptions.makeSceneTransitionAnimation( + mainActivity, + userImage, + getString(R.string.transition_user_image) + ) NavigationUtil.goToUserInfo(requireActivity(), options) } titleWelcome?.text = String.format("%s", PreferenceUtil.getInstance(requireContext()).userName) @@ -118,14 +144,8 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba } homePresenter.attachView(this) homePresenter.loadSections() - } - private fun toolbarColor(): Int { - return if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) { - ColorUtil.withAlpha(RetroColorUtil.toolbarColor(mainActivity), 0.85f) - } else { - RetroColorUtil.toolbarColor(mainActivity) - } + OverScrollDecoratorHelper.setUpOverScroll(container) } private fun setupToolbar() { @@ -133,7 +153,11 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)) setNavigationIcon(R.drawable.ic_menu_white_24dp) setOnClickListener { - val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, toolbarContainer, getString(R.string.transition_toolbar)) + val options = ActivityOptions.makeSceneTransitionAnimation( + mainActivity, + toolbarContainer, + getString(R.string.transition_toolbar) + ) NavigationUtil.goToSearch(requireActivity(), options) } @@ -164,7 +188,12 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba super.onCreateOptionsMenu(menu, inflater) inflater.inflate(R.menu.menu_search, menu) - ToolbarContentTintHelper.handleOnCreateOptionsMenu(requireActivity(), toolbar, menu, ATHToolbarActivity.getToolbarBackgroundColor(toolbar)) + ToolbarContentTintHelper.handleOnCreateOptionsMenu( + requireActivity(), + toolbar, + menu, + ATHToolbarActivity.getToolbarBackgroundColor(toolbar) + ) } override fun onPrepareOptionsMenu(menu: Menu) { @@ -174,7 +203,11 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == R.id.action_search) { - val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, toolbarContainer, getString(R.string.transition_toolbar)) + val options = ActivityOptions.makeSceneTransitionAnimation( + mainActivity, + toolbarContainer, + getString(R.string.transition_toolbar) + ) NavigationUtil.goToSearch(requireActivity(), true, options) } return super.onOptionsItemSelected(item) @@ -195,25 +228,24 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba loadTimeImage(day) } - private fun loadTimeImage(day: String) { bannerImage?.let { val request = Glide.with(requireContext()) if (PreferenceUtil.getInstance(requireContext()).bannerImage.isEmpty()) { request.load(day) - .diskCacheStrategy(DiskCacheStrategy.NONE) - .skipMemoryCache(true) - .placeholder(R.drawable.material_design_default) - .error(R.drawable.material_design_default) - .into(it) + .diskCacheStrategy(DiskCacheStrategy.NONE) + .skipMemoryCache(true) + .placeholder(R.drawable.material_design_default) + .error(R.drawable.material_design_default) + .into(it) } else { request.load(File(PreferenceUtil.getInstance(requireContext()).bannerImage, USER_BANNER)) - .asBitmap() - .diskCacheStrategy(DiskCacheStrategy.NONE) - .skipMemoryCache(true) - .placeholder(R.drawable.material_design_default) - .error(R.drawable.material_design_default) - .into(it) + .asBitmap() + .diskCacheStrategy(DiskCacheStrategy.NONE) + .skipMemoryCache(true) + .placeholder(R.drawable.material_design_default) + .error(R.drawable.material_design_default) + .into(it) } } loadImageFromStorage() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt index f56142f9..e19316f3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt @@ -26,8 +26,18 @@ import androidx.preference.PreferenceManager import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceFragmentCompat import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.retromusic.R -import code.name.monkey.retromusic.preferences.* +import code.name.monkey.retromusic.preferences.AlbumCoverStylePreference +import code.name.monkey.retromusic.preferences.AlbumCoverStylePreferenceDialog +import code.name.monkey.retromusic.preferences.BlacklistPreference +import code.name.monkey.retromusic.preferences.BlacklistPreferenceDialog +import code.name.monkey.retromusic.preferences.LibraryPreference +import code.name.monkey.retromusic.preferences.LibraryPreferenceDialog +import code.name.monkey.retromusic.preferences.MaterialListPreference +import code.name.monkey.retromusic.preferences.MaterialListPreferenceDialog +import code.name.monkey.retromusic.preferences.NowPlayingScreenPreference +import code.name.monkey.retromusic.preferences.NowPlayingScreenPreferenceDialog import code.name.monkey.retromusic.util.NavigationUtil +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper /** * @author Hemanth S (h4h13). @@ -54,9 +64,11 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() { protected fun setSummary(preference: Preference?) { preference?.let { - setSummary(it, PreferenceManager + setSummary( + it, PreferenceManager .getDefaultSharedPreferences(it.context) - .getString(it.key, "")) + .getString(it.key, "") + ) } } @@ -68,6 +80,7 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() { listView.setPadding(0, 0, 0, 0) listView.setPaddingRelative(0, 0, 0, 0) invalidateSettings() + OverScrollDecoratorHelper.setUpOverScroll(listView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL) } override fun onCreatePreferenceDialog(preference: Preference): DialogFragment? { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt index 82d8e84f..e60dc8ca 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt @@ -28,12 +28,23 @@ import code.name.monkey.retromusic.activities.SettingsActivity import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.util.NavigationUtil -import kotlinx.android.synthetic.main.fragment_main_settings.* - +import kotlinx.android.synthetic.main.fragment_main_settings.aboutSettings +import kotlinx.android.synthetic.main.fragment_main_settings.audioSettings +import kotlinx.android.synthetic.main.fragment_main_settings.buyPremium +import kotlinx.android.synthetic.main.fragment_main_settings.buyProContainer +import kotlinx.android.synthetic.main.fragment_main_settings.container +import kotlinx.android.synthetic.main.fragment_main_settings.diamondIcon +import kotlinx.android.synthetic.main.fragment_main_settings.generalSettings +import kotlinx.android.synthetic.main.fragment_main_settings.imageSettings +import kotlinx.android.synthetic.main.fragment_main_settings.notificationSettings +import kotlinx.android.synthetic.main.fragment_main_settings.nowPlayingSettings +import kotlinx.android.synthetic.main.fragment_main_settings.otherSettings +import kotlinx.android.synthetic.main.fragment_main_settings.personalizeSettings +import me.everything.android.ui.overscroll.OverScrollDecoratorHelper class MainSettingsFragment : Fragment(), View.OnClickListener { - override fun onClick(v: View) { - when (v.id) { + override fun onClick(view: View) { + when (view.id) { R.id.generalSettings -> inflateFragment(ThemeSettingsFragment(), R.string.general_settings_title) R.id.audioSettings -> inflateFragment(AudioSettings(), R.string.pref_header_audio) R.id.nowPlayingSettings -> inflateFragment(NowPlayingSettingsFragment(), R.string.now_playing) @@ -45,8 +56,10 @@ class MainSettingsFragment : Fragment(), View.OnClickListener { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View? { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { return inflater.inflate(R.layout.fragment_main_settings, container, false) } @@ -75,7 +88,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener { buyPremium.setTextColor(it) diamondIcon.imageTintList = ColorStateList.valueOf(it) } - + OverScrollDecoratorHelper.setUpOverScroll(container) } private fun inflateFragment(fragment: Fragment, @StringRes title: Int) { diff --git a/app/src/main/res/layout-land/activity_album.xml b/app/src/main/res/layout-land/activity_album.xml index 51916281..e753cb33 100644 --- a/app/src/main/res/layout-land/activity_album.xml +++ b/app/src/main/res/layout-land/activity_album.xml @@ -67,6 +67,7 @@ android:layout_height="match_parent" android:layout_weight="1" android:fillViewport="true" + android:id="@+id/container" android:overScrollMode="never"> - diff --git a/app/src/main/res/layout-land/fragment_banner_home.xml b/app/src/main/res/layout-land/fragment_banner_home.xml index 9bf58251..2c156295 100644 --- a/app/src/main/res/layout-land/fragment_banner_home.xml +++ b/app/src/main/res/layout-land/fragment_banner_home.xml @@ -28,11 +28,11 @@ @@ -48,7 +48,6 @@ android:layout_height="wrap_content" app:liftOnScroll="true"> - diff --git a/app/src/main/res/layout/activity_album.xml b/app/src/main/res/layout/activity_album.xml index e30dd78e..c2e026e0 100755 --- a/app/src/main/res/layout/activity_album.xml +++ b/app/src/main/res/layout/activity_album.xml @@ -43,6 +43,7 @@ @@ -50,7 +51,6 @@ + app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp" + tools:background="?attr/colorSurface" /> diff --git a/app/src/main/res/layout/activity_whats_new.xml b/app/src/main/res/layout/activity_whats_new.xml index e441a793..735378cb 100644 --- a/app/src/main/res/layout/activity_whats_new.xml +++ b/app/src/main/res/layout/activity_whats_new.xml @@ -42,6 +42,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="fill_vertical" + android:id="@+id/container" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index ee7beef4..e3138288 100755 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -70,6 +70,7 @@ diff --git a/liboverscroll/src/main/java/me/everything/android/ui/overscroll/adapters/NestedScrollViewOverScrollDecorAdapter.java b/liboverscroll/src/main/java/me/everything/android/ui/overscroll/adapters/NestedScrollViewOverScrollDecorAdapter.java new file mode 100644 index 00000000..1d8e6b6c --- /dev/null +++ b/liboverscroll/src/main/java/me/everything/android/ui/overscroll/adapters/NestedScrollViewOverScrollDecorAdapter.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 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 me.everything.android.ui.overscroll.adapters; + +import android.view.View; +import androidx.annotation.NonNull; +import androidx.core.widget.NestedScrollView; + +public class NestedScrollViewOverScrollDecorAdapter implements IOverScrollDecoratorAdapter { + + protected final NestedScrollView mView; + + public NestedScrollViewOverScrollDecorAdapter(@NonNull NestedScrollView view) { + this.mView = view; + } + + public View getView() { + return this.mView; + } + + public boolean isInAbsoluteEnd() { + return !this.mView.canScrollVertically(1); + } + + public boolean isInAbsoluteStart() { + return !this.mView.canScrollVertically(-1); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index d170d34c..052922a7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':appthemehelper', ':core' \ No newline at end of file +include ':app', ':appthemehelper', ':liboverscroll' \ No newline at end of file