From 9e0f0506752305e1cf83f50044748a7a480af45c Mon Sep 17 00:00:00 2001 From: Harimurti Date: Sun, 12 Apr 2020 01:14:37 +0700 Subject: [PATCH] renamer: put abi at the end --- ApkManager/Lib/LibExtended.cs | 4 +++- ApkManager/RenamerWindow.xaml.cs | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ApkManager/Lib/LibExtended.cs b/ApkManager/Lib/LibExtended.cs index ef6f105..c99d905 100644 --- a/ApkManager/Lib/LibExtended.cs +++ b/ApkManager/Lib/LibExtended.cs @@ -27,9 +27,11 @@ public static bool IsMatchInTextAndNotInLabel(this Tuple tuple, return mtext && !mlabel; } - public static string Append(this string text, string appendtext) + public static string Append(this string text, string appendtext, bool space = true) { var separator = string.IsNullOrWhiteSpace(text) ? "" : " "; + if (!space) separator = ""; + return string.Concat(text, separator, appendtext).Trim(); } diff --git a/ApkManager/RenamerWindow.xaml.cs b/ApkManager/RenamerWindow.xaml.cs index 513d5c5..dab3676 100644 --- a/ApkManager/RenamerWindow.xaml.cs +++ b/ApkManager/RenamerWindow.xaml.cs @@ -150,14 +150,28 @@ private void CheckChanged_Click(object sender, RoutedEventArgs e) if (cbSuffixBeta.IsChecked == true) namesuffix = namesuffix.Append("Beta"); - // suffix final - if (cbSuffixEnclosure.IsChecked == true) + // suffix enclosure + var useEnclosure = cbSuffixEnclosure.IsChecked == true; + if (useEnclosure) { namesuffix = Regex.Replace(namesuffix, "(\\w+)", delegate (Match match) { return string.Format("[{0}]", match.Groups[1].Value); }).Replace(" ",""); } - else + + // suffix abi + var filename = Path.GetFileName(apk.FilePath); + if (filename.IsMatch("armeabi-v7a")) + namesuffix = namesuffix.Append(useEnclosure ? "[armeabi-v7a]" : "armeabi-v7a", !useEnclosure); + if (filename.IsMatch("arm64-v8a")) + namesuffix = namesuffix.Append(useEnclosure ? "[arm64-v8a]" : "arm64-v8a", !useEnclosure); + if (filename.IsMatch("x86_x64")) + namesuffix = namesuffix.Append(useEnclosure ? "[x86_x64]" : "x86_x64", !useEnclosure); + else if (filename.IsMatch("x86")) + namesuffix = namesuffix.Append(useEnclosure ? "[x86]" : "x86", !useEnclosure); + + // suffix final + if (!useEnclosure) { if (rbSeparatorStrip.IsChecked == true) namesuffix = namesuffix.Replace(" ", "-");