diff --git a/MusicApp/MainActivity.cs b/MusicApp/MainActivity.cs index b42b39a..f66d080 100644 --- a/MusicApp/MainActivity.cs +++ b/MusicApp/MainActivity.cs @@ -38,6 +38,8 @@ namespace MusicApp { public static MainActivity instance; public static int paddingBot = 0; + public new static int Theme = 1; + public static int dialogTheme; public Android.Support.V7.Widget.Toolbar ToolBar; public bool NoToolbarMenu = false; @@ -82,6 +84,8 @@ namespace MusicApp { base.OnCreate(savedInstanceState); + ISharedPreferences pref = PreferenceManager.GetDefaultSharedPreferences(this); + SwitchTheme(pref.GetInt("theme", 1)); SetContentView(Resource.Layout.Main); Song song = (Song) Intent.GetStringExtra("Song"); instance = this; @@ -127,6 +131,22 @@ namespace MusicApp Navigate(Resource.Id.musicLayout); } + public void SwitchTheme(int themeID) + { + Theme = themeID; + if (themeID == 0) + { + dialogTheme = Resource.Style.AppCompatAlertDialogStyle; + SetTheme(Resource.Style.Theme); + } + else + { + SetTheme(Resource.Style.DarkTheme); + dialogTheme = Resource.Style.AppCompatDarkAlertDialogStyle; + //((RelativeLayout)FindViewById(Resource.Id.snackBar).Parent).SetBackgroundColor(new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.primary_material_dark))); + } + } + public void Login() { AccountStore accountStore = AccountStore.Create(); @@ -985,7 +1005,9 @@ namespace MusicApp if(paths.Count == 0) { - //MAKE HERE ERROR MESSAGE FOR NO FILES ON THE DEVICE + ((Snackbar)Snackbar.Make(FindViewById(Resource.Id.snackBar), "No music file found on this device. Can't create a mix.", Snackbar.LengthLong) + .AddCallback(new SnackbarCallback()) + ).Show(); return; } @@ -1009,8 +1031,15 @@ namespace MusicApp HideSearch(); SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).Commit(); } - //else - //MAKE ERROR MESSAGE WHEN PLAYLIST ID IS NULL + else + ((Snackbar)Snackbar.Make(FindViewById(Resource.Id.snackBar), "No playlist set on setting.", Snackbar.LengthLong) + .SetAction("Set it now", (v) => + { + Intent intent = new Intent(Application.Context, typeof(Preferences)); + StartActivity(intent); + }) + .AddCallback(new SnackbarCallback()) + ).Show(); } } diff --git a/MusicApp/MusicApp.csproj b/MusicApp/MusicApp.csproj index 2e2f815..1eca778 100644 --- a/MusicApp/MusicApp.csproj +++ b/MusicApp/MusicApp.csproj @@ -493,6 +493,9 @@ + + + diff --git a/MusicApp/Resources/Portable Class/Adapter.cs b/MusicApp/Resources/Portable Class/Adapter.cs index adc0513..512b5ab 100644 --- a/MusicApp/Resources/Portable Class/Adapter.cs +++ b/MusicApp/Resources/Portable Class/Adapter.cs @@ -1,5 +1,6 @@ using Android.App; using Android.Content; +using Android.Graphics; using Android.Views; using Android.Widget; using MusicApp.Resources.values; @@ -57,6 +58,13 @@ namespace MusicApp.Resources.Portable_Class Picasso.With(Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(holder.AlbumArt); } + if(MainActivity.Theme == 1) + { + holder.Title.SetTextColor(Color.White); + holder.Artist.SetTextColor(Color.White); + holder.Artist.Alpha = 0.7f; + } + if (!holder.more.HasOnClickListeners) { holder.more.Tag = position; diff --git a/MusicApp/Resources/Portable Class/Browse.cs b/MusicApp/Resources/Portable Class/Browse.cs index f53bd4c..839e087 100644 --- a/MusicApp/Resources/Portable Class/Browse.cs +++ b/MusicApp/Resources/Portable Class/Browse.cs @@ -218,7 +218,7 @@ namespace MusicApp.Resources.Portable_Class public void More(Song item) { - AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AppCompatAlertDialogStyle); + AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme); builder.SetTitle("Pick an action"); builder.SetItems(actions, (senderAlert, args) => { diff --git a/MusicApp/Resources/Portable Class/Player.cs b/MusicApp/Resources/Portable Class/Player.cs index 630d6b1..20b26f3 100644 --- a/MusicApp/Resources/Portable Class/Player.cs +++ b/MusicApp/Resources/Portable Class/Player.cs @@ -12,6 +12,7 @@ using Java.Util; using AlarmManager = Android.App.AlarmManager; using PendingIntent = Android.App.PendingIntent; +using Android.Graphics; namespace MusicApp.Resources.Portable_Class { @@ -89,6 +90,13 @@ namespace MusicApp.Resources.Portable_Class artist.Selected = true; artist.SetMarqueeRepeatLimit(3); + if (MainActivity.Theme == 1) + { + title.SetTextColor(Color.White); + artist.SetTextColor(Color.White); + artist.Alpha = 0.7f; + } + if (MusicPlayer.isRunning) playerView.FindViewById(Resource.Id.playButton).SetImageResource(Resource.Drawable.ic_pause_black_24dp); else diff --git a/MusicApp/Resources/Portable Class/Preferences.cs b/MusicApp/Resources/Portable Class/Preferences.cs index b1d497c..13995ad 100644 --- a/MusicApp/Resources/Portable Class/Preferences.cs +++ b/MusicApp/Resources/Portable Class/Preferences.cs @@ -67,6 +67,15 @@ namespace MusicApp.Resources.Portable_Class localShortcutPreference.PreferenceClick += LocalShortcut; localShortcutPreference.Summary = prefManager.GetString("localPlay", "Shuffle All Audio Files"); + //Theme + Preference themePreference = PreferenceScreen.FindPreference("theme"); + themePreference.PreferenceClick += ChangeTheme; + themePreference.Summary = prefManager.GetInt("theme", 0) == 0 ? "White Theme" : "Dark Theme"; + + //SmallOnTop + Preference smallOnTopPreference = PreferenceScreen.FindPreference("smallOnTop"); + smallOnTopPreference.PreferenceClick += SmallOnTop; + smallOnTopPreference.Summary = prefManager.GetBoolean("smallOnTop", false) ? "True" : "False"; } public override void OnDestroy() @@ -274,7 +283,7 @@ namespace MusicApp.Resources.Portable_Class editor.Apply(); Preference prefButton = FindPreference("localPlay"); - prefButton.Summary = path; + prefButton.Summary = "Shuffle All Audio Files"; } void LCSufflePlaylist() @@ -319,7 +328,47 @@ namespace MusicApp.Resources.Portable_Class editor.Apply(); Preference prefButton = FindPreference("localPlay"); - prefButton.Summary = path; + prefButton.Summary = "Shuffle " + playlist; + } + #endregion + + #region Theme + private void ChangeTheme(object sender, Preference.PreferenceClickEventArgs e) + { + AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AppCompatAlertDialogStyle); + builder.SetTitle("Choose a theme :"); + builder.SetItems(new[] { "White Theme", "Dark Theme" }, (s, args) => + { + ISharedPreferences pref = PreferenceManager.GetDefaultSharedPreferences(Application.Context); + ISharedPreferencesEditor editor = pref.Edit(); + editor.PutInt("theme", args.Which); + editor.Apply(); + + Preference prefButton = FindPreference("theme"); + prefButton.Summary = args.Which == 0 ? "White Theme" : "Dark Theme"; + + //MainActivity.SwitchTheme(args.Which); + }); + builder.Show(); + } + #endregion + + #region SmallOnTop + private void SmallOnTop(object sender, Preference.PreferenceClickEventArgs e) + { + new AlertDialog.Builder(Activity, Resource.Style.AppCompatAlertDialogStyle) + .SetTitle("Display the small player on top of the bottom navigation :") + .SetItems(new[] { "True", "False" }, (s, args) => + { + ISharedPreferences pref = PreferenceManager.GetDefaultSharedPreferences(Application.Context); + ISharedPreferencesEditor editor = pref.Edit(); + editor.PutBoolean("smallOnTop", args.Which == 0 ? true : false); + editor.Apply(); + + Preference prefButton = FindPreference("smallOnTop"); + prefButton.Summary = args.Which == 0 ? "True" : "False"; + }) + .Show(); } #endregion } diff --git a/MusicApp/Resources/Portable Class/TwoLineAdapter.cs b/MusicApp/Resources/Portable Class/TwoLineAdapter.cs index f08eb6e..b5f16b2 100644 --- a/MusicApp/Resources/Portable Class/TwoLineAdapter.cs +++ b/MusicApp/Resources/Portable Class/TwoLineAdapter.cs @@ -44,6 +44,12 @@ namespace MusicApp.Resources.Portable_Class Line1 = { Text = line1[position] }, Line2 = { Text = line2[position].ToString() + ((line2[position] > 1) ? " elements" : " element") }, }; + if(MainActivity.Theme == 1) + { + holder.Line1.SetTextColor(Color.White); + holder.Line2.SetTextColor(Color.White); + holder.Line2.Alpha = 0.7f; + } return convertView; } } diff --git a/MusicApp/Resources/Resource.Designer.cs b/MusicApp/Resources/Resource.Designer.cs index 3bf8550..1dbf8bc 100644 --- a/MusicApp/Resources/Resource.Designer.cs +++ b/MusicApp/Resources/Resource.Designer.cs @@ -523,6 +523,9 @@ namespace MusicApp // aapt resource value: 0x7f01005e public const int customNavigationLayout = 2130772062; + // aapt resource value: 0x7f0101bc + public const int defaultColor = 2130772412; + // aapt resource value: 0x7f01011a public const int defaultQueryHint = 2130772250; @@ -4211,8 +4214,11 @@ namespace MusicApp // aapt resource value: 0x7f09017a public const int Animation_Design_BottomSheetDialog = 2131296634; - // aapt resource value: 0x7f0901a5 - public const int AppCompatAlertDialogStyle = 2131296677; + // aapt resource value: 0x7f0901a6 + public const int AppCompatAlertDialogStyle = 2131296678; + + // aapt resource value: 0x7f0901a7 + public const int AppCompatDarkAlertDialogStyle = 2131296679; // aapt resource value: 0x7f0900b3 public const int Base_AlertDialog_AppCompat = 2131296435; @@ -4715,6 +4721,9 @@ namespace MusicApp // aapt resource value: 0x7f090010 public const int CardView_Light = 2131296272; + // aapt resource value: 0x7f0901a5 + public const int DarkTheme = 2131296677; + // aapt resource value: 0x7f09019b public const int ExoMediaButton = 2131296667; diff --git a/MusicApp/Resources/layout/Main.axml b/MusicApp/Resources/layout/Main.axml index 973315f..9cbe004 100644 --- a/MusicApp/Resources/layout/Main.axml +++ b/MusicApp/Resources/layout/Main.axml @@ -27,7 +27,7 @@ android:layout_height="wrap_content" app:tabTextColor="@android:color/white" app:tabSelectedTextColor="@android:color/white" - app:tabIndicatorColor="@android:color/white" + app:tabIndicatorColor="?colorAccent" app:tabGravity="fill" app:tabMode="fixed" /> @@ -67,7 +67,7 @@ - + - - + + + + + + + + \ No newline at end of file diff --git a/MusicApp/Resources/layout/QuickPlayLayout.xml b/MusicApp/Resources/layout/QuickPlayLayout.xml index 0058653..19c4136 100644 --- a/MusicApp/Resources/layout/QuickPlayLayout.xml +++ b/MusicApp/Resources/layout/QuickPlayLayout.xml @@ -20,7 +20,7 @@ app:fabSize="mini" app:elevation="5dp" app:pressedTranslationZ="12dp" - app:backgroundTint="#15b7ed" + app:backgroundTint="?colorAccent" android:layout_marginBottom="15dp" android:src="@drawable/ic_playlist_play_black_24dp" android:id="@+id/localPlay"/> diff --git a/MusicApp/Resources/layout/SongList.xml b/MusicApp/Resources/layout/SongList.xml index 3205dc1..914a61e 100644 --- a/MusicApp/Resources/layout/SongList.xml +++ b/MusicApp/Resources/layout/SongList.xml @@ -35,8 +35,8 @@ android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textColor="#000" android:textSize="16dip" + android:textColor="#000" android:textStyle="bold" /> + + + \ No newline at end of file diff --git a/MusicApp/Resources/values/styles.xml b/MusicApp/Resources/values/styles.xml index 6e0586d..0f35528 100644 --- a/MusicApp/Resources/values/styles.xml +++ b/MusicApp/Resources/values/styles.xml @@ -1,15 +1,31 @@  + + + + + \ No newline at end of file