Skip to content

Commit

Permalink
renamer: put abi at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
hariimurti committed Apr 11, 2020
1 parent 79f2676 commit 9e0f050
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ApkManager/Lib/LibExtended.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public static bool IsMatchInTextAndNotInLabel(this Tuple<string, string> 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();
}

Expand Down
20 changes: 17 additions & 3 deletions ApkManager/RenamerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ", "-");
Expand Down

0 comments on commit 9e0f050

Please sign in to comment.