mirror of
https://github.com/zoriya/Opus.git
synced 2026-06-10 00:57:44 +00:00
Solving auto-updater bugs.
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
Version: 2.0.2
|
Version: 2.0.3
|
||||||
Link: https://github.com/AnonymusRaccoon/MusicApp/releases/download/2.0.2/MusicApp.v.2.0.2.apk
|
Link: https://github.com/AnonymusRaccoon/MusicApp/releases/download/2.0.3/MusicApp.v2.0.3.apk
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ namespace MusicApp
|
|||||||
public BottomSheetBehavior SheetBehavior;
|
public BottomSheetBehavior SheetBehavior;
|
||||||
|
|
||||||
private const int RequestCode = 8539;
|
private const int RequestCode = 8539;
|
||||||
|
public const int NotifUpdateID = 4626;
|
||||||
private const string versionURI = "https://raw.githubusercontent.com/AnonymusRaccoon/MusicApp/master/MusicApp/Assets/Version.txt";
|
private const string versionURI = "https://raw.githubusercontent.com/AnonymusRaccoon/MusicApp/master/MusicApp/Assets/Version.txt";
|
||||||
|
|
||||||
private const string clientID = "112086459272-8m4do6aehtdg4a7nffd0a84jk94c64e8.apps.googleusercontent.com";
|
private const string clientID = "112086459272-8m4do6aehtdg4a7nffd0a84jk94c64e8.apps.googleusercontent.com";
|
||||||
@@ -1282,7 +1283,7 @@ namespace MusicApp
|
|||||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||||
snackBar.Show();
|
snackBar.Show();
|
||||||
}
|
}
|
||||||
else if(Preferences.instance != null)
|
if(Preferences.instance != null)
|
||||||
{
|
{
|
||||||
Snackbar snackBar = Snackbar.Make(Preferences.instance.FindViewById(Android.Resource.Id.Content), "You are not connected to internet, can't check for updates.", Snackbar.LengthLong);
|
Snackbar snackBar = Snackbar.Make(Preferences.instance.FindViewById(Android.Resource.Id.Content), "You are not connected to internet, can't check for updates.", Snackbar.LengthLong);
|
||||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
|
||||||
@@ -1313,16 +1314,13 @@ namespace MusicApp
|
|||||||
{
|
{
|
||||||
string GitVersion = await client.DownloadStringTaskAsync(new System.Uri(versionURI));
|
string GitVersion = await client.DownloadStringTaskAsync(new System.Uri(versionURI));
|
||||||
gitVersionID = GitVersion.Substring(9, 5);
|
gitVersionID = GitVersion.Substring(9, 5);
|
||||||
gitVersionID = gitVersionID.Remove(1, 1);
|
string gitID = gitVersionID.Remove(1, 1);
|
||||||
gitVersion = int.Parse(gitVersionID.Remove(2, 1));
|
gitVersion = int.Parse(gitID.Remove(2, 1));
|
||||||
downloadPath = GitVersion.Substring(18);
|
downloadPath = GitVersion.Substring(GitVersion.IndexOf("Link: ") + 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("&Version: " + version + " GitVersion: " + gitVersion);
|
|
||||||
|
|
||||||
if(gitVersion > version)
|
if(gitVersion > version)
|
||||||
{
|
{
|
||||||
Console.WriteLine("&An update is available");
|
|
||||||
Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(activity, dialogTheme);
|
Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(activity, dialogTheme);
|
||||||
builder.SetTitle(string.Format("The version {0} is available", gitVersionID));
|
builder.SetTitle(string.Format("The version {0} is available", gitVersionID));
|
||||||
builder.SetMessage("An update is available, do you want to download it now ?");
|
builder.SetMessage("An update is available, do you want to download it now ?");
|
||||||
@@ -1352,10 +1350,23 @@ namespace MusicApp
|
|||||||
public async static void InstallUpdate(string version, string downloadPath)
|
public async static void InstallUpdate(string version, string downloadPath)
|
||||||
{
|
{
|
||||||
Toast.MakeText(Application.Context, "Downloading update, you will be prompt for the installation soon.", ToastLength.Short).Show();
|
Toast.MakeText(Application.Context, "Downloading update, you will be prompt for the installation soon.", ToastLength.Short).Show();
|
||||||
|
|
||||||
|
NotificationCompat.Builder notification = new NotificationCompat.Builder(Application.Context, "MusicApp.Channel")
|
||||||
|
.SetVisibility(NotificationCompat.VisibilityPublic)
|
||||||
|
.SetSmallIcon(Resource.Drawable.MusicIcon)
|
||||||
|
.SetContentTitle("Updating app...")
|
||||||
|
.SetOngoing(true);
|
||||||
|
|
||||||
|
NotificationManager notificationManager = (NotificationManager)Application.Context.GetSystemService(NotificationService);
|
||||||
|
notificationManager.Notify(NotifUpdateID, notification.Build());
|
||||||
|
|
||||||
using (WebClient client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
{
|
{
|
||||||
await client.DownloadFileTaskAsync(downloadPath, Android.OS.Environment.ExternalStorageDirectory + "/download/" + "MusicApp-v" + version + ".apk");
|
await client.DownloadFileTaskAsync(downloadPath, Android.OS.Environment.ExternalStorageDirectory + "/download/" + "MusicApp-v" + version + ".apk");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notificationManager.Cancel(NotifUpdateID);
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ActionView);
|
Intent intent = new Intent(Intent.ActionView);
|
||||||
intent.SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/download/" + "MusicApp-v" + version + ".apk")), "application/vnd.android.package-archive");
|
intent.SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/download/" + "MusicApp-v" + version + ".apk")), "application/vnd.android.package-archive");
|
||||||
intent.SetFlags(ActivityFlags.NewTask);
|
intent.SetFlags(ActivityFlags.NewTask);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.musicapp.android" android:installLocation="preferExternal" android:versionName="2.0.2" android:versionCode="14">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.musicapp.android" android:installLocation="preferExternal" android:versionName="2.0.3" android:versionCode="15">
|
||||||
<uses-sdk android:minSdkVersion="21" />
|
<uses-sdk android:minSdkVersion="21" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|||||||
@@ -89,16 +89,17 @@ namespace MusicApp.Resources.Portable_Class
|
|||||||
currentStrike++;
|
currentStrike++;
|
||||||
CreateNotification(file.name);
|
CreateNotification(file.name);
|
||||||
|
|
||||||
if (YoutubeEngine.FileIsAlreadyDownloaded(file.videoID) && !file.skipCheck)
|
//if (YoutubeEngine.FileIsAlreadyDownloaded(file.videoID) && !file.skipCheck)
|
||||||
{
|
//{
|
||||||
Snackbar snackBar = Snackbar.Make(MainActivity.instance.FindViewById(Resource.Id.snackBar), file.name + " is already on your device.", Snackbar.LengthShort).SetAction("Download Anyway", (v) =>
|
// Snackbar snackBar = Snackbar.Make(MainActivity.instance.FindViewById(Resource.Id.snackBar), file.name + " is already on your device.", Snackbar.LengthShort).SetAction("Download Anyway", (v) =>
|
||||||
{
|
// {
|
||||||
file.skipCheck = true;
|
// file.skipCheck = true;
|
||||||
Download(file);
|
// Download(file);
|
||||||
});
|
// });
|
||||||
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Android.Graphics.Color.White);
|
// snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Android.Graphics.Color.White);
|
||||||
snackBar.Show();
|
// snackBar.Show();
|
||||||
}
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -740,11 +740,11 @@ namespace MusicApp.Resources.Portable_Class
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
|
//ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
|
||||||
if (YoutubeEngine.FileIsAlreadyDownloaded(song.Path) && !prefManager.GetBoolean("skipExistVerification", false))
|
//if (!prefManager.GetBoolean("skipExistVerification", false) && YoutubeEngine.FileIsAlreadyDownloaded(song.Path))
|
||||||
{
|
//{
|
||||||
GetTrackSong(YoutubeEngine.GetLocalPathFromYTID(song.Path), out song);
|
// GetTrackSong(YoutubeEngine.GetLocalPathFromYTID(song.Path), out song);
|
||||||
}
|
//}
|
||||||
|
|
||||||
Play(song, false);
|
Play(song, false);
|
||||||
|
|
||||||
|
|||||||
@@ -527,39 +527,39 @@ namespace MusicApp.Resources.Portable_Class
|
|||||||
|
|
||||||
public static bool FileIsAlreadyDownloaded(string youtubeID)
|
public static bool FileIsAlreadyDownloaded(string youtubeID)
|
||||||
{
|
{
|
||||||
Android.Net.Uri musicUri = MediaStore.Audio.Media.ExternalContentUri;
|
//Android.Net.Uri musicUri = MediaStore.Audio.Media.ExternalContentUri;
|
||||||
|
|
||||||
CursorLoader cursorLoader = new CursorLoader(Android.App.Application.Context, musicUri, null, null, null, null);
|
//CursorLoader cursorLoader = new CursorLoader(Android.App.Application.Context, musicUri, null, null, null, null);
|
||||||
ICursor musicCursor = (ICursor)cursorLoader.LoadInBackground();
|
//ICursor musicCursor = (ICursor)cursorLoader.LoadInBackground();
|
||||||
|
|
||||||
if (musicCursor != null && musicCursor.MoveToFirst())
|
//if (musicCursor != null && musicCursor.MoveToFirst())
|
||||||
{
|
//{
|
||||||
int pathKey = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data);
|
// int pathKey = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data);
|
||||||
do
|
// do
|
||||||
{
|
// {
|
||||||
string path = musicCursor.GetString(pathKey);
|
// string path = musicCursor.GetString(pathKey);
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
// Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||||
var meta = TagLib.File.Create(new StreamFileAbstraction(path, stream, stream));
|
// var meta = TagLib.File.Create(new StreamFileAbstraction(path, stream, stream));
|
||||||
string ytID = meta.Tag.Comment;
|
// string ytID = meta.Tag.Comment;
|
||||||
stream.Dispose();
|
// stream.Dispose();
|
||||||
|
|
||||||
if (ytID == youtubeID)
|
// if (ytID == youtubeID)
|
||||||
{
|
// {
|
||||||
musicCursor.Close();
|
// musicCursor.Close();
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (CorruptFileException)
|
// catch (CorruptFileException)
|
||||||
{
|
// {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
while (musicCursor.MoveToNext());
|
// while (musicCursor.MoveToNext());
|
||||||
musicCursor.Close();
|
// musicCursor.Close();
|
||||||
}
|
//}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user