|
|
|
@ -126,7 +126,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
|
if (accountManager.activeAccount == null) { |
|
|
|
|
|
|
|
|
|
val activeAccount = accountManager.activeAccount |
|
|
|
|
if (activeAccount == null) { |
|
|
|
|
// will be redirected to LoginActivity by BaseActivity |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
@ -191,8 +193,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
val hideTopToolbar = preferences.getBoolean(PrefKeys.HIDE_TOP_TOOLBAR, false) |
|
|
|
|
mainToolbar.visible(!hideTopToolbar) |
|
|
|
|
|
|
|
|
|
val navIconSize = resources.getDimensionPixelSize(R.dimen.avatar_toolbar_nav_icon_size) |
|
|
|
|
mainToolbar.navigationIcon = FixedSizeDrawable(getDrawable(R.drawable.avatar_default), navIconSize, navIconSize) |
|
|
|
|
loadDrawerAvatar(activeAccount.profilePictureUrl, true) |
|
|
|
|
|
|
|
|
|
mainToolbar.menu.add(R.string.action_search).apply { |
|
|
|
|
setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM) |
|
|
|
@ -661,23 +662,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
.load(me.header) |
|
|
|
|
.into(header.accountHeaderBackground) |
|
|
|
|
|
|
|
|
|
val navIconSize = resources.getDimensionPixelSize(R.dimen.avatar_toolbar_nav_icon_size) |
|
|
|
|
|
|
|
|
|
glide.asDrawable() |
|
|
|
|
.override(navIconSize) |
|
|
|
|
.load(me.avatar) |
|
|
|
|
.transform( |
|
|
|
|
RoundedCorners(resources.getDimensionPixelSize(R.dimen.avatar_radius_36dp)) |
|
|
|
|
) |
|
|
|
|
.into(object : CustomTarget<Drawable>() { |
|
|
|
|
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) { |
|
|
|
|
mainToolbar.navigationIcon = resource |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onLoadCleared(placeholder: Drawable?) { |
|
|
|
|
mainToolbar.navigationIcon = placeholder |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
loadDrawerAvatar(me.avatar, false) |
|
|
|
|
|
|
|
|
|
accountManager.updateActiveAccount(me) |
|
|
|
|
NotificationHelper.createNotificationChannelsForAccount(accountManager.activeAccount!!, this) |
|
|
|
@ -704,6 +689,36 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje |
|
|
|
|
updateShortcut(this, accountManager.activeAccount!!) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun loadDrawerAvatar(avatarUrl: String, showPlaceholder: Boolean) { |
|
|
|
|
val navIconSize = resources.getDimensionPixelSize(R.dimen.avatar_toolbar_nav_icon_size) |
|
|
|
|
|
|
|
|
|
glide.asDrawable() |
|
|
|
|
.load(avatarUrl) |
|
|
|
|
.transform( |
|
|
|
|
RoundedCorners(resources.getDimensionPixelSize(R.dimen.avatar_radius_36dp)) |
|
|
|
|
) |
|
|
|
|
.apply { |
|
|
|
|
if (showPlaceholder) { |
|
|
|
|
placeholder(R.drawable.avatar_default) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.into(object : CustomTarget<Drawable>(navIconSize, navIconSize) { |
|
|
|
|
|
|
|
|
|
override fun onLoadStarted(placeholder: Drawable?) { |
|
|
|
|
if(placeholder != null) { |
|
|
|
|
mainToolbar.navigationIcon = FixedSizeDrawable(placeholder, navIconSize, navIconSize) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) { |
|
|
|
|
mainToolbar.navigationIcon = resource |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onLoadCleared(placeholder: Drawable?) { |
|
|
|
|
mainToolbar.navigationIcon = placeholder |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun fetchAnnouncements() { |
|
|
|
|
mastodonApi.listAnnouncements(false) |
|
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
|
|