-
Notifications
You must be signed in to change notification settings - Fork 870
FTUE - Homeserver sign in/up deeplinks #6036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
690fda1
b8418f9
59afb5c
100aa24
ea7df9b
797e0ee
75d038b
73c9395
f6190b1
86c9e60
096db6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| FTUE - Adds homeserver login/register deeplink support |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,13 @@ | |
|
|
||
| package im.vector.app.core.extensions | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import android.content.Context | ||
| import android.graphics.drawable.Drawable | ||
| import android.net.ConnectivityManager | ||
| import android.net.NetworkCapabilities | ||
| import android.net.Uri | ||
| import android.os.Build | ||
| import android.text.Spannable | ||
| import android.text.SpannableString | ||
| import android.text.style.ImageSpan | ||
|
|
@@ -27,11 +31,13 @@ import androidx.annotation.ColorRes | |
| import androidx.annotation.DrawableRes | ||
| import androidx.annotation.FloatRange | ||
| import androidx.core.content.ContextCompat | ||
| import androidx.core.content.getSystemService | ||
| import androidx.datastore.core.DataStore | ||
| import androidx.datastore.preferences.core.Preferences | ||
| import dagger.hilt.EntryPoints | ||
| import im.vector.app.core.datastore.dataStoreProvider | ||
| import im.vector.app.core.di.SingletonEntryPoint | ||
| import im.vector.app.core.resources.BuildMeta | ||
| import java.io.OutputStream | ||
| import kotlin.math.roundToInt | ||
|
|
||
|
|
@@ -77,3 +83,31 @@ val Context.dataStoreProvider: (String) -> DataStore<Preferences> by dataStorePr | |
| fun Context.safeOpenOutputStream(uri: Uri): OutputStream? { | ||
| return contentResolver.openOutputStream(uri, "wt") | ||
| } | ||
|
|
||
| /** | ||
| * Checks for an active connection to infer if the device is offline. | ||
| * This is useful for breaking down UnknownHost exceptions and should not be used to determine if a valid connection is present | ||
| * | ||
| * @return true if no active connection is found | ||
| */ | ||
| @Suppress("deprecation") | ||
| @SuppressLint("NewApi") // false positive | ||
| fun Context.inferNoConnectivity(buildMeta: BuildMeta): Boolean { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a description about
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will add some java doc 👍 |
||
| val connectivityManager = getSystemService<ConnectivityManager>()!! | ||
| return if (buildMeta.sdkInt > Build.VERSION_CODES.M) { | ||
| val networkCapabilities = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) | ||
| when { | ||
| networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true -> false | ||
| networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true -> false | ||
| networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_VPN) == true -> false | ||
| else -> true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be a silly question/use case but should we check the internet connection over
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch! I will double check if |
||
| } | ||
| } else { | ||
| when (connectivityManager.activeNetworkInfo?.type) { | ||
| ConnectivityManager.TYPE_WIFI -> false | ||
| ConnectivityManager.TYPE_MOBILE -> false | ||
| ConnectivityManager.TYPE_VPN -> false | ||
| else -> true | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Copyright (c) 2022 New Vector Ltd | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package im.vector.app.core.resources | ||
|
|
||
| import android.os.Build | ||
|
|
||
| data class BuildMeta( | ||
| val sdkInt: Int = Build.VERSION.SDK_INT | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,12 @@ import org.matrix.android.sdk.api.auth.data.Credentials | |
| import org.matrix.android.sdk.api.network.ssl.Fingerprint | ||
|
|
||
| sealed interface OnboardingAction : VectorViewModelAction { | ||
| data class OnGetStarted(val resetLoginConfig: Boolean, val onboardingFlow: OnboardingFlow) : OnboardingAction | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| data class OnIAlreadyHaveAnAccount(val resetLoginConfig: Boolean, val onboardingFlow: OnboardingFlow) : OnboardingAction | ||
| sealed interface SplashAction : OnboardingAction { | ||
| val onboardingFlow: OnboardingFlow | ||
|
|
||
| data class OnGetStarted(override val onboardingFlow: OnboardingFlow) : SplashAction | ||
| data class OnIAlreadyHaveAnAccount(override val onboardingFlow: OnboardingFlow) : SplashAction | ||
| } | ||
|
|
||
| data class UpdateServerType(val serverType: ServerType) : OnboardingAction | ||
|
|
||
|
|
@@ -58,7 +62,7 @@ sealed interface OnboardingAction : VectorViewModelAction { | |
|
|
||
| // Reset actions | ||
| sealed interface ResetAction : OnboardingAction | ||
|
|
||
| object ResetDeeplinkConfig : ResetAction | ||
| object ResetHomeServerType : ResetAction | ||
| object ResetHomeServerUrl : ResetAction | ||
| object ResetSignMode : ResetAction | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduces a build meta abstraction to allow for providing Build version overrides for unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome idea!