mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-06 06:26:15 +00:00
Totally remade the download system.
This commit is contained in:
@@ -18,6 +18,7 @@ using Android.Provider;
|
||||
using Android.Runtime;
|
||||
using Android.Support.Design.Widget;
|
||||
using Android.Support.V4.App;
|
||||
using Android.Support.V4.Content;
|
||||
using Android.Support.V4.Widget;
|
||||
using Android.Support.V7.App;
|
||||
using Android.Support.V7.Preferences;
|
||||
@@ -39,6 +40,7 @@ using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using YoutubeExplode;
|
||||
using CursorLoader = Android.Support.V4.Content.CursorLoader;
|
||||
using Environment = Android.OS.Environment;
|
||||
using Fragment = Android.Support.V4.App.Fragment;
|
||||
using Playlist = MusicApp.Resources.Portable_Class.Playlist;
|
||||
using Request = Square.OkHttp.Request;
|
||||
@@ -1125,6 +1127,12 @@ namespace MusicApp
|
||||
|
||||
public async static void InstallUpdate(string version, bool beta, string downloadPath)
|
||||
{
|
||||
if (await instance.GetWritePermission())
|
||||
{
|
||||
string localPath = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDownloads).AbsolutePath + "/MusicApp-v" + version + (beta ? "-beta" : "") + ".apk";
|
||||
Console.WriteLine("&DownloadPath: " + downloadPath);
|
||||
Console.WriteLine("&Local path: " + localPath);
|
||||
|
||||
Toast.MakeText(Application.Context, Application.Context.GetString(Resource.String.downloading_update), ToastLength.Short).Show();
|
||||
|
||||
NotificationCompat.Builder notification = new NotificationCompat.Builder(Application.Context, "MusicApp.Channel")
|
||||
@@ -1138,16 +1146,18 @@ namespace MusicApp
|
||||
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
await client.DownloadFileTaskAsync(downloadPath, Android.OS.Environment.ExternalStorageDirectory + "/download/" + "MusicApp-v" + version + (beta ? "-beta" : "") + ".apk");
|
||||
await client.DownloadFileTaskAsync(downloadPath, localPath);
|
||||
}
|
||||
|
||||
notificationManager.Cancel(NotifUpdateID);
|
||||
|
||||
Intent intent = new Intent(Intent.ActionView);
|
||||
intent.SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/download/" + "MusicApp-v" + version + (beta ? "-beta" : "") + ".apk")), "application/vnd.android.package-archive");
|
||||
intent.SetDataAndType(FileProvider.GetUriForFile(instance, Application.Context.PackageName + ".provider", new Java.IO.File(localPath)), "application/vnd.android.package-archive");
|
||||
intent.SetFlags(ActivityFlags.NewTask);
|
||||
intent.AddFlags(ActivityFlags.GrantReadUriPermission);
|
||||
Application.Context.StartActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
|
||||
@@ -875,6 +875,9 @@
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\Empty.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\xml\provider.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" />
|
||||
<Import Project="..\packages\Xamarin.Android.Support.v7.Preference.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.v7.Preference.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.Preference.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.v7.Preference.targets')" />
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<application android:allowBackup="true" android:label="MusicApp">
|
||||
<meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:value="MusicApp.CastProvider" />
|
||||
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
|
||||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
||||
7420
MusicApp/Resources/Resource.Designer.cs
generated
7420
MusicApp/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
4
MusicApp/Resources/xml/provider.xml
Normal file
4
MusicApp/Resources/xml/provider.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="."/>
|
||||
</paths>
|
||||
Reference in New Issue
Block a user