improved users lists navbar style
This commit is contained in:
parent
9058d19437
commit
977550c7b0
|
@ -31,6 +31,7 @@ import android.support.v4.app.Fragment
|
||||||
import android.support.v4.app.FragmentManager
|
import android.support.v4.app.FragmentManager
|
||||||
import android.support.v4.app.FragmentManager.FragmentLifecycleCallbacks
|
import android.support.v4.app.FragmentManager.FragmentLifecycleCallbacks
|
||||||
import android.support.v4.app.NavUtils
|
import android.support.v4.app.NavUtils
|
||||||
|
import android.support.v4.view.ViewCompat
|
||||||
import android.support.v4.view.WindowCompat
|
import android.support.v4.view.WindowCompat
|
||||||
import android.support.v4.view.WindowInsetsCompat
|
import android.support.v4.view.WindowInsetsCompat
|
||||||
import android.support.v7.widget.Toolbar
|
import android.support.v7.widget.Toolbar
|
||||||
|
@ -66,6 +67,7 @@ import org.mariotaku.twidere.fragment.search.MastodonSearchFragment
|
||||||
import org.mariotaku.twidere.fragment.search.SearchFragment
|
import org.mariotaku.twidere.fragment.search.SearchFragment
|
||||||
import org.mariotaku.twidere.fragment.statuses.*
|
import org.mariotaku.twidere.fragment.statuses.*
|
||||||
import org.mariotaku.twidere.fragment.users.*
|
import org.mariotaku.twidere.fragment.users.*
|
||||||
|
import org.mariotaku.twidere.graphic.ActionBarColorDrawable
|
||||||
import org.mariotaku.twidere.graphic.EmptyDrawable
|
import org.mariotaku.twidere.graphic.EmptyDrawable
|
||||||
import org.mariotaku.twidere.model.UserKey
|
import org.mariotaku.twidere.model.UserKey
|
||||||
import org.mariotaku.twidere.model.analyzer.PurchaseFinished
|
import org.mariotaku.twidere.model.analyzer.PurchaseFinished
|
||||||
|
@ -136,6 +138,7 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowInsetsCallback, IControl
|
||||||
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
|
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY)
|
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY)
|
||||||
}
|
}
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(window.decorView, this)
|
||||||
contentFragmentId = android.R.id.content
|
contentFragmentId = android.R.id.content
|
||||||
} else {
|
} else {
|
||||||
setContentView(R.layout.activity_link_handler)
|
setContentView(R.layout.activity_link_handler)
|
||||||
|
@ -166,6 +169,8 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowInsetsCallback, IControl
|
||||||
setTitle(linkId, uri)
|
setTitle(linkId, uri)
|
||||||
finishOnly = uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY)?.toBoolean() ?: false
|
finishOnly = uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY)?.toBoolean() ?: false
|
||||||
|
|
||||||
|
supportActionBar?.setBackgroundDrawable(ActionBarColorDrawable.create(overrideTheme.colorToolbar,
|
||||||
|
true))
|
||||||
if (fragment is IToolBarSupportFragment) {
|
if (fragment is IToolBarSupportFragment) {
|
||||||
ThemeUtils.setCompatContentViewOverlay(window, EmptyDrawable())
|
ThemeUtils.setCompatContentViewOverlay(window, EmptyDrawable())
|
||||||
}
|
}
|
||||||
|
@ -212,7 +217,9 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowInsetsCallback, IControl
|
||||||
if (fragment is IBaseFragment<*>) {
|
if (fragment is IBaseFragment<*>) {
|
||||||
fragment.requestApplyInsets()
|
fragment.requestApplyInsets()
|
||||||
}
|
}
|
||||||
|
if (fragment is IToolBarSupportFragment) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
return result.consumeSystemWindowInsets()
|
return result.consumeSystemWindowInsets()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.graphics.Rect
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
import android.support.v4.app.FragmentActivity
|
import android.support.v4.app.FragmentActivity
|
||||||
|
import android.support.v4.view.OnApplyWindowInsetsListener
|
||||||
import android.support.v4.view.ViewPager.OnPageChangeListener
|
import android.support.v4.view.ViewPager.OnPageChangeListener
|
||||||
import android.support.v7.widget.Toolbar
|
import android.support.v7.widget.Toolbar
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
@ -28,6 +29,7 @@ import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface
|
||||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback
|
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback
|
||||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler
|
||||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
|
||||||
|
import org.mariotaku.twidere.util.ThemeUtils
|
||||||
import org.mariotaku.twidere.view.TabPagerIndicator
|
import org.mariotaku.twidere.view.TabPagerIndicator
|
||||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||||
|
|
||||||
|
@ -52,6 +54,11 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||||
toolbarTabs.setViewPager(viewPager)
|
toolbarTabs.setViewPager(viewPager)
|
||||||
toolbarTabs.setTabDisplayOption(TabPagerIndicator.DisplayOption.LABEL)
|
toolbarTabs.setTabDisplayOption(TabPagerIndicator.DisplayOption.LABEL)
|
||||||
|
|
||||||
|
tabPagesFragmentView.applyWindowInsetsListener = OnApplyWindowInsetsListener listener@ { _, insets ->
|
||||||
|
val top = insets.systemWindowInsetTop
|
||||||
|
tabPagesFragmentView.setPadding(0, top, 0, 0)
|
||||||
|
return@listener insets
|
||||||
|
}
|
||||||
|
|
||||||
addTabs(pagerAdapter)
|
addTabs(pagerAdapter)
|
||||||
toolbarTabs.notifyDataSetChanged()
|
toolbarTabs.notifyDataSetChanged()
|
||||||
|
@ -138,8 +145,13 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSystemWindowInsets(caller: Fragment, insets: Rect): Boolean {
|
override fun getSystemWindowInsets(caller: Fragment, insets: Rect): Boolean {
|
||||||
if (toolbarTabs == null) return false
|
insetsCallback?.getSystemWindowInsets(this, insets)
|
||||||
insets.set(0, toolbarContainer.height, 0, 0)
|
val height = toolbarContainer.height
|
||||||
|
if (height != 0) {
|
||||||
|
insets.top = height
|
||||||
|
} else {
|
||||||
|
insets.top = ThemeUtils.getActionBarHeight(context)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -555,7 +555,9 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSystemWindowInsets(caller: Fragment, insets: Rect): Boolean {
|
override fun getSystemWindowInsets(caller: Fragment, insets: Rect): Boolean {
|
||||||
return false
|
insetsCallback?.getSystemWindowInsets(this, insets)
|
||||||
|
insets.top = 0
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUserInfo(accountKey: UserKey, userKey: UserKey?, screenName: String?,
|
fun getUserInfo(accountKey: UserKey, userKey: UserKey?, screenName: String?,
|
||||||
|
|
|
@ -39,18 +39,22 @@ interface IBaseFragment<out F : Fragment> {
|
||||||
val tabId: Long
|
val tabId: Long
|
||||||
get() = (this as Fragment).arguments?.getLong(IntentConstants.EXTRA_TAB_ID, -1L) ?: -1L
|
get() = (this as Fragment).arguments?.getLong(IntentConstants.EXTRA_TAB_ID, -1L) ?: -1L
|
||||||
|
|
||||||
fun requestApplyInsets() {
|
val insetsCallback: SystemWindowInsetsCallback?
|
||||||
|
get() {
|
||||||
val fragment = this as Fragment
|
val fragment = this as Fragment
|
||||||
val activity = fragment.activity
|
val activity = fragment.activity
|
||||||
val parentFragment = fragment.parentFragment
|
val parentFragment = fragment.parentFragment
|
||||||
val callback: SystemWindowInsetsCallback
|
|
||||||
if (parentFragment is SystemWindowInsetsCallback) {
|
if (parentFragment is SystemWindowInsetsCallback) {
|
||||||
callback = parentFragment
|
return parentFragment
|
||||||
} else if (activity is SystemWindowInsetsCallback) {
|
} else if (activity is SystemWindowInsetsCallback) {
|
||||||
callback = activity
|
return activity
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestApplyInsets() {
|
||||||
|
val fragment = this as Fragment
|
||||||
|
val callback = insetsCallback ?: return
|
||||||
val insets = Rect()
|
val insets = Rect()
|
||||||
if (callback.getSystemWindowInsets(fragment, insets)) {
|
if (callback.getSystemWindowInsets(fragment, insets)) {
|
||||||
onApplySystemWindowInsets(insets)
|
onApplySystemWindowInsets(insets)
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
android:id="@+id/contentView"
|
android:id="@+id/contentView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
app:setPadding="false">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/contentFragment"
|
android:id="@+id/contentFragment"
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
android:id="@+id/contentView"
|
android:id="@+id/contentView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
app:setPadding="false">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/contentFragment"
|
android:id="@+id/contentFragment"
|
||||||
|
|
|
@ -17,10 +17,11 @@
|
||||||
~ You should have received a copy of the GNU General Public License
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<RelativeLayout
|
<org.mariotaku.twidere.view.TintedStatusRelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/tabPagesFragmentView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
@ -61,4 +62,4 @@
|
||||||
android:layout_below="@+id/toolbarContainer"
|
android:layout_below="@+id/toolbarContainer"
|
||||||
android:background="?android:windowContentOverlay"/>
|
android:background="?android:windowContentOverlay"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</org.mariotaku.twidere.view.TintedStatusRelativeLayout>
|
Loading…
Reference in New Issue