commit b406e8301ae2a431245a3f91bbc7937ba3270091 Author: ganfra Date: Wed Oct 3 17:56:33 2018 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..5edb4eeb07 --- /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 0000000000..8636578c62 Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000..30aa626c23 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/ganfra.xml b/.idea/dictionaries/ganfra.xml new file mode 100644 index 0000000000..2c6e3c0cba --- /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 0000000000..043ba65437 --- /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 0000000000..2679eba654 --- /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 0000000000..99202cc2d6 --- /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 0000000000..7f68460d8b --- /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 0000000000..e1f84f4f5d --- /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 0000000000..796b96d1c4 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000000..0e4eafaa06 --- /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 0000000000..f1b424510d --- /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 0000000000..b9ed47d06e --- /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 0000000000..54863ea504 --- /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 0000000000..d916a1d2b5 --- /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 0000000000..d6e3ccb200 --- /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 0000000000..3a6a5f6caa --- /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 0000000000..93953b7fd7 --- /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 0000000000..fb0f658bb1 --- /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 0000000000..c7bd21dbd8 --- /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 0000000000..d5fccc538c --- /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 0000000000..84615cdd2f --- /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 0000000000..c8984e1579 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,66 @@ + + + + + + + + + + +