forked from canheo136/QuickLook.Plugin.ApkViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
44 lines (37 loc) · 1.44 KB
/
Plugin.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
using AAPTForNet;
using QuickLook.Common.Plugin;
using System.Windows;
namespace QuickLook.Plugin.ApkViewer {
public class Plugin : IViewer {
public int Priority => 0;
public void Init() {}
public bool CanHandle(string path) => path.ToLower().EndsWith(".apk");
public void Prepare(string path, ContextObject context) {
context.Title = path;
context.TitlebarOverlap = false;
context.FullWindowDragging = true;
context.TitlebarBlurVisibility = false;
context.TitlebarColourVisibility = false;
context.PreferredSize = new Size { Width = 750, Height = 350 };
}
public void View(string path, ContextObject context) {
var apk = AAPTool.Decompile(path);
if (apk.IsEmpty) {
context.ViewerContent = new System.Windows.Controls.Label() {
Content = "Can not load package.",
Foreground = System.Windows.Media.Brushes.White,
FontSize = 16,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
};
}
else {
context.ViewerContent = new ViewerPane(context) {
ApkInfo = apk
};
}
context.IsBusy = false;
}
public void Cleanup() { }
}
}