Skip to content

Commit

Permalink
app: rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
hariimurti committed Jul 10, 2020
1 parent cffa487 commit 0e22556
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 34 deletions.
4 changes: 2 additions & 2 deletions ApkManager/AdbWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@
<TextBlock Grid.Row="1" Grid.Column="1" Text=":"/>
<TextBlock Grid.Row="1" Grid.Column="2" Text=". . . ." Padding="2,0,5,0"
Name="txtDevice" TextTrimming="CharacterEllipsis"/>
<TextBlock Grid.Row="1" Grid.Column="3" Text="Arch"/>
<TextBlock Grid.Row="1" Grid.Column="3" Text="ABI"/>
<TextBlock Grid.Row="1" Grid.Column="4" Text=":"/>
<TextBlock Grid.Row="1" Grid.Column="5" Text=". . . ." Padding="2,0,0,0"
Name="txtArch" TextTrimming="CharacterEllipsis"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Android"/>
<TextBlock Grid.Row="2" Grid.Column="1" Text=":"/>
<TextBlock Grid.Row="2" Grid.Column="2" Text=". . . ." Padding="2,0,5,0"
Name="txtAndroid" TextTrimming="CharacterEllipsis"/>
<TextBlock Grid.Row="2" Grid.Column="3" Text="Sdk"/>
<TextBlock Grid.Row="2" Grid.Column="3" Text="SDK"/>
<TextBlock Grid.Row="2" Grid.Column="4" Text=":"/>
<TextBlock Grid.Row="2" Grid.Column="5" Text=". . . ." Padding="2,0,0,0"
Name="txtSdk" TextTrimming="CharacterEllipsis"/>
Expand Down
2 changes: 1 addition & 1 deletion ApkManager/AdbWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private async void ComboDevices_SelectionChanged(object sender, SelectionChanged

txtDevice.Text = device.Name;
txtAndroid.Text = device.Android;
txtArch.Text = device.Arch;
txtArch.Text = device.Abi;
txtArch.Foreground = isArchCompatible ? txtArch.Foreground : Brushes.Red;
txtArch.ToolTip = isArchCompatible ? null : "not compatible";
txtSdk.Text = device.Sdk.ToString();
Expand Down
11 changes: 1 addition & 10 deletions ApkManager/Lib/Aapt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,7 @@ public static async Task<Result> DumbBadging(string pathApk)

//native-code
match = Regex.Match(output, "native-code: '([^:=]+)'");
if (match.Success)
{
apk.AbiList = match.Groups[1].Value.Replace("' '",", ");
apk.Platforms = match.Groups[1].Value.Replace("' '"," ").Split(' ').ToList();
}
else
{
apk.AbiList = "any-cpu";
apk.Platforms.Add("any-cpu");
}
apk.AbiList = match.Success ? match.Groups[1].Value.Replace("' '", ", ") : "Unknown";

//launchable-activity
match = Regex.Match(output, "launchable-activity: name='(.+?)'");
Expand Down
6 changes: 3 additions & 3 deletions ApkManager/Lib/Adb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Device
{
public string Name { get; set; }
public string Android { get; set; }
public string Arch { get; set; }
public string Abi { get; set; }
public int Sdk { get; set; }

public override string ToString()
Expand Down Expand Up @@ -274,7 +274,7 @@ public async Task<Device> GetDevice(string address)
var sdk = await GetProp(address, "ro.build.version.sdk");
int.TryParse(sdk, out int _sdk);

var arch = await GetProp(address, "ro.product.cpu.abi");
var _abi = await GetProp(address, "ro.product.cpu.abi");

OnProcess?.Invoke(false);
OVERRIDE_ONPROCESSEVENT = false;
Expand All @@ -284,7 +284,7 @@ public async Task<Device> GetDevice(string address)
Name = name,
Android = android,
Sdk = _sdk,
Arch = arch
Abi = _abi
};
}
}
Expand Down
14 changes: 6 additions & 8 deletions ApkManager/Lib/Apk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,40 @@ public class Apk
public int TargetSdkVersion { get; set; }
public BitmapImage Icon { get; set; }
public IList<string> Permissions { get; set; }
public IList<string> Platforms { get; set; }
public string AbiList { get; set; }
public string FilePath { get; set; }
public string LaunchableActivity { get; set; }

public Apk()
{
Permissions = new List<string>();
Platforms = new List<string>();
}

public bool isAbiCompatible(Adb.Device device)
{
if (AbiList == "any-cpu") return true;
if (AbiList == "Unknown" || device.Abi == "Unknown") return true;

if (device.Arch == "armeabi-v7a")
if (device.Abi == "armeabi-v7a")
{
return AbiList.Contains("armeabi");
}

if (device.Arch == "arm64-v8a")
if (device.Abi == "arm64-v8a")
{
return AbiList.Contains("arm");
}

if (device.Arch == "x86_64")
if (device.Abi == "x86_64")
{
return AbiList.Contains("x86");
}

return AbiList.Contains(device.Arch);
return AbiList.Contains(device.Abi);
}

public bool isSdkCompatible(Adb.Device device)
{
return SdkVersion <= device.Sdk;
return SdkVersion <= device.Sdk || device.Sdk == 0;
}

public bool canInstallTo(Adb.Device device)
Expand Down
4 changes: 2 additions & 2 deletions ApkManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<TextBlock Grid.Row="2" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<TextBlock Grid.Row="2" Grid.Column="2" Text=". . . ."
Name="txtVersion" TextTrimming="CharacterEllipsis" VerticalAlignment="Center"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="Arch" VerticalAlignment="Center"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="ABI" VerticalAlignment="Center"/>
<TextBlock Grid.Row="3" Grid.Column="1" Text=":" VerticalAlignment="Center"/>
<Grid Grid.Row="3" Grid.Column="2">
<Grid.ColumnDefinitions>
Expand All @@ -109,7 +109,7 @@
<ColumnDefinition Width="10" />
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text=". . . ." Name="txtArch" VerticalAlignment="Center" Margin="0,0,10,0" />
<TextBlock Grid.Column="0" Text=". . . ." Name="txtAbi" VerticalAlignment="Center" Margin="0,0,10,0" />
<TextBlock Grid.Column="1" Text="SDK" VerticalAlignment="Center"/>
<TextBlock Grid.Column="2" Text=":" VerticalAlignment="Center"/>
<TextBlock Grid.Column="3" Text=". . . ." Name="txtSdk" VerticalAlignment="Center"/>
Expand Down
16 changes: 8 additions & 8 deletions ApkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ private async void TxtPath_TextChanged(object sender, TextChangedEventArgs e)
txtLabel.Text = ". . . .";
txtPackage.Text = ". . . .";
txtVersion.Text = ". . . .";
txtArch.Text = ". . . .";
txtArch.ToolTip = null;
txtAbi.Text = ". . . .";
txtAbi.ToolTip = null;
txtSdk.Text = ". . . .";
imgIcon.Source = App.GetPlaystoreImageFromResources();
gbAction.IsEnabled = false;
Expand All @@ -134,11 +134,11 @@ private async void TxtPath_TextChanged(object sender, TextChangedEventArgs e)
txtPackage.Text = loadedApk.PackageName;
txtVersion.Text = string.Format("{0} ( {1} )", loadedApk.VersionName, loadedApk.VersionCode);

var foundOne = loadedApk.Platforms.Count <= 1;
txtArch.Text = foundOne ? loadedApk.AbiList : "see list";
txtArch.ToolTip = foundOne ? null : loadedApk.AbiList;
txtArch.FontStyle = foundOne ? FontStyles.Normal : FontStyles.Italic;
txtArch.Foreground = foundOne ? txtSdk.Foreground : Brushes.Blue;
var foundOne = !loadedApk.AbiList.Contains(",");
txtAbi.Text = foundOne ? loadedApk.AbiList : "see list";
txtAbi.ToolTip = foundOne ? null : loadedApk.AbiList;
txtAbi.FontStyle = foundOne ? FontStyles.Normal : FontStyles.Italic;
txtAbi.Foreground = foundOne ? txtSdk.Foreground : Brushes.Blue;

txtSdk.Text = loadedApk.SdkVersion.ToString();
imgIcon.Source = loadedApk.Icon;
Expand All @@ -149,7 +149,7 @@ private async void TxtPath_TextChanged(object sender, TextChangedEventArgs e)
txtLabel.Text = "file corrupt?";
txtPackage.Text = "not an apk file?";
txtVersion.Text = "???";
txtArch.Text = "???";
txtAbi.Text = "???";
txtSdk.Text = "???";
}

Expand Down

0 comments on commit 0e22556

Please sign in to comment.