├── lib ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ └── kotlin │ │ │ └── net │ │ │ └── dean │ │ │ └── jraw │ │ │ └── android │ │ │ ├── AppInfoProvider.kt │ │ │ ├── AppInfo.kt │ │ │ ├── SimpleAndroidLogAdapter.kt │ │ │ ├── AndroidHelper.kt │ │ │ ├── SharedPreferencesTokenStore.kt │ │ │ └── ManifestAppInfoProvider.kt │ └── test │ │ └── kotlin │ │ └── net │ │ └── dean │ │ └── jraw │ │ └── android │ │ ├── util.kt │ │ ├── AndroidHelperTest.kt │ │ ├── SimpleAndroidLogAdapterTest.kt │ │ ├── SharedPreferencesTokenStoreTest.kt │ │ └── ManifestAppInfoProviderTest.kt ├── proguard-rules.pro └── build.gradle ├── example-app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── drawable │ │ │ ├── ic_plus.xml │ │ │ ├── ic_user.xml │ │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ │ ├── activity_new_user.xml │ │ │ ├── view_tokenstore_row.xml │ │ │ ├── activity_main.xml │ │ │ └── activity_user_overview.xml │ │ └── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── net │ │ └── dean │ │ └── jraw │ │ └── android │ │ └── example │ │ ├── TokenStoreUserView.java │ │ ├── App.java │ │ ├── UserOverviewActivity.java │ │ ├── NewUserActivity.java │ │ └── MainActivity.java ├── proguard-rules.pro ├── build.gradle └── README.md ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .travis.yml ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':example-app', ':lib' 2 | -------------------------------------------------------------------------------- /example-app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea/ 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | -------------------------------------------------------------------------------- /lib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /lib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | net.dean.jraw.android.prefs_file 3 | 4 | -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/src/main/kotlin/net/dean/jraw/android/AppInfoProvider.kt: -------------------------------------------------------------------------------- 1 | package net.dean.jraw.android 2 | 3 | interface AppInfoProvider { 4 | fun provide(): AppInfo 5 | } 6 | -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbdean/JRAW-Android/HEAD/example-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example-app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example-app/src/main/res/drawable/ic_plus.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /lib/src/main/kotlin/net/dean/jraw/android/AppInfo.kt: -------------------------------------------------------------------------------- 1 | package net.dean.jraw.android 2 | 3 | import net.dean.jraw.http.UserAgent 4 | 5 | /** 6 | * This class contains all the information required to authenticate an Android app using reddit's 7 | * OAuth2 authentication process. 8 | */ 9 | data class AppInfo(val clientId: String, val redirectUrl: String, val userAgent: UserAgent) 10 | -------------------------------------------------------------------------------- /example-app/src/main/res/drawable/ic_user.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: android 3 | before_install: 4 | # https://stackoverflow.com/a/47719835/1275092 5 | - yes | sdkmanager "platforms;android-27" 6 | android: 7 | components: 8 | - tools 9 | - platform-tools 10 | - tools 11 | 12 | - build-tools-27.0.3 13 | - android-27 14 | script: 15 | - "./gradlew check jacocoTestReportDebug" 16 | after_success: 17 | - bash <(curl -s https://codecov.io/bash) -f lib/build/reports/jacoco/debug/jacoco.xml -------------------------------------------------------------------------------- /example-app/src/main/res/layout/activity_new_user.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /lib/src/main/kotlin/net/dean/jraw/android/SimpleAndroidLogAdapter.kt: -------------------------------------------------------------------------------- 1 | package net.dean.jraw.android 2 | 3 | import android.util.Log 4 | import net.dean.jraw.http.LogAdapter 5 | 6 | /** 7 | * Uses android.util.Log to log messages. 8 | */ 9 | class SimpleAndroidLogAdapter @JvmOverloads constructor( 10 | /** The priority of each message to log. Must be one of the android.util.Log constants. */ 11 | var level: Int = Log.VERBOSE, 12 | 13 | /** The tag to use when logging. Default is "JRAW" */ 14 | var tag: String = "JRAW" 15 | ) : LogAdapter { 16 | override fun writeln(data: String) { 17 | if (Log.isLoggable(tag, level)) 18 | Log.println(level, tag, data) 19 | } 20 | } -------------------------------------------------------------------------------- /lib/src/test/kotlin/net/dean/jraw/android/util.kt: -------------------------------------------------------------------------------- 1 | package net.dean.jraw.android 2 | 3 | inline fun expectException(doWork: () -> Unit): T { 4 | val message = "Should have thrown ${T::class.java.name}" 5 | try { 6 | doWork() 7 | throw IllegalStateException(message) 8 | } catch (e: Exception) { 9 | // Make sure rethrow the Exception we created here 10 | if (e.message == message) throw e 11 | // Make sure we got the right kind of Exception 12 | if (e::class.java != T::class.java) 13 | throw IllegalStateException("Expecting function to throw ${T::class.java.name}, instead threw ${e::class.java.name}", e) 14 | return e as T 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /example-app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |