Merge pull request #350 from h4h13/no-profile

No profile
This commit is contained in:
Hemanth S 2019-06-02 09:15:28 +05:30 committed by GitHub
commit 9ac24be7ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 44 additions and 455 deletions

View file

@ -14,54 +14,26 @@
package code.name.monkey.retromusic.dialogs package code.name.monkey.retromusic.dialogs
import android.app.Dialog
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.app.ShareCompat import androidx.core.app.ShareCompat
import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.Constants.USER_PROFILE
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.MainActivity import code.name.monkey.retromusic.activities.MainActivity
import code.name.monkey.retromusic.activities.bugreport.BugReportActivity import code.name.monkey.retromusic.activities.bugreport.BugReportActivity
import code.name.monkey.retromusic.util.Compressor
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment import com.afollestad.materialdialogs.MaterialDialog
import io.reactivex.android.schedulers.AndroidSchedulers import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.fragment_main_options.* import kotlinx.android.synthetic.main.fragment_main_options.*
import java.io.File
import java.util.*
class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnClickListener { class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
private val disposable = CompositeDisposable()
private val timeOfTheDay: String
get() {
var message = getString(R.string.title_good_day)
val c = Calendar.getInstance()
when (c.get(Calendar.HOUR_OF_DAY)) {
in 0..5 -> message = getString(R.string.title_good_night)
in 6..11 -> message = getString(R.string.title_good_morning)
in 12..15 -> message = getString(R.string.title_good_afternoon)
in 16..19 -> message = getString(R.string.title_good_evening)
in 20..23 -> message = getString(R.string.title_good_night)
}
return message
}
override fun onDestroyView() {
super.onDestroyView()
disposable.dispose()
}
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_options, container, false) return inflater.inflate(R.layout.fragment_main_options, container, false)
@ -70,18 +42,9 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
text.setTextColor(ThemeStore.textColorSecondary(context!!))
text.text = PreferenceUtil.getInstance().userBio
titleWelcome.setTextColor(ThemeStore.textColorPrimary(context!!))
titleWelcome.text = String.format("%s %s!", timeOfTheDay, PreferenceUtil.getInstance().userName)
loadImageFromStorage()
actionSettings.setOnClickListener(this) actionSettings.setOnClickListener(this)
actionSleepTimer.setOnClickListener(this) actionSleepTimer.setOnClickListener(this)
actionLibrary.setOnClickListener(this) actionLibrary.setOnClickListener(this)
userInfoContainer.setOnClickListener(this)
actionEqualizer.setOnClickListener(this) actionEqualizer.setOnClickListener(this)
actionFolders.setOnClickListener(this) actionFolders.setOnClickListener(this)
actionRate.setOnClickListener(this) actionRate.setOnClickListener(this)
@ -103,11 +66,9 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
R.id.actionFolders -> mainActivity.selectedFragment(R.id.action_folder) R.id.actionFolders -> mainActivity.selectedFragment(R.id.action_folder)
R.id.actionLibrary -> mainActivity.selectedFragment(PreferenceUtil.getInstance().lastPage) R.id.actionLibrary -> mainActivity.selectedFragment(PreferenceUtil.getInstance().lastPage)
R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity) R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity)
R.id.actionSleepTimer -> if (fragmentManager != null) { R.id.actionSleepTimer -> if (fragmentManager != null) {
SleepTimerDialog().show(fragmentManager!!, TAG) SleepTimerDialog().show(fragmentManager!!, TAG)
} }
R.id.userInfoContainer -> NavigationUtil.goToUserInfo(mainActivity)
R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity) R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity)
R.id.actionShare -> shareApp() R.id.actionShare -> shareApp()
R.id.actionBugReport -> prepareBugReport() R.id.actionBugReport -> prepareBugReport()
@ -132,23 +93,11 @@ class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), View.OnCl
} }
} }
private fun loadImageFromStorage() { override fun getDialog(): Dialog? {
return MaterialDialog(activity!!, BottomSheet())
.show {
disposable.add(Compressor(context!!) }
.setMaxHeight(300)
.setMaxWidth(300)
.setQuality(75)
.setCompressFormat(Bitmap.CompressFormat.WEBP)
.compressToBitmapAsFlowable(
File(PreferenceUtil.getInstance().profileImage, USER_PROFILE))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ userImage!!.setImageBitmap(it) }, {
userImage!!.setImageDrawable(ContextCompat
.getDrawable(context!!, R.drawable.ic_account_white_24dp))
}, {
}))
} }
companion object { companion object {

File diff suppressed because one or more lines are too long

View file

@ -9,8 +9,6 @@ import android.view.MenuItem;
import android.view.SubMenu; import android.view.SubMenu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -53,9 +51,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
private MaterialCab cab; private MaterialCab cab;
private FragmentManager fragmentManager; private FragmentManager fragmentManager;
private ImageView userImage;
private CompositeDisposable disposable; private CompositeDisposable disposable;
private TextView bannerTitle;
@NonNull @NonNull
public static Fragment newInstance(int tab) { public static Fragment newInstance(int tab) {
@ -84,16 +81,15 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
View view = inflater.inflate(R.layout.fragment_library, container, false); View view = inflater.inflate(R.layout.fragment_library, container, false);
disposable = new CompositeDisposable(); disposable = new CompositeDisposable();
contentContainer = view.findViewById(R.id.fragmentContainer); contentContainer = view.findViewById(R.id.fragmentContainer);
bannerTitle = view.findViewById(R.id.bannerTitle);
appBarLayout = view.findViewById(R.id.appBarLayout); appBarLayout = view.findViewById(R.id.appBarLayout);
toolbar = view.findViewById(R.id.toolbar); toolbar = view.findViewById(R.id.toolbar);
userImage = view.findViewById(R.id.userImage);
userImage.setOnClickListener(v -> showMainMenu());
return view; return view;
} }
public void setTitle(@StringRes int name) { public void setTitle(@StringRes int name) {
bannerTitle.setText(getString(name)); toolbar.setTitle(getString(name));
} }
public void addOnAppBarOffsetChangedListener(@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) { public void addOnAppBarOffsetChangedListener(@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
@ -143,17 +139,16 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
private void setupToolbar() { private void setupToolbar() {
int primaryColor = ThemeStore.Companion.primaryColor(getContext()); int primaryColor = ThemeStore.Companion.primaryColor(getContext());
TintHelper.setTintAuto(contentContainer, primaryColor, true); TintHelper.setTintAuto(contentContainer, primaryColor, true);
bannerTitle.setTextColor(ThemeStore.Companion.textColorPrimary(getContext())); toolbar.setOnClickListener(v -> {
showMainMenu();
});
toolbar.setBackgroundColor(primaryColor); toolbar.setBackgroundColor(primaryColor);
toolbar.setNavigationIcon(null); toolbar.setNavigationIcon(null);
appBarLayout.setBackgroundColor(primaryColor); appBarLayout.setBackgroundColor(primaryColor);
appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) ->
getMainActivity().setLightStatusbar(!ATHUtil.INSTANCE.isWindowBackgroundDark(getContext()))); getMainActivity().setLightStatusbar(!ATHUtil.INSTANCE.isWindowBackgroundDark(getContext())));
getMainActivity().setTitle(null);
getMainActivity().setSupportActionBar(toolbar); getMainActivity().setSupportActionBar(toolbar);
} }
private Fragment getCurrentFragment() { private Fragment getCurrentFragment() {

View file

@ -2,7 +2,6 @@ package code.name.monkey.retromusic.fragments.mainactivity.folders;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable;
import android.media.MediaScannerConnection; import android.media.MediaScannerConnection;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
@ -14,10 +13,8 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import android.widget.ImageView;
import android.widget.PopupMenu; import android.widget.PopupMenu;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -31,10 +28,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.afollestad.materialcab.MaterialCab; import com.afollestad.materialcab.MaterialCab;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.bottomsheets.BottomSheet; import com.afollestad.materialdialogs.bottomsheets.BottomSheet;
import com.bumptech.glide.request.Request;
import com.bumptech.glide.request.target.SizeReadyCallback;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView; import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
@ -59,7 +52,6 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.adapter.SongFileAdapter; import code.name.monkey.retromusic.adapter.SongFileAdapter;
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment; import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment;
import code.name.monkey.retromusic.glide.GlideApp;
import code.name.monkey.retromusic.helper.MusicPlayerRemote; import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.helper.menu.SongMenuHelper; import code.name.monkey.retromusic.helper.menu.SongMenuHelper;
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper; import code.name.monkey.retromusic.helper.menu.SongsMenuHelper;
@ -76,8 +68,6 @@ import code.name.monkey.retromusic.util.RetroColorUtil;
import code.name.monkey.retromusic.util.ViewUtil; import code.name.monkey.retromusic.util.ViewUtil;
import code.name.monkey.retromusic.views.BreadCrumbLayout; import code.name.monkey.retromusic.views.BreadCrumbLayout;
import static code.name.monkey.retromusic.Constants.USER_PROFILE;
public class FoldersFragment extends AbsMainActivityFragment implements public class FoldersFragment extends AbsMainActivityFragment implements
MainActivityFragmentCallbacks, MainActivityFragmentCallbacks,
CabHolder, BreadCrumbLayout.SelectionCallback, SongFileAdapter.Callbacks, CabHolder, BreadCrumbLayout.SelectionCallback, SongFileAdapter.Callbacks,
@ -95,15 +85,12 @@ public class FoldersFragment extends AbsMainActivityFragment implements
private View coordinatorLayout, container, empty; private View coordinatorLayout, container, empty;
private TextView title;
private Toolbar toolbar; private Toolbar toolbar;
private BreadCrumbLayout breadCrumbs; private BreadCrumbLayout breadCrumbs;
private AppBarLayout appBarLayout; private AppBarLayout appBarLayout;
private ImageView userImage;
private FastScrollRecyclerView recyclerView; private FastScrollRecyclerView recyclerView;
@ -162,14 +149,12 @@ public class FoldersFragment extends AbsMainActivityFragment implements
private void initViews(View view) { private void initViews(View view) {
coordinatorLayout = view.findViewById(R.id.coordinatorLayout); coordinatorLayout = view.findViewById(R.id.coordinatorLayout);
userImage = view.findViewById(R.id.userImage);
userImage.setOnClickListener(v -> showMainMenu());
recyclerView = view.findViewById(R.id.recyclerView); recyclerView = view.findViewById(R.id.recyclerView);
appBarLayout = view.findViewById(R.id.appBarLayout); appBarLayout = view.findViewById(R.id.appBarLayout);
breadCrumbs = view.findViewById(R.id.breadCrumbs); breadCrumbs = view.findViewById(R.id.breadCrumbs);
toolbar = view.findViewById(R.id.toolbar); toolbar = view.findViewById(R.id.toolbar);
empty = view.findViewById(android.R.id.empty); empty = view.findViewById(android.R.id.empty);
title = view.findViewById(R.id.bannerTitle);
container = view.findViewById(R.id.container); container = view.findViewById(R.id.container);
} }
@ -242,19 +227,14 @@ public class FoldersFragment extends AbsMainActivityFragment implements
} }
private void setUpAppbarColor() { private void setUpAppbarColor() {
title.setTextColor(ThemeStore.Companion.textColorPrimary(getContext()));
int primaryColor = ThemeStore.Companion.primaryColor(getContext()); int primaryColor = ThemeStore.Companion.primaryColor(getContext());
getActivity().setTitle(null);
getMainActivity().setSupportActionBar(toolbar); getMainActivity().setSupportActionBar(toolbar);
TintHelper.setTintAuto(container, primaryColor, true); TintHelper.setTintAuto(container, primaryColor, true);
appBarLayout.setBackgroundColor(primaryColor); appBarLayout.setBackgroundColor(primaryColor);
toolbar.setBackgroundColor(primaryColor); toolbar.setBackgroundColor(primaryColor);
toolbar.setNavigationOnClickListener(v -> { toolbar.setOnClickListener(v -> {
getActivity().onBackPressed(); showMainMenu();
}); });
breadCrumbs.setActivatedContentColor(ToolbarContentTintHelper.toolbarTitleColor(getActivity(), ColorUtil.INSTANCE.darkenColor(primaryColor))); breadCrumbs.setActivatedContentColor(ToolbarContentTintHelper.toolbarTitleColor(getActivity(), ColorUtil.INSTANCE.darkenColor(primaryColor)));
breadCrumbs.setDeactivatedContentColor(ToolbarContentTintHelper.toolbarSubtitleColor(getActivity(), breadCrumbs.setDeactivatedContentColor(ToolbarContentTintHelper.toolbarSubtitleColor(getActivity(),
ColorUtil.INSTANCE.darkenColor(primaryColor))); ColorUtil.INSTANCE.darkenColor(primaryColor)));

View file

@ -1,23 +1,17 @@
package code.name.monkey.retromusic.fragments.mainactivity.home package code.name.monkey.retromusic.fragments.mainactivity.home
import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.view.* import android.view.*
import android.widget.ImageView
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.common.ATHToolbarActivity import code.name.monkey.appthemehelper.common.ATHToolbarActivity
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.Constants.USER_BANNER
import code.name.monkey.retromusic.Constants.USER_PROFILE
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.HomeAdapter import code.name.monkey.retromusic.adapter.HomeAdapter
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
import code.name.monkey.retromusic.glide.GlideApp
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
import code.name.monkey.retromusic.loaders.SongLoader import code.name.monkey.retromusic.loaders.SongLoader
@ -27,22 +21,11 @@ import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
import code.name.monkey.retromusic.mvp.contract.HomeContract import code.name.monkey.retromusic.mvp.contract.HomeContract
import code.name.monkey.retromusic.mvp.presenter.HomePresenter import code.name.monkey.retromusic.mvp.presenter.HomePresenter
import code.name.monkey.retromusic.util.Compressor
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.Request
import com.bumptech.glide.request.target.SizeReadyCallback
import com.bumptech.glide.request.target.Target
import com.bumptech.glide.request.transition.Transition
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.fragment_banner_home.* import kotlinx.android.synthetic.main.fragment_banner_home.*
import java.io.File
import java.util.*
import kotlin.collections.ArrayList
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeContract.HomeView { class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks, HomeContract.HomeView {
override fun showEmpty() { override fun showEmpty() {
@ -56,11 +39,10 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
private lateinit var topPlayed: View private lateinit var topPlayed: View
private lateinit var actionShuffle: View private lateinit var actionShuffle: View
private lateinit var history: View private lateinit var history: View
private lateinit var userImage: ImageView
private lateinit var toolbar: Toolbar private lateinit var toolbar: Toolbar
override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(if (PreferenceUtil.getInstance().isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, viewGroup, false) return inflater.inflate(R.layout.fragment_home, viewGroup, false)
} }
private val displayMetrics: DisplayMetrics private val displayMetrics: DisplayMetrics
@ -71,44 +53,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
return metrics return metrics
} }
private fun getTimeOfTheDay() {
val c = Calendar.getInstance()
val timeOfDay = c.get(Calendar.HOUR_OF_DAY)
var images = arrayOf<String>()
when (timeOfDay) {
in 0..5 -> images = resources.getStringArray(R.array.night)
in 6..11 -> images = resources.getStringArray(R.array.morning)
in 12..15 -> images = resources.getStringArray(R.array.after_noon)
in 16..19 -> images = resources.getStringArray(R.array.evening)
in 20..23 -> images = resources.getStringArray(R.array.night)
}
val day = images[Random().nextInt(images.size)]
loadTimeImage(day)
}
private fun loadTimeImage(day: String) {
if (bannerImage != null) {
if (PreferenceUtil.getInstance().bannerImage.isEmpty()) {
GlideApp.with(activity!!)
.load(day)
.placeholder(R.drawable.material_design_default)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(bannerImage!!)
} else {
disposable.add(Compressor(context!!)
.setQuality(100)
.setCompressFormat(Bitmap.CompressFormat.WEBP)
.compressToBitmapAsFlowable(File(PreferenceUtil.getInstance().bannerImage, USER_BANNER))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { bannerImage!!.setImageBitmap(it) })
}
}
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
homePresenter = HomePresenter(this) homePresenter = HomePresenter(this)
@ -142,9 +86,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
NavigationUtil.goToPlaylistNew(mainActivity, HistoryPlaylist(mainActivity)) NavigationUtil.goToPlaylistNew(mainActivity, HistoryPlaylist(mainActivity))
} }
userImage = view.findViewById(R.id.userImage)
userImage.setOnClickListener { showMainMenu() }
homePresenter = HomePresenter(this) homePresenter = HomePresenter(this)
contentContainerView = view.findViewById(R.id.contentContainer) contentContainerView = view.findViewById(R.id.contentContainer)
@ -168,12 +109,12 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
} }
private fun setupToolbar() { private fun setupToolbar() {
mainActivity.title = null
toolbar.apply { toolbar.apply {
setBackgroundColor(if (PreferenceUtil.getInstance().isHomeBanner) Color.TRANSPARENT else ThemeStore.primaryColor(context)) setBackgroundColor(if (PreferenceUtil.getInstance().isHomeBanner) Color.TRANSPARENT else ThemeStore.primaryColor(context))
setNavigationOnClickListener { setNavigationOnClickListener {
NavigationUtil.goToSearch(activity) NavigationUtil.goToSearch(activity)
} }
setOnClickListener { showMainMenu() }
} }
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
} }
@ -185,7 +126,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
disposable = CompositeDisposable() disposable = CompositeDisposable()
getTimeOfTheDay()
} }
override fun onDestroyView() { override fun onDestroyView() {

View file

@ -14,27 +14,16 @@
package code.name.monkey.retromusic.fragments.settings package code.name.monkey.retromusic.fragments.settings
import android.graphics.Bitmap
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.Constants.USER_PROFILE
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.SettingsActivity import code.name.monkey.retromusic.activities.SettingsActivity
import code.name.monkey.retromusic.util.Compressor
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.fragment_main_settings.* import kotlinx.android.synthetic.main.fragment_main_settings.*
import java.io.File
import java.util.*
class MainSettingsFragment : Fragment(), View.OnClickListener { class MainSettingsFragment : Fragment(), View.OnClickListener {
@ -70,30 +59,11 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
otherSettings.setOnClickListener(this) otherSettings.setOnClickListener(this)
aboutSettings.setOnClickListener(this) aboutSettings.setOnClickListener(this)
text.setTextColor(ThemeStore.textColorSecondary(context!!))
text.text = PreferenceUtil.getInstance().userBio
titleWelcome.setTextColor(ThemeStore.textColorPrimary(context!!))
titleWelcome.text = String.format("%s %s!", getTimeOfTheDay(), PreferenceUtil.getInstance().userName)
userInfoContainer.setOnClickListener { NavigationUtil.goToUserInfo(activity!!) }
} }
private fun inflateFragment(fragment: Fragment, @StringRes title: Int) { private fun inflateFragment(fragment: Fragment, @StringRes title: Int) {
if (activity != null) { if (activity != null) {
(activity as SettingsActivity).setupFragment(fragment, title) (activity as SettingsActivity).setupFragment(fragment, title)
} }
} }
private fun getTimeOfTheDay(): String {
var message = getString(R.string.title_good_day)
val c = Calendar.getInstance()
val timeOfDay = c.get(Calendar.HOUR_OF_DAY)
when (timeOfDay) {
in 0..5 -> message = getString(R.string.title_good_night)
in 6..11 -> message = getString(R.string.title_good_morning)
in 12..15 -> message = getString(R.string.title_good_afternoon)
in 16..19 -> message = getString(R.string.title_good_evening)
in 20..23 -> message = getString(R.string.title_good_night)
}
return message
}
} }

View file

@ -25,36 +25,12 @@
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:elevation="0dp" android:elevation="0dp"
app:elevation="0dp"> app:elevation="0dp">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
app:title="@string/app_name"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute" />
<code.name.monkey.retromusic.views.UserImageView
android:id="@+id/userImage"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="14dp"
android:layout_weight="0"
android:background="@android:color/transparent"
app:civ_border="false"
app:civ_border_width="0dp"
app:civ_shadow="false" />
<TextView
android:id="@+id/bannerTitle"
style="@style/BigTitleTextAppearanceToolbar"
android:layout_gravity="start|center_vertical"
android:paddingStart="24dp"
android:paddingEnd="8dp"
android:text="@string/library"
android:textColor="@color/md_white_1000"
tools:ignore="MissingPrefix" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>

View file

@ -31,32 +31,8 @@
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
tools:ignore="UnusedAttribute"> app:title="@string/app_name"
tools:ignore="UnusedAttribute" />
<code.name.monkey.retromusic.views.UserImageView
android:id="@+id/userImage"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="14dp"
android:layout_weight="0"
android:background="@android:color/transparent"
app:civ_border="false"
app:civ_border_width="0dp"
app:civ_shadow="false" />
<TextView
android:id="@+id/bannerTitle"
style="@style/BigTitleTextAppearanceToolbar"
android:layout_gravity="start|center_vertical"
android:paddingStart="24dp"
android:paddingEnd="8dp"
android:text="@string/library"
android:textColor="@color/md_white_1000"
tools:ignore="MissingPrefix" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView

View file

@ -32,31 +32,8 @@
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
tools:ignore="UnusedAttribute"> app:title="@string/app_name"
tools:ignore="UnusedAttribute" />
<code.name.monkey.retromusic.views.UserImageView
android:id="@+id/userImage"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="14dp"
android:layout_weight="0"
android:background="@android:color/transparent"
app:civ_border="false"
app:civ_border_width="0dp"
app:civ_shadow="false" />
<TextView
android:id="@+id/bannerTitle"
style="@style/BigTitleTextAppearanceToolbar"
android:layout_gravity="start|center_vertical"
android:paddingStart="24dp"
android:paddingEnd="8dp"
android:text="@string/library"
android:textColor="@color/md_white_1000"
tools:ignore="MissingPrefix" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView

View file

@ -40,30 +40,8 @@
style="@style/Toolbar" style="@style/Toolbar"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
tools:ignore="UnusedAttribute"> app:title="@string/folders"
tools:ignore="UnusedAttribute" />
<code.name.monkey.retromusic.views.UserImageView
android:id="@+id/userImage"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="14dp"
android:layout_weight="0"
android:background="@android:color/transparent"
app:civ_border="false"
app:civ_border_width="0dp"
app:civ_shadow="false" />
<TextView
android:id="@+id/bannerTitle"
style="@style/BigTitleTextAppearanceToolbar"
android:layout_gravity="start|center_vertical"
android:paddingStart="24dp"
android:paddingEnd="8dp"
android:text="@string/folders"
tools:ignore="MissingPrefix" />
</androidx.appcompat.widget.Toolbar>
<ViewStub <ViewStub
android:id="@+id/cab_stub" android:id="@+id/cab_stub"

View file

@ -27,31 +27,9 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
app:title="@string/app_name"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute" />
<code.name.monkey.retromusic.views.UserImageView
android:id="@+id/userImage"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="14dp"
android:layout_weight="0"
android:background="@android:color/transparent"
app:civ_border="false"
app:civ_border_width="0dp"
app:civ_shadow="false" />
<TextView
android:id="@+id/bannerTitle"
style="@style/BigTitleTextAppearanceToolbar"
android:layout_gravity="start|center_vertical"
android:paddingStart="24dp"
android:paddingEnd="8dp"
android:text="@string/app_name"
tools:ignore="MissingPrefix" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>

View file

@ -38,31 +38,7 @@
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute" />
<code.name.monkey.retromusic.views.UserImageView
android:id="@+id/userImage"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="14dp"
android:layout_weight="0"
android:background="@android:color/transparent"
app:civ_border="false"
app:civ_border_width="0dp"
app:civ_shadow="false" />
<TextView
android:id="@+id/bannerTitle"
style="@style/BigTitleTextAppearanceToolbar"
android:layout_gravity="start|center_vertical"
android:paddingStart="24dp"
android:paddingEnd="8dp"
android:text="@string/library"
android:textColor="@color/md_white_1000"
tools:ignore="MissingPrefix" />
</androidx.appcompat.widget.Toolbar>
<ViewStub <ViewStub
android:id="@+id/cab_stub" android:id="@+id/cab_stub"

View file

@ -7,59 +7,6 @@
android:orientation="vertical" android:orientation="vertical"
tools:ignore="MissingPrefix"> tools:ignore="MissingPrefix">
<LinearLayout
android:id="@+id/userInfoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp">
<code.name.monkey.retromusic.views.CircularImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_weight="0"
app:civ_border="false" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingStart="12dp"
android:paddingEnd="12dp">
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
android:textSize="18sp" />
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.75"
android:ellipsize="end"
android:text="@string/lets_play_something" />
</LinearLayout>
<code.name.monkey.retromusic.views.IconImageView
android:id="@+id/actionSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?roundSelector"
android:gravity="center_vertical"
android:padding="12dp"
android:textAllCaps="false"
app:srcCompat="@drawable/ic_settings_white_24dp" />
</LinearLayout>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/buyProContainer" android:id="@+id/buyProContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -116,6 +63,16 @@
app:optionIcon="@drawable/ic_folder_white_24dp" app:optionIcon="@drawable/ic_folder_white_24dp"
app:optionTitle="@string/folders" /> app:optionTitle="@string/folders" />
<code.name.monkey.retromusic.views.OptionMenuItemView
android:id="@+id/actionSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?rectSelector"
android:clickable="true"
android:focusable="true"
app:optionIcon="@drawable/ic_settings_white_24dp"
app:optionTitle="@string/action_settings" />
<code.name.monkey.retromusic.views.OptionMenuItemView <code.name.monkey.retromusic.views.OptionMenuItemView
android:id="@+id/actionEqualizer" android:id="@+id/actionEqualizer"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -13,60 +13,6 @@
android:orientation="vertical" android:orientation="vertical"
tools:background="@color/md_black_1000"> tools:background="@color/md_black_1000">
<LinearLayout
android:id="@+id/userInfoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="72dp"
android:orientation="horizontal">
<code.name.monkey.retromusic.views.UserImageView
android:id="@+id/userImage"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_weight="0"
android:background="@android:color/transparent"
app:civ_border="false"
app:civ_border_width="0dp"
app:civ_shadow="false" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:orientation="vertical"
android:paddingEnd="12dp"
android:paddingBottom="8dp">
<code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/titleWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="@string/general_settings_title"
android:textSize="@dimen/ate_default_textsize_subheading"
app:fontFamily="@font/circular_std_medium" />
<code.name.monkey.appthemehelper.common.views.ATESecondaryTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:maxLines="4"
android:text="@string/lets_play_something"
android:textSize="@dimen/ate_default_textsize_body"
tools:text="Summary" />
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/generalSettings" android:id="@+id/generalSettings"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -2,12 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_scan"
android:icon="@drawable/ic_scanner_white_24dp"
android:title="@string/scan_media"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_go_to_start_directory" android:id="@+id/action_go_to_start_directory"
android:icon="@drawable/ic_bookmark_music_white_24dp" android:icon="@drawable/ic_bookmark_music_white_24dp"

View file

@ -41,8 +41,6 @@
<style name="ToolbarTextAppearance"> <style name="ToolbarTextAppearance">
<item name="android:textStyle">bold</item>
<item name="android:fontFamily">@font/circular</item>
</style> </style>
<style name="ToolbarSubTitleTextAppearance"> <style name="ToolbarSubTitleTextAppearance">