Commit a4f47d3a authored by Thomas Markiewicz's avatar Thomas Markiewicz
Browse files

Merged Tusky v12.1

parents 060042a0 a79fea86
Pipeline #58992 canceled with stage
...@@ -4,7 +4,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -4,7 +4,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
- Merged upstream Tusky version 11.0 (2020-09-11) ## [1.4.0] - 2020-09-11
- Merged upstream Tusky version 12.1
## [1.3.0] - 2020-02-07 ## [1.3.0] - 2020-02-07
......
...@@ -111,39 +111,40 @@ project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { ...@@ -111,39 +111,40 @@ project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
ext.lifecycleVersion = "2.2.0" ext.lifecycleVersion = "2.2.0"
ext.roomVersion = '2.2.5' ext.roomVersion = '2.2.5'
ext.retrofitVersion = '2.8.1' ext.retrofitVersion = '2.9.0'
ext.okhttpVersion = '4.5.0' ext.okhttpVersion = '4.8.1'
ext.glideVersion = '4.11.0' ext.glideVersion = '4.11.0'
ext.daggerVersion = '2.27' ext.daggerVersion = '2.28.3'
ext.materialdrawerVersion = '8.0.1' ext.materialdrawerVersion = '8.1.4'
// if libraries are changed here, they should also be changed in LicenseActivity // if libraries are changed here, they should also be changed in LicenseActivity
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "androidx.core:core-ktx:1.2.0" implementation "androidx.core:core-ktx:1.3.1"
implementation "androidx.appcompat:appcompat:1.2.0-beta01" implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.fragment:fragment-ktx:1.2.4" implementation "androidx.fragment:fragment-ktx:1.2.5"
implementation "androidx.browser:browser:1.2.0" implementation "androidx.browser:browser:1.2.0"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.1.0" implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.exifinterface:exifinterface:1.2.0" implementation "androidx.exifinterface:exifinterface:1.2.0"
implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.preference:preference:1.1.1" implementation "androidx.preference:preference:1.1.1"
implementation "androidx.sharetarget:sharetarget:1.0.0-rc01" implementation "androidx.sharetarget:sharetarget:1.0.0"
implementation "androidx.emoji:emoji:1.0.0" implementation "androidx.emoji:emoji:1.1.0"
implementation "androidx.emoji:emoji-appcompat:1.0.0" implementation "androidx.emoji:emoji-appcompat:1.1.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycleVersion"
implementation "androidx.constraintlayout:constraintlayout:1.1.3" implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "androidx.paging:paging-runtime-ktx:2.1.2" implementation "androidx.paging:paging-runtime-ktx:2.1.2"
implementation "androidx.viewpager2:viewpager2:1.0.0" implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation "androidx.work:work-runtime:2.4.0"
implementation "androidx.room:room-runtime:$roomVersion" implementation "androidx.room:room-runtime:$roomVersion"
implementation "androidx.room:room-rxjava2:$roomVersion" implementation "androidx.room:room-rxjava2:$roomVersion"
kapt "androidx.room:room-compiler:$roomVersion" kapt "androidx.room:room-compiler:$roomVersion"
implementation "com.google.android.material:material:1.1.0" implementation "com.google.android.material:material:1.2.0"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
...@@ -157,7 +158,7 @@ dependencies { ...@@ -157,7 +158,7 @@ dependencies {
implementation "com.github.bumptech.glide:glide:$glideVersion" implementation "com.github.bumptech.glide:glide:$glideVersion"
implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion" implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion"
implementation "io.reactivex.rxjava2:rxjava:2.2.17" implementation "io.reactivex.rxjava2:rxjava:2.2.19"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1" implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxkotlin:2.4.0" implementation "io.reactivex.rxjava2:rxkotlin:2.4.0"
...@@ -180,13 +181,11 @@ dependencies { ...@@ -180,13 +181,11 @@ dependencies {
implementation "com.theartofdev.edmodo:android-image-cropper:2.8.0" implementation "com.theartofdev.edmodo:android-image-cropper:2.8.0"
implementation "com.evernote:android-job:1.4.2"
implementation "de.c1710:filemojicompat:1.0.17" implementation "de.c1710:filemojicompat:1.0.17"
testImplementation "androidx.test.ext:junit:1.1.1" testImplementation "androidx.test.ext:junit:1.1.1"
testImplementation "org.robolectric:robolectric:4.3.1" testImplementation "org.robolectric:robolectric:4.3.1"
testImplementation "org.mockito:mockito-inline:3.2.4" testImplementation "org.mockito:mockito-inline:3.3.3"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0" androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
# keep setters in Views so that animations can still work. # keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans # see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View { -keepclassmembers public class * extends android.view.View {
void set*(***); void set*(***);
*** get*(); *** get*();
} }
# We want to keep methods in Activity that could be used in the XML attribute onClick # We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity { -keepclassmembers class * extends android.app.Activity {
public void *(android.view.View); public void *(android.view.View);
} }
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * { -keepclassmembers enum * {
...@@ -30,43 +30,19 @@ ...@@ -30,43 +30,19 @@
public static ** valueOf(java.lang.String); public static ** valueOf(java.lang.String);
} }
-keepclassmembers class * implements android.os.Parcelable { -keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR; public static final ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
} }
# TUSKY SPECIFIC OPTIONS # TUSKY SPECIFIC OPTIONS
## for okhttp # keep members of our model classes, they are used in json de/serialization
-dontwarn javax.annotation.** -keepclassmembers class com.keylesspalace.tusky.entity.* { *; }
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.ConscryptPlatform
##for keep
-dontwarn android.arch.util.paging.CountedDataSource
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource
## for retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}
-keep class com.keylesspalace.tusky.entity.** { *; }
-keep public enum com.keylesspalace.tusky.entity.*$** { -keep public enum com.keylesspalace.tusky.entity.*$** {
**[] $VALUES; **[] $VALUES;
public *; public *;
} }
# preserve line numbers for crash reporting # preserve line numbers for crash reporting
-keepattributes SourceFile,LineNumberTable -keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile -renamesourcefileattribute SourceFile
...@@ -87,17 +63,7 @@ ...@@ -87,17 +63,7 @@
static void throwUninitializedPropertyAccessException(java.lang.String); static void throwUninitializedPropertyAccessException(java.lang.String);
} }
-dontwarn com.google.errorprone.annotations.*
# without this emoji font downloading fails with AbstractMethodError # without this emoji font downloading fails with AbstractMethodError
-keep class * extends android.os.AsyncTask { -keep class * extends android.os.AsyncTask {
public *; public *;
} }
# Glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
...@@ -189,6 +189,13 @@ ...@@ -189,6 +189,13 @@
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" /> android:resource="@xml/file_paths" />
</provider> </provider>
<!-- disable automatic WorkManager initialization -->
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:exported="false"
tools:node="remove"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -58,6 +58,7 @@ import com.keylesspalace.tusky.interfaces.LinkListener ...@@ -58,6 +58,7 @@ import com.keylesspalace.tusky.interfaces.LinkListener
import com.keylesspalace.tusky.interfaces.ReselectableFragment import com.keylesspalace.tusky.interfaces.ReselectableFragment
import com.keylesspalace.tusky.pager.AccountPagerAdapter import com.keylesspalace.tusky.pager.AccountPagerAdapter
import com.keylesspalace.tusky.util.* import com.keylesspalace.tusky.util.*
import com.keylesspalace.tusky.view.showMuteAccountDialog
import com.keylesspalace.tusky.viewmodel.AccountViewModel import com.keylesspalace.tusky.viewmodel.AccountViewModel
import dagger.android.DispatchingAndroidInjector import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
...@@ -81,6 +82,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -81,6 +82,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
private var followState: FollowState = FollowState.NOT_FOLLOWING private var followState: FollowState = FollowState.NOT_FOLLOWING
private var blocking: Boolean = false private var blocking: Boolean = false
private var muting: Boolean = false private var muting: Boolean = false
private var blockingDomain: Boolean = false
private var showingReblogs: Boolean = false private var showingReblogs: Boolean = false
private var loadedAccount: Account? = null private var loadedAccount: Account? = null
...@@ -351,8 +353,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -351,8 +353,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
swipeToRefreshLayout.isRefreshing = isRefreshing == true swipeToRefreshLayout.isRefreshing = isRefreshing == true
}) })
swipeToRefreshLayout.setColorSchemeResources(R.color.tusky_blue) swipeToRefreshLayout.setColorSchemeResources(R.color.tusky_blue)
swipeToRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(this,
android.R.attr.colorBackground))
} }
private fun onAccountChanged(account: Account?) { private fun onAccountChanged(account: Account?) {
...@@ -360,9 +360,9 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -360,9 +360,9 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
val usernameFormatted = getString(R.string.status_username_format, account.username) val usernameFormatted = getString(R.string.status_username_format, account.username)
accountUsernameTextView.text = usernameFormatted accountUsernameTextView.text = usernameFormatted
accountDisplayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, accountDisplayNameTextView) accountDisplayNameTextView.text = account.name.emojify(account.emojis, accountDisplayNameTextView)
val emojifiedNote = CustomEmojiHelper.emojifyText(account.note, account.emojis, accountNoteTextView) val emojifiedNote = account.note.emojify(account.emojis, accountNoteTextView)
LinkHelper.setClickableText(accountNoteTextView, emojifiedNote, null, this) LinkHelper.setClickableText(accountNoteTextView, emojifiedNote, null, this)
// accountFieldAdapter.fields = account.fields ?: emptyList() // accountFieldAdapter.fields = account.fields ?: emptyList()
...@@ -381,7 +381,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -381,7 +381,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
invalidateOptionsMenu() invalidateOptionsMenu()
accountMuteButton.setOnClickListener { accountMuteButton.setOnClickListener {
viewModel.changeMuteState() viewModel.unmuteAccount()
updateMuteButton() updateMuteButton()
} }
} }
...@@ -423,7 +423,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -423,7 +423,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
private fun updateToolbar() { private fun updateToolbar() {
loadedAccount?.let { account -> loadedAccount?.let { account ->
val emojifiedName = CustomEmojiHelper.emojifyString(account.name, account.emojis, accountToolbar) val emojifiedName = account.name.emojify(account.emojis, accountToolbar)
try { try {
supportActionBar?.title = EmojiCompat.get().process(emojifiedName) supportActionBar?.title = EmojiCompat.get().process(emojifiedName)
...@@ -528,6 +528,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -528,6 +528,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
} }
blocking = relation.blocking blocking = relation.blocking
muting = relation.muting muting = relation.muting
blockingDomain = relation.blockingDomain
showingReblogs = relation.showingReblogs showingReblogs = relation.showingReblogs
accountFollowsYouTextView.visible(relation.followedBy) accountFollowsYouTextView.visible(relation.followedBy)
...@@ -626,7 +627,11 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -626,7 +627,11 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
// If we can't get the domain, there's no way we can mute it anyway... // If we can't get the domain, there's no way we can mute it anyway...
menu.removeItem(R.id.action_mute_domain) menu.removeItem(R.id.action_mute_domain)
} else { } else {
muteDomain.title = getString(R.string.action_mute_domain, domain) if (blockingDomain) {
muteDomain.title = getString(R.string.action_unmute_domain, domain)
} else {
muteDomain.title = getString(R.string.action_mute_domain, domain)
}
} }
} }
...@@ -671,12 +676,16 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -671,12 +676,16 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
.show() .show()
} }
private fun showMuteDomainWarningDialog(instance: String) { private fun toggleBlockDomain(instance: String) {
AlertDialog.Builder(this) if(blockingDomain) {
.setMessage(getString(R.string.mute_domain_warning, instance)) viewModel.unblockDomain(instance)
.setPositiveButton(getString(R.string.mute_domain_warning_dialog_ok)) { _, _ -> viewModel.muteDomain(instance) } } else {
.setNegativeButton(android.R.string.cancel, null) AlertDialog.Builder(this)
.show() .setMessage(getString(R.string.mute_domain_warning, instance))
.setPositiveButton(getString(R.string.mute_domain_warning_dialog_ok)) { _, _ -> viewModel.blockDomain(instance) }
.setNegativeButton(android.R.string.cancel, null)
.show()
}
} }
private fun toggleBlock() { private fun toggleBlock() {
...@@ -693,13 +702,15 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -693,13 +702,15 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
private fun toggleMute() { private fun toggleMute() {
if (viewModel.relationshipData.value?.data?.muting != true) { if (viewModel.relationshipData.value?.data?.muting != true) {
AlertDialog.Builder(this) loadedAccount?.let {
.setMessage(getString(R.string.dialog_mute_warning, loadedAccount?.username)) showMuteAccountDialog(
.setPositiveButton(android.R.string.ok) { _, _ -> viewModel.changeMuteState() } this,
.setNegativeButton(android.R.string.cancel, null) it.username,
.show() { notifications -> viewModel.muteAccount(notifications) }
)
}
} else { } else {
viewModel.changeMuteState() viewModel.unmuteAccount()
} }
} }
...@@ -757,7 +768,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI ...@@ -757,7 +768,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
return true return true
} }
R.id.action_mute_domain -> { R.id.action_mute_domain -> {
showMuteDomainWarningDialog(domain) toggleBlockDomain(domain)
return true return true
} }
R.id.action_show_reblogs -> { R.id.action_show_reblogs -> {
......
...@@ -209,7 +209,7 @@ class AccountsInListFragment : DialogFragment(), Injectable { ...@@ -209,7 +209,7 @@ class AccountsInListFragment : DialogFragment(), Injectable {
} }
fun bind(account: Account) { fun bind(account: Account) {
displayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, displayNameTextView) displayNameTextView.text = account.name.emojify(account.emojis, displayNameTextView)
usernameTextView.text = account.username usernameTextView.text = account.username
loadAvatar(account.avatar, avatar, radius, animateAvatar) loadAvatar(account.avatar, avatar, radius, animateAvatar)
} }
...@@ -252,7 +252,7 @@ class AccountsInListFragment : DialogFragment(), Injectable { ...@@ -252,7 +252,7 @@ class AccountsInListFragment : DialogFragment(), Injectable {
override val containerView = itemView override val containerView = itemView
fun bind(account: Account, inAList: Boolean) { fun bind(account: Account, inAList: Boolean) {
displayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, displayNameTextView) displayNameTextView.text = account.name.emojify(account.emojis, displayNameTextView)
usernameTextView.text = account.username usernameTextView.text = account.username
loadAvatar(account.avatar, avatar, radius, animateAvatar) loadAvatar(account.avatar, avatar, radius, animateAvatar)
......
...@@ -43,6 +43,18 @@ public class EmojiPreference extends Preference { ...@@ -43,6 +43,18 @@ public class EmojiPreference extends Preference {
private boolean updated, currentNeedsUpdate; private boolean updated, currentNeedsUpdate;
public EmojiPreference(Context context) {
super(context);
// Find out which font is currently active
this.selected = EmojiCompatFont.byId(PreferenceManager
.getDefaultSharedPreferences(context)
.getInt(FONT_PREFERENCE, 0));
// We'll use this later to determine if anything has changed
this.original = this.selected;
setSummary(selected.getDisplay(context));
}
public EmojiPreference(Context context, AttributeSet attrs) { public EmojiPreference(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
......
...@@ -35,6 +35,7 @@ import android.view.View ...@@ -35,6 +35,7 @@ import android.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.content.pm.ShortcutManagerCompat
import androidx.emoji.text.EmojiCompat import androidx.emoji.text.EmojiCompat
...@@ -52,6 +53,7 @@ import com.keylesspalace.tusky.appstore.* ...@@ -52,6 +53,7 @@ import com.keylesspalace.tusky.appstore.*
import com.keylesspalace.tusky.components.compose.ComposeActivity import com.keylesspalace.tusky.components.compose.ComposeActivity
import com.keylesspalace.tusky.components.compose.ComposeActivity.Companion.canHandleMimeType import com.keylesspalace.tusky.components.compose.ComposeActivity.Companion.canHandleMimeType
import com.keylesspalace.tusky.components.conversation.ConversationsRepository import com.keylesspalace.tusky.components.conversation.ConversationsRepository
import com.keylesspalace.tusky.components.notifications.NotificationHelper
import com.keylesspalace.tusky.components.scheduled.ScheduledTootActivity import com.keylesspalace.tusky.components.scheduled.ScheduledTootActivity
import com.keylesspalace.tusky.components.search.SearchActivity import com.keylesspalace.tusky.components.search.SearchActivity
import com.keylesspalace.tusky.db.AccountEntity import com.keylesspalace.tusky.db.AccountEntity
...@@ -61,8 +63,12 @@ import com.keylesspalace.tusky.interfaces.AccountSelectionListener ...@@ -61,8 +63,12 @@ import com.keylesspalace.tusky.interfaces.AccountSelectionListener
import com.keylesspalace.tusky.interfaces.ActionButtonActivity import com.keylesspalace.tusky.interfaces.ActionButtonActivity
import com.keylesspalace.tusky.interfaces.ReselectableFragment import com.keylesspalace.tusky.interfaces.ReselectableFragment
import com.keylesspalace.tusky.pager.MainPagerAdapter import com.keylesspalace.tusky.pager.MainPagerAdapter
import com.keylesspalace.tusky.settings.PrefKeys
import com.keylesspalace.tusky.util.* import com.keylesspalace.tusky.util.*
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import com.mikepenz.iconics.utils.colorInt
import com.mikepenz.iconics.utils.sizeDp
import com.mikepenz.materialdrawer.iconics.iconicsIcon import com.mikepenz.materialdrawer.iconics.iconicsIcon
import com.mikepenz.materialdrawer.model.* import com.mikepenz.materialdrawer.model.*
import com.mikepenz.materialdrawer.model.interfaces.* import com.mikepenz.materialdrawer.model.interfaces.*
...@@ -92,8 +98,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje ...@@ -92,8 +98,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
private lateinit var drawerToggle: ActionBarDrawerToggle private lateinit var drawerToggle: ActionBarDrawerToggle
private var notificationTabPosition = 0 private var notificationTabPosition = 0
private var onTabSelectedListener: OnTabSelectedListener? = null
private var adapter: MainPagerAdapter? = null private val preferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
private val emojiInitCallback = object : InitCallback() { private val emojiInitCallback = object : InitCallback() {
override fun onInitialized() { override fun onInitialized() {
...@@ -162,7 +169,23 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje ...@@ -162,7 +169,23 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
val composeIntent = Intent(applicationContext, ComposeActivity::class.java) val composeIntent = Intent(applicationContext, ComposeActivity::class.java)
startActivity(composeIntent) startActivity(composeIntent)
} }
setupDrawer(savedInstanceState)
val hideTopToolbar = preferences.getBoolean(PrefKeys.HIDE_TOP_TOOLBAR, false)
mainToolbar.visible(!hideTopToolbar)
mainToolbar.menu.add(R.string.action_search).apply {
setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
icon = IconicsDrawable(this@MainActivity, GoogleMaterial.Icon.gmd_search).apply {
sizeDp = 20
colorInt = ThemeUtils.getColor(this@MainActivity, android.R.attr.textColorPrimary)
}
setOnMenuItemClickListener {
startActivity(SearchActivity.getIntent(this@MainActivity))
true
}
}
setupDrawer(savedInstanceState, addSearchButton = hideTopToolbar)
/* Fetch user info while we're doing other things. This has to be done after setting up the /* Fetch user info while we're doing other things. This has to be done after setting up the
* drawer, though, because its callback touches the header in the drawer. */ * drawer, though, because its callback touches the header in the drawer. */
...@@ -170,35 +193,11 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje ...@@ -170,35 +193,11 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje