Creating quick play button

This commit is contained in:
Gboy9155
2018-01-05 00:30:19 +01:00
parent 1c3ac3c4e9
commit 7550de0b09
15 changed files with 513 additions and 250 deletions

View File

@@ -2,6 +2,7 @@
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Graphics.Drawables;
using Android.OS;
using Android.Runtime;
using Android.Support.Design.Widget;
@@ -10,6 +11,7 @@ using Android.Support.V4.Widget;
using Android.Support.V7.App;
using Android.Support.V7.Preferences;
using Android.Views;
using Android.Views.Animations;
using Android.Widget;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Auth.OAuth2.Flows;
@@ -32,15 +34,22 @@ namespace MusicApp
public class MainActivity : AppCompatActivity, ViewPager.IOnPageChangeListener
{
public static MainActivity instance;
public static int paddingBot = 0;
public Android.Support.V7.Widget.Toolbar ToolBar;
public IMenu menu;
public SwipeRefreshLayout contentRefresh;
public SwipeRefreshLayout pagerRefresh;
public bool usePager;
public View quickPlayLayout;
private Handler handler = new Handler();
private ProgressBar bar;
private bool prepared = false;
private bool searchDisplayed;
private bool canSwitch = true;
private string tab;
private bool QuickPlayOpenned = false;
private const int RequestCode = 8539;
@@ -48,9 +57,51 @@ namespace MusicApp
public static YouTubeService youtubeService;
public static OAuth2Authenticator auth;
public static string refreshToken;
private bool searchDisplayed;
private bool canSwitch = true;
private string tab;
public event EventHandler<PaddingChange> OnPaddingChanged;
public virtual void PaddingHasChanged(PaddingChange e)
{
paddingBot = (((FrameLayout)instance.FindViewById(Resource.Id.smallPlayer).Parent).Visibility == ViewStates.Gone)
? FindViewById<BottomNavigationView>(Resource.Id.bottomView).Height
: FindViewById<BottomNavigationView>(Resource.Id.bottomView).Height + ((FrameLayout)instance.FindViewById(Resource.Id.smallPlayer).Parent).Height;
OnPaddingChanged?.Invoke(this, e);
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
instance = this;
var bottomNavigation = FindViewById<BottomNavigationView>(Resource.Id.bottomView);
bottomNavigation.NavigationItemSelected += PreNavigate;
ToolBar = (Android.Support.V7.Widget.Toolbar) FindViewById(Resource.Id.toolbar);
SetSupportActionBar(ToolBar);
SupportActionBar.Title = "MusicApp";
pagerRefresh = FindViewById<SwipeRefreshLayout>(Resource.Id.pagerRefresh);
contentRefresh = FindViewById<SwipeRefreshLayout>(Resource.Id.contentRefresh);
if (MusicPlayer.queue.Count > 0)
ReCreateSmallPlayer();
else
PrepareApp();
if (Intent?.Action == "Player")
ActionPlayer();
}
async void PrepareApp()
{
await Task.Delay(100);
paddingBot = FindViewById<BottomNavigationView>(Resource.Id.bottomView).Height;
Navigate(Resource.Id.musicLayout);
}
public void Login()
{
@@ -164,26 +215,6 @@ namespace MusicApp
});
}
public static int paddingBot
{
get
{
if (((FrameLayout)instance.FindViewById(Resource.Id.smallPlayer).Parent).Visibility == ViewStates.Gone)
return instance.FindViewById<BottomNavigationView>(Resource.Id.bottomView).Height;
else
return instance.FindViewById<BottomNavigationView>(Resource.Id.bottomView).Height + ((FrameLayout)instance.FindViewById(Resource.Id.smallPlayer).Parent).Height;
}
}
public static int paddinTop
{
get
{
return 0/*instance.SupportActionBar.Height*/;
}
}
public void Scroll(object sender, AbsListView.ScrollEventArgs e)
{
if (usePager)
@@ -192,34 +223,6 @@ namespace MusicApp
contentRefresh.SetEnabled(e.FirstVisibleItem == 0);
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
instance = this;
var bottomNavigation = FindViewById<BottomNavigationView>(Resource.Id.bottomView);
bottomNavigation.NavigationItemSelected += PreNavigate;
ToolBar = (Android.Support.V7.Widget.Toolbar) FindViewById(Resource.Id.toolbar);
SetSupportActionBar(ToolBar);
SupportActionBar.Title = "MusicApp";
pagerRefresh = FindViewById<SwipeRefreshLayout>(Resource.Id.pagerRefresh);
contentRefresh = FindViewById<SwipeRefreshLayout>(Resource.Id.contentRefresh);
if (MusicPlayer.queue.Count > 0)
ReCreateSmallPlayer();
else
Navigate(Resource.Id.musicLayout);
if (Intent?.Action == "Player")
ActionPlayer();
}
private async void ActionPlayer()
{
await Task.Delay(100);
@@ -251,8 +254,7 @@ namespace MusicApp
{
if (PlaylistTracks.instance != null)
{
var item2 = menu.FindItem(Resource.Id.search);
item2.SetVisible(false);
HideSearch();
if (PlaylistTracks.instance.isEmpty)
{
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
@@ -266,8 +268,7 @@ namespace MusicApp
}
if (FolderTracks.instance != null)
{
var item2 = menu.FindItem(Resource.Id.search);
item2.SetVisible(false);
HideSearch();
if (FolderTracks.instance.isEmpty)
{
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
@@ -402,6 +403,7 @@ namespace MusicApp
tab = "Queue";
HideTabs();
HideSearch();
ShowQuickPlay();
fragment = Queue.NewInstance();
break;
@@ -415,6 +417,7 @@ namespace MusicApp
tab = "Browse";
SetBrowseTabs();
DisplaySearch();
HideQuickPlay();
break;
case Resource.Id.downloadLayout:
@@ -429,6 +432,7 @@ namespace MusicApp
tab = "Youtube";
HideTabs();
DisplaySearch();
HideQuickPlay();
fragment = YoutubeEngine.NewInstance();
break;
@@ -442,6 +446,7 @@ namespace MusicApp
tab = "Playlist";
SetYtTabs();
HideSearch();
HideQuickPlay();
break;
}
@@ -492,8 +497,6 @@ namespace MusicApp
tabs.AddTab(tabs.NewTab().SetText("Songs"));
tabs.AddTab(tabs.NewTab().SetText("Folders"));
pager.SetPadding(0, (int)Math.Round(paddinTop * 1.90f), 0, 0);
ViewPagerAdapter adapter = new ViewPagerAdapter(SupportFragmentManager);
adapter.AddFragment(Browse.NewInstance(), "Songs");
adapter.AddFragment(FolderBrowse.NewInstance(), "Folders");
@@ -503,6 +506,7 @@ namespace MusicApp
pager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabs));
tabs.SetupWithViewPager(pager);
tabs.TabReselected += OnTabReselected;
}
pager.CurrentItem = selectedTab;
@@ -553,8 +557,6 @@ namespace MusicApp
tabs.AddTab(tabs.NewTab().SetText("Playlists"));
tabs.AddTab(tabs.NewTab().SetText("Youtube playlists"));
pager.SetPadding(0, (int)Math.Round(paddinTop * 1.90f), 0, 0);
ViewPagerAdapter adapter = new ViewPagerAdapter(SupportFragmentManager);
adapter.AddFragment(Playlist.NewInstance(), "Playlists");
adapter.AddFragment(YtPlaylist.NewInstance(), "Youtube playlists");
@@ -563,6 +565,7 @@ namespace MusicApp
pager.AddOnPageChangeListener(this);
pager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabs));
tabs.SetupWithViewPager(pager);
tabs.TabReselected += OnTabReselected;
}
pager.CurrentItem = selectedTab;
@@ -571,6 +574,24 @@ namespace MusicApp
CanSwitchDelay();
}
private void OnTabReselected(object sender, TabLayout.TabReselectedEventArgs e)
{
if (Browse.instance != null)
{
if (Browse.instance.focused)
Browse.instance.ListView.SmoothScrollToPosition(0);
else
FolderBrowse.instance.ListView.SmoothScrollToPosition(0);
}
else if (Playlist.instance != null)
{
if (Playlist.instance.focused)
Playlist.instance.ListView.SmoothScrollToPosition(0);
else
YtPlaylist.instance.ListView.SmoothScrollToPosition(0);
}
}
async void CanSwitchDelay()
{
await Task.Delay(350);
@@ -597,6 +618,8 @@ namespace MusicApp
Playlist.instance.focused = true;
YtPlaylist.instance.focused = false;
Playlist.instance.ListView.SmoothScrollToPosition(0);
}
if (position == 1)
{
@@ -607,6 +630,8 @@ namespace MusicApp
Playlist.instance.focused = false;
YtPlaylist.instance.focused = true;
YtPlaylist.instance.ListView.SmoothScrollToPosition(0);
}
}
@@ -619,11 +644,15 @@ namespace MusicApp
{
Browse.instance.focused = true;
FolderBrowse.instance.focused = false;
DisplaySearch();
Browse.instance.ListView.SmoothScrollToPosition(0);
}
if(position == 1)
{
Browse.instance.focused = false;
FolderBrowse.instance.focused = true;
HideSearch();
Browse.instance.ListView.SmoothScrollToPosition(0);
}
}
}
@@ -689,14 +718,6 @@ namespace MusicApp
}
}
public void ShowSmallPlayer()
{
RelativeLayout smallPlayer = FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
parent.Visibility = ViewStates.Visible;
smallPlayer.Visibility = ViewStates.Visible;
}
private void Last_Click(object sender, EventArgs e)
{
Intent intent = new Intent(Application.Context, typeof(MusicPlayer));
@@ -725,6 +746,46 @@ namespace MusicApp
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Player.NewInstance()).Commit();
}
public void GetStoragePermission()
{
const string permission = Manifest.Permission.ReadExternalStorage;
if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, permission) == (int)Permission.Granted)
{
PremissionAuthorized();
return;
}
string[] permissions = new string[] { permission };
RequestPermissions(permissions, RequestCode);
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
if (requestCode == RequestCode)
{
if (grantResults.Length > 0)
{
if (grantResults[0] == Permission.Granted)
PremissionAuthorized();
else
Snackbar.Make(FindViewById<View>(Resource.Id.contentView), "Permission denied, can't list musics.", Snackbar.LengthShort).Show();
}
}
}
void PremissionAuthorized()
{
Browse.instance?.PopulateList();
Playlist.instance?.PopulateView();
}
public void Transition(int Resource, Android.Support.V4.App.Fragment fragment, bool backStack)
{
if (backStack)
SupportFragmentManager.BeginTransaction().Replace(Resource, fragment).AddToBackStack(null).Commit();
else
SupportFragmentManager.BeginTransaction().Replace(Resource, fragment).Commit();
}
void SetSmallPlayerProgressBar()
{
bar = FindViewById<ProgressBar>(Resource.Id.spProgress);
@@ -745,51 +806,88 @@ namespace MusicApp
handler.PostDelayed(UpdateProgressBar, 1000);
}
public void HideSmallPlayer()
public async void HideSmallPlayer()
{
RelativeLayout smallPlayer = FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
bool hasChanged = parent.Visibility != ViewStates.Gone;
parent.Visibility = ViewStates.Gone;
await Task.Delay(75);
if (hasChanged)
PaddingHasChanged(new PaddingChange(paddingBot));
}
public void GetStoragePermission()
public async void ShowSmallPlayer()
{
const string permission = Manifest.Permission.ReadExternalStorage;
if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, permission) == (int)Permission.Granted)
RelativeLayout smallPlayer = FindViewById<RelativeLayout>(Resource.Id.smallPlayer);
FrameLayout parent = (FrameLayout)smallPlayer.Parent;
bool hasChanged = parent.Visibility == ViewStates.Gone;
parent.Visibility = ViewStates.Visible;
smallPlayer.Visibility = ViewStates.Visible;
await Task.Delay(75);
if (hasChanged)
PaddingHasChanged(new PaddingChange(paddingBot));
}
public void ShowQuickPlay()
{
if(quickPlayLayout != null)
{
PremissionAuthorized();
quickPlayLayout.Visibility = ViewStates.Visible;
FloatingActionButton fab = quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.quickPlay);
fab.Animate().Alpha(1);
return;
}
string[] permissions = new string[] { permission };
RequestPermissions(permissions, RequestCode);
quickPlayLayout = LayoutInflater.Inflate(Resource.Layout.QuickPlayLayout, null);
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
AddContentView(quickPlayLayout, rootView.LayoutParameters);
Console.WriteLine("&Starting padding bot: " + paddingBot);
quickPlayLayout.SetPadding(0, 0, 0, paddingBot + PxToDp(6));
FloatingActionButton QuickPlayFAB = quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.quickPlay);
QuickPlayFAB.Click += QuickPlay;
OnPaddingChanged += QuickPlayChangePosition;
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
public void HideQuickPlay()
{
if (requestCode == RequestCode)
FloatingActionButton QuickPlayFAB = quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.quickPlay);
QuickPlayFAB.Animate().Alpha(0);
}
private void QuickPlayChangePosition(object sender, PaddingChange e)
{
Console.WriteLine("&Padding bot: " + paddingBot);
FloatingActionButton QuickPlayFab = quickPlayLayout.FindViewById<FloatingActionButton>(Resource.Id.quickPlay);
QuickPlayFab.Animate().TranslationYBy(-(paddingBot - e.oldPadding));
}
public async void QuickPlay(object sender, EventArgs e)
{
FloatingActionButton quickPlay = FindViewById<FloatingActionButton>(Resource.Id.quickPlay);
if (QuickPlayOpenned)
{
if(grantResults.Length > 0)
{
if (grantResults[0] == Permission.Granted)
PremissionAuthorized();
else
Snackbar.Make(FindViewById<View>(Resource.Id.contentView), "Permission denied, can't list musics.", Snackbar.LengthShort).Show();
}
Drawable icon = quickPlay.Drawable;
((AnimatedVectorDrawable)icon).Start();
QuickPlayOpenned = false;
await Task.Delay(200);
quickPlay.SetImageResource(Resource.Drawable.PlayToCross);
}
else
{
Drawable icon = quickPlay.Drawable;
((AnimatedVectorDrawable)icon).Start();
QuickPlayOpenned = true;
await Task.Delay(200);
quickPlay.SetImageResource(Resource.Drawable.CrossToPlay);
}
}
void PremissionAuthorized()
int PxToDp(int px)
{
Browse.instance?.PopulateList();
Playlist.instance?.PopulateView();
}
public void Transition(int Resource, Android.Support.V4.App.Fragment fragment, bool backStack)
{
if(backStack)
SupportFragmentManager.BeginTransaction().Replace(Resource, fragment).AddToBackStack(null).Commit();
else
SupportFragmentManager.BeginTransaction().Replace(Resource, fragment).Commit();
float scale = Resources.DisplayMetrics.Density;
return (int) (px * scale + 0.5f);
}
}
}

View File

@@ -254,9 +254,11 @@
<Compile Include="Resources\Portable Class\YtPlaylists.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\values\DownloadFile.cs" />
<Compile Include="Resources\values\Folder.cs" />
<Compile Include="Resources\values\FolderHolder.cs" />
<Compile Include="Resources\values\Holder.cs" />
<Compile Include="Resources\values\PaddingChange.cs" />
<Compile Include="Resources\values\Song.cs" />
<Compile Include="Resources\values\TwoLineHolder.cs" />
</ItemGroup>
@@ -459,6 +461,17 @@
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\QuickPlayLayout.xml">
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\PlayToCross.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\CrossToPlay.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@@ -3,22 +3,26 @@ using Android.Content;
using Android.OS;
using Android.Provider;
using Android.Support.V4.App;
using System.IO;
using MusicApp.Resources.values;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using YoutubeExplode;
using YoutubeExplode.Models;
using YoutubeExplode.Models.MediaStreams;
using Console = System.Console;
using File = System.IO.File;
using MusicApp.Resources.values;
using System.Threading.Tasks;
namespace MusicApp.Resources.Portable_Class
{
[Service]
public class Downloader : Service
{
public static Downloader instance;
public string downloadPath;
private static List<DownloadFile> queue = new List<DownloadFile>();
private int currentStrike = 0;
private static bool isDownloading = false;
private NotificationCompat.Builder notification;
private int notificationID = 1001;
@@ -34,26 +38,38 @@ namespace MusicApp.Resources.Portable_Class
base.OnCreate();
}
public override void OnDestroy()
{
instance = null;
}
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
Console.WriteLine("Downloader service started");
string videoID = intent.GetStringExtra("videoID");
string path = intent.GetStringExtra("path");
string name = intent.GetStringExtra("name");
DownloadAudio(videoID, path, name);
instance = this;
return StartCommandResult.Sticky;
}
private async void DownloadAudio(string videoID, string path, string name)
public void Download(DownloadFile file)
{
queue.Add(file);
if (!isDownloading)
DownloadAudio(file, downloadPath);
else
SetNotificationCount();
}
private async void DownloadAudio(DownloadFile file, string path)
{
while (isDownloading)
await Task.Delay(1000);
isDownloading = true;
CreateNotification("Downloading: ", name);
queue.Remove(file);
currentStrike++;
CreateNotification(file.name);
YoutubeClient client = new YoutubeClient();
Video videoInfo = await client.GetVideoAsync(videoID);
Video videoInfo = await client.GetVideoAsync(file.videoID);
AudioStreamInfo streamInfo = videoInfo.AudioStreamInfos.OrderBy(s => s.Bitrate).Last();
string fileExtension = streamInfo.Container.GetFileExtension();
@@ -66,15 +82,15 @@ namespace MusicApp.Resources.Portable_Class
FileStream output = File.Create(filePath);
await input.CopyToAsync(output);
output.Dispose();
SetMetaData(filePath, videoInfo.Title, videoInfo.Author.Name, videoInfo.Thumbnails.HighResUrl);
isDownloading = false;
SetMetaData(filePath, videoInfo.Title, videoInfo.Author.Name, videoInfo.Thumbnails.HighResUrl);
if (queue.Count != 0)
DownloadAudio(queue[0], path);
}
private void SetMetaData(string filePath, string title, string artist, string album)
{
EditNotification("Retriving meta-data");
ContentResolver resolver = MainActivity.instance.ContentResolver;
ContentValues value = new ContentValues();
value.Put(MediaStore.Audio.Media.InterfaceConsts.Title, title);
@@ -86,19 +102,22 @@ namespace MusicApp.Resources.Portable_Class
StopForeground(true);
}
void CreateNotification(string title, string artist)
void CreateNotification(string title)
{
notification = new NotificationCompat.Builder(Application.Context)
.SetVisibility(NotificationCompat.VisibilityPublic)
.SetSmallIcon(Resource.Drawable.MusicIcon)
.SetContentTitle(title)
.SetContentText(artist);
.SetContentTitle("Downloading: ")
.SetContentText(title);
if(queue.Count > 1)
notification.SetSubText(currentStrike + "/" + queue.Count);
StartForeground(notificationID, notification.Build());
}
void EditNotification(string title)
void SetNotificationCount()
{
notification.SetContentTitle(title);
notification.SetSubText(currentStrike + "/" + queue.Count);
StartForeground(notificationID, notification.Build());
}
}

View File

@@ -47,7 +47,7 @@ namespace MusicApp.Resources.Portable_Class
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = base.OnCreateView(inflater, container, savedInstanceState);
view.SetPadding(0, MainActivity.paddinTop, 0, MainActivity.paddingBot);
view.SetPadding(0, 0, 0, MainActivity.paddingBot);
return view;
}

View File

@@ -178,7 +178,6 @@ namespace MusicApp.Resources.Portable_Class
if(song.queueSlot == -1)
song.queueSlot = CurrentID() + 1;
Console.WriteLine("QueueSlot: " + song.queueSlot);
currentID = song.queueSlot;
CreateNotification(song.GetName(), song.GetArtist(), song.GetAlbumArt(), song.GetAlbum());
@@ -217,7 +216,7 @@ namespace MusicApp.Resources.Portable_Class
if (song.queueSlot == -1)
song.queueSlot = CurrentID() + 1;
Console.WriteLine(song.GetName() + " : " + song.queueSlot);
currentID = song.queueSlot;
if (addToQueue)

View File

@@ -65,6 +65,7 @@ namespace MusicApp.Resources.Portable_Class
while (MusicPlayer.CurrentID() == -1)
await Task.Delay(100);
MainActivity.instance.ShowQuickPlay();
MainActivity.instance.ToolBar.Visibility = ViewStates.Gone;
MainActivity.instance.FindViewById<BottomNavigationView>(Resource.Id.bottomView).Visibility = ViewStates.Gone;
TextView title = playerView.FindViewById<TextView>(Resource.Id.playerTitle);

View File

@@ -51,7 +51,7 @@ namespace MusicApp.Resources.Portable_Class
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = base.OnCreateView(inflater, container, savedInstanceState);
view.SetPadding(0, MainActivity.paddinTop, 0, MainActivity.paddingBot);
view.SetPadding(0, 0, 0, MainActivity.paddingBot);
return view;
}

View File

@@ -1,4 +1,5 @@
using Android.OS;
using Android.Support.Design.Widget;
using Android.Support.V4.App;
using Android.Views;
using Android.Widget;
@@ -43,7 +44,7 @@ namespace MusicApp.Resources.Portable_Class
{
View view = base.OnCreateView(inflater, container, savedInstanceState);
this.view = view;
view.SetPadding(0, MainActivity.paddinTop, 0, MainActivity.paddingBot);
view.SetPadding(0, 0, 0, MainActivity.paddingBot);
return view;
}
@@ -82,6 +83,8 @@ namespace MusicApp.Resources.Portable_Class
if (adapter == null || adapter.Count == 0)
{
if (isEmpty)
return;
isEmpty = true;
Activity.AddContentView(emptyView, View.LayoutParameters);
}

View File

@@ -70,7 +70,7 @@ namespace MusicApp.Resources.Portable_Class
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = base.OnCreateView(inflater, container, savedInstanceState);
view.SetPadding(0, MainActivity.paddinTop, 0, MainActivity.paddingBot);
view.SetPadding(0, 0, 0, MainActivity.paddingBot);
return view;
}
@@ -268,7 +268,7 @@ namespace MusicApp.Resources.Portable_Class
parseProgress.Visibility = ViewStates.Gone;
}
public static void Download(string name, string videoID)
public async static void Download(string name, string videoID)
{
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
if (prefManager.GetString("downloadPath", null) != null)
@@ -276,10 +276,13 @@ namespace MusicApp.Resources.Portable_Class
Toast.MakeText(Android.App.Application.Context, "Downloading...", ToastLength.Short).Show();
Context context = Android.App.Application.Context;
Intent intent = new Intent(context, typeof(Downloader));
intent.PutExtra("videoID", videoID);
intent.PutExtra("path", prefManager.GetString("downloadPath", null));
intent.PutExtra("name", name);
context.StartService(intent);
while (Downloader.instance == null)
await Task.Delay(10);
Downloader.instance.downloadPath = prefManager.GetString("downloadPath", null);
Downloader.instance.Download(new DownloadFile(name, videoID));
}
else
{
@@ -298,15 +301,16 @@ namespace MusicApp.Resources.Portable_Class
{
Toast.MakeText(Android.App.Application.Context, "Downloading...", ToastLength.Short).Show();
Context context = Android.App.Application.Context;
Intent intent = new Intent(context, typeof(Downloader));
context.StartService(intent);
while (Downloader.instance == null)
await Task.Delay(10);
Downloader.instance.downloadPath = prefManager.GetString("downloadPath", null);
for(int i = 0; i < names.Length; i++)
{
Intent intent = new Intent(context, typeof(Downloader));
intent.PutExtra("videoID", videoIDs[i]);
intent.PutExtra("path", prefManager.GetString("downloadPath", null));
intent.PutExtra("name", names[i]);
context.StartService(intent);
await Task.Delay(10000);
}
Downloader.instance.Download(new DownloadFile(names[i], videoIDs[i]));
}
else
{

View File

@@ -2360,170 +2360,188 @@ namespace MusicApp
// aapt resource value: 0x7f020053
public const int avd_hide_password = 2130837587;
// aapt resource value: 0x7f020085
public const int avd_hide_password_1 = 2130837637;
// aapt resource value: 0x7f020086
public const int avd_hide_password_2 = 2130837638;
// aapt resource value: 0x7f020087
public const int avd_hide_password_3 = 2130837639;
public const int avd_hide_password_1 = 2130837639;
// aapt resource value: 0x7f020088
public const int avd_hide_password_2 = 2130837640;
// aapt resource value: 0x7f020089
public const int avd_hide_password_3 = 2130837641;
// aapt resource value: 0x7f020054
public const int avd_show_password = 2130837588;
// aapt resource value: 0x7f020088
public const int avd_show_password_1 = 2130837640;
// aapt resource value: 0x7f020089
public const int avd_show_password_2 = 2130837641;
// aapt resource value: 0x7f02008a
public const int avd_show_password_3 = 2130837642;
public const int avd_show_password_1 = 2130837642;
// aapt resource value: 0x7f02008b
public const int avd_show_password_2 = 2130837643;
// aapt resource value: 0x7f02008c
public const int avd_show_password_3 = 2130837644;
// aapt resource value: 0x7f020055
public const int design_bottom_navigation_item_background = 2130837589;
public const int CrossToPlay = 2130837589;
// aapt resource value: 0x7f02008d
public const int crosstoplay_1 = 2130837645;
// aapt resource value: 0x7f02008e
public const int crosstoplay_2 = 2130837646;
// aapt resource value: 0x7f020056
public const int design_fab_background = 2130837590;
public const int design_bottom_navigation_item_background = 2130837590;
// aapt resource value: 0x7f020057
public const int design_ic_visibility = 2130837591;
public const int design_fab_background = 2130837591;
// aapt resource value: 0x7f020058
public const int design_ic_visibility_off = 2130837592;
public const int design_ic_visibility = 2130837592;
// aapt resource value: 0x7f020059
public const int design_password_eye = 2130837593;
public const int design_ic_visibility_off = 2130837593;
// aapt resource value: 0x7f02005a
public const int design_snackbar_background = 2130837594;
public const int design_password_eye = 2130837594;
// aapt resource value: 0x7f02005b
public const int DownloadIcon = 2130837595;
public const int design_snackbar_background = 2130837595;
// aapt resource value: 0x7f02005c
public const int exo_controls_fastforward = 2130837596;
public const int DownloadIcon = 2130837596;
// aapt resource value: 0x7f02005d
public const int exo_controls_next = 2130837597;
public const int exo_controls_fastforward = 2130837597;
// aapt resource value: 0x7f02005e
public const int exo_controls_pause = 2130837598;
public const int exo_controls_next = 2130837598;
// aapt resource value: 0x7f02005f
public const int exo_controls_play = 2130837599;
public const int exo_controls_pause = 2130837599;
// aapt resource value: 0x7f020060
public const int exo_controls_previous = 2130837600;
public const int exo_controls_play = 2130837600;
// aapt resource value: 0x7f020061
public const int exo_controls_repeat_all = 2130837601;
public const int exo_controls_previous = 2130837601;
// aapt resource value: 0x7f020062
public const int exo_controls_repeat_off = 2130837602;
public const int exo_controls_repeat_all = 2130837602;
// aapt resource value: 0x7f020063
public const int exo_controls_repeat_one = 2130837603;
public const int exo_controls_repeat_off = 2130837603;
// aapt resource value: 0x7f020064
public const int exo_controls_rewind = 2130837604;
public const int exo_controls_repeat_one = 2130837604;
// aapt resource value: 0x7f020065
public const int exo_edit_mode_logo = 2130837605;
public const int exo_controls_rewind = 2130837605;
// aapt resource value: 0x7f020066
public const int folderIcon = 2130837606;
public const int exo_edit_mode_logo = 2130837606;
// aapt resource value: 0x7f020067
public const int ic_arrow_back = 2130837607;
public const int folderIcon = 2130837607;
// aapt resource value: 0x7f020068
public const int ic_expand_less_black_24dp = 2130837608;
public const int ic_arrow_back = 2130837608;
// aapt resource value: 0x7f020069
public const int ic_expand_more_black_24dp = 2130837609;
public const int ic_expand_less_black_24dp = 2130837609;
// aapt resource value: 0x7f02006a
public const int ic_more_vert_black_24dp = 2130837610;
public const int ic_expand_more_black_24dp = 2130837610;
// aapt resource value: 0x7f02006b
public const int ic_pause_black_24dp = 2130837611;
public const int ic_more_vert_black_24dp = 2130837611;
// aapt resource value: 0x7f02006c
public const int ic_play_arrow_black_24dp = 2130837612;
public const int ic_pause_black_24dp = 2130837612;
// aapt resource value: 0x7f02006d
public const int ic_playlist_add_white_24dp = 2130837613;
public const int ic_play_arrow_black_24dp = 2130837613;
// aapt resource value: 0x7f02006e
public const int ic_query_builder_black_24dp = 2130837614;
public const int ic_playlist_add_white_24dp = 2130837614;
// aapt resource value: 0x7f02006f
public const int ic_skip_next_black_24dp = 2130837615;
public const int ic_query_builder_black_24dp = 2130837615;
// aapt resource value: 0x7f020070
public const int ic_skip_previous_black_24dp = 2130837616;
public const int ic_skip_next_black_24dp = 2130837616;
// aapt resource value: 0x7f020071
public const int ic_timer_white_24dp = 2130837617;
public const int ic_skip_previous_black_24dp = 2130837617;
// aapt resource value: 0x7f020072
public const int MusicIcon = 2130837618;
public const int ic_timer_white_24dp = 2130837618;
// aapt resource value: 0x7f020073
public const int navigation_empty_icon = 2130837619;
public const int MusicIcon = 2130837619;
// aapt resource value: 0x7f020074
public const int noAlbum = 2130837620;
public const int navigation_empty_icon = 2130837620;
// aapt resource value: 0x7f020075
public const int notification_action_background = 2130837621;
public const int noAlbum = 2130837621;
// aapt resource value: 0x7f020076
public const int notification_bg = 2130837622;
public const int notification_action_background = 2130837622;
// aapt resource value: 0x7f020077
public const int notification_bg_low = 2130837623;
public const int notification_bg = 2130837623;
// aapt resource value: 0x7f020078
public const int notification_bg_low_normal = 2130837624;
public const int notification_bg_low = 2130837624;
// aapt resource value: 0x7f020079
public const int notification_bg_low_pressed = 2130837625;
public const int notification_bg_low_normal = 2130837625;
// aapt resource value: 0x7f02007a
public const int notification_bg_normal = 2130837626;
public const int notification_bg_low_pressed = 2130837626;
// aapt resource value: 0x7f02007b
public const int notification_bg_normal_pressed = 2130837627;
public const int notification_bg_normal = 2130837627;
// aapt resource value: 0x7f02007c
public const int notification_icon_background = 2130837628;
// aapt resource value: 0x7f020083
public const int notification_template_icon_bg = 2130837635;
// aapt resource value: 0x7f020084
public const int notification_template_icon_low_bg = 2130837636;
public const int notification_bg_normal_pressed = 2130837628;
// aapt resource value: 0x7f02007d
public const int notification_tile_bg = 2130837629;
public const int notification_icon_background = 2130837629;
// aapt resource value: 0x7f020085
public const int notification_template_icon_bg = 2130837637;
// aapt resource value: 0x7f020086
public const int notification_template_icon_low_bg = 2130837638;
// aapt resource value: 0x7f02007e
public const int notify_panel_notification_icon_bg = 2130837630;
public const int notification_tile_bg = 2130837630;
// aapt resource value: 0x7f02007f
public const int PlaylistPlay = 2130837631;
public const int notify_panel_notification_icon_bg = 2130837631;
// aapt resource value: 0x7f020080
public const int PlaylistPlayIcon = 2130837632;
public const int PlaylistPlay = 2130837632;
// aapt resource value: 0x7f020081
public const int search = 2130837633;
public const int PlaylistPlayIcon = 2130837633;
// aapt resource value: 0x7f020082
public const int settings = 2130837634;
public const int PlayToCross = 2130837634;
// aapt resource value: 0x7f02008f
public const int playtocross_1 = 2130837647;
// aapt resource value: 0x7f020090
public const int playtocross_2 = 2130837648;
// aapt resource value: 0x7f020083
public const int search = 2130837635;
// aapt resource value: 0x7f020084
public const int settings = 2130837636;
static Drawable()
{
@@ -2601,8 +2619,8 @@ namespace MusicApp
// aapt resource value: 0x7f08002f
public const int add = 2131230767;
// aapt resource value: 0x7f0800e0
public const int albumArt = 2131230944;
// aapt resource value: 0x7f0800e1
public const int albumArt = 2131230945;
// aapt resource value: 0x7f08006f
public const int alertTitle = 2131230831;
@@ -2613,8 +2631,8 @@ namespace MusicApp
// aapt resource value: 0x7f080034
public const int always = 2131230772;
// aapt resource value: 0x7f0800e1
public const int artist = 2131230945;
// aapt resource value: 0x7f0800e2
public const int artist = 2131230946;
// aapt resource value: 0x7f080040
public const int auto = 2131230784;
@@ -2628,8 +2646,8 @@ namespace MusicApp
// aapt resource value: 0x7f0800a8
public const int bottomView = 2131230888;
// aapt resource value: 0x7f0800e7
public const int browseLayout = 2131230951;
// aapt resource value: 0x7f0800e8
public const int browseLayout = 2131230952;
// aapt resource value: 0x7f08008b
public const int browseList = 2131230859;
@@ -2712,8 +2730,8 @@ namespace MusicApp
// aapt resource value: 0x7f0800d0
public const int downFAB = 2131230928;
// aapt resource value: 0x7f0800e8
public const int downloadLayout = 2131230952;
// aapt resource value: 0x7f0800e9
public const int downloadLayout = 2131230953;
// aapt resource value: 0x7f08007d
public const int edit_query = 2131230845;
@@ -2868,8 +2886,8 @@ namespace MusicApp
// aapt resource value: 0x7f0800bd
public const int line1 = 2131230909;
// aapt resource value: 0x7f0800e3
public const int line2 = 2131230947;
// aapt resource value: 0x7f0800e4
public const int line2 = 2131230948;
// aapt resource value: 0x7f0800bf
public const int line3 = 2131230911;
@@ -2883,8 +2901,8 @@ namespace MusicApp
// aapt resource value: 0x7f08005f
public const int list_item = 2131230815;
// aapt resource value: 0x7f0800e5
public const int masked = 2131230949;
// aapt resource value: 0x7f0800e6
public const int masked = 2131230950;
// aapt resource value: 0x7f0800b1
public const int media_actions = 2131230897;
@@ -2895,14 +2913,14 @@ namespace MusicApp
// aapt resource value: 0x7f08004f
public const int mini = 2131230799;
// aapt resource value: 0x7f0800e2
public const int moreButton = 2131230946;
// aapt resource value: 0x7f0800e3
public const int moreButton = 2131230947;
// aapt resource value: 0x7f08002a
public const int multiply = 2131230762;
// aapt resource value: 0x7f0800e6
public const int musicLayout = 2131230950;
// aapt resource value: 0x7f0800e7
public const int musicLayout = 2131230951;
// aapt resource value: 0x7f080095
public const int navigation_header_container = 2131230869;
@@ -2979,8 +2997,8 @@ namespace MusicApp
// aapt resource value: 0x7f0800c9
public const int playerTitle = 2131230921;
// aapt resource value: 0x7f0800e9
public const int playlistLayout = 2131230953;
// aapt resource value: 0x7f0800ea
public const int playlistLayout = 2131230954;
// aapt resource value: 0x7f08008c
public const int playlistName = 2131230860;
@@ -2991,6 +3009,9 @@ namespace MusicApp
// aapt resource value: 0x7f080007
public const int progress_horizontal = 2131230727;
// aapt resource value: 0x7f0800d7
public const int quickPlay = 2131230935;
// aapt resource value: 0x7f080074
public const int radio = 2131230836;
@@ -3021,8 +3042,8 @@ namespace MusicApp
// aapt resource value: 0x7f080051
public const int scrollable = 2131230801;
// aapt resource value: 0x7f0800d7
public const int search = 2131230935;
// aapt resource value: 0x7f0800d8
public const int search = 2131230936;
// aapt resource value: 0x7f08007f
public const int search_badge = 2131230847;
@@ -3063,8 +3084,8 @@ namespace MusicApp
// aapt resource value: 0x7f080089
public const int select_dialog_listview = 2131230857;
// aapt resource value: 0x7f0800ea
public const int settings = 2131230954;
// aapt resource value: 0x7f0800eb
public const int settings = 2131230955;
// aapt resource value: 0x7f080073
public const int shortcut = 2131230835;
@@ -3096,29 +3117,29 @@ namespace MusicApp
// aapt resource value: 0x7f0800cf
public const int songTimer = 2131230927;
// aapt resource value: 0x7f0800d9
public const int spArt = 2131230937;
// aapt resource value: 0x7f0800db
public const int spArtist = 2131230939;
// aapt resource value: 0x7f0800d8
public const int spContainer = 2131230936;
// aapt resource value: 0x7f0800de
public const int spLast = 2131230942;
// aapt resource value: 0x7f0800da
public const int spArt = 2131230938;
// aapt resource value: 0x7f0800dc
public const int spNext = 2131230940;
public const int spArtist = 2131230940;
// aapt resource value: 0x7f0800dd
public const int spPlay = 2131230941;
// aapt resource value: 0x7f0800d9
public const int spContainer = 2131230937;
// aapt resource value: 0x7f0800df
public const int spProgress = 2131230943;
public const int spLast = 2131230943;
// aapt resource value: 0x7f0800da
public const int spTitle = 2131230938;
// aapt resource value: 0x7f0800dd
public const int spNext = 2131230941;
// aapt resource value: 0x7f0800de
public const int spPlay = 2131230942;
// aapt resource value: 0x7f0800e0
public const int spProgress = 2131230944;
// aapt resource value: 0x7f0800db
public const int spTitle = 2131230939;
// aapt resource value: 0x7f080063
public const int spacer = 2131230819;
@@ -3228,8 +3249,8 @@ namespace MusicApp
// aapt resource value: 0x7f08000e
public const int view_offset_helper = 2131230734;
// aapt resource value: 0x7f0800e4
public const int visible = 2131230948;
// aapt resource value: 0x7f0800e5
public const int visible = 2131230949;
// aapt resource value: 0x7f08008a
public const int webview = 2131230858;
@@ -3552,37 +3573,40 @@ namespace MusicApp
public const int PreferenceToolbar = 2130903124;
// aapt resource value: 0x7f030055
public const int search_layout = 2130903125;
public const int QuickPlayLayout = 2130903125;
// aapt resource value: 0x7f030056
public const int select_dialog_item_material = 2130903126;
public const int search_layout = 2130903126;
// aapt resource value: 0x7f030057
public const int select_dialog_multichoice_material = 2130903127;
public const int select_dialog_item_material = 2130903127;
// aapt resource value: 0x7f030058
public const int select_dialog_singlechoice_material = 2130903128;
public const int select_dialog_multichoice_material = 2130903128;
// aapt resource value: 0x7f030059
public const int SmallPlayer = 2130903129;
public const int select_dialog_singlechoice_material = 2130903129;
// aapt resource value: 0x7f03005a
public const int SongList = 2130903130;
public const int SmallPlayer = 2130903130;
// aapt resource value: 0x7f03005b
public const int support_simple_spinner_dropdown_item = 2130903131;
public const int SongList = 2130903131;
// aapt resource value: 0x7f03005c
public const int tabs = 2130903132;
public const int support_simple_spinner_dropdown_item = 2130903132;
// aapt resource value: 0x7f03005d
public const int TimerLayout = 2130903133;
public const int tabs = 2130903133;
// aapt resource value: 0x7f03005e
public const int TwoLineLayout = 2130903134;
public const int TimerLayout = 2130903134;
// aapt resource value: 0x7f03005f
public const int YtList = 2130903135;
public const int TwoLineLayout = 2130903135;
// aapt resource value: 0x7f030060
public const int YtList = 2130903136;
static Layout()
{

View File

@@ -0,0 +1,28 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="play"
android:pathData="M 8 5 L 8 19 L 19 12 Z"
android:fillColor="#000000"/>
</vector>
</aapt:attr>
<target android:name="play">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="200"
android:valueFrom="M 6.41 5 L 5 6.41 L 10.59 12 L 5 17.59 L 6.41 19 L 12 13.41 L 17.59 19 L 19 17.59 L 13.41 12 L 19 6.41 L 17.59 5 L 12 10.59 L 6.41 5"
android:valueTo="M 8 5 L 8 8.5 L 8 12 L 8 15.5 L 8 19 L 10.2 17.6 L 12.4 16.2 L 14.6 14.8 L 16.8 13.4 L 19 12 L 15.333 9.667 L 11.667 7.333 L 8 5"
android:valueType="pathType"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</aapt:attr>
</target>
</animated-vector>

View File

@@ -0,0 +1,28 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="play"
android:pathData="M 8 5 L 8 19 L 19 12 Z"
android:fillColor="#000000"/>
</vector>
</aapt:attr>
<target android:name="play">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="200"
android:valueFrom="M 8 5 L 8 8.5 L 8 12 L 8 15.5 L 8 19 L 10.2 17.6 L 12.4 16.2 L 14.6 14.8 L 16.8 13.4 L 19 12 L 15.333 9.667 L 11.667 7.333 L 8 5"
android:valueTo="M 6.41 5 L 5 6.41 L 10.59 12 L 5 17.59 L 6.41 19 L 12 13.41 L 17.59 19 L 19 17.59 L 13.41 12 L 19 6.41 L 17.59 5 L 12 10.59 L 6.41 5"
android:valueType="pathType"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</aapt:attr>
</target>
</animated-vector>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="bottom|end"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_margin="25dp"
android:src="@drawable/PlayToCross"
android:id="@+id/quickPlay"/>
</android.support.design.widget.CoordinatorLayout>

View File

@@ -0,0 +1,15 @@
namespace MusicApp.Resources.values
{
[System.Serializable]
public class DownloadFile
{
public string name;
public string videoID;
public DownloadFile(string name, string videoID)
{
this.name = name;
this.videoID = videoID;
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace MusicApp.Resources.values
{
public class PaddingChange : EventArgs
{
public int oldPadding;
public PaddingChange(int oldPadding)
{
this.oldPadding = oldPadding;
}
}
}