-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read manifest for app name and some git infos for upload
- Loading branch information
1 parent
6404a12
commit d6e516e
Showing
11 changed files
with
161 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Dev App Example</string> | ||
</resources> |
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
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
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
46 changes: 46 additions & 0 deletions
46
plugin-build/plugin/src/main/java/ch/ubique/linth/common/StringUtils.kt
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ch.ubique.linth.common | ||
|
||
import java.io.File | ||
|
||
object StringUtils { | ||
|
||
private fun getLabelName(manifestFile: File): String? { | ||
if (manifestFile.isDirectory || manifestFile.exists().not()) { | ||
return null | ||
} | ||
|
||
val xmlParser = XmlParser(manifestFile) | ||
val fileName = xmlParser.findAttribute("application", "android:label") | ||
|
||
return fileName?.split("/")?.get(1) | ||
} | ||
|
||
/** | ||
* Finds all icon files matching the icon specified in the given manifest. | ||
*/ | ||
fun findAppName(resDirs: List<File>, manifest: File): String? { | ||
val labelName = getLabelName(manifest) ?: return null | ||
|
||
val stringFiles = mutableListOf<File>() | ||
for (resDir in resDirs) { | ||
if (resDir.exists()) { | ||
resDir.walkTopDown().maxDepth(1) | ||
.filter { it.isDirectory && (it.name.startsWith("values")) } | ||
.forEach { dir -> | ||
dir.walkTopDown().filter { it.isFile && it.name.matches(Regex(".*strings.*.xml")) } | ||
.forEach { stringFiles.add(it) } | ||
} | ||
} | ||
} | ||
if (stringFiles.isEmpty()) return null | ||
|
||
stringFiles.forEach { | ||
val xmlParser = XmlParser(it) | ||
val appName = xmlParser.findAttribute("string", "name", labelName, findTextValue = true) | ||
if (appName != null) return appName | ||
} | ||
|
||
return null | ||
} | ||
|
||
} |
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