Skip to content
Snippets Groups Projects
Commit 4a3c8623 authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Cleaned up username registration logic, added :data:network module

parent 62c4cdd2
No related branches found
No related tags found
No related merge requests found
Showing
with 292 additions and 24 deletions
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<data> <data>
<variable <variable
name="ui" name="ui"
type="io.xxlabs.messenger.ui.intro.registration.username.UsernameRegistrationUI" /> type="io.elixxir.feature.registration.registration.username.UsernameRegistrationUI" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout style="@style/registration_flow_root_view"> <androidx.constraintlayout.widget.ConstraintLayout style="@style/registration_flow_root_view">
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<fragment <fragment
android:id="@+id/registrationUsernameFragment" android:id="@+id/registrationUsernameFragment"
android:name="io.xxlabs.messenger.ui.intro.registration.username.RegistrationUsernameFragment" android:name="io.elixxir.feature.registration.registration.username.RegistrationUsernameFragment"
android:label="Username Registration" android:label="Username Registration"
tools:layout="@layout/fragment_registration_username"> tools:layout="@layout/fragment_registration_username">
<action <action
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<fragment <fragment
android:id="@+id/registrationWelcomeFragment" android:id="@+id/registrationWelcomeFragment"
android:name="io.xxlabs.messenger.ui.intro.registration.welcome.RegistrationWelcomeFragment" android:name="io.elixxir.feature.registration.registration.welcome.RegistrationWelcomeFragment"
android:label="RegistrationWelcomeFragment" android:label="RegistrationWelcomeFragment"
tools:layout="@layout/fragment_registration_welcome"> tools:layout="@layout/fragment_registration_welcome">
<action <action
......
...@@ -58,7 +58,7 @@ object Libs { ...@@ -58,7 +58,7 @@ object Libs {
} }
object DI { object DI {
const val HILT_VERSION = "2.38.1" const val HILT_VERSION = "2.43.2"
const val HILT = "com.google.dagger:hilt-android" const val HILT = "com.google.dagger:hilt-android"
const val HILT_KAPT = "com.google.dagger:hilt-android-compiler:$HILT_VERSION" const val HILT_KAPT = "com.google.dagger:hilt-android-compiler:$HILT_VERSION"
} }
......
package io.elixxir.core.ui.dialog.info
import android.content.DialogInterface
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.method.LinkMovementMethod
import android.text.style.ForegroundColorSpan
import android.text.style.URLSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import io.elixxir.core.ui.R
import io.elixxir.core.ui.databinding.ComponentInfoDialogBinding
import io.elixxir.core.ui.dialog.XxBottomSheetDialog
class InfoDialog : XxBottomSheetDialog() {
private lateinit var binding: ComponentInfoDialogBinding
private val dialogUI: InfoDialogUi by lazy {
requireArguments().getSerializable(ARG_UI) as InfoDialogUi
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = DataBindingUtil.inflate(
inflater,
R.layout.component_info_dialog,
container,
false
)
dialogUI.spans?.let {
binding.infoDialogBody.text = getSpannableBody(dialogUI)
binding.infoDialogBody.movementMethod = LinkMovementMethod.getInstance()
} ?: run {
binding.infoDialogBody.text= dialogUI.body
}
binding.ui = dialogUI
binding.infoDialogButton.setOnClickListener { dismiss() }
return binding.root
}
private fun getSpannableBody(dialogUI: InfoDialogUi): Spannable {
val builder = SpannableStringBuilder(dialogUI.body)
dialogUI.spans?.forEach {
val highlight = requireContext().getColor(it.color)
val text = it.text
val startIndex = dialogUI.body.indexOf(text, ignoreCase = true)
val endIndex = startIndex + text.length
builder.apply {
it.url?.let { link ->
setSpan(
URLSpan(link),
startIndex,
endIndex,
Spannable.SPAN_INCLUSIVE_INCLUSIVE
)
}
setSpan(
ForegroundColorSpan(highlight),
startIndex,
endIndex,
Spannable.SPAN_INCLUSIVE_INCLUSIVE
)
}
}
return builder
}
override fun onDismiss(dialog: DialogInterface) {
dialogUI.onDismissed?.invoke()
super.onDismiss(dialog)
}
companion object Factory {
private const val ARG_UI: String = "ui"
fun newInstance(dialogUI: InfoDialogUI): InfoDialog =
InfoDialog().apply {
arguments = Bundle().apply {
putSerializable(ARG_UI, dialogUI)
}
}
}
}
\ No newline at end of file
...@@ -30,18 +30,18 @@ interface InfoDialogUi : Serializable { ...@@ -30,18 +30,18 @@ interface InfoDialogUi : Serializable {
interface SpanConfig : Serializable { interface SpanConfig : Serializable {
val text: UiText val text: UiText
val color: Int val color: Int
val url: String? val url: UiText?
companion object Factory { companion object Factory {
fun create( fun create(
text: UiText, text: UiText,
url: String?, url: UiText?,
color: Int = R.color.brand_default color: Int = R.color.brand_default
): SpanConfig { ): SpanConfig {
return object : SpanConfig { return object : SpanConfig {
override val text: UiText = text override val text: UiText = text
override val color = color override val color = color
override val url: String? = url override val url: UiText? = url
} }
} }
} }
......
core/ui/src/main/res/drawable/ic_powered_by_xx_network.png

5.72 KiB

core/ui/src/main/res/drawable/xxm_logotype_white.png

3.48 KiB

<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="ui"
type="io.elixxir.core.ui.dialog.info.InfoDialogUi" />
</data>
<androidx.cardview.widget.CardView
android:id="@+id/infoDialogRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/bottom_sheet_dialog_corner_radius">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/info_dialog_title"
android:text="@{ui.title}"
android:layout_marginBottom="@dimen/registration_body_vertical_margin"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/info_dialog_body"
style="@style/SubtitleText"
tools:text="@string/registration_username_info_title"/>
<TextView
android:id="@+id/info_dialog_body"
android:layout_marginBottom="@dimen/registration_body_vertical_margin"
app:layout_constraintTop_toBottomOf="@id/info_dialog_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/info_dialog_button"
tools:text="@string/registration_username_info_body"
style="@style/BodyText" />
<io.elixxir.core.ui.view.SingleClickButton
android:id="@+id/info_dialog_button"
android:text="@string/registration_flow_ok"
android:layout_marginTop="@dimen/registration_body_vertical_margin"
app:layout_constraintTop_toBottomOf="@id/info_dialog_body"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
style="@style/OutlinedButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</layout>
\ No newline at end of file
...@@ -93,4 +93,17 @@ ...@@ -93,4 +93,17 @@
<item name="android:textColor">@color/neutral_off_white</item> <item name="android:textColor">@color/neutral_off_white</item>
<item name="android:gravity">center</item> <item name="android:gravity">center</item>
</style> </style>
<!-- Was: registration_step_next_button -->
<style name="ButtonFilled" parent="AppFont">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">@dimen/registration_button_height</item>
<item name="android:layout_marginStart">@dimen/registration_horizontal_margin</item>
<item name="android:layout_marginEnd">@dimen/registration_horizontal_margin</item>
<item name="android:layout_marginBottom">@dimen/registration_body_vertical_margin</item>
<item name="android:textColor">@color/neutral_off_white</item>
<item name="android:background">@drawable/bg_rectangle_rounded_corners_big_radius</item>
<item name="android:backgroundTint">@color/selector_btn_default</item>
<item name="android:textAllCaps">false</item>
</style>
</resources> </resources>
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
android {
compileSdk = 32
defaultConfig {
minSdk = 21
targetSdk = 32
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("com.google.android.material:material:1.6.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
}
\ No newline at end of file
# 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
\ No newline at end of file
package io.elixxir.data.networking
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
assertEquals("io.elixxir.data.networking.test", appContext.packageName)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.elixxir.data.networking">
</manifest>
\ No newline at end of file
package io.elixxir.data.networking
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
\ No newline at end of file
...@@ -48,8 +48,6 @@ dependencies { ...@@ -48,8 +48,6 @@ dependencies {
implementation(Libs.Core.CORE_KTX) implementation(Libs.Core.CORE_KTX)
implementation(Libs.Core.CORE_COROUTINES) implementation(Libs.Core.CORE_COROUTINES)
implementation(Libs.DI.HILT)
implementation(Libs.DI.HILT) implementation(Libs.DI.HILT)
kapt(Libs.DI.HILT_KAPT) kapt(Libs.DI.HILT_KAPT)
} }
\ No newline at end of file
package io.elixxir.data.session.di package io.elixxir.data.session
import dagger.Binds
import dagger.Module import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent import dagger.hilt.android.components.ViewModelComponent
import io.elixxir.data.session.SessionRepository
import io.elixxir.data.session.data.SessionDataSource import io.elixxir.data.session.data.SessionDataSource
@Module @Module
@InstallIn(ViewModelComponent::class) @InstallIn(ViewModelComponent::class)
interface SessionModule { interface SessionModule {
@Provides @Binds
fun provideSessionRepository(): SessionRepository { fun bindSessionRepository(
return SessionDataSource() repo: SessionDataSource
} ): SessionRepository
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ package io.elixxir.data.session.data ...@@ -2,8 +2,9 @@ package io.elixxir.data.session.data
import io.elixxir.data.session.SessionRepository import io.elixxir.data.session.SessionRepository
import io.elixxir.data.session.model.SessionState import io.elixxir.data.session.model.SessionState
import javax.inject.Inject
internal class SessionDataSource : SessionRepository { class SessionDataSource @Inject internal constructor() : SessionRepository {
override fun getSessionState(): SessionState { override fun getSessionState(): SessionState {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
......
package io.elixxir.data.version.di package io.elixxir.data.version
import dagger.Binds
import dagger.Module import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent import dagger.hilt.android.components.ViewModelComponent
import io.elixxir.data.version.VersionRepository
import io.elixxir.data.version.data.VersionDataSource import io.elixxir.data.version.data.VersionDataSource
@Module @Module
@InstallIn(ViewModelComponent::class) @InstallIn(ViewModelComponent::class)
interface VersionModule { interface VersionModule {
@Provides @Binds
fun provideVersionRepository(): VersionRepository { fun bindVersionRepository(
return VersionDataSource() repo: VersionDataSource
} ): VersionRepository
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment