-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
132 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,73 @@ | ||
using System.IO; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace AAPTForNet { | ||
public class ApkInfo { | ||
private readonly string unknownInfo = "<Empty>"; | ||
private readonly string defaultIconName = "ic_launcher.png"; | ||
|
||
private string _name; | ||
private string _package; | ||
private string _ver; | ||
private string _icon; | ||
private static readonly string unknownInfo = "<Empty>"; | ||
// Default icon name generated by Android Studio | ||
private static readonly string defaultIconName = "ic_launcher.png"; | ||
|
||
private string _iconName = defaultIconName; | ||
|
||
public static readonly string SmallScreen = "small"; | ||
public static readonly string NormalScreen = "normal"; | ||
public static readonly string LargeScreen = "large"; | ||
public static readonly string xLargeScreen = "xlarge"; | ||
|
||
public static readonly ApkInfo Empty = new ApkInfo(); | ||
|
||
public string AppName => _name.Length > 0 ? _name : unknownInfo; | ||
public string PackageName => _package.Length > 0 ? _package : unknownInfo; | ||
public string Version => _ver.Length > 0 ? _ver : unknownInfo; | ||
public SDKInfo MinSDK { get; } | ||
public string IconName => _icon.Length > 4 ? _icon : defaultIconName; | ||
public string FullPath { get; } | ||
public long PackageSize => File.Exists(FullPath) ? | ||
new FileInfo(FullPath).Length : 0; | ||
public string IconPath => (IconName != string.Empty && IconName != defaultIconName) ? | ||
AAPTool.TempPath + @"\" + IconName : string.Empty; | ||
public bool isEmpty { get; } | ||
public string AppName { get; set; } | ||
public string PackageName { get; set; } | ||
public string Version { get; set; } | ||
public string FullPath { get; set; } | ||
public SDKInfo MinSDK { get; set; } | ||
public SDKInfo TargetSDK { get; set; } | ||
public List<string> Permissions { get; set; } | ||
public List<string> SupportScreens { get; set; } | ||
|
||
public string IconName { | ||
// IconName include name and extension | ||
get => _iconName.Length > 3 ? _iconName : defaultIconName; | ||
set { | ||
if (value == string.Empty || value.ToLower().EndsWith(".xml")) | ||
// Exclude markup icon only. Many packages do not use .png icon | ||
_iconName = defaultIconName; | ||
else | ||
_iconName = Path.GetFileName(value); | ||
} | ||
} | ||
public string IconPath { | ||
get { | ||
if (IconName == defaultIconName) return string.Empty; | ||
|
||
internal ApkInfo() { | ||
isEmpty = true; | ||
MinSDK = SDKInfo.Unknown; | ||
_icon = FullPath = string.Empty; | ||
_ver = _package = _name = unknownInfo; | ||
return AAPTool.TempPath + @"\" + IconName; | ||
} | ||
} | ||
public long PackageSize { | ||
get { | ||
if (!File.Exists(FullPath)) | ||
return 0; | ||
|
||
internal ApkInfo(string path, string name, string package, string ver, SDKInfo sdk, string iconName) { | ||
this.isEmpty = false; | ||
this.MinSDK = sdk; | ||
this.FullPath = path; | ||
this._name = name; | ||
this._package = package; | ||
this._ver = ver; | ||
this._icon = iconName.Length > 4 ? // Include name and extension | ||
Path.GetFileNameWithoutExtension(iconName) + ".png" : defaultIconName; | ||
return new FileInfo(FullPath).Length; | ||
} | ||
} | ||
public bool IsEmpty { | ||
get { | ||
return (AppName == string.Empty || AppName == unknownInfo) && | ||
(PackageName == string.Empty || PackageName == unknownInfo); | ||
} | ||
} | ||
|
||
public override string ToString() { | ||
return string.Format("Name: {0};\nPackage: {1};\nVer: {2};\nMinSDK: {3};\nIcon: {4}\n", | ||
this.AppName, this.PackageName, this.Version, this.MinSDK.ToString(), this.IconPath); | ||
internal ApkInfo() { | ||
AppName = unknownInfo; | ||
PackageName = unknownInfo; | ||
Version = unknownInfo; | ||
FullPath = string.Empty; | ||
MinSDK = SDKInfo.Unknown; | ||
TargetSDK = SDKInfo.Unknown; | ||
Permissions = new List<string>(); | ||
SupportScreens = new List<string>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters