diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt index 3180b8f2..2a1511a7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt @@ -14,54 +14,26 @@ package code.name.monkey.retromusic.dialogs +import android.app.Dialog import android.content.Intent -import android.graphics.Bitmap import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup 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.retromusic.App -import code.name.monkey.retromusic.Constants.USER_PROFILE import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.MainActivity 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.PreferenceUtil -import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.disposables.CompositeDisposable -import io.reactivex.schedulers.Schedulers +import com.afollestad.materialdialogs.MaterialDialog +import com.afollestad.materialdialogs.bottomsheets.BottomSheet import kotlinx.android.synthetic.main.fragment_main_options.* -import java.io.File -import java.util.* -class OptionsSheetDialogFragment : RoundedBottomSheetDialogFragment(), 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() - } +class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { 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?) { 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) - actionSleepTimer.setOnClickListener(this) actionLibrary.setOnClickListener(this) - userInfoContainer.setOnClickListener(this) actionEqualizer.setOnClickListener(this) actionFolders.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.actionLibrary -> mainActivity.selectedFragment(PreferenceUtil.getInstance().lastPage) R.id.actionSettings -> NavigationUtil.goToSettings(mainActivity) - R.id.actionSleepTimer -> if (fragmentManager != null) { SleepTimerDialog().show(fragmentManager!!, TAG) } - R.id.userInfoContainer -> NavigationUtil.goToUserInfo(mainActivity) R.id.actionRate -> NavigationUtil.goToPlayStore(mainActivity) R.id.actionShare -> shareApp() 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 { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/ScanMediaFolderChooserDialog.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/ScanMediaFolderChooserDialog.java deleted file mode 100644 index 5b4acea7..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/ScanMediaFolderChooserDialog.java +++ /dev/null @@ -1 +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.dialogs; import android.app.Activity; import android.content.Context; import android.media.MediaScannerConnection; import android.os.Bundle; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener; import code.name.monkey.retromusic.util.PreferenceUtil; public class ScanMediaFolderChooserDialog extends DialogFragment /*implements MaterialDialog.ListCallback*/ { String initialPath = PreferenceUtil.getInstance().getStartDirectory().getAbsolutePath(); private File parentFolder; private File[] parentContents; private boolean canGoUp = false; public static ScanMediaFolderChooserDialog create() { return new ScanMediaFolderChooserDialog(); } private static void scanPaths(@NonNull WeakReference activityWeakReference, @NonNull Context applicationContext, @Nullable String[] toBeScanned) { Activity activity = activityWeakReference.get(); if (toBeScanned == null || toBeScanned.length < 1) { Toast.makeText(applicationContext, R.string.nothing_to_scan, Toast.LENGTH_SHORT).show(); } else { MediaScannerConnection.scanFile(applicationContext, toBeScanned, null, activity != null ? new UpdateToastMediaScannerCompletionListener(activity, toBeScanned) : null); } } private String[] getContentsArray() { if (parentContents == null) { if (canGoUp) { return new String[]{".."}; } return new String[]{}; } String[] results = new String[parentContents.length + (canGoUp ? 1 : 0)]; if (canGoUp) { results[0] = ".."; } for (int i = 0; i < parentContents.length; i++) { results[canGoUp ? i + 1 : i] = parentContents[i].getName(); } return results; } private File[] listFiles() { File[] contents = parentFolder.listFiles(); List results = new ArrayList<>(); if (contents != null) { for (File fi : contents) { if (fi.isDirectory()) { results.add(fi); } } Collections.sort(results, new FolderSorter()); return results.toArray(new File[results.size()]); } return null; } /*@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission( getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { return new MaterialDialog.Builder(getActivity()) .title(R.string.md_error_label) .content(R.string.md_storage_perm_error) .positiveText(android.R.string.ok) .build(); } if (savedInstanceState == null) { savedInstanceState = new Bundle(); } if (!savedInstanceState.containsKey("current_path")) { savedInstanceState.putString("current_path", initialPath); } parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator)); checkIfCanGoUp(); parentContents = listFiles(); MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()) .title(parentFolder.getAbsolutePath()) .items((CharSequence[]) getContentsArray()) .itemsCallback(this) .autoDismiss(false) .onPositive((dialog, which) -> { final Context applicationContext = getActivity().getApplicationContext(); final WeakReference activityWeakReference = new WeakReference<>(getActivity()); dismiss(); new FoldersFragment.ListPathsAsyncTask(getActivity(), paths -> scanPaths(activityWeakReference, applicationContext, paths)).execute(new FoldersFragment.ListPathsAsyncTask.LoadingInfo(parentFolder, FoldersFragment.AUDIO_FILE_FILTER)); }) .onNegative((materialDialog, dialogAction) -> dismiss()) .positiveText(R.string.action_scan_directory) .negativeText(android.R.string.cancel); return builder.build(); } @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) { if (canGoUp && i == 0) { parentFolder = parentFolder.getParentFile(); if (parentFolder.getAbsolutePath().equals("/storage/emulated")) { parentFolder = parentFolder.getParentFile(); } checkIfCanGoUp(); } else { parentFolder = parentContents[canGoUp ? i - 1 : i]; canGoUp = true; if (parentFolder.getAbsolutePath().equals("/storage/emulated")) { parentFolder = Environment.getExternalStorageDirectory(); } } reload(); }*/ private void checkIfCanGoUp() { canGoUp = parentFolder.getParent() != null; } private void reload() { parentContents = listFiles(); MaterialDialog dialog = (MaterialDialog) getDialog(); dialog.setTitle(parentFolder.getAbsolutePath()); //dialog.setItems((CharSequence[]) getContentsArray()); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("current_path", parentFolder.getAbsolutePath()); } private static class FolderSorter implements Comparator { @Override public int compare(File lhs, File rhs) { return lhs.getName().compareTo(rhs.getName()); } } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java index 5cd05650..7c73171d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/LibraryFragment.java @@ -9,8 +9,6 @@ import android.view.MenuItem; import android.view.SubMenu; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -53,9 +51,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde private MaterialCab cab; private FragmentManager fragmentManager; - private ImageView userImage; private CompositeDisposable disposable; - private TextView bannerTitle; + @NonNull 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); disposable = new CompositeDisposable(); contentContainer = view.findViewById(R.id.fragmentContainer); - bannerTitle = view.findViewById(R.id.bannerTitle); + appBarLayout = view.findViewById(R.id.appBarLayout); toolbar = view.findViewById(R.id.toolbar); - userImage = view.findViewById(R.id.userImage); - userImage.setOnClickListener(v -> showMainMenu()); + return view; } - + public void setTitle(@StringRes int name) { - bannerTitle.setText(getString(name)); + toolbar.setTitle(getString(name)); } public void addOnAppBarOffsetChangedListener(@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) { @@ -143,17 +139,16 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde private void setupToolbar() { int primaryColor = ThemeStore.Companion.primaryColor(getContext()); TintHelper.setTintAuto(contentContainer, primaryColor, true); - bannerTitle.setTextColor(ThemeStore.Companion.textColorPrimary(getContext())); - + toolbar.setOnClickListener(v -> { + showMainMenu(); + }); toolbar.setBackgroundColor(primaryColor); toolbar.setNavigationIcon(null); appBarLayout.setBackgroundColor(primaryColor); appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> getMainActivity().setLightStatusbar(!ATHUtil.INSTANCE.isWindowBackgroundDark(getContext()))); - getMainActivity().setTitle(null); getMainActivity().setSupportActionBar(toolbar); - } private Fragment getCurrentFragment() { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java index b6951fc7..8d8560eb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/folders/FoldersFragment.java @@ -2,7 +2,6 @@ package code.name.monkey.retromusic.fragments.mainactivity.folders; import android.app.Dialog; import android.content.Context; -import android.graphics.drawable.Drawable; import android.media.MediaScannerConnection; import android.os.Bundle; import android.os.Environment; @@ -14,10 +13,8 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.webkit.MimeTypeMap; -import android.widget.ImageView; import android.widget.PopupMenu; import android.widget.ProgressBar; -import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; @@ -31,10 +28,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.afollestad.materialcab.MaterialCab; import com.afollestad.materialdialogs.MaterialDialog; 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.snackbar.Snackbar; 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.adapter.SongFileAdapter; 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.menu.SongMenuHelper; 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.views.BreadCrumbLayout; -import static code.name.monkey.retromusic.Constants.USER_PROFILE; - public class FoldersFragment extends AbsMainActivityFragment implements MainActivityFragmentCallbacks, CabHolder, BreadCrumbLayout.SelectionCallback, SongFileAdapter.Callbacks, @@ -95,15 +85,12 @@ public class FoldersFragment extends AbsMainActivityFragment implements private View coordinatorLayout, container, empty; - private TextView title; - private Toolbar toolbar; private BreadCrumbLayout breadCrumbs; private AppBarLayout appBarLayout; - private ImageView userImage; private FastScrollRecyclerView recyclerView; @@ -162,14 +149,12 @@ public class FoldersFragment extends AbsMainActivityFragment implements private void initViews(View view) { coordinatorLayout = view.findViewById(R.id.coordinatorLayout); - userImage = view.findViewById(R.id.userImage); - userImage.setOnClickListener(v -> showMainMenu()); + recyclerView = view.findViewById(R.id.recyclerView); appBarLayout = view.findViewById(R.id.appBarLayout); breadCrumbs = view.findViewById(R.id.breadCrumbs); toolbar = view.findViewById(R.id.toolbar); empty = view.findViewById(android.R.id.empty); - title = view.findViewById(R.id.bannerTitle); container = view.findViewById(R.id.container); } @@ -242,19 +227,14 @@ public class FoldersFragment extends AbsMainActivityFragment implements } private void setUpAppbarColor() { - title.setTextColor(ThemeStore.Companion.textColorPrimary(getContext())); - int primaryColor = ThemeStore.Companion.primaryColor(getContext()); - - getActivity().setTitle(null); getMainActivity().setSupportActionBar(toolbar); TintHelper.setTintAuto(container, primaryColor, true); appBarLayout.setBackgroundColor(primaryColor); toolbar.setBackgroundColor(primaryColor); - toolbar.setNavigationOnClickListener(v -> { - getActivity().onBackPressed(); + toolbar.setOnClickListener(v -> { + showMainMenu(); }); - breadCrumbs.setActivatedContentColor(ToolbarContentTintHelper.toolbarTitleColor(getActivity(), ColorUtil.INSTANCE.darkenColor(primaryColor))); breadCrumbs.setDeactivatedContentColor(ToolbarContentTintHelper.toolbarSubtitleColor(getActivity(), ColorUtil.INSTANCE.darkenColor(primaryColor))); 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 57b87883..9ebf6bcb 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 @@ -1,23 +1,17 @@ package code.name.monkey.retromusic.fragments.mainactivity.home -import android.graphics.Bitmap import android.graphics.Color -import android.graphics.drawable.Drawable import android.os.Bundle import android.util.DisplayMetrics import android.view.* -import android.widget.ImageView import androidx.appcompat.widget.Toolbar import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.common.ATHToolbarActivity 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.adapter.HomeAdapter 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.interfaces.MainActivityFragmentCallbacks 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.mvp.contract.HomeContract 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.PreferenceUtil 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.schedulers.Schedulers 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 { override fun showEmpty() { @@ -56,11 +39,10 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba private lateinit var topPlayed: View private lateinit var actionShuffle: View private lateinit var history: View - private lateinit var userImage: ImageView private lateinit var toolbar: Toolbar 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 @@ -71,44 +53,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba return metrics } - private fun getTimeOfTheDay() { - val c = Calendar.getInstance() - val timeOfDay = c.get(Calendar.HOUR_OF_DAY) - - var images = arrayOf() - 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?) { super.onCreate(savedInstanceState) homePresenter = HomePresenter(this) @@ -142,9 +86,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba NavigationUtil.goToPlaylistNew(mainActivity, HistoryPlaylist(mainActivity)) } - userImage = view.findViewById(R.id.userImage) - userImage.setOnClickListener { showMainMenu() } - homePresenter = HomePresenter(this) contentContainerView = view.findViewById(R.id.contentContainer) @@ -168,12 +109,12 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba } private fun setupToolbar() { - mainActivity.title = null toolbar.apply { setBackgroundColor(if (PreferenceUtil.getInstance().isHomeBanner) Color.TRANSPARENT else ThemeStore.primaryColor(context)) setNavigationOnClickListener { NavigationUtil.goToSearch(activity) } + setOnClickListener { showMainMenu() } } mainActivity.setSupportActionBar(toolbar) } @@ -185,7 +126,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba override fun onResume() { super.onResume() disposable = CompositeDisposable() - getTimeOfTheDay() } override fun onDestroyView() { 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 0e9ca834..bf15722b 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 @@ -14,27 +14,16 @@ package code.name.monkey.retromusic.fragments.settings -import android.graphics.Bitmap import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.annotation.StringRes -import androidx.core.content.ContextCompat 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.activities.SettingsActivity -import code.name.monkey.retromusic.util.Compressor 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 java.io.File -import java.util.* class MainSettingsFragment : Fragment(), View.OnClickListener { @@ -70,30 +59,11 @@ class MainSettingsFragment : Fragment(), View.OnClickListener { otherSettings.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) { if (activity != null) { (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 - } } \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_home.xml b/app/src/main/res/layout-land/fragment_home.xml index 61b51fd7..ec646ecd 100644 --- a/app/src/main/res/layout-land/fragment_home.xml +++ b/app/src/main/res/layout-land/fragment_home.xml @@ -25,36 +25,12 @@ android:background="@android:color/transparent" android:elevation="0dp" app:elevation="0dp"> - - - - - - - + tools:ignore="UnusedAttribute" /> diff --git a/app/src/main/res/layout-xlarge-land/fragment_home.xml b/app/src/main/res/layout-xlarge-land/fragment_home.xml index c332b986..e735bb92 100644 --- a/app/src/main/res/layout-xlarge-land/fragment_home.xml +++ b/app/src/main/res/layout-xlarge-land/fragment_home.xml @@ -31,32 +31,8 @@ android:id="@+id/toolbar" style="@style/Toolbar" app:layout_collapseMode="pin" - tools:ignore="UnusedAttribute"> - - - - - - - + app:title="@string/app_name" + tools:ignore="UnusedAttribute" /> - - - - - - + app:title="@string/app_name" + tools:ignore="UnusedAttribute" /> - - - - - - + app:title="@string/folders" + tools:ignore="UnusedAttribute" /> - - - - - - + tools:ignore="UnusedAttribute" /> diff --git a/app/src/main/res/layout/fragment_library.xml b/app/src/main/res/layout/fragment_library.xml index 9a696c75..f59b53a6 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -38,31 +38,7 @@ android:id="@+id/toolbar" style="@style/Toolbar" app:layout_collapseMode="pin" - tools:ignore="UnusedAttribute"> - - - - - - + tools:ignore="UnusedAttribute" /> - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - bold - @font/circular