From b406e8301ae2a431245a3f91bbc7937ba3270091 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 3 Oct 2018 17:56:33 +0200 Subject: [PATCH] first commit --- .gitignore | 10 + .idea/caches/build_file_checksums.ser | Bin 0 -> 708 bytes .idea/codeStyles/Project.xml | 29 +++ .idea/dictionaries/ganfra.xml | 8 + .idea/gradle.xml | 21 +++ .idea/inspectionProfiles/Project_Default.xml | 6 + .idea/misc.xml | 34 ++++ .idea/runConfigurations.xml | 12 ++ README.md | 1 + app/.gitignore | 1 + app/build.gradle | 37 ++++ app/proguard-rules.pro | 21 +++ .../riotredesign/ExampleInstrumentedTest.kt | 24 +++ app/src/main/AndroidManifest.xml | 25 +++ .../main/java/im/vector/riotredesign/Riot.kt | 13 ++ .../core/platform/RiotActivity.kt | 7 + .../core/platform/RiotFragment.kt | 6 + .../features/home/HomeActivity.kt | 25 +++ .../features/login/LoginActivity.kt | 54 ++++++ .../drawable-v24/ic_launcher_foreground.xml | 34 ++++ .../res/drawable/ic_launcher_background.xml | 170 +++++++++++++++++ app/src/main/res/layout/activity_home.xml | 26 +++ app/src/main/res/layout/activity_login.xml | 66 +++++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes app/src/main/res/values/colors.xml | 6 + app/src/main/res/values/strings.xml | 3 + app/src/main/res/values/styles.xml | 11 ++ .../im/vector/riotredesign/ExampleUnitTest.kt | 17 ++ build.gradle | 30 +++ gradle.properties | 13 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54708 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 172 ++++++++++++++++++ gradlew.bat | 84 +++++++++ matrix-sdk-android/.gitignore | 1 + matrix-sdk-android/build.gradle | 35 ++++ matrix-sdk-android/proguard-rules.pro | 21 +++ .../android/ExampleInstrumentedTest.java | 26 +++ .../src/main/AndroidManifest.xml | 2 + .../android/thread/MainThreadExecutor.java | 16 ++ .../src/main/res/values/strings.xml | 3 + .../matrix/android/ExampleUnitTest.java | 17 ++ matrix-sdk-core/.gitignore | 1 + matrix-sdk-core/build.gradle | 25 +++ .../java/im/vector/matrix/core/api/Matrix.kt | 21 +++ .../vector/matrix/core/api/MatrixCallback.kt | 11 ++ .../vector/matrix/core/api/MatrixOptions.kt | 5 + .../java/im/vector/matrix/core/api/Session.kt | 11 ++ .../im/vector/matrix/core/api/events/Event.kt | 4 + .../matrix/core/api/events/EventType.kt | 41 +++++ .../vector/matrix/core/api/failure/Failure.kt | 11 ++ .../matrix/core/api/failure/MatrixError.kt | 33 ++++ .../matrix/core/api/login/Authenticator.kt | 11 ++ .../matrix/core/api/login/CredentialsStore.kt | 6 + .../matrix/core/api/login/data/Credentials.kt | 11 ++ .../login/data/HomeServerConnectionConfig.kt | 9 + .../vector/matrix/core/api/storage/MxQuery.kt | 11 ++ .../matrix/core/api/storage/MxQueryBuilder.kt | 7 + .../core/api/storage/MxQueryDataObserver.java | 5 + .../vector/matrix/core/api/storage/MxStore.kt | 13 ++ .../vector/matrix/core/api/util/Cancelable.kt | 5 + .../im/vector/matrix/core/api/util/Logger.kt | 57 ++++++ .../matrix/core/internal/DefaultSession.kt | 37 ++++ .../internal/MatrixCoroutineDispatchers.kt | 9 + .../matrix/core/internal/MatrixModule.kt | 27 +++ .../internal/login/DefaultAuthenticator.kt | 37 ++++ .../matrix/core/internal/login/LoginApi.kt | 24 +++ .../matrix/core/internal/login/LoginModule.kt | 33 ++++ .../core/internal/login/data/LoginFlow.kt | 7 + .../internal/login/data/LoginFlowResponse.kt | 6 + .../internal/login/data/LoginFlowTypes.kt | 12 ++ .../core/internal/login/data/LoginParams.kt | 5 + .../login/data/PasswordLoginParams.kt | 47 +++++ .../login/db/InMemoryCredentialsStore.kt | 26 +++ .../core/internal/network/NetworkConstants.kt | 8 + .../core/internal/network/NetworkModule.kt | 30 +++ .../matrix/core/internal/network/Request.kt | 56 ++++++ .../core/internal/util/CancelableCoroutine.kt | 12 ++ .../matrix/core/internal/util/Either.kt | 35 ++++ matrix-sdk-rx/.gitignore | 1 + matrix-sdk-rx/build.gradle | 8 + .../main/java/im/vector/matrix/rx/MatrixRx.kt | 3 + settings.gradle | 1 + 94 files changed, 1825 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/caches/build_file_checksums.ser create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/dictionaries/ganfra.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 README.md create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/im/vector/riotredesign/ExampleInstrumentedTest.kt create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/im/vector/riotredesign/Riot.kt create mode 100644 app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt create mode 100644 app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt create mode 100644 app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt create mode 100644 app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/layout/activity_home.xml create mode 100644 app/src/main/res/layout/activity_login.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/test/java/im/vector/riotredesign/ExampleUnitTest.kt create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 matrix-sdk-android/.gitignore create mode 100644 matrix-sdk-android/build.gradle create mode 100644 matrix-sdk-android/proguard-rules.pro create mode 100644 matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/ExampleInstrumentedTest.java create mode 100644 matrix-sdk-android/src/main/AndroidManifest.xml create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/thread/MainThreadExecutor.java create mode 100644 matrix-sdk-android/src/main/res/values/strings.xml create mode 100644 matrix-sdk-android/src/test/java/im/vector/matrix/android/ExampleUnitTest.java create mode 100644 matrix-sdk-core/.gitignore create mode 100644 matrix-sdk-core/build.gradle create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Matrix.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixCallback.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixOptions.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Session.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/Event.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/EventType.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/Failure.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/MatrixError.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/Authenticator.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/CredentialsStore.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/Credentials.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/HomeServerConnectionConfig.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQuery.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryBuilder.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryDataObserver.java create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxStore.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Cancelable.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Logger.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/DefaultSession.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixCoroutineDispatchers.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixModule.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/DefaultAuthenticator.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginApi.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginModule.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlow.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowTypes.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginParams.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/PasswordLoginParams.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/db/InMemoryCredentialsStore.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkConstants.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkModule.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/Request.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/CancelableCoroutine.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/Either.kt create mode 100644 matrix-sdk-rx/.gitignore create mode 100644 matrix-sdk-rx/build.gradle create mode 100644 matrix-sdk-rx/src/main/java/im/vector/matrix/rx/MatrixRx.kt create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..5edb4eeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000000000000000000000000000000000000..8636578c627edd805daeb39eb90902b38b1e7553 GIT binary patch literal 708 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}uGBYr_F>vMNC#JY1CYR(Fc`|U8WE7iFWTqCE7BbW^uz}3DBHMGbpJ5Zr%LdLFZ+;RV8>g`Z#FvmoV^Px8%CL^XrdXLaoLt+Gkz)HGg3VgFsGxa$*iBk}*6| zf9=eIDW$e&1Rt(hP-oUyRl*>M$J+wC%L2~7)%; + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/ganfra.xml b/.idea/dictionaries/ganfra.xml new file mode 100644 index 00000000..2c6e3c0c --- /dev/null +++ b/.idea/dictionaries/ganfra.xml @@ -0,0 +1,8 @@ + + + + coroutine + moshi + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 00000000..043ba654 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..2679eba6 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..99202cc2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 00000000..7f68460d --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..e1f84f4f --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# riot-android-redesign-PoC diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 00000000..0e4eafaa --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,37 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "im.vector.riotredesign" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(":matrix-sdk-core") + + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation "org.koin:koin-core:$koin_version" + implementation "org.koin:koin-core-ext:$koin_version" + + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + compile project(path: ':matrix-sdk-android') +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/im/vector/riotredesign/ExampleInstrumentedTest.kt b/app/src/androidTest/java/im/vector/riotredesign/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..b9ed47d0 --- /dev/null +++ b/app/src/androidTest/java/im/vector/riotredesign/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package im.vector.riotredesign + +import android.support.test.InstrumentationRegistry +import android.support.test.runner.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getTargetContext() + assertEquals("im.vector.riotredesign", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..54863ea5 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/Riot.kt b/app/src/main/java/im/vector/riotredesign/Riot.kt new file mode 100644 index 00000000..d916a1d2 --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/Riot.kt @@ -0,0 +1,13 @@ +package im.vector.riotredesign + +import android.app.Application +import org.koin.standalone.StandAloneContext.startKoin + +class Riot : Application() { + + override fun onCreate() { + super.onCreate() + startKoin(emptyList()) + } + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt b/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt new file mode 100644 index 00000000..d6e3ccb2 --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt @@ -0,0 +1,7 @@ +package im.vector.riotredesign.core.platform + +import android.support.v7.app.AppCompatActivity + +open class RiotActivity : AppCompatActivity() { + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt b/app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt new file mode 100644 index 00000000..3a6a5f6c --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt @@ -0,0 +1,6 @@ +package im.vector.riotredesign.core.platform + +import android.support.v4.app.Fragment + +class RiotFragment : Fragment() { +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt new file mode 100644 index 00000000..93953b7f --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt @@ -0,0 +1,25 @@ +package im.vector.riotredesign.features.home + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import im.vector.riotredesign.R +import im.vector.riotredesign.core.platform.RiotActivity + +class HomeActivity : RiotActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_home) + } + + + companion object { + + fun newIntent(context: Context): Intent { + return Intent(context, HomeActivity::class.java) + } + + } + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt new file mode 100644 index 00000000..fb0f658b --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt @@ -0,0 +1,54 @@ +package im.vector.riotredesign.features.login + +import android.os.Bundle +import android.view.View +import android.widget.Toast +import im.vector.matrix.android.thread.MainThreadExecutor +import im.vector.matrix.core.api.Matrix +import im.vector.matrix.core.api.MatrixCallback +import im.vector.matrix.core.api.MatrixOptions +import im.vector.matrix.core.api.failure.Failure +import im.vector.matrix.core.api.login.data.Credentials +import im.vector.matrix.core.api.login.data.HomeServerConnectionConfig +import im.vector.riotredesign.R +import im.vector.riotredesign.core.platform.RiotActivity +import im.vector.riotredesign.features.home.HomeActivity +import kotlinx.android.synthetic.main.activity_login.* + +class LoginActivity : RiotActivity() { + + private val matrixOptions = MatrixOptions(mainExecutor = MainThreadExecutor()) + private val matrix = Matrix(matrixOptions) + private val homeServerConnectionConfig = HomeServerConnectionConfig("https://matrix.org/") + private val session = matrix.createSession(homeServerConnectionConfig) + private val authenticator = session.authenticator() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_login) + authenticateButton.setOnClickListener { authenticate() } + } + + private fun authenticate() { + val login = loginField.text.trim().toString() + val password = passwordField.text.trim().toString() + progressBar.visibility = View.VISIBLE + authenticator.authenticate(login, password, object : MatrixCallback { + override fun onSuccess(data: Credentials?) { + goToHomeScreen() + } + + override fun onFailure(failure: Failure) { + progressBar.visibility = View.GONE + Toast.makeText(this@LoginActivity, "Authenticate failure: $failure", Toast.LENGTH_LONG).show() + } + }) + } + + private fun goToHomeScreen() { + val intent = HomeActivity.newIntent(this) + startActivity(intent) + finish() + } + +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..c7bd21db --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..d5fccc53 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml new file mode 100644 index 00000000..84615cdd --- /dev/null +++ b/app/src/main/res/layout/activity_home.xml @@ -0,0 +1,26 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 00000000..c8984e15 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,66 @@ + + + + + + + + + + +