1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-02-07 23:38:40 +01:00

fixed toolbar background in transparent theme

improved user profile shortcuts
This commit is contained in:
Mariotaku Lee 2017-09-01 00:58:23 +08:00
parent 20d014e370
commit aeeb1a0e75
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
12 changed files with 149 additions and 83 deletions

View File

@ -14,7 +14,7 @@ buildscript {
allprojects { allprojects {
ext{ ext {
projectGroupId = 'org.mariotaku.twidere' projectGroupId = 'org.mariotaku.twidere'
projectVersionCode = 385 projectVersionCode = 385
projectVersionName = '3.6.25' projectVersionName = '3.6.25'
@ -23,8 +23,8 @@ allprojects {
repositories { repositories {
mavenLocal() mavenLocal()
jcenter() jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' } maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
} }
} }
@ -32,7 +32,7 @@ allprojects {
subprojects { subprojects {
buildscript { buildscript {
ext { ext {
kotlinVersion = '1.1.4-2' kotlinVersion = '1.1.4-3'
pluginVersions = [ pluginVersions = [
AndroidSvgDrawable: '3.0.0', AndroidSvgDrawable: '3.0.0',
Fabric : '1.22.1', Fabric : '1.22.1',
@ -40,7 +40,7 @@ subprojects {
PlayServices : '3.1.0', PlayServices : '3.1.0',
] ]
libVersions = [ libVersions = [
Kotlin : '1.1.4-2', Kotlin : "${kotlinVersion}",
SupportLib : '26.0.1', SupportLib : '26.0.1',
SupportTest : '1.0.0', SupportTest : '1.0.0',
MariotakuCommons : '0.9.17', MariotakuCommons : '0.9.17',
@ -68,7 +68,7 @@ subprojects {
KPreferences : '0.9.7', KPreferences : '0.9.7',
Kovenant : '3.3.0', Kovenant : '3.3.0',
ParcelablePlease : '1.0.2', ParcelablePlease : '1.0.2',
Chameleon : '0.9.18', Chameleon : '0.9.19-SNAPSHOT',
UniqR : '0.9.4', UniqR : '0.9.4',
SQLiteQB : '0.9.15', SQLiteQB : '0.9.15',
Glide : '3.7.0', Glide : '3.7.0',

View File

@ -47,19 +47,23 @@ fun Menu.setItemChecked(id: Int, checked: Boolean) {
findItem(id)?.isChecked = checked findItem(id)?.isChecked = checked
} }
fun Menu.setMenuItemIcon(id: Int, icon: Int) { fun Menu.setItemIcon(id: Int, icon: Int) {
findItem(id)?.setIcon(icon) findItem(id)?.setIcon(icon)
} }
fun Menu.setMenuItemIcon(id: Int, icon: Drawable) { fun Menu.setItemIcon(id: Int, icon: Drawable) {
findItem(id)?.icon = icon findItem(id)?.icon = icon
} }
fun Menu.setMenuItemTitle(id: Int, title: Int) { fun Menu.setItemTitle(id: Int, title: Int) {
findItem(id)?.setTitle(title) findItem(id)?.setTitle(title)
} }
fun Menu.setMenuItemShowAsActionFlags(id: Int, flags: Int) { fun Menu.setItemTitle(id: Int, title: CharSequence?) {
findItem(id)?.title = title
}
fun Menu.setItemShowAsActionFlags(id: Int, flags: Int) {
val item = findItem(id) ?: return val item = findItem(id) ?: return
item.setShowAsActionFlags(flags) item.setShowAsActionFlags(flags)
} }

View File

@ -115,6 +115,7 @@ import javax.inject.Inject
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import android.Manifest.permission as AndroidPermission import android.Manifest.permission as AndroidPermission
@SuppressLint("RestrictedApi")
class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener, OnLongClickListener, class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener, OnLongClickListener,
ActionMode.Callback, PermissionRequestCancelCallback, EditAltTextDialogFragment.EditAltTextCallback { ActionMode.Callback, PermissionRequestCancelCallback, EditAltTextDialogFragment.EditAltTextCallback {
@ -128,6 +129,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
private lateinit var itemTouchHelper: ItemTouchHelper private lateinit var itemTouchHelper: ItemTouchHelper
private lateinit var bottomMenuAnimator: ViewAnimator private lateinit var bottomMenuAnimator: ViewAnimator
private val supportMenuInflater by lazy { SupportMenuInflater(this) } private val supportMenuInflater by lazy { SupportMenuInflater(this) }
private val backTimeoutRunnable = Runnable { navigateBackPressed = false } private val backTimeoutRunnable = Runnable { navigateBackPressed = false }
@ -172,7 +174,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
// Listeners // Listeners
private var locationListener: LocationListener? = null private var locationListener: LocationListener? = null
private val draftAction: String get() = draft?.action_type ?: when (intent.action) { private val draftAction: String
get() = draft?.action_type ?: when (intent.action) {
INTENT_ACTION_REPLY -> Draft.Action.REPLY INTENT_ACTION_REPLY -> Draft.Action.REPLY
INTENT_ACTION_QUOTE -> Draft.Action.QUOTE INTENT_ACTION_QUOTE -> Draft.Action.QUOTE
else -> Draft.Action.UPDATE_STATUS else -> Draft.Action.UPDATE_STATUS
@ -1317,39 +1320,39 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
if (!attachLocation) { if (!attachLocation) {
menu.setItemChecked(R.id.location_off, true) menu.setItemChecked(R.id.location_off, true)
menu.setMenuItemIcon(R.id.location_submenu, R.drawable.ic_action_location_off) menu.setItemIcon(R.id.location_submenu, R.drawable.ic_action_location_off)
} else if (attachPreciseLocation) { } else if (attachPreciseLocation) {
menu.setItemChecked(R.id.location_precise, true) menu.setItemChecked(R.id.location_precise, true)
menu.setMenuItemIcon(R.id.location_submenu, R.drawable.ic_action_location) menu.setItemIcon(R.id.location_submenu, R.drawable.ic_action_location)
} else { } else {
menu.setItemChecked(R.id.location_coarse, true) menu.setItemChecked(R.id.location_coarse, true)
menu.setMenuItemIcon(R.id.location_submenu, R.drawable.ic_action_location) menu.setItemIcon(R.id.location_submenu, R.drawable.ic_action_location)
} }
when (statusVisibility) { when (statusVisibility) {
StatusVisibility.UNLISTED -> { StatusVisibility.UNLISTED -> {
menu.setItemChecked(R.id.visibility_unlisted, true) menu.setItemChecked(R.id.visibility_unlisted, true)
menu.setMenuItemIcon(R.id.visibility_submenu, R.drawable.ic_action_web_lock) menu.setItemIcon(R.id.visibility_submenu, R.drawable.ic_action_web_lock)
menu.setItemChecked(R.id.attachment_visibility_unlisted, true) menu.setItemChecked(R.id.attachment_visibility_unlisted, true)
menu.setMenuItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_web_lock) menu.setItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_web_lock)
} }
StatusVisibility.PRIVATE -> { StatusVisibility.PRIVATE -> {
menu.setItemChecked(R.id.visibility_private, true) menu.setItemChecked(R.id.visibility_private, true)
menu.setMenuItemIcon(R.id.visibility_submenu, R.drawable.ic_action_lock) menu.setItemIcon(R.id.visibility_submenu, R.drawable.ic_action_lock)
menu.setItemChecked(R.id.attachment_visibility_private, true) menu.setItemChecked(R.id.attachment_visibility_private, true)
menu.setMenuItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_lock) menu.setItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_lock)
} }
StatusVisibility.DIRECT -> { StatusVisibility.DIRECT -> {
menu.setItemChecked(R.id.visibility_direct, true) menu.setItemChecked(R.id.visibility_direct, true)
menu.setMenuItemIcon(R.id.visibility_submenu, R.drawable.ic_action_message) menu.setItemIcon(R.id.visibility_submenu, R.drawable.ic_action_message)
menu.setItemChecked(R.id.attachment_visibility_direct, true) menu.setItemChecked(R.id.attachment_visibility_direct, true)
menu.setMenuItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_message) menu.setItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_message)
} }
else -> { // Default to public else -> { // Default to public
menu.setItemChecked(R.id.visibility_public, true) menu.setItemChecked(R.id.visibility_public, true)
menu.setMenuItemIcon(R.id.visibility_submenu, R.drawable.ic_action_web) menu.setItemIcon(R.id.visibility_submenu, R.drawable.ic_action_web)
menu.setItemChecked(R.id.attachment_visibility_public, true) menu.setItemChecked(R.id.attachment_visibility_public, true)
menu.setMenuItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_web) menu.setItemIcon(R.id.attachment_visibility_submenu, R.drawable.ic_action_web)
} }
} }
@ -1473,13 +1476,13 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
val update = try { val update = try {
getStatusUpdate(true) getStatusUpdate(true)
} catch(e: NoAccountException) { } catch (e: NoAccountException) {
editText.error = getString(R.string.message_toast_no_account_selected) editText.error = getString(R.string.message_toast_no_account_selected)
return return
} catch(e: NoContentException) { } catch (e: NoContentException) {
editText.error = getString(R.string.error_message_no_content) editText.error = getString(R.string.error_message_no_content)
return return
} catch(e: StatusTooLongException) { } catch (e: StatusTooLongException) {
editText.error = getString(R.string.error_message_status_too_long) editText.error = getString(R.string.error_message_status_too_long)
editText.setSelection(e.exceededStartIndex, editText.length()) editText.setSelection(e.exceededStartIndex, editText.length())
return return
@ -1675,7 +1678,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
private fun saveToDrafts(): Uri? { private fun saveToDrafts(): Uri? {
val statusUpdate = try { val statusUpdate = try {
getStatusUpdate(false) getStatusUpdate(false)
} catch(e: ComposeException) { } catch (e: ComposeException) {
return null return null
} }
val draft = UpdateStatusTask.createDraft(draftAction) { val draft = UpdateStatusTask.createDraft(draftAction) {

View File

@ -143,7 +143,8 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowInsetsCallback, IControl
contentFragmentId = android.R.id.content contentFragmentId = android.R.id.content
} else { } else {
setContentView(R.layout.activity_link_handler) setContentView(R.layout.activity_link_handler)
toolbar?.let { toolbar -> val toolbar = this.toolbar
if (toolbar != null) {
if (supportActionBar != null) { if (supportActionBar != null) {
toolbar.visibility = View.GONE toolbar.visibility = View.GONE
windowOverlay?.visibility = View.GONE windowOverlay?.visibility = View.GONE
@ -221,6 +222,7 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowInsetsCallback, IControl
if (fragment is IToolBarSupportFragment) { if (fragment is IToolBarSupportFragment) {
return result return result
} }
contentView?.statusBarHeight = insets.systemWindowInsetTop - controlBarHeight
return result.consumeSystemWindowInsets() return result.consumeSystemWindowInsets()
} }
@ -341,11 +343,13 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowInsetsCallback, IControl
get() { get() {
val fragment = currentVisibleFragment val fragment = currentVisibleFragment
val actionBar = supportActionBar val actionBar = supportActionBar
var height = 0
if (fragment is IToolBarSupportFragment) { if (fragment is IToolBarSupportFragment) {
return fragment.controlBarHeight fragment.controlBarHeight
} else if (actionBar != null) { } else if (actionBar != null) {
return actionBar.height height = actionBar.height
} }
if (height != 0) return height
if (actionBarHeight != 0) return actionBarHeight if (actionBarHeight != 0) return actionBarHeight
actionBarHeight = ThemeUtils.getActionBarHeight(this) actionBarHeight = ThemeUtils.getActionBarHeight(this)
return actionBarHeight return actionBarHeight

View File

@ -52,6 +52,9 @@ abstract class AbsContentListViewFragment<A : ListAdapter> : BaseFragment(),
protected open val overrideDivider: Drawable? protected open val overrideDivider: Drawable?
get() = ThemeUtils.getDrawableFromThemeAttribute(context, android.R.attr.listDivider) get() = ThemeUtils.getDrawableFromThemeAttribute(context, android.R.attr.listDivider)
protected val isProgressShowing: Boolean
get() = progressContainer.visibility == View.VISIBLE
override lateinit var adapter: A override lateinit var adapter: A

View File

@ -64,6 +64,25 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
private val refreshCompleteListener: RefreshCompleteListener? private val refreshCompleteListener: RefreshCompleteListener?
get() = parentFragment as? RefreshCompleteListener get() = parentFragment as? RefreshCompleteListener
val isProgressShowing: Boolean
get() = progressContainer.visibility == View.VISIBLE
override var refreshing: Boolean
get () = swipeLayout.isRefreshing
set(value) {
if (isProgressShowing) return
val currentRefreshing = swipeLayout.isRefreshing
if (!currentRefreshing) {
updateRefreshProgressOffset()
}
if (!value) {
refreshCompleteListener?.onRefreshComplete(this)
}
if (value == currentRefreshing) return
val layoutRefreshing = value && adapter.loadMoreIndicatorPosition != ILoadMoreSupportAdapter.NONE
swipeLayout.isRefreshing = layoutRefreshing
}
override fun canScroll(dy: Float): Boolean { override fun canScroll(dy: Float): Boolean {
return drawerCallback.canScroll(dy) return drawerCallback.canScroll(dy)
} }
@ -136,21 +155,6 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
drawerCallback.topChanged(offset) drawerCallback.topChanged(offset)
} }
override var refreshing: Boolean
get () = swipeLayout.isRefreshing
set(value) {
val currentRefreshing = swipeLayout.isRefreshing
if (!currentRefreshing) {
updateRefreshProgressOffset()
}
if (!value) {
refreshCompleteListener?.onRefreshComplete(this)
}
if (value == currentRefreshing) return
val layoutRefreshing = value && adapter.loadMoreIndicatorPosition != ILoadMoreSupportAdapter.NONE
swipeLayout.isRefreshing = layoutRefreshing
}
var refreshEnabled: Boolean var refreshEnabled: Boolean
get() = swipeLayout.isEnabled get() = swipeLayout.isEnabled
set(value) { set(value) {

View File

@ -369,9 +369,9 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
val icon = ContextCompat.getDrawable(context, R.drawable.ic_action_infinity) val icon = ContextCompat.getDrawable(context, R.drawable.ic_action_infinity)
val color = ContextCompat.getColor(context, R.color.material_red) val color = ContextCompat.getColor(context, R.color.material_red)
val size = resources.getDimensionPixelSize(R.dimen.element_spacing_msmall) val size = resources.getDimensionPixelSize(R.dimen.element_spacing_msmall)
menu.setMenuItemIcon(R.id.premium_features, BadgeDrawable(icon, color, size)) menu.setItemIcon(R.id.premium_features, BadgeDrawable(icon, color, size))
} else { } else {
menu.setMenuItemIcon(R.id.premium_features, R.drawable.ic_action_infinity) menu.setItemIcon(R.id.premium_features, R.drawable.ic_action_infinity)
} }
var hasLists = false var hasLists = false
var hasGroups = false var hasGroups = false

View File

@ -81,7 +81,6 @@ import kotlinx.android.synthetic.main.header_user.*
import kotlinx.android.synthetic.main.header_user.view.* import kotlinx.android.synthetic.main.header_user.view.*
import kotlinx.android.synthetic.main.layout_content_fragment_common.* import kotlinx.android.synthetic.main.layout_content_fragment_common.*
import kotlinx.android.synthetic.main.layout_content_pages_common.* import kotlinx.android.synthetic.main.layout_content_pages_common.*
import nl.komponents.kovenant.combine.and
import nl.komponents.kovenant.task import nl.komponents.kovenant.task
import nl.komponents.kovenant.then import nl.komponents.kovenant.then
import nl.komponents.kovenant.ui.alwaysUi import nl.komponents.kovenant.ui.alwaysUi
@ -802,7 +801,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
menu.setItemAvailability(R.id.blocked_users, isMyself) menu.setItemAvailability(R.id.blocked_users, isMyself)
menu.setItemAvailability(R.id.block, !isMyself) menu.setItemAvailability(R.id.block, !isMyself)
menu.setItemAvailability(R.id.add_to_home_screen, menu.setItemAvailability(R.id.add_to_home_screen_submenu,
ShortcutManagerCompat.isRequestPinShortcutSupported(context)) ShortcutManagerCompat.isRequestPinShortcutSupported(context))
var canAddToList = false var canAddToList = false
@ -1036,17 +1035,19 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
} }
return true return true
} }
R.id.add_to_home_screen -> { R.id.add_user_to_home_screen -> {
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(context)) return true ShortcutCreator.performCreation(this) {
val promise = showProgressDialog(FRAGMENT_TAG_ADD_USER_SHORTCUT_TO_HOME_SCREEN) ShortcutCreator.user(context, user.account_key, user)
.and(ShortcutCreator.user(context, user.account_key, user)) }
val weakThis = WeakReference(this) }
promise.successUi { (_, shortcut) -> R.id.add_statuses_to_home_screen -> {
val fragment = weakThis.get() ?: return@successUi ShortcutCreator.performCreation(this) {
ShortcutManagerCompat.requestPinShortcut(fragment.context, shortcut, null) ShortcutCreator.userTimeline(context, user.account_key, user)
}.alwaysUi { }
val fragment = weakThis.get() ?: return@alwaysUi }
fragment.dismissProgressDialog(FRAGMENT_TAG_ADD_USER_SHORTCUT_TO_HOME_SCREEN) R.id.add_favorites_to_home_screen -> {
ShortcutCreator.performCreation(this) {
ShortcutCreator.userFavorites(context, user.account_key, user)
} }
} }
else -> { else -> {
@ -1860,6 +1861,6 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
private const val TAB_TYPE_STATUSES_WITH_REPLIES = "statuses_with_replies" private const val TAB_TYPE_STATUSES_WITH_REPLIES = "statuses_with_replies"
private const val TAB_TYPE_MEDIA = "media" private const val TAB_TYPE_MEDIA = "media"
private const val TAB_TYPE_FAVORITES = "favorites" private const val TAB_TYPE_FAVORITES = "favorites"
private const val FRAGMENT_TAG_ADD_USER_SHORTCUT_TO_HOME_SCREEN = "add_user_shortcut_to_home_screen" private const val FRAGMENT_TAG_ADD_SHORTCUT_TO_HOME_SCREEN = "add_shortcut_to_home_screen"
} }
} }

View File

@ -25,17 +25,24 @@ import android.graphics.Canvas
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Build import android.os.Build
import android.support.v4.content.pm.ShortcutInfoCompat import android.support.v4.content.pm.ShortcutInfoCompat
import android.support.v4.content.pm.ShortcutManagerCompat
import android.support.v4.graphics.drawable.IconCompat import android.support.v4.graphics.drawable.IconCompat
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import nl.komponents.kovenant.Promise import nl.komponents.kovenant.Promise
import nl.komponents.kovenant.combine.and
import nl.komponents.kovenant.then import nl.komponents.kovenant.then
import nl.komponents.kovenant.ui.alwaysUi
import nl.komponents.kovenant.ui.successUi
import org.mariotaku.kpreferences.get import org.mariotaku.kpreferences.get
import org.mariotaku.twidere.R import org.mariotaku.twidere.R
import org.mariotaku.twidere.annotation.ImageShapeStyle import org.mariotaku.twidere.annotation.ImageShapeStyle
import org.mariotaku.twidere.constant.iWantMyStarsBackKey import org.mariotaku.twidere.constant.iWantMyStarsBackKey
import org.mariotaku.twidere.constant.nameFirstKey import org.mariotaku.twidere.constant.nameFirstKey
import org.mariotaku.twidere.constant.profileImageStyleKey import org.mariotaku.twidere.constant.profileImageStyleKey
import org.mariotaku.twidere.extension.dismissProgressDialog
import org.mariotaku.twidere.extension.loadProfileImage import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.showProgressDialog
import org.mariotaku.twidere.fragment.BaseFragment
import org.mariotaku.twidere.model.ParcelableUser import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.util.IntentUtils import org.mariotaku.twidere.util.IntentUtils
@ -109,6 +116,20 @@ object ShortcutCreator {
return Promise.of(builder.build()) return Promise.of(builder.build())
} }
inline fun performCreation(fragment: BaseFragment, createPromise: () -> Promise<ShortcutInfoCompat, Exception>) {
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(fragment.context)) return
val promise = fragment.showProgressDialog("create_shortcut")
.and(createPromise())
val weakThis = WeakReference(fragment)
promise.successUi { (_, shortcut) ->
val f = weakThis.get() ?: return@successUi
ShortcutManagerCompat.requestPinShortcut(f.context, shortcut, null)
}.alwaysUi {
val f = weakThis.get() ?: return@alwaysUi
f.dismissProgressDialog("create_shortcut")
}
}
private fun Drawable.toProfileImageIcon(context: Context): IconCompat { private fun Drawable.toProfileImageIcon(context: Context): IconCompat {
if (useAdaptiveIcon) { if (useAdaptiveIcon) {
val density = context.resources.displayMetrics.density val density = context.resources.displayMetrics.density

View File

@ -45,7 +45,11 @@ class TintedStatusRelativeLayout(context: Context, attrs: AttributeSet? = null)
override var setPaddingEnabled: Boolean = false override var setPaddingEnabled: Boolean = false
private val colorPaint: Paint private val colorPaint: Paint
private var statusBarHeight: Int = 0 var statusBarHeight: Int = 0
set(value) {
field = value
invalidate()
}
var applyWindowInsetsListener: OnApplyWindowInsetsListenerCompat? = null var applyWindowInsetsListener: OnApplyWindowInsetsListenerCompat? = null
init { init {
@ -56,17 +60,21 @@ class TintedStatusRelativeLayout(context: Context, attrs: AttributeSet? = null)
setWillNotDraw(false) setWillNotDraw(false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets -> ViewCompat.setOnApplyWindowInsetsListener(this) lambda@ { view, insets ->
val top = insets.systemWindowInsetTop val consumed = applyWindowInsetsListener?.onApplyWindowInsets(view, insets) ?: insets
val left = insets.systemWindowInsetLeft if (!consumed.isConsumed) {
val right = insets.systemWindowInsetRight val top = consumed.systemWindowInsetTop
val bottom = insets.systemWindowInsetBottom val left = consumed.systemWindowInsetLeft
val right = consumed.systemWindowInsetRight
val bottom = consumed.systemWindowInsetBottom
if (setPaddingEnabled) { if (setPaddingEnabled) {
setPadding(left, top, right, bottom) setPadding(left, top, right, bottom)
} }
setStatusBarHeight(top) statusBarHeight = top
applyWindowInsetsListener?.onApplyWindowInsets(view, insets) return@lambda consumed
insets.consumeSystemWindowInsets() } else {
return@lambda consumed.consumeSystemWindowInsets()
}
} }
} }
} }
@ -78,11 +86,6 @@ class TintedStatusRelativeLayout(context: Context, attrs: AttributeSet? = null)
invalidate() invalidate()
} }
fun setStatusBarHeight(height: Int) {
statusBarHeight = height
invalidate()
}
override fun dispatchDraw(canvas: Canvas) { override fun dispatchDraw(canvas: Canvas) {
super.dispatchDraw(canvas) super.dispatchDraw(canvas)
canvas.drawRect(0f, 0f, canvas.width.toFloat(), statusBarHeight.toFloat(), colorPaint) canvas.drawRect(0f, 0f, canvas.width.toFloat(), statusBarHeight.toFloat(), colorPaint)

View File

@ -87,8 +87,28 @@
android:icon="@drawable/ic_action_web" android:icon="@drawable/ic_action_web"
android:title="@string/action_open_in_browser"/> android:title="@string/action_open_in_browser"/>
<item <item
android:id="@id/add_to_home_screen" android:id="@+id/add_to_home_screen_submenu"
android:icon="@drawable/ic_action_home" android:icon="@drawable/ic_action_home"
android:title="@string/action_add_to_home_screen"/> android:title="@string/action_add_to_home_screen_more">
<menu>
<item
android:id="@+id/add_user_to_home_screen"
android:icon="@drawable/ic_action_user"
android:title="@string/title_user"/>
<item
android:id="@+id/add_statuses_to_home_screen"
android:icon="@drawable/ic_action_quote"
android:title="@string/title_statuses"/>
<item
android:id="@+id/add_media_to_home_screen"
android:enabled="@bool/debug"
android:icon="@drawable/ic_action_gallery"
android:title="@string/title_media_timeline"
android:visible="@bool/debug"/>
<item
android:id="@+id/add_favorites_to_home_screen"
android:icon="@drawable/ic_action_star"
android:title="@string/title_favorites"/>
</menu>
</item>
</menu> </menu>

View File

@ -21,9 +21,12 @@
<string name="action_add_gif">Add GIF</string> <string name="action_add_gif">Add GIF</string>
<string name="action_add_media">Add media</string> <string name="action_add_media">Add media</string>
<string name="action_add_member">Add member</string> <string name="action_add_member">Add member</string>
<string name="action_add_name_to_home_screen">Add <xliff:g example="Name" id="name">%1$s</xliff:g> to home screen</string>
<string name="action_add_tab_to_home_screen">Add tab to home screen</string>
<string name="action_add_tab">Add tab</string> <string name="action_add_tab">Add tab</string>
<string name="action_add_to_filter">Add to filter</string> <string name="action_add_to_filter">Add to filter</string>
<string name="action_add_to_home_screen">Add to home screen</string> <string name="action_add_to_home_screen">Add to home screen</string>
<string name="action_add_to_home_screen_more">Add to home screen…</string>
<string name="action_add_to_list">Add to list</string> <string name="action_add_to_list">Add to list</string>
<!-- [verb] Action for blocking user --> <!-- [verb] Action for blocking user -->
<string name="action_block">Block</string> <string name="action_block">Block</string>