From 76ff959824da47e078c44b02143a6c2a0a348884 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Thu, 26 Oct 2017 15:52:12 +0200 Subject: [PATCH] update project --- Habitica/build.gradle | 619 +++++++++--------- .../habitica/helpers/RxErrorHandler.java | 2 +- .../habitica/ui/fragments/NewsFragment.kt | 8 +- .../habitica/ui/fragments/StatsFragment.kt | 41 +- .../preferences/APIPreferenceFragment.kt | 2 +- .../AuthenticationPreferenceFragment.kt | 152 +++-- .../android/habitica/ui/views/StatsView.kt | 14 +- .../ui/views/settings/FixValuesEditText.kt | 4 +- build.gradle | 11 +- gradle/wrapper/gradle-wrapper.properties | 4 +- seeds-sdk/build.gradle | 25 +- 11 files changed, 461 insertions(+), 421 deletions(-) diff --git a/Habitica/build.gradle b/Habitica/build.gradle index 8d81a4249..64caa6a90 100644 --- a/Habitica/build.gradle +++ b/Habitica/build.gradle @@ -1,307 +1,312 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'com.android.databinding' -apply plugin: 'io.fabric' -apply plugin: 'com.neenbedankt.android-apt' -apply plugin: 'com.noveogroup.android.check' -apply plugin: 'realm-android' - -buildscript { - repositories { - mavenLocal() - mavenCentral() - maven { url 'https://maven.fabric.io/public' } - jcenter() - } - dependencies { - classpath 'io.fabric.tools:gradle:1.21.6' - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' - classpath('com.noveogroup.android:check:1.2.3') { - exclude module: 'checkstyle' - exclude module: 'pmd-java' - } - classpath 'com.puppycrawl.tools:checkstyle:7.5' - classpath 'net.sourceforge.pmd:pmd-java:5.5.3' - } -} - -repositories { - mavenLocal() - mavenCentral() - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } - maven { url 'https://maven.fabric.io/public' } - - // Material View Pager - maven { url "http://dl.bintray.com/florent37/maven" } - - // Markdown - maven { url "https://s3.amazonaws.com/repo.commonsware.com" } - - maven { url "https://jitpack.io" } - - maven { url "https://maven.google.com" } -} - -dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - //Networking - compile 'com.squareup.okhttp3:okhttp:3.9.0' - compile 'com.squareup.okhttp3:logging-interceptor:3.9.0' - //REST API handling - compile('com.squareup.retrofit2:retrofit:2.3.0') { - exclude module: 'okhttp' - } - compile 'com.squareup.retrofit2:converter-gson:2.3.0' - compile 'com.squareup.retrofit2:adapter-rxjava:2.3.0' - //Crash Logging - releaseCompile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { - transitive = true; - } - // View Elements Binding :) - compile 'com.jakewharton:butterknife:8.8.1' - apt 'com.jakewharton:butterknife-compiler:8.8.1' - //Dependency Injection - compile 'com.google.dagger:dagger:2.11' - apt 'com.google.dagger:dagger-compiler:2.11' - provided 'org.glassfish:javax.annotation:10.0-b28' - //App Compatibility and Material Design - compile('com.mikepenz:materialdrawer:5.8.3@aar') { - transitive = true - } - compile 'com.android.support:appcompat-v7:26.1.0' - compile 'com.android.support:design:26.1.0' - compile 'com.android.support:recyclerview-v7:26.1.0' - compile 'com.android.support:preference-v14:26.1.0' - //QR Code - compile 'com.github.kenglxn.QRGen:android:2.2.0' - // Emojis - compile 'com.github.viirus:emoji-lib:0.0.5' - // Markdown - compile 'com.commonsware.cwac:anddown:0.4.0' - // About View for all dependent Libraries, we are using - compile('com.mikepenz:aboutlibraries:5.9.4@aar') { - transitive = true - } - // a better fab alternative - compile 'com.github.clans:fab:1.6.4' - //Eventbus - compile 'org.greenrobot:eventbus:3.0.0' - // IAP Handling / Verification - compile 'org.solovyev.android:checkout:1.0.1' - //Facebook - compile('com.facebook.android:facebook-android-sdk:4.19.0') { - transitive = true - } - compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar' - // lodash/underscore - compile 'com.github.javadev:underscore:1.23' - //RxJava - compile 'io.reactivex:rxandroid:1.2.1' - compile 'io.reactivex:rxjava:1.3.2' - //Analytics - compile 'com.amplitude:android-sdk:2.14.1' - // Fresco Image Management Library - compile('com.facebook.fresco:fresco:1.5.0') { - exclude module: 'bolts-android' - } - compile('com.facebook.fresco:animated-gif:1.5.0') { - exclude module: 'bolts-android' - } - //Tests - testCompile 'junit:junit:4.10' - testCompile 'org.assertj:assertj-core:1.7.0' - testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' - testCompile 'org.robolectric:robolectric:3.3.2' - testCompile 'org.robolectric:shadows-multidex:3.3.2' - testCompile 'org.robolectric:shadows-support-v4:3.3.2' - testCompile 'org.mockito:mockito-core:2.8.9' - testCompile 'org.powermock:powermock-api-mockito2:1.7.0' - testCompile 'org.powermock:powermock-module-junit4-rule-agent:1.7.0' - testCompile 'org.powermock:powermock-module-junit4-rule:1.7.0' - testCompile 'org.powermock:powermock-module-junit4:1.7.0' - //Leak Detection - debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1' - releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' - //Push Notifications - compile 'com.google.firebase:firebase-core:11.4.0' - compile 'com.google.firebase:firebase-messaging:11.4.0' - compile 'com.google.android.gms:play-services-auth:11.4.0' - compile 'org.apmem.tools:layouts:1.10@aar' - compile 'com.roughike:bottom-bar:2.3.1' - compile 'io.realm:android-adapters:2.1.0' - compile(project(':seeds-sdk')) { - exclude group: 'com.google.android.gms' - exclude group: 'com.android.support', module: 'multidex' - } - compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" -} - -android { - compileSdkVersion sdk_version - buildToolsVersion build_tools_version - - defaultConfig { - applicationId "com.habitrpg.android.habitica" - vectorDrawables.useSupportLibrary = true - buildConfigField "String", "STORE", "\"google\"" - } - - lintOptions { - abortOnError false - } - signingConfigs { - release - } - - buildTypes { - debug { - applicationIdSuffix ".debug" - debuggable true - multiDexEnabled true - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - // Disable fabric build ID generation for debug builds - ext.enableCrashlytics = false - ext.alwaysUpdateBuildId = false - resValue "string", "content_provider", "com.habitrpg.android.habitica.debug.fileprovider" - resValue "string", "app_name", "Habitica Debug" - } - release { - signingConfig signingConfigs.release - debuggable false - multiDexEnabled false - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - resValue "string", "content_provider", "com.habitrpg.android.habitica.fileprovider" - resValue "string", "app_name", "Habitica" - } - } - - productFlavors { - dev { - minSdkVersion 21 - buildConfigField "String", "STAGING_KEY", "\"1dcf9ed3-3b14-45b3-9e7e-acdfff68a368\"" - } - - prod { - } - - amazon { - buildConfigField "String", "STORE", "\"amazon\"" - } - } - - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src/main/java'] - resources.srcDirs = ['src/main/java'] - aidl.srcDirs = ['src/main/java'] - renderscript.srcDirs = ['src/main/java'] - res.srcDirs = ['res'] - assets.srcDirs = ['assets'] - } - robolectric { - manifest.srcFile 'AndroidManifestTesting.xml' - java.srcDir file('src/test/java/') - res.srcDirs = ['res'] - } - instrumentTest.setRoot('tests') - release { java.srcDirs = ['src/release/java'] } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - dexOptions { - preDexLibraries false - javaMaxHeapSize "6g" // Use gig increments depending on needs - } - - lintOptions { - disable 'MissingTranslation','InvalidPackage' - enable 'LogConditional','IconExpectedSize','MissingRegistered','TypographyQuotes' - } - - splits { - abi { - enable true - reset() - include 'armeabi-v7a', 'arm64-v8a', 'mips', 'x86', 'x86_64' - universalApk true - } - } -} - -def Properties props = new Properties() -def propFile = new File('signingrelease.properties') -if (propFile.canRead()) { - props.load(new FileInputStream(propFile)) - - if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') && - props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) { - android.signingConfigs.release.storeFile = file(props['STORE_FILE']) - android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] - android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] - android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] - } else { - println 'signing.properties found but some entries are missing' - android.buildTypes.release.signingConfig = null - } -} else { - println 'signing.properties not found' - android.buildTypes.release.signingConfig = null -} - -// Add Habitica Properties to buildConfigField -final File HRPG_PROPS_FILE = new File('habitica.properties') -if (HRPG_PROPS_FILE.canRead()) { - def Properties HRPG_PROPS = new Properties() - HRPG_PROPS.load(new FileInputStream(HRPG_PROPS_FILE)) - - if (HRPG_PROPS != null) { - android.buildTypes.all { buildType -> - HRPG_PROPS.any { property -> - buildType.buildConfigField "String", property.key, "\"${property.value}\"" - } - } - } else { - throw new InvalidUserDataException('habitica.properties found but some entries are missing') - } -} else { - throw new MissingResourceException('habitica.properties not found') -} - -// Add Habitica Resources to resources -final File HRPG_RES_FILE = new File('habitica.resources') -if (HRPG_RES_FILE.canRead()) { - def Properties HRPG_RES = new Properties() - HRPG_RES.load(new FileInputStream(HRPG_RES_FILE)) - - if (HRPG_RES != null) { - android.buildTypes.all { buildType -> - HRPG_RES.any { property -> - buildType.resValue "string", property.key, "\"${property.value}\"" - } - } - } else { - throw new InvalidUserDataException('habitica.resources found but some entries are missing') - } -} else { - throw new MissingResourceException('habitica.resources not found') -} - -tasks.whenTaskAdded { task -> - if (task.name == "lint") { - task.enabled = false - } -} - -check { findbugs { skip true } } - -apply plugin: 'com.android.application' //or apply plugin: 'java' -apply plugin: 'me.tatarka.retrolambda' -apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'io.fabric' +apply plugin: 'com.noveogroup.android.check' +apply plugin: 'realm-android' + +buildscript { + repositories { + mavenLocal() + mavenCentral() + maven { url 'https://maven.fabric.io/public' } + jcenter() + } + dependencies { + classpath 'io.fabric.tools:gradle:1.22.1' + classpath('com.noveogroup.android:check:1.2.3') { + exclude module: 'checkstyle' + exclude module: 'pmd-java' + } + classpath 'com.puppycrawl.tools:checkstyle:7.5' + classpath 'net.sourceforge.pmd:pmd-java:5.5.3' + } +} + +repositories { + mavenLocal() + mavenCentral() + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + maven { url 'https://maven.fabric.io/public' } + + // Material View Pager + maven { url "http://dl.bintray.com/florent37/maven" } + + // Markdown + maven { url "https://s3.amazonaws.com/repo.commonsware.com" } + + maven { url "https://jitpack.io" } + + maven { url "https://maven.google.com" } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + //Networking + implementation 'com.squareup.okhttp3:okhttp:3.9.0' + implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0' + //REST API handling + implementation('com.squareup.retrofit2:retrofit:2.3.0') { + exclude module: 'okhttp' + } + implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.3.0' + //Crash Logging + releaseImplementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { + transitive = true + } + // View Elements Binding :) + implementation 'com.jakewharton:butterknife:8.8.1' + annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' + //Dependency Injection + implementation 'com.google.dagger:dagger:2.11' + annotationProcessor 'com.google.dagger:dagger-compiler:2.11' + compileOnly 'org.glassfish:javax.annotation:10.0-b28' + //App Compatibility and Material Design + implementation('com.mikepenz:materialdrawer:5.8.3@aar') { + transitive = true + } + implementation 'com.android.support:appcompat-v7:27.0.0' + implementation 'com.android.support:design:27.0.0' + implementation 'com.android.support:recyclerview-v7:27.0.0' + implementation 'com.android.support:preference-v14:27.0.0' + //QR Code + implementation 'com.github.kenglxn.QRGen:android:2.2.0' + // Emojis + implementation 'com.github.viirus:emoji-lib:0.0.5' + // Markdown + implementation 'com.commonsware.cwac:anddown:0.4.0' + // About View for all dependent Libraries, we are using + implementation('com.mikepenz:aboutlibraries:5.9.4@aar') { + transitive = true + } + // a better fab alternative + implementation 'com.github.clans:fab:1.6.4' + //Eventbus + implementation 'org.greenrobot:eventbus:3.0.0' + // IAP Handling / Verification + implementation 'org.solovyev.android:checkout:1.0.1' + //Facebook + implementation('com.facebook.android:facebook-android-sdk:4.19.0') { + transitive = true + } + implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar' + // lodash/underscore + implementation 'com.github.javadev:underscore:1.23' + //RxJava + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'io.reactivex:rxjava:1.3.2' + //Analytics + implementation 'com.amplitude:android-sdk:2.14.1' + // Fresco Image Management Library + implementation('com.facebook.fresco:fresco:1.5.0') { + exclude module: 'bolts-android' + } + implementation('com.facebook.fresco:animated-gif:1.5.0') { + exclude module: 'bolts-android' + } + //Tests + testImplementation 'junit:junit:4.12' + testImplementation 'org.assertj:assertj-core:2.6.0' + testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.3' + testImplementation 'org.robolectric:robolectric:3.3.2' + testImplementation 'org.robolectric:shadows-multidex:3.3.2' + testImplementation 'org.robolectric:shadows-support-v4:3.3.2' + testImplementation 'org.mockito:mockito-core:2.8.9' + testImplementation 'org.powermock:powermock-api-mockito2:1.7.0' + testImplementation 'org.powermock:powermock-module-junit4-rule-agent:1.7.0' + testImplementation 'org.powermock:powermock-module-junit4-rule:1.7.0' + testImplementation 'org.powermock:powermock-module-junit4:1.7.0' + //Leak Detection + debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.3' + releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.3' + //Push Notifications + implementation 'com.google.firebase:firebase-core:11.4.2' + implementation 'com.google.firebase:firebase-messaging:11.4.2' + implementation 'com.google.android.gms:play-services-auth:11.4.2' + implementation 'org.apmem.tools:layouts:1.10@aar' + implementation 'com.roughike:bottom-bar:2.3.1' + implementation 'io.realm:android-adapters:2.1.0' + implementation(project(':seeds-sdk')) { + exclude group: 'com.google.android.gms' + exclude group: 'com.android.support', module: 'multidex' + } + implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" +} + + +android { + compileSdkVersion sdk_version + buildToolsVersion build_tools_version + + defaultConfig { + applicationId "com.habitrpg.android.habitica" + vectorDrawables.useSupportLibrary = true + buildConfigField "String", "STORE", "\"google\"" + } + + lintOptions { + abortOnError false + } + signingConfigs { + release + } + flavorDimensions "buildType" + + buildTypes { + debug { + applicationIdSuffix ".debug" + debuggable true + multiDexEnabled true + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + // Disable fabric build ID generation for debug builds + ext.enableCrashlytics = false + ext.alwaysUpdateBuildId = false + resValue "string", "content_provider", "com.habitrpg.android.habitica.debug.fileprovider" + resValue "string", "app_name", "Habitica Debug" + } + release { + signingConfig signingConfigs.release + debuggable false + multiDexEnabled false + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + resValue "string", "content_provider", "com.habitrpg.android.habitica.fileprovider" + resValue "string", "app_name", "Habitica" + } + } + + productFlavors { + dev { + minSdkVersion 21 + buildConfigField "String", "STAGING_KEY", "\"1dcf9ed3-3b14-45b3-9e7e-acdfff68a368\"" + dimension "buildType" + } + + prod { + dimension "buildType" + } + + amazon { + buildConfigField "String", "STORE", "\"amazon\"" + dimension "buildType" + } + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src/main/java'] + resources.srcDirs = ['src/main/java'] + aidl.srcDirs = ['src/main/java'] + renderscript.srcDirs = ['src/main/java'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + robolectric { + manifest.srcFile 'AndroidManifestTesting.xml' + java.srcDir file('src/test/java/') + res.srcDirs = ['res'] + } + instrumentTest.setRoot('tests') + release { java.srcDirs = ['src/release/java'] } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + dexOptions { + preDexLibraries false + javaMaxHeapSize "6g" // Use gig increments depending on needs + } + + lintOptions { + disable 'MissingTranslation','InvalidPackage' + enable 'LogConditional','IconExpectedSize','MissingRegistered','TypographyQuotes' + } + + splits { + abi { + enable true + reset() + include 'armeabi-v7a', 'arm64-v8a', 'mips', 'x86', 'x86_64' + universalApk true + } + } + + dataBinding { + enabled = true + } +} + +Properties props = new Properties() +def propFile = new File('signingrelease.properties') +if (propFile.canRead()) { + props.load(new FileInputStream(propFile)) + + if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') && + props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) { + android.signingConfigs.release.storeFile = file(props['STORE_FILE']) + android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] + android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] + android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] + } else { + println 'signing.properties found but some entries are missing' + android.buildTypes.release.signingConfig = null + } +} else { + println 'signing.properties not found' + android.buildTypes.release.signingConfig = null +} + +// Add Habitica Properties to buildConfigField +final File HRPG_PROPS_FILE = new File('habitica.properties') +if (HRPG_PROPS_FILE.canRead()) { + Properties HRPG_PROPS = new Properties() + HRPG_PROPS.load(new FileInputStream(HRPG_PROPS_FILE)) + + if (HRPG_PROPS != null) { + android.buildTypes.all { buildType -> + HRPG_PROPS.any { property -> + buildType.buildConfigField "String", property.key, "\"${property.value}\"" + } + } + } else { + throw new InvalidUserDataException('habitica.properties found but some entries are missing') + } +} else { + throw new MissingResourceException('habitica.properties not found') +} + +// Add Habitica Resources to resources +final File HRPG_RES_FILE = new File('habitica.resources') +if (HRPG_RES_FILE.canRead()) { + Properties HRPG_RES = new Properties() + HRPG_RES.load(new FileInputStream(HRPG_RES_FILE)) + + if (HRPG_RES != null) { + android.buildTypes.all { buildType -> + HRPG_RES.any { property -> + buildType.resValue "string", property.key, "\"${property.value}\"" + } + } + } else { + throw new InvalidUserDataException('habitica.resources found but some entries are missing') + } +} else { + throw new MissingResourceException('habitica.resources not found') +} + +tasks.whenTaskAdded { task -> + if (task.name == "lint") { + task.enabled = false + } +} + +check { findbugs { skip true } } + +apply plugin: 'com.android.application' //or apply plugin: 'java' +apply plugin: 'com.google.gms.google-services' diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/RxErrorHandler.java b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/RxErrorHandler.java index 26fe157b7..36cf5d179 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/RxErrorHandler.java +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/RxErrorHandler.java @@ -8,7 +8,7 @@ import com.habitrpg.android.habitica.proxy.CrashlyticsProxy; import java.io.EOFException; import java.io.IOException; -import cz.msebera.android.httpclient.HttpException; +import retrofit2.HttpException; import rx.functions.Action1; import rx.plugins.RxJavaHooks; diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/NewsFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/NewsFragment.kt index 8937aa568..c835d6016 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/NewsFragment.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/NewsFragment.kt @@ -14,14 +14,14 @@ import kotlinx.android.synthetic.main.fragment_news.* class NewsFragment : BaseMainFragment() { - override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { super.onCreateView(inflater, container, savedInstanceState) - return inflater?.inflate(R.layout.fragment_news, container, false) + return inflater.inflate(R.layout.fragment_news, container, false) } - override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val address = if (BuildConfig.DEBUG) BuildConfig.BASE_URL else context.getString(R.string.base_url) + val address = if (BuildConfig.DEBUG) BuildConfig.BASE_URL else context?.getString(R.string.base_url) newsWebview.webChromeClient = WebChromeClient() newsWebview.loadUrl(address + "/static/new-stuff") } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/StatsFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/StatsFragment.kt index 1ebdc763c..914c4d3aa 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/StatsFragment.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/StatsFragment.kt @@ -51,10 +51,10 @@ class StatsFragment: BaseMainFragment() { perceptionStatsView.totalValue = value } - override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { super.onCreateView(inflater, container, savedInstanceState) hideToolbar() - return inflater?.inflate(R.layout.fragment_stats, container, false) + return inflater.inflate(R.layout.fragment_stats, container, false) } override fun onDestroyView() { @@ -67,7 +67,7 @@ class StatsFragment: BaseMainFragment() { super.onDestroy() } - override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) leftSparklesView.setImageBitmap(HabiticaIconsHelper.imageOfAttributeSparklesLeft()) @@ -82,17 +82,17 @@ class StatsFragment: BaseMainFragment() { updateAttributePoints() }, RxErrorHandler.handleEmptyError())) - distributeEvenlyButton.setOnCheckedChangeListener { button, isChecked -> + distributeEvenlyButton.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { changeAutoAllocationMode(Stats.AUTO_ALLOCATE_FLAT) } } - distributeClassButton.setOnCheckedChangeListener { button, isChecked -> + distributeClassButton.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { changeAutoAllocationMode(Stats.AUTO_ALLOCATE_CLASSBASED) } } - distributeTaskButton.setOnCheckedChangeListener { button, isChecked -> + distributeTaskButton.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { changeAutoAllocationMode(Stats.AUTO_ALLOCATE_TASKBASED) } @@ -146,19 +146,22 @@ class StatsFragment: BaseMainFragment() { intelligenceStatsView.canDistributePoints = canDistributePoints constitutionStatsView.canDistributePoints = canDistributePoints perceptionStatsView.canDistributePoints = canDistributePoints - if (canDistributePoints) { - val points = user?.stats?.points ?: 0 - numberOfPointsTextView.text = getString(R.string.points_to_allocate, points) - numberOfPointsTextView.setTextColor(ContextCompat.getColor(context, R.color.white)) - numberOfPointsTextView.background = ContextCompat.getDrawable(context, R.drawable.pill_bg_gray_100) - leftSparklesView.visibility = View.VISIBLE - rightSparklesView.visibility = View.VISIBLE - } else { - numberOfPointsTextView.text = getString(R.string.no_points_to_allocate) - numberOfPointsTextView.setTextColor(ContextCompat.getColor(context, R.color.gray_300)) - numberOfPointsTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent)) - leftSparklesView.visibility = View.GONE - rightSparklesView.visibility = View.GONE + val context = context + if (context != null) { + if (canDistributePoints) { + val points = user?.stats?.points ?: 0 + numberOfPointsTextView.text = getString(R.string.points_to_allocate, points) + numberOfPointsTextView.setTextColor(ContextCompat.getColor(context, R.color.white)) + numberOfPointsTextView.background = ContextCompat.getDrawable(context, R.drawable.pill_bg_gray_100) + leftSparklesView.visibility = View.VISIBLE + rightSparklesView.visibility = View.VISIBLE + } else { + numberOfPointsTextView.text = getString(R.string.no_points_to_allocate) + numberOfPointsTextView.setTextColor(ContextCompat.getColor(context, R.color.gray_300)) + numberOfPointsTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent)) + leftSparklesView.visibility = View.GONE + rightSparklesView.visibility = View.GONE + } } numberOfPointsTextView.setScaledPadding(context, 18, 4, 18, 4) } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/APIPreferenceFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/APIPreferenceFragment.kt index f8fcfdb86..ae3e6f405 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/APIPreferenceFragment.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/APIPreferenceFragment.kt @@ -33,7 +33,7 @@ class APIPreferenceFragment: BasePreferencesFragment() { when (preference.key) { "SP_user_qr_code" -> qrCodeManager.showDialogue() else -> { - val clipMan = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clipMan = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager clipMan.primaryClip = ClipData.newPlainText(preference.key, preference.summary) Toast.makeText(activity, "Copied " + preference.key + " to clipboard.", Toast.LENGTH_SHORT).show() } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AuthenticationPreferenceFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AuthenticationPreferenceFragment.kt index 84f01f833..c472300a3 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AuthenticationPreferenceFragment.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/preferences/AuthenticationPreferenceFragment.kt @@ -75,7 +75,7 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() { "reset_account" -> showAccountResetConfirmation() "delete_account" -> showAccountDeleteConfirmation() else -> { - val clipMan = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clipMan = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager clipMan.primaryClip = ClipData.newPlainText(preference.key, preference.summary) Toast.makeText(activity, "Copied " + preference.key + " to clipboard.", Toast.LENGTH_SHORT).show() } @@ -88,45 +88,52 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() { } private fun showEmailDialog() { - val inflater = context.layoutInflater - val view = inflater.inflate(R.layout.dialog_edittext_confirm_pw, null) - val emailEditText = view.findViewById(R.id.editText) - emailEditText.setText(user?.authentication?.localAuthentication?.email) - val passwordEditText = view.findViewById(R.id.passwordEditText) - val dialog = AlertDialog.Builder(context) - .setTitle(R.string.change_email) - .setPositiveButton(R.string.change) { thisDialog, _ -> - thisDialog.dismiss() - userRepository.updateEmail(emailEditText.text.toString(), passwordEditText.text.toString()) - .subscribe(Action1 { - configurePreference(findPreference("email"), emailEditText.text.toString()) - }, RxErrorHandler.handleEmptyError()) - } - .setNegativeButton(R.string.action_cancel) { thisDialog, _ -> thisDialog.dismiss() } - .create() - dialog.setView(view) - dialog.show() + val inflater = context?.layoutInflater + val view = inflater?.inflate(R.layout.dialog_edittext_confirm_pw, null) + val emailEditText = view?.findViewById(R.id.editText) + emailEditText?.setText(user?.authentication?.localAuthentication?.email) + val passwordEditText = view?.findViewById(R.id.passwordEditText) + val context = context + if (context != null) { + val dialog = AlertDialog.Builder(context) + .setTitle(R.string.change_email) + .setPositiveButton(R.string.change) { thisDialog, _ -> + thisDialog.dismiss() + userRepository.updateEmail(emailEditText?.text.toString(), passwordEditText?.text.toString()) + .subscribe(Action1 { + configurePreference(findPreference("email"), emailEditText?.text.toString()) + }, RxErrorHandler.handleEmptyError()) + } + .setNegativeButton(R.string.action_cancel) { thisDialog, _ -> thisDialog.dismiss() } + .create() + dialog.setView(view) + dialog.show() + } } private fun showLoginNameDialog() { - val inflater = context.layoutInflater - val view = inflater.inflate(R.layout.dialog_edittext_confirm_pw, null) - val loginNameEditText = view.findViewById(R.id.editText) - loginNameEditText.setText(user?.authentication?.localAuthentication?.username) - val passwordEditText = view.findViewById(R.id.passwordEditText) - val dialog = AlertDialog.Builder(context) - .setTitle(R.string.change_login_name) - .setPositiveButton(R.string.change) { thisDialog, _ -> - thisDialog.dismiss() - userRepository.updateLoginName(loginNameEditText.text.toString(), passwordEditText.text.toString()) - .subscribe(Action1 { - configurePreference(findPreference("login_name"), loginNameEditText.text.toString()) - }, RxErrorHandler.handleEmptyError()) - } - .setNegativeButton(R.string.action_cancel) { thisDialog, _ -> thisDialog.dismiss() } - .create() - dialog.setView(view) - dialog.show() + val inflater = context?.layoutInflater + val view = inflater?.inflate(R.layout.dialog_edittext_confirm_pw, null) + val loginNameEditText = view?.findViewById(R.id.editText) + loginNameEditText?.setText(user?.authentication?.localAuthentication?.username) + val passwordEditText = view?.findViewById(R.id.passwordEditText) + val context = context + if (context != null) { + val dialog = AlertDialog.Builder(context) + + .setTitle(R.string.change_login_name) + .setPositiveButton(R.string.change) { thisDialog, _ -> + thisDialog.dismiss() + userRepository.updateLoginName(loginNameEditText?.text.toString(), passwordEditText?.text.toString()) + .subscribe(Action1 { + configurePreference(findPreference("login_name"), loginNameEditText?.text.toString()) + }, RxErrorHandler.handleEmptyError()) + } + .setNegativeButton(R.string.action_cancel) { thisDialog, _ -> thisDialog.dismiss() } + .create() + dialog.setView(view) + dialog.show() + } } private fun showAccountDeleteConfirmation() { @@ -135,25 +142,28 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() { LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT) input.layoutParams = lp - val dialog = AlertDialog.Builder(context) - .setTitle(R.string.delete_account) - .setMessage(R.string.delete_account_description) - .setPositiveButton(R.string.delete_account_confirmation) { thisDialog, _ -> - thisDialog.dismiss() - deleteAccount(input.text.toString()) - } - .setNegativeButton(R.string.nevermind) { thisDialog, _ -> thisDialog.dismiss() } - .create() - dialog.setOnShowListener { _ -> dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(context, R.color.red_10)) } - dialog.setView(input) - dialog.show() + val context = context + if (context != null) { + val dialog = AlertDialog.Builder(context) + .setTitle(R.string.delete_account) + .setMessage(R.string.delete_account_description) + .setPositiveButton(R.string.delete_account_confirmation) { thisDialog, _ -> + thisDialog.dismiss() + deleteAccount(input.text.toString()) + } + .setNegativeButton(R.string.nevermind) { thisDialog, _ -> thisDialog.dismiss() } + .create() + dialog.setOnShowListener { _ -> dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(context, R.color.red_10)) } + dialog.setView(input) + dialog.show() + } } private fun deleteAccount(password: String) { - val dialog = ProgressDialog.show(context, context.getString(R.string.deleting_account), null, true) + val dialog = ProgressDialog.show(context, context?.getString(R.string.deleting_account), null, true) userRepository.deleteAccount(password).subscribe({ _ -> HabiticaApplication.logout(context) - activity.finish() + activity?.finish() }) { throwable -> dialog.dismiss() RxErrorHandler.reportError(throwable) @@ -161,21 +171,24 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() { } private fun showAccountResetConfirmation() { - val dialog = AlertDialog.Builder(context) - .setTitle(R.string.reset_account) - .setMessage(R.string.reset_account_description) - .setPositiveButton(R.string.reset_account_confirmation) { thisDialog, _ -> - thisDialog.dismiss() - resetAccount() - } - .setNegativeButton(R.string.nevermind) { thisDialog, _ -> thisDialog.dismiss() } - .create() - dialog.setOnShowListener { _ -> dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(context, R.color.red_10)) } - dialog.show() + val context = context + if (context != null) { + val dialog = AlertDialog.Builder(context) + .setTitle(R.string.reset_account) + .setMessage(R.string.reset_account_description) + .setPositiveButton(R.string.reset_account_confirmation) { thisDialog, _ -> + thisDialog.dismiss() + resetAccount() + } + .setNegativeButton(R.string.nevermind) { thisDialog, _ -> thisDialog.dismiss() } + .create() + dialog.setOnShowListener { _ -> dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(context, R.color.red_10)) } + dialog.show() + } } private fun resetAccount() { - val dialog = ProgressDialog.show(context, context.getString(R.string.resetting_account), null, true) + val dialog = ProgressDialog.show(context, context?.getString(R.string.resetting_account), null, true) userRepository.resetAccount().subscribe({ _ -> dialog.dismiss() }) { throwable -> dialog.dismiss() RxErrorHandler.reportError(throwable) @@ -185,10 +198,13 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() { private fun showSubscriptionStatusDialog() { val view = SubscriptionDetailsView(context) view.setPlan(user?.purchased?.plan) - val dialog = AlertDialog.Builder(context) - .setView(view) - .setTitle(R.string.subscription_status) - .setPositiveButton(R.string.close) { dialogInterface, _ -> dialogInterface.dismiss() }.create() - dialog.show() + val context = context + if (context != null) { + val dialog = AlertDialog.Builder(context) + .setView(view) + .setTitle(R.string.subscription_status) + .setPositiveButton(R.string.close) { dialogInterface, _ -> dialogInterface.dismiss() }.create() + dialog.show() + } } } \ No newline at end of file diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/StatsView.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/StatsView.kt index 2e99b8826..1e23dcd0e 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/StatsView.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/StatsView.kt @@ -67,13 +67,15 @@ class StatsView(context: Context?, attrs: AttributeSet?) : LinearLayout(context, R.styleable.StatsView, 0, 0) - val backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.layout_top_rounded_bg) - if (attributes != null) { - statColor = attributes.getColor(R.styleable.StatsView_statsColor, 0) - backgroundDrawable.setColorFilter(attributes.getColor(R.styleable.StatsView_titleBackgroundColor, 0), PorterDuff.Mode.MULTIPLY) - titleTextView.text = attributes.getString(R.styleable.StatsView_statsTitle) + if (context != null) { + val backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.layout_top_rounded_bg) + if (attributes != null) { + statColor = attributes.getColor(R.styleable.StatsView_statsColor, 0) + backgroundDrawable?.setColorFilter(attributes.getColor(R.styleable.StatsView_titleBackgroundColor, 0), PorterDuff.Mode.MULTIPLY) + titleTextView.text = attributes.getString(R.styleable.StatsView_statsTitle) + } + titleWrapper.background = backgroundDrawable } - titleWrapper.background = backgroundDrawable allocateButton.setOnClickListener { allocateAction?.invoke() diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/settings/FixValuesEditText.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/settings/FixValuesEditText.kt index a1b2fbed0..9e479f762 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/settings/FixValuesEditText.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/settings/FixValuesEditText.kt @@ -39,8 +39,8 @@ class FixValuesEditText(context: Context, attrs: AttributeSet) : FrameLayout(con editTextWrapper.hint = editText.hint editTextWrapper.setHintTextAppearance(attributes.getResourceId(R.styleable.FixValuesEditText_hintStyle, R.style.PurpleTextLabel)) val backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg) - backgroundDrawable.setColorFilter(attributes.getColor(R.styleable.FixValuesEditText_iconBgColor, 0), PorterDuff.Mode.MULTIPLY) - backgroundDrawable.alpha = 50 + backgroundDrawable?.setColorFilter(attributes.getColor(R.styleable.FixValuesEditText_iconBgColor, 0), PorterDuff.Mode.MULTIPLY) + backgroundDrawable?.alpha = 50 iconBackgroundView.background = backgroundDrawable diff --git a/build.gradle b/build.gradle index 6fd6b6ed6..a404ca8c8 100644 --- a/build.gradle +++ b/build.gradle @@ -2,20 +2,18 @@ buildscript { ext.kotlin_version = '1.1.51' - ext.build_tools_version = '26.0.1' + ext.build_tools_version = '26.0.2' ext.sdk_version = 26 repositories { jcenter() + google() maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' - classpath 'com.android.databinding:dataBinder:1.0-rc4' + classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' - classpath 'com.google.gms:google-services:3.0.0' - classpath 'me.tatarka:gradle-retrolambda:3.3.1' - classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2' + classpath 'com.google.gms:google-services:3.1.1' classpath "io.realm:realm-gradle-plugin:3.7.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0.RC4-3" @@ -30,6 +28,7 @@ apply plugin: 'io.gitlab.arturbosch.detekt' allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bb378a8ca..532a7d093 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Mar 23 10:38:10 CET 2017 +#Thu Oct 26 13:59:07 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/seeds-sdk/build.gradle b/seeds-sdk/build.gradle index 74413e37b..6140497fe 100755 --- a/seeds-sdk/build.gradle +++ b/seeds-sdk/build.gradle @@ -10,6 +10,21 @@ buildscript { } } +repositories { + mavenLocal() + mavenCentral() + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + maven { url 'https://maven.fabric.io/public' } + + // Material View Pager + maven { url "http://dl.bintray.com/florent37/maven" } + + // Markdown + maven { url "https://s3.amazonaws.com/repo.commonsware.com" } + maven { url "https://jitpack.io" } + maven { url "https://maven.google.com" } +} + android { compileSdkVersion sdk_version buildToolsVersion build_tools_version @@ -46,17 +61,17 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'org.glassfish:javax.json:1.0.4' - implementation 'com.google.android.gms:play-services:10.2.6' + implementation 'com.google.android.gms:play-services:11.4.2' implementation 'com.google.code.gson:gson:2.8.0' - implementation 'com.android.support:multidex:1.0.1' + implementation 'com.android.support:multidex:1.0.2' implementation 'com.loopj.android:android-async-http:1.4.9' - implementation 'org.solovyev.android:checkout:0.9.3@aar' + implementation 'org.solovyev.android:checkout:1.0.1@aar' androidTestImplementation 'org.mockito:mockito-core:2.8.9' androidTestImplementation 'com.google.dexmaker:dexmaker:1.2' androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2' testImplementation 'junit:junit:4.12' - testImplementation "org.robolectric:robolectric:3.2" - testImplementation "org.robolectric:shadows-multidex:3.1" + testImplementation "org.robolectric:robolectric:3.3.2" + testImplementation "org.robolectric:shadows-multidex:3.3.2" } publish {