Account activity redesign (#662)

* Refactor-all-the-things version of the fix for issue #573

* Migrate SpanUtils to kotlin because why not

* Minimal fix for issue #573

* Add tests for compose spanning

* Clean up code suggestions

* Make FakeSpannable.getSpans implementation less awkward

* Add secondary validation pass for urls

* Address code review feedback

* Fixup type filtering in FakeSpannable again

* Make all mentions in compose activity use the default link color

* new layout for AccountActivity

* fix the light theme

* convert AccountActivity to Kotlin

* introduce AccountViewModel

* Merge branch 'master' into account-activity-redesign

# Conflicts:
#	app/src/main/java/com/keylesspalace/tusky/AccountActivity.java

* add Bot badge to profile

* parse custom emojis in usernames

* add possibility to cancel follow request

* add third tab on profiles

* add account fields to profile

* add support for moved accounts

* set click listener on account moved view

* fix tests

* use 24dp as statusbar size

* add ability to hide reblogs from followed accounts

* add button to edit own account to AccountActivity

* set toolbar top margin programmatically

* fix crash

* add shadow behind statusbar

* introduce ViewExtensions to clean up code

* move code out of offsetChangedListener for perf reasons

* clean up stuff

* add error handling

* improve type safety

* fix ConstraintLayout warning

* remove unneeded ressources

* fix event dispatching

* fix crash in event handling

* set correct emoji on title

* improve some things

* wrap follower/foillowing/status views
This commit is contained in:
Konrad Pozniak 2018-06-18 13:26:18 +02:00 committed by GitHub
commit 63f9d99390
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 1422 additions and 978 deletions

View file

@ -33,7 +33,8 @@ import javax.inject.Singleton
AndroidInjectionModule::class,
ActivitiesModule::class,
ServicesModule::class,
BroadcastReceiverModule::class
BroadcastReceiverModule::class,
ViewModelModule::class
])
interface AppComponent {
@Component.Builder

View file

@ -75,7 +75,7 @@ class NetworkModule {
.apply {
addInterceptor(InstanceSwitchAuthInterceptor(accountManager))
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))
addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
}
}
.build()

View file

@ -0,0 +1,40 @@
// from https://proandroiddev.com/viewmodel-with-dagger2-architecture-components-2e06f06c9455
package com.keylesspalace.tusky.di
import android.arch.lifecycle.ViewModel
import android.arch.lifecycle.ViewModelProvider
import com.keylesspalace.tusky.viewmodel.AccountViewModel
import dagger.Binds
import dagger.MapKey
import dagger.Module
import dagger.multibindings.IntoMap
import javax.inject.Inject
import javax.inject.Provider
import javax.inject.Singleton
import kotlin.reflect.KClass
@Singleton
class ViewModelFactory @Inject constructor(private val viewModels: MutableMap<Class<out ViewModel>, Provider<ViewModel>>) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T = viewModels[modelClass]?.get() as T
}
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
@MapKey
internal annotation class ViewModelKey(val value: KClass<out ViewModel>)
@Module
abstract class ViewModelModule {
@Binds
internal abstract fun bindViewModelFactory(factory: ViewModelFactory): ViewModelProvider.Factory
@Binds
@IntoMap
@ViewModelKey(AccountViewModel::class)
internal abstract fun accountViewModel(viewModel: AccountViewModel): ViewModel
//Add more ViewModels here
}