| Name | Message | Date |
|---|---|---|
| 📄 FolderPickerActivity.cs | 4 days ago | |
| 📄 NoteListActivity.cs | 4 days ago | |
| 📄 NoteViewActivity.cs | 4 days ago | |
| 📄 SettingsActivity.cs | 4 days ago |
📄
src/Activities/FolderPickerActivity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using Android.Content; using Android.Views; using AndroidX.RecyclerView.Widget; using NotesApp.Adapters; using NotesApp.Auth; using NotesApp.Graph; using NotesApp.Models; namespace NotesApp.Activities; [Activity(Label = "@string/choose_folder_title", Exported = false)] public class FolderPickerActivity : Activity { private const int SelectFolderRequestCode = 100; public const string ExtraFolderId = "folder_id"; public const string ExtraFolderPath = "folder_path"; private ProgressBar _progressBar = null!; private FolderListAdapter _adapter = null!; private GraphService _graphService = null!; private string? _folderId; private string _folderPath = "/"; protected override void OnCreate(Bundle? savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_folder_picker); _folderId = Intent?.GetStringExtra(ExtraFolderId); _folderPath = Intent?.GetStringExtra(ExtraFolderPath) ?? "/"; FindViewById<TextView>(Resource.Id.folder_path_label)!.Text = _folderPath; _progressBar = FindViewById<ProgressBar>(Resource.Id.folder_progress)!; var recyclerView = FindViewById<RecyclerView>(Resource.Id.folder_recycler_view)!; recyclerView.SetLayoutManager(new LinearLayoutManager(this)); _adapter = new FolderListAdapter(OnFolderTapped); recyclerView.SetAdapter(_adapter); FindViewById<Button>(Resource.Id.select_folder_button)!.Click += (_, _) => SelectThisFolder(); _graphService = new GraphService(this); _ = LoadFoldersAsync(); } protected override void OnActivityResult(int requestCode, Result resultCode, Intent? data) { base.OnActivityResult(requestCode, resultCode, data); AuthService.HandleActivityResult(requestCode, resultCode, data); if (requestCode == SelectFolderRequestCode && resultCode == Result.Ok && data != null) { // A nested picker (a subfolder browsed into) selected a folder; forward the // result up the recursive chain and close this level too. SetResult(Result.Ok, data); Finish(); } } private async Task LoadFoldersAsync() { _progressBar.Visibility = ViewStates.Visible; try { var folders = await _graphService.ListChildFoldersAsync(_folderId); _adapter.SetItems(folders); } catch (Exception ex) { Toast.MakeText(this, ex.Message, ToastLength.Long)?.Show(); } finally { _progressBar.Visibility = ViewStates.Gone; } } private void OnFolderTapped(DriveFolderItem folder) { var intent = new Intent(this, typeof(FolderPickerActivity)); intent.PutExtra(ExtraFolderId, folder.Id); intent.PutExtra(ExtraFolderPath, _folderPath.TrimEnd('/') + "/" + folder.Name); StartActivityForResult(intent, SelectFolderRequestCode); } private void SelectThisFolder() { var data = new Intent(); data.PutExtra(ExtraFolderId, _folderId ?? "root"); data.PutExtra(ExtraFolderPath, _folderPath); SetResult(Result.Ok, data); Finish(); } }