Adding a mount check for the external storage in the edit metadata activity finish.

This commit is contained in:
Tristan Roux
2019-04-23 21:57:20 +02:00
parent 81564ea0fb
commit eddeb8d5fb
3 changed files with 134 additions and 110 deletions

View File

@@ -164,15 +164,15 @@ namespace Opus.Fragments
async void LeaveAndValidate()
{
await ValidateChanges();
Finish();
if(await ValidateChanges(true))
Finish();
}
async Task ValidateChanges()
async Task<bool> ValidateChanges(bool displayActionIfMountFail = false)
{
System.Console.WriteLine("&Validaing changes");
if (song.Title == title.Text && song.Artist == artist.Text && song.YoutubeID == youtubeID.Text && song.Album == album.Text && artURI == null)
return;
return true;
System.Console.WriteLine("&Requesting permission");
const string permission = Manifest.Permission.WriteExternalStorage;
@@ -186,6 +186,21 @@ namespace Opus.Fragments
await Task.Delay(1000);
}
if(!Environment.MediaMounted.Equals(Environment.GetExternalStorageState(new Java.IO.File(song.Path))))
{
Snackbar snackBar = Snackbar.Make(FindViewById<CoordinatorLayout>(Resource.Id.snackBar), Resource.String.mount_error, Snackbar.LengthLong);
snackBar.View.FindViewById<TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
if(displayActionIfMountFail)
{
snackBar.SetAction(Resource.String.mount_error_action, (v) =>
{
Finish();
});
}
snackBar.Show();
return false;
}
System.Console.WriteLine("&Creating write stream");
Stream stream = new FileStream(song.Path, FileMode.Open, FileAccess.ReadWrite);
var meta = TagLib.File.Create(new StreamFileAbstraction(song.Path, stream, stream));
@@ -266,6 +281,7 @@ namespace Opus.Fragments
Android.Media.MediaScannerConnection.ScanFile(this, new string[] { song.Path }, null, null);
Toast.MakeText(this, Resource.String.changes_saved, ToastLength.Short).Show();
return true;
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)

View File

@@ -7186,8 +7186,8 @@ namespace Opus
// aapt resource value: 0x7f0d0072
public const int abc_toolbar_collapse_description = 2131558514;
// aapt resource value: 0x7f0d012a
public const int add = 2131558698;
// aapt resource value: 0x7f0d012c
public const int add = 2131558700;
// aapt resource value: 0x7f0d00fb
public const int add_playlist = 2131558651;
@@ -7213,11 +7213,11 @@ namespace Opus
// aapt resource value: 0x7f0d0080
public const int appbar_scrolling_view_behavior = 2131558528;
// aapt resource value: 0x7f0d0134
public const int appearances = 2131558708;
// aapt resource value: 0x7f0d0136
public const int appearances = 2131558710;
// aapt resource value: 0x7f0d0127
public const int apply = 2131558695;
// aapt resource value: 0x7f0d0129
public const int apply = 2131558697;
// aapt resource value: 0x7f0d0114
public const int artist = 2131558676;
@@ -7228,11 +7228,11 @@ namespace Opus
// aapt resource value: 0x7f0d00cb
public const int autoplay_desc = 2131558603;
// aapt resource value: 0x7f0d012e
public const int behavior = 2131558702;
// aapt resource value: 0x7f0d0130
public const int behavior = 2131558704;
// aapt resource value: 0x7f0d014c
public const int beta_available = 2131558732;
// aapt resource value: 0x7f0d014e
public const int beta_available = 2131558734;
// aapt resource value: 0x7f0d0081
public const int bottom_sheet_behavior = 2131558529;
@@ -7240,17 +7240,17 @@ namespace Opus
// aapt resource value: 0x7f0d00b3
public const int browse = 2131558579;
// aapt resource value: 0x7f0d0128
public const int cancel = 2131558696;
// aapt resource value: 0x7f0d012a
public const int cancel = 2131558698;
// aapt resource value: 0x7f0d0152
public const int cancelling = 2131558738;
// aapt resource value: 0x7f0d0154
public const int cancelling = 2131558740;
// aapt resource value: 0x7f0d00f1
public const int cant_delete = 2131558641;
// aapt resource value: 0x7f0d014f
public const int cant_play_non_youtube = 2131558735;
// aapt resource value: 0x7f0d0151
public const int cant_play_non_youtube = 2131558737;
// aapt resource value: 0x7f0d00b8
public const int cast = 2131558584;
@@ -7333,11 +7333,11 @@ namespace Opus
// aapt resource value: 0x7f0d0015
public const int cast_play = 2131558421;
// aapt resource value: 0x7f0d0125
public const int cast_queue_push = 2131558693;
// aapt resource value: 0x7f0d0127
public const int cast_queue_push = 2131558695;
// aapt resource value: 0x7f0d0126
public const int cast_queue_pushed = 2131558694;
// aapt resource value: 0x7f0d0128
public const int cast_queue_pushed = 2131558696;
// aapt resource value: 0x7f0d0016
public const int cast_rewind = 2131558422;
@@ -7402,8 +7402,8 @@ namespace Opus
// aapt resource value: 0x7f0d0083
public const int character_counter_pattern = 2131558531;
// aapt resource value: 0x7f0d013a
public const int check_updates = 2131558714;
// aapt resource value: 0x7f0d013c
public const int check_updates = 2131558716;
// aapt resource value: 0x7f0d00b0
public const int clientID = 2131558576;
@@ -7465,11 +7465,11 @@ namespace Opus
// aapt resource value: 0x7f0d003b
public const int common_signin_button_text_long = 2131558459;
// aapt resource value: 0x7f0d0124
public const int completed = 2131558692;
// aapt resource value: 0x7f0d0126
public const int completed = 2131558694;
// aapt resource value: 0x7f0d0146
public const int country_blocked = 2131558726;
// aapt resource value: 0x7f0d0148
public const int country_blocked = 2131558728;
// aapt resource value: 0x7f0d0110
public const int create_local = 2131558672;
@@ -7489,8 +7489,8 @@ namespace Opus
// aapt resource value: 0x7f0d0111
public const int create_youtube = 2131558673;
// aapt resource value: 0x7f0d0138
public const int dark_theme = 2131558712;
// aapt resource value: 0x7f0d013a
public const int dark_theme = 2131558714;
// aapt resource value: 0x7f0d00db
public const int delete = 2131558619;
@@ -7498,8 +7498,8 @@ namespace Opus
// aapt resource value: 0x7f0d0107
public const int delete_playlist = 2131558663;
// aapt resource value: 0x7f0d011f
public const int deleted_file = 2131558687;
// aapt resource value: 0x7f0d0121
public const int deleted_file = 2131558689;
// aapt resource value: 0x7f0d00d3
public const int download = 2131558611;
@@ -7507,8 +7507,8 @@ namespace Opus
// aapt resource value: 0x7f0d0119
public const int download_albumart = 2131558681;
// aapt resource value: 0x7f0d0130
public const int download_directory = 2131558704;
// aapt resource value: 0x7f0d0132
public const int download_directory = 2131558706;
// aapt resource value: 0x7f0d011a
public const int download_meta = 2131558682;
@@ -7519,20 +7519,20 @@ namespace Opus
// aapt resource value: 0x7f0d00ec
public const int download_path_not_set = 2131558636;
// aapt resource value: 0x7f0d011e
public const int download_queue = 2131558686;
// aapt resource value: 0x7f0d0120
public const int download_queue = 2131558688;
// aapt resource value: 0x7f0d00ef
public const int downloading = 2131558639;
// aapt resource value: 0x7f0d0150
public const int downloading_notification = 2131558736;
// aapt resource value: 0x7f0d0152
public const int downloading_notification = 2131558738;
// aapt resource value: 0x7f0d0122
public const int downloading_status = 2131558690;
// aapt resource value: 0x7f0d0124
public const int downloading_status = 2131558692;
// aapt resource value: 0x7f0d014d
public const int downloading_update = 2131558733;
// aapt resource value: 0x7f0d014f
public const int downloading_update = 2131558735;
// aapt resource value: 0x7f0d00d2
public const int edit_metadata = 2131558610;
@@ -7669,11 +7669,11 @@ namespace Opus
// aapt resource value: 0x7f0d00c3
public const int hours = 2131558595;
// aapt resource value: 0x7f0d0120
public const int initialization = 2131558688;
// aapt resource value: 0x7f0d0122
public const int initialization = 2131558690;
// aapt resource value: 0x7f0d012b
public const int later = 2131558699;
// aapt resource value: 0x7f0d012d
public const int later = 2131558701;
// aapt resource value: 0x7f0d00d6
public const int list_songs = 2131558614;
@@ -7687,23 +7687,23 @@ namespace Opus
// aapt resource value: 0x7f0d00f9
public const int local_playlists = 2131558649;
// aapt resource value: 0x7f0d013e
public const int log_in = 2131558718;
// aapt resource value: 0x7f0d0140
public const int log_in = 2131558720;
// aapt resource value: 0x7f0d0141
public const int log_out = 2131558721;
// aapt resource value: 0x7f0d013f
public const int log_out = 2131558719;
public const int logged_in = 2131558719;
// aapt resource value: 0x7f0d013d
public const int logged_in = 2131558717;
// aapt resource value: 0x7f0d0133
public const int max_download = 2131558707;
// aapt resource value: 0x7f0d0131
public const int max_download = 2131558705;
// aapt resource value: 0x7f0d0134
public const int max_download_dialog = 2131558708;
// aapt resource value: 0x7f0d0132
public const int max_download_dialog = 2131558706;
// aapt resource value: 0x7f0d0121
public const int metadata = 2131558689;
// aapt resource value: 0x7f0d0123
public const int metadata = 2131558691;
// aapt resource value: 0x7f0d011d
public const int metdata_error_noid = 2131558685;
@@ -7717,6 +7717,12 @@ namespace Opus
// aapt resource value: 0x7f0d00e3
public const int more = 2131558627;
// aapt resource value: 0x7f0d011e
public const int mount_error = 2131558686;
// aapt resource value: 0x7f0d011f
public const int mount_error_action = 2131558687;
// aapt resource value: 0x7f0d0040
public const int mr_button_content_description = 2131558464;
@@ -7798,8 +7804,8 @@ namespace Opus
// aapt resource value: 0x7f0d00bd
public const int next_loading = 2131558589;
// aapt resource value: 0x7f0d012d
public const int no = 2131558701;
// aapt resource value: 0x7f0d012f
public const int no = 2131558703;
// aapt resource value: 0x7f0d00f6
public const int no_channel = 2131558646;
@@ -7807,8 +7813,8 @@ namespace Opus
// aapt resource value: 0x7f0d00f5
public const int no_lives = 2131558645;
// aapt resource value: 0x7f0d0141
public const int no_permission = 2131558721;
// aapt resource value: 0x7f0d0143
public const int no_permission = 2131558723;
// aapt resource value: 0x7f0d00f4
public const int no_playlist = 2131558644;
@@ -7819,17 +7825,17 @@ namespace Opus
// aapt resource value: 0x7f0d00e8
public const int no_song = 2131558632;
// aapt resource value: 0x7f0d0142
public const int no_song_mix = 2131558722;
// aapt resource value: 0x7f0d0144
public const int no_song_mix = 2131558724;
// aapt resource value: 0x7f0d00f3
public const int no_track = 2131558643;
// aapt resource value: 0x7f0d013c
public const int not_log = 2131558716;
// aapt resource value: 0x7f0d013e
public const int not_log = 2131558718;
// aapt resource value: 0x7f0d0147
public const int not_streamable = 2131558727;
// aapt resource value: 0x7f0d0149
public const int not_streamable = 2131558729;
// aapt resource value: 0x7f0d00bc
public const int nothing = 2131558588;
@@ -7837,14 +7843,14 @@ namespace Opus
// aapt resource value: 0x7f0d00bf
public const int off = 2131558591;
// aapt resource value: 0x7f0d0129
public const int ok = 2131558697;
// aapt resource value: 0x7f0d012b
public const int ok = 2131558699;
// aapt resource value: 0x7f0d00c5
public const int open_youtube = 2131558597;
// aapt resource value: 0x7f0d0139
public const int others = 2131558713;
// aapt resource value: 0x7f0d013b
public const int others = 2131558715;
// aapt resource value: 0x7f0d0088
public const int password_toggle_content_description = 2131558536;
@@ -7984,32 +7990,32 @@ namespace Opus
// aapt resource value: 0x7f0d00dd
public const int sync_now = 2131558621;
// aapt resource value: 0x7f0d0133
public const int sync_remove = 2131558707;
// aapt resource value: 0x7f0d0135
public const int sync_remove = 2131558709;
// aapt resource value: 0x7f0d00f0
public const int syncing = 2131558640;
// aapt resource value: 0x7f0d0151
public const int tap_details = 2131558737;
// aapt resource value: 0x7f0d0153
public const int tap_details = 2131558739;
// aapt resource value: 0x7f0d0135
public const int theme = 2131558709;
// aapt resource value: 0x7f0d0137
public const int theme = 2131558711;
// aapt resource value: 0x7f0d0136
public const int theme_dialog = 2131558710;
// aapt resource value: 0x7f0d0138
public const int theme_dialog = 2131558712;
// aapt resource value: 0x7f0d00c4
public const int timer = 2131558596;
// aapt resource value: 0x7f0d0144
public const int timout = 2131558724;
// aapt resource value: 0x7f0d0146
public const int timout = 2131558726;
// aapt resource value: 0x7f0d0113
public const int title = 2131558675;
// aapt resource value: 0x7f0d0140
public const int undo = 2131558720;
// aapt resource value: 0x7f0d0142
public const int undo = 2131558722;
// aapt resource value: 0x7f0d011b
public const int undo_change = 2131558683;
@@ -8020,29 +8026,29 @@ namespace Opus
// aapt resource value: 0x7f0d010a
public const int unfork_playlist = 2131558666;
// aapt resource value: 0x7f0d0145
public const int unknow = 2131558725;
// aapt resource value: 0x7f0d0147
public const int unknow = 2131558727;
// aapt resource value: 0x7f0d00bb
public const int up_next = 2131558587;
// aapt resource value: 0x7f0d014d
public const int up_to_date = 2131558733;
// aapt resource value: 0x7f0d0125
public const int up_to_date_status = 2131558693;
// aapt resource value: 0x7f0d014b
public const int up_to_date = 2131558731;
public const int update = 2131558731;
// aapt resource value: 0x7f0d0123
public const int up_to_date_status = 2131558691;
// aapt resource value: 0x7f0d0149
public const int update = 2131558729;
// aapt resource value: 0x7f0d014c
public const int update_message = 2131558732;
// aapt resource value: 0x7f0d014a
public const int update_message = 2131558730;
public const int update_no_internet = 2131558730;
// aapt resource value: 0x7f0d0148
public const int update_no_internet = 2131558728;
// aapt resource value: 0x7f0d014e
public const int updating = 2131558734;
// aapt resource value: 0x7f0d0150
public const int updating = 2131558736;
// aapt resource value: 0x7f0d003e
public const int v7_preference_off = 2131558462;
@@ -8050,20 +8056,20 @@ namespace Opus
// aapt resource value: 0x7f0d003f
public const int v7_preference_on = 2131558463;
// aapt resource value: 0x7f0d013b
public const int version = 2131558715;
// aapt resource value: 0x7f0d013d
public const int version = 2131558717;
// aapt resource value: 0x7f0d012f
public const int volume = 2131558703;
// aapt resource value: 0x7f0d0131
public const int volume = 2131558705;
// aapt resource value: 0x7f0d0137
public const int white_theme = 2131558711;
// aapt resource value: 0x7f0d0139
public const int white_theme = 2131558713;
// aapt resource value: 0x7f0d012c
public const int yes = 2131558700;
// aapt resource value: 0x7f0d012e
public const int yes = 2131558702;
// aapt resource value: 0x7f0d0143
public const int youtube_endpoint = 2131558723;
// aapt resource value: 0x7f0d0145
public const int youtube_endpoint = 2131558725;
// aapt resource value: 0x7f0d00fc
public const int youtube_loading_error = 2131558652;

View File

@@ -133,6 +133,8 @@
<string name="undo_change">Undo changes</string>
<string name="changes_saved">Changes saved.</string>
<string name="metdata_error_noid">Can\'t get meta data on youtube, Youtube ID isn\'t set.</string>
<string name="mount_error">There is a probleme with your storage, please stop using your storage elsewhere and try again.</string>
<string name="mount_error_action">DISCARD AND LEAVE</string>
<!--Download Queue-->
<string name="download_queue">Download Queue</string>