mirror of
https://github.com/gsantner/dandelion
synced 2024-11-15 17:02:10 +01:00
Update and improve buildscript
This commit is contained in:
parent
255c6d650e
commit
28dac50d84
5 changed files with 90 additions and 46 deletions
|
@ -1,28 +1,20 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
if (enable_plugin_kotlin) {
|
||||||
ext {
|
apply plugin: 'kotlin-android'
|
||||||
version_sdk = [
|
apply plugin: 'kotlin-android-extensions'
|
||||||
compileSdk: 27,
|
apply plugin: 'kotlin-kapt'
|
||||||
minSdk : 17,
|
|
||||||
]
|
|
||||||
version_lib = [
|
|
||||||
appcompat : "27.0.0",
|
|
||||||
butterknife: "8.8.1",
|
|
||||||
netcipher : "2.0.0-alpha1",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion version_sdk.compileSdk
|
compileSdkVersion version_setup_compileSdk
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion version_sdk.minSdk
|
minSdkVersion version_setup_minSdk
|
||||||
targetSdkVersion version_sdk.compileSdk
|
targetSdkVersion version_setup_targetSdk
|
||||||
buildConfigField "boolean", "IS_TEST_BUILD", "false"
|
buildConfigField "boolean", "IS_TEST_BUILD", "false"
|
||||||
buildConfigField "boolean", "IS_GPLAY_BUILD", "false"
|
buildConfigField "boolean", "IS_GPLAY_BUILD", "false"
|
||||||
buildConfigField("String[]", "APPLICATION_LANGUAGES", '{' + getUsedAndroidLanguages().collect {"\"${it}\""}.join(",") + '}')
|
buildConfigField "String[]", "APPLICATION_LANGUAGES", "${getUsedAndroidLanguages()}"
|
||||||
buildConfigField "String", "GITHASH", "\"${getGitHash()}\""
|
buildConfigField "String", "GITHASH", "\"${getGitHash()}\""
|
||||||
|
|
||||||
applicationId "com.github.dfa.diaspora_android"
|
applicationId "com.github.dfa.diaspora_android"
|
||||||
|
@ -47,12 +39,18 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
if (enable_plugin_kotlin) {
|
||||||
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
flavorDefault {
|
flavorDefault {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
flavorGplay {
|
flavorGplay {
|
||||||
buildConfigField "boolean", "IS_GPLAY_BUILD", "true"
|
buildConfigField "boolean", "IS_GPLAY_BUILD", "true"
|
||||||
}*/
|
}*/
|
||||||
flavorTest {
|
flavorTest {
|
||||||
|
@ -78,19 +76,30 @@ dependencies {
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
|
||||||
// Android standard libs
|
// Android standard libs
|
||||||
implementation "com.android.support:appcompat-v7:${version_lib.appcompat}"
|
implementation "com.android.support:appcompat-v7:${version_library_appcompat}"
|
||||||
implementation "com.android.support:design:${version_lib.appcompat}"
|
implementation "com.android.support:design:${version_library_appcompat}"
|
||||||
implementation "com.android.support:support-v4:${version_lib.appcompat}"
|
implementation "com.android.support:support-v4:${version_library_appcompat}"
|
||||||
implementation "com.android.support:customtabs:${version_lib.appcompat}"
|
implementation "com.android.support:customtabs:${version_library_appcompat}"
|
||||||
implementation "com.android.support:cardview-v7:${version_lib.appcompat}"
|
implementation "com.android.support:cardview-v7:${version_library_appcompat}"
|
||||||
|
|
||||||
// UI libraries
|
// UI libraries
|
||||||
implementation "com.github.DASAR:ShiftColorPicker:v0.5"
|
implementation "com.github.DASAR:ShiftColorPicker:v0.5"
|
||||||
|
|
||||||
// Tool libraries
|
// Tool libraries
|
||||||
implementation "com.jakewharton:butterknife:${version_lib.butterknife}"
|
implementation "info.guardianproject.netcipher:netcipher:${version_library_netcipher}"
|
||||||
implementation "info.guardianproject.netcipher:netcipher:${version_lib.netcipher}"
|
implementation "info.guardianproject.netcipher:netcipher-webkit:${version_library_netcipher}"
|
||||||
implementation "info.guardianproject.netcipher:netcipher-webkit:${version_lib.netcipher}"
|
implementation "com.jakewharton:butterknife:${version_library_butterknife}"
|
||||||
|
if (enable_plugin_kotlin) {
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$version_plugin_kotlin"
|
||||||
|
}
|
||||||
|
|
||||||
annotationProcessor "com.jakewharton:butterknife-compiler:${version_lib.butterknife}"
|
// Processors
|
||||||
|
def anpros = ["com.jakewharton:butterknife-compiler:${version_library_butterknife}"]
|
||||||
|
for (anpro in anpros) {
|
||||||
|
if (enable_plugin_kotlin) {
|
||||||
|
kapt anpro
|
||||||
|
} else {
|
||||||
|
annotationProcessor anpro
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import net.gsantner.opoc.util.ContextUtils;
|
import net.gsantner.opoc.util.ContextUtils;
|
||||||
|
@ -155,7 +156,9 @@ public class LanguagePreference extends ListPreference {
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
Locale locale = new ContextUtils(getContext()).getLocaleByAndroidCode(getValue());
|
Locale locale = new ContextUtils(getContext()).getLocaleByAndroidCode(getValue());
|
||||||
return super.getSummary() + "\n\n" + summarizeLocale(locale);
|
String prefix = TextUtils.isEmpty(super.getSummary())
|
||||||
|
? "" : super.getSummary() + "\n\n";
|
||||||
|
return prefix + summarizeLocale(locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSystemLanguageName() {
|
public String getSystemLanguageName() {
|
||||||
|
|
|
@ -12,8 +12,11 @@
|
||||||
package net.gsantner.opoc.util;
|
package net.gsantner.opoc.util;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -96,6 +99,13 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showSoftKeyboard() {
|
||||||
|
InputMethodManager inputMethodManager = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||||
|
if (_activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) {
|
||||||
|
inputMethodManager.showSoftInput(_activity.getCurrentFocus(), InputMethodManager.SHOW_FORCED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String html) {
|
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String html) {
|
||||||
showDialogWithHtmlTextView(resTitleId, html, true, null);
|
showDialogWithHtmlTextView(resTitleId, html, true, null);
|
||||||
}
|
}
|
||||||
|
@ -129,4 +139,18 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils {
|
||||||
}
|
}
|
||||||
_activity.getWindow().setAttributes(attrs);
|
_activity.getWindow().setAttributes(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showRateOnGplayDialog() {
|
||||||
|
String pkgId = "details?id=" + _activity.getPackageName();
|
||||||
|
Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + pkgId));
|
||||||
|
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
|
||||||
|
(Build.VERSION.SDK_INT >= 21 ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) |
|
||||||
|
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
|
try {
|
||||||
|
_activity.startActivity(goToMarket);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
_activity.startActivity(new Intent(Intent.ACTION_VIEW,
|
||||||
|
Uri.parse("http://play.google.com/store/apps/" + pkgId)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,18 +543,4 @@ public class ContextUtils {
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showRateOnGplayDialog() {
|
|
||||||
String pkgId = "details?id=" + _context.getPackageName();
|
|
||||||
Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + pkgId));
|
|
||||||
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
|
|
||||||
(Build.VERSION.SDK_INT >= 21 ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) |
|
|
||||||
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
|
||||||
try {
|
|
||||||
_context.startActivity(goToMarket);
|
|
||||||
} catch (ActivityNotFoundException e) {
|
|
||||||
_context.startActivity(new Intent(Intent.ACTION_VIEW,
|
|
||||||
Uri.parse("http://play.google.com/store/apps/" + pkgId)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
32
build.gradle
32
build.gradle
|
@ -1,6 +1,23 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
ext.version_setup_compileSdk = 27
|
||||||
|
ext.version_setup_minSdk = 17
|
||||||
|
ext.version_setup_targetSdk = ext.version_setup_compileSdk
|
||||||
|
ext.version_setup_buildTools = "27.0.1" // Specifying optional
|
||||||
|
|
||||||
|
// https://developer.android.com/topic/libraries/support-library/revisions.html
|
||||||
|
ext.version_library_appcompat = "27.0.1"
|
||||||
|
// https://github.com/JakeWharton/butterknife/releases
|
||||||
|
ext.version_library_butterknife = "8.8.1"
|
||||||
|
// https://github.com/atlassian/commonmark-java/releases
|
||||||
|
ext.version_library_commonmark = "0.10.0"
|
||||||
|
// https://github.com/guardianproject/NetCipher/releases
|
||||||
|
ext.version_library_netcipher = "2.0.0-alpha1"
|
||||||
|
// https://github.com/JetBrains/kotlin/blob/master/ReadMe.md
|
||||||
|
ext.version_plugin_kotlin = "1.1.60"
|
||||||
|
ext.enable_plugin_kotlin = false
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
google()
|
google()
|
||||||
|
@ -8,6 +25,9 @@ buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||||
|
if (project.enable_plugin_kotlin) {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_plugin_kotlin"
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
@ -27,15 +47,17 @@ task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] ROOT_TO_RAW_COPYFILES = ["README.md", "LICENSE.md", "CHANGELOG.md", "CONTRIBUTORS.md"]
|
final String[] ROOT_TO_RAW_COPYFILES = ["README.md", "CHANGELOG.md", "CONTRIBUTORS.md","LICENSE.txt","LICENSE.md","LICENSE"]
|
||||||
task copyRepoFiles(type: Copy) {
|
task copyRepoFiles(type: Copy) {
|
||||||
from rootProject.files(ROOT_TO_RAW_COPYFILES)
|
from rootProject.files(ROOT_TO_RAW_COPYFILES)
|
||||||
into "app/src/main/res/raw"
|
into "app/src/main/res/raw"
|
||||||
rename { String fileName -> fileName.replace(fileName, fileName.toLowerCase()) }
|
rename { String fileName -> fileName.replace(fileName, fileName.toLowerCase()) }
|
||||||
} ; tasks.copyRepoFiles.execute()
|
}; tasks.copyRepoFiles.execute()
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection", "GroovyUnusedDeclaration"])
|
@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection", "GroovyUnusedDeclaration"])
|
||||||
static String[] getUsedAndroidLanguages() {
|
// Returns used android languages as a buildConfig array: {'de', 'it', ..}"
|
||||||
|
static String getUsedAndroidLanguages() {
|
||||||
Set<String> langs = new HashSet<>()
|
Set<String> langs = new HashSet<>()
|
||||||
new File('.').eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
|
new File('.').eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
|
||||||
final foldername = it.name
|
final foldername = it.name
|
||||||
|
@ -47,7 +69,7 @@ static String[] getUsedAndroidLanguages() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return langs.toArray(new String[langs.size()])
|
return '{' + langs.collect { "\"${it}\"" }.join(",") + '}'
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.getGitHash = { ->
|
ext.getGitHash = { ->
|
||||||
|
|
Loading…
Reference in a new issue