Skip to content
Snippets Groups Projects
Commit 460605f8 authored by John's avatar John
Browse files

Migration for users that are missing username or email

parent 7cdbf7d4
No related branches found
No related tags found
No related merge requests found
Change Log
==========
 
Version 2.6.1
----------------------------
- Fix crash with accounts not having username/email saved
- Parse links that are leading to a project
Version 2.6.0
----------------------------
 
Loading
Loading
Loading
Loading
@@ -38,8 +38,8 @@ android {
minSdkVersion 16
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 2060000
versionName "2.6.0"
versionCode 2060100
versionName "2.6.1"
manifestPlaceholders = [fabric_key: project.ext.LABCOAT_FABRIC_KEY]
vectorDrawables.useSupportLibrary = true
 
Loading
Loading
Loading
Loading
@@ -7,6 +7,7 @@ import android.content.Context
*/
object FabricUtil {
 
@Suppress("UNUSED_PARAMETER")
fun init(context: Context) {
//do nothing
}
Loading
Loading
Loading
Loading
@@ -7,13 +7,17 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.ViewGroup
import androidx.core.widget.toast
import butterknife.BindView
import butterknife.ButterKnife
import com.commit451.gitlab.R
import com.commit451.gitlab.data.Prefs
import com.commit451.gitlab.extension.with
import com.commit451.gitlab.migration.Migration261
import com.commit451.gitlab.model.Account
import com.commit451.gitlab.navigation.Navigator
import com.commit451.gitlab.ssl.CustomKeyManager
import timber.log.Timber
 
/**
* This activity acts as switching platform for the application directing the user to the appropriate
Loading
Loading
@@ -59,7 +63,7 @@ class LaunchActivity : BaseActivity() {
}
 
@TargetApi(21)
fun showKeyguard() {
private fun showKeyguard() {
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
val intent = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.device_auth_title), getString(R.string.device_auth_message))
if (intent == null) {
Loading
Loading
@@ -70,7 +74,20 @@ class LaunchActivity : BaseActivity() {
}
 
private fun moveAlong() {
Navigator.navigateToStartingActivity(this)
finish()
if (account.username == null || account.email == null) {
Migration261.run()
.with(this)
.subscribe({
Navigator.navigateToStartingActivity(this)
finish()
}, {
Timber.e(it)
toast("Unable to migrate. Unfortunately, you probably need to re-install the app")
finish()
})
} else {
Navigator.navigateToStartingActivity(this)
finish()
}
}
}
Loading
Loading
@@ -26,7 +26,7 @@ object GitLabFactory {
*/
fun create(account: Account, client: OkHttpClient): GitLabService {
val retrofitBuilder = Retrofit.Builder()
.baseUrl(account.serverUrl.toString())
.baseUrl("${account.serverUrl.toString()}${GitLabService.API_VERSION}/")
.client(client)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(ScalarsConverterFactory.create())
Loading
Loading
package com.commit451.gitlab.migration
import com.commit451.gitlab.App
import com.commit451.gitlab.data.Prefs
import io.reactivex.Completable
import java.util.*
/**
* We started saving username and email to the user account in a certain update
* so that we could more easily fetch projects, but we did not account for the
* fact that users that were already signed in would not have these values stored.
* This makes sure that we add these values if they do not exist.
*/
object Migration261 {
fun run(): Completable {
return Completable.defer {
val user = App.get().gitLab.getThisUser()
.blockingGet()
.body()!!
val currentAccount = App.get().currentAccount
currentAccount.lastUsed = Date()
currentAccount.email = user.email
currentAccount.username = user.username
Prefs.updateAccount(currentAccount)
Completable.complete()
}
}
}
\ No newline at end of file
apply plugin: 'com.github.ben-manes.versions'
buildscript {
ext.kotlinVersion = '1.2.41'
ext.kotlinVersion = '1.2.50'
repositories {
google()
jcenter()
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment