Adding dark theme.

This commit is contained in:
Anonymous Raccoon
2018-02-16 21:20:01 +01:00
parent 7078569cb1
commit 465f0da361
14 changed files with 169 additions and 19 deletions
+32 -3
View File
@@ -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<View>(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<View>(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();
}
}
+3
View File
@@ -493,6 +493,9 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable\ic_done_black_24dp.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\attars.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@@ -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;
+1 -1
View File
@@ -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) =>
{
@@ -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<ImageButton>(Resource.Id.playButton).SetImageResource(Resource.Drawable.ic_pause_black_24dp);
else
@@ -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
}
@@ -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;
}
}
+11 -2
View File
@@ -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;
+4 -2
View File
@@ -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" />
</android.support.design.widget.AppBarLayout>
@@ -67,7 +67,7 @@
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@android:color/white"
android:background="?attr/defaultColor"
android:elevation="12dp"
android:layout_alignParentBottom="true">
<android.support.design.widget.CoordinatorLayout
@@ -79,6 +79,8 @@
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_below="@id/snackBar"
app:itemIconTint="?colorAccent"
app:itemTextColor="?colorAccent"
app:menu="@menu/bottom_items" />
<FrameLayout
android:layout_height="70dp"
+20 -4
View File
@@ -1,15 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="Download">
<PreferenceCategory android:title="Behavior">
<Preference
android:key="downloadPath"
android:title="Download directory"
android:summary="test"/>
</PreferenceCategory>
<PreferenceCategory android:title="QuickPlay Shortcut">
<Preference
android:key="localPlay"
android:title="Local Play Action"
android:title="Local Play Shortcut"
android:summary="Shuffle All Audio Files" />
</PreferenceCategory>
<PreferenceCategory android:title="Appearances">
<Preference
android:key="theme"
android:title="Theme :"
android:summary="White Theme" />
<Preference
android:key="smallOnTop"
android:title="Display small player on top of the bottom bar :"
android:summary="False" />
</PreferenceCategory>
<PreferenceCategory android:title="Others">
<Preference
android:title="Update app :"
android:summary="Comming soon" />
<Preference
android:title="Version :"
android:summary="V. 1.1" />
</PreferenceCategory>
</PreferenceScreen>
@@ -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"/>
+1 -1
View File
@@ -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" />
<TextView
android:id="@+id/artist"
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<attr name="defaultColor" format="reference|color" />
</resources>
+19 -3
View File
@@ -1,15 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="Theme" parent="Theme.Base"> </style>
<style name="Theme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowContentTransitions">true</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="colorAccent">#15b7ed</item>
<item name="android:textColor">#000</item>
<item name="defaultColor">#ffffff</item>
</style>
<style name="DarkTheme" parent="Theme.AppCompat">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowContentTransitions">true</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="colorAccent">#3E50B4</item>
<item name="android:textColor">#ffffff</item>
<item name="defaultColor">#212121</item>
</style>
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#5fa3d0</item>
<item name="android:textColorPrimary">#000000</item>
<item name="android:background">#FFFFFF</item>
<item name="colorAccent">#3E50B4 </item>
</style>
<style name="AppCompatDarkAlertDialogStyle" parent="Theme.AppCompat.Dialog.Alert">
<item name="colorAccent">#3E50B4 </item>
</style>
</resources>