From d3a2c2051549585fb9d216e9f967e959d069aaf5 Mon Sep 17 00:00:00 2001 From: Gregor Santner Date: Mon, 5 Mar 2018 17:22:06 +0100 Subject: [PATCH] . --- app/build.gradle | 3 +- .../nonsupport/LanguagePreference.java | 2 ++ .../net/gsantner/opoc/util/ContextUtils.java | 5 ++++ build.gradle | 30 +++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 82a4c23a..1daf33a7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,7 +14,8 @@ android { targetSdkVersion version_setup_targetSdk buildConfigField "boolean", "IS_TEST_BUILD", "false" buildConfigField "boolean", "IS_GPLAY_BUILD", "false" - buildConfigField "String[]", "APPLICATION_LANGUAGES", "${getUsedAndroidLanguages()}" + //buildConfigField "String[]", "APPLICATION_LANGUAGES", "${getUsedAndroidLanguages()}" + resValue "string", "bc_notr__detected_languages", "${getUsedAndroidLanguages()}" buildConfigField "String", "GITHASH", "\"${getGitHash()}\"" applicationId "com.github.dfa.diaspora_android" diff --git a/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java b/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java index a47a1a8d..51edbb83 100644 --- a/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java +++ b/app/src/main/java/net/gsantner/opoc/preference/nonsupport/LanguagePreference.java @@ -121,6 +121,8 @@ public class LanguagePreference extends ListPreference { languages.add(summarizeLocale(locale, langId) + ";" + langId); } } + String aa = contextUtils.str("build_conf__detected_languages"); + String a = aa; // Sort languages naturally Collections.sort(languages); diff --git a/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java b/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java index efbd8423..c5d70462 100644 --- a/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java +++ b/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java @@ -100,6 +100,7 @@ public class ContextUtils { public static final String ARRAY = "array"; public static final String DIMEN = "dimen"; public static final String MENU = "menu"; + public static final String BOOL = "bool"; public static final String RAW = "raw"; } @@ -107,6 +108,10 @@ public class ContextUtils { return _context.getString(strResId); } + public String str(String strResKey) { + return str(getResId(ResType.STRING, strResKey)); + } + public Drawable drawable(@DrawableRes int resId) { return ContextCompat.getDrawable(_context, resId); } diff --git a/build.gradle b/build.gradle index f86d3bbf..3f5895c9 100644 --- a/build.gradle +++ b/build.gradle @@ -47,12 +47,42 @@ allprojects { tasks.matching { task -> task.name.matches('.*generate.*Resources') }.all { task -> task.dependsOn copyRepoFiles } + + tasks.matching { task -> task.name.matches('.*generate.*Resources') }.all { + task -> task.doLast { markUntranslatableBuildFields() } + } } task clean(type: Delete) { delete rootProject.buildDir } +def markUntranslatableBuildFields() { + Set proc_projects = new HashSet<>(subprojects) + proc_projects.add(rootProject) + + proc_projects.each { proc_project -> + File mergeDir = new File("${proc_project.buildDir}/intermediates/res/merged") + if (!mergeDir.exists()) return + mergeDir.eachDir { dir -> + println("Resources" + dir) + dir.eachFileRecurse { file -> + if (file.name.endsWith(".xml")) { + println(file) + String content = file.getText('UTF-8') + if (content != null && content.contains('