mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-14 18:50:39 +01:00
kotlin migration
This commit is contained in:
parent
0734f9f0dd
commit
d71407f294
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView;
|
||||
|
||||
public class ExtendedFrameLayout extends FrameLayout implements IExtendedView {
|
||||
|
||||
private TouchInterceptor mTouchInterceptor;
|
||||
private OnSizeChangedListener mOnSizeChangedListener;
|
||||
private OnFitSystemWindowsListener mOnFitSystemWindowsListener;
|
||||
|
||||
public ExtendedFrameLayout(final Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ExtendedFrameLayout(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ExtendedFrameLayout(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispatchTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.dispatchTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onInterceptTouchEvent(final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onInterceptTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFitSystemWindowsListener(OnFitSystemWindowsListener listener) {
|
||||
mOnFitSystemWindowsListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOnSizeChangedListener(final OnSizeChangedListener listener) {
|
||||
mOnSizeChangedListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTouchInterceptor(final TouchInterceptor listener) {
|
||||
mTouchInterceptor = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected boolean fitSystemWindows(@NonNull Rect insets) {
|
||||
if (mOnFitSystemWindowsListener != null) {
|
||||
mOnFitSystemWindowsListener.onFitSystemWindows(insets);
|
||||
}
|
||||
return super.fitSystemWindows(insets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (mOnSizeChangedListener != null) {
|
||||
mOnSizeChangedListener.onSizeChanged(this, w, h, oldw, oldh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView;
|
||||
|
||||
public class ExtendedImageView extends ImageView implements IExtendedView {
|
||||
|
||||
private OnSizeChangedListener mOnSizeChangedListener;
|
||||
private TouchInterceptor mTouchInterceptor;
|
||||
private OnFitSystemWindowsListener mOnFitSystemWindowsListener;
|
||||
|
||||
public ExtendedImageView(final Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ExtendedImageView(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ExtendedImageView(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFitSystemWindowsListener(OnFitSystemWindowsListener listener) {
|
||||
mOnFitSystemWindowsListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOnSizeChangedListener(final OnSizeChangedListener listener) {
|
||||
mOnSizeChangedListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTouchInterceptor(final TouchInterceptor listener) {
|
||||
mTouchInterceptor = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected boolean fitSystemWindows(@NonNull Rect insets) {
|
||||
if (mOnFitSystemWindowsListener != null) {
|
||||
mOnFitSystemWindowsListener.onFitSystemWindows(insets);
|
||||
}
|
||||
return super.fitSystemWindows(insets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispatchTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.dispatchTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (mOnSizeChangedListener != null) {
|
||||
mOnSizeChangedListener.onSizeChanged(this, w, h, oldw, oldh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView;
|
||||
|
||||
public class ExtendedLinearLayout extends LinearLayout implements IExtendedView {
|
||||
|
||||
private TouchInterceptor mTouchInterceptor;
|
||||
private OnSizeChangedListener mOnSizeChangedListener;
|
||||
private OnFitSystemWindowsListener mOnFitSystemWindowsListener;
|
||||
|
||||
public ExtendedLinearLayout(final Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ExtendedLinearLayout(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ExtendedLinearLayout(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispatchTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.dispatchTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onInterceptTouchEvent(final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onInterceptTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFitSystemWindowsListener(OnFitSystemWindowsListener listener) {
|
||||
mOnFitSystemWindowsListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOnSizeChangedListener(final OnSizeChangedListener listener) {
|
||||
mOnSizeChangedListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTouchInterceptor(final TouchInterceptor listener) {
|
||||
mTouchInterceptor = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected boolean fitSystemWindows(@NonNull Rect insets) {
|
||||
if (mOnFitSystemWindowsListener != null) {
|
||||
mOnFitSystemWindowsListener.onFitSystemWindows(insets);
|
||||
}
|
||||
return super.fitSystemWindows(insets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (mOnSizeChangedListener != null) {
|
||||
mOnSizeChangedListener.onSizeChanged(this, w, h, oldw, oldh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -36,10 +36,10 @@ import org.mariotaku.twidere.util.MouseScrollDirectionDecider;
|
||||
*/
|
||||
public class ExtendedRecyclerView extends RecyclerView {
|
||||
|
||||
private final MouseScrollDirectionDecider mMouseScrollDirectionDecider;
|
||||
private final MouseScrollDirectionDecider mouseScrollDirectionDecider;
|
||||
// This value is used when handling generic motion events.
|
||||
private float mScrollFactor = Float.MIN_VALUE;
|
||||
private ContextMenuInfo mContextMenuInfo;
|
||||
private float scrollFactor = Float.MIN_VALUE;
|
||||
private ContextMenuInfo contextMenuInfo;
|
||||
|
||||
public ExtendedRecyclerView(Context context) {
|
||||
this(context, null);
|
||||
@ -51,18 +51,18 @@ public class ExtendedRecyclerView extends RecyclerView {
|
||||
|
||||
public ExtendedRecyclerView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mMouseScrollDirectionDecider = new MouseScrollDirectionDecider(getScrollFactorBackport());
|
||||
mouseScrollDirectionDecider = new MouseScrollDirectionDecider(getScrollFactorBackport());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mMouseScrollDirectionDecider.attach(this);
|
||||
mouseScrollDirectionDecider.attach(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
mMouseScrollDirectionDecider.detach();
|
||||
mouseScrollDirectionDecider.detach();
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@ -77,24 +77,24 @@ public class ExtendedRecyclerView extends RecyclerView {
|
||||
final float vScroll, hScroll;
|
||||
if (lm.canScrollVertically()) {
|
||||
vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
|
||||
if (!mMouseScrollDirectionDecider.isVerticalAvailable()) {
|
||||
mMouseScrollDirectionDecider.guessDirection(event);
|
||||
if (!mouseScrollDirectionDecider.isVerticalAvailable()) {
|
||||
mouseScrollDirectionDecider.guessDirection(event);
|
||||
}
|
||||
} else {
|
||||
vScroll = 0f;
|
||||
}
|
||||
if (lm.canScrollHorizontally()) {
|
||||
hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
|
||||
if (!mMouseScrollDirectionDecider.isHorizontalAvailable()) {
|
||||
mMouseScrollDirectionDecider.guessDirection(event);
|
||||
if (!mouseScrollDirectionDecider.isHorizontalAvailable()) {
|
||||
mouseScrollDirectionDecider.guessDirection(event);
|
||||
}
|
||||
} else {
|
||||
hScroll = 0f;
|
||||
}
|
||||
if (vScroll != 0 || hScroll != 0) {
|
||||
final float scrollFactor = getScrollFactorBackport();
|
||||
float horizontalDirection = mMouseScrollDirectionDecider.getHorizontalDirection();
|
||||
float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection();
|
||||
float horizontalDirection = mouseScrollDirectionDecider.getHorizontalDirection();
|
||||
float verticalDirection = mouseScrollDirectionDecider.getVerticalDirection();
|
||||
final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1);
|
||||
final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1);
|
||||
scrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor));
|
||||
@ -142,7 +142,7 @@ public class ExtendedRecyclerView extends RecyclerView {
|
||||
|
||||
@Override
|
||||
protected ContextMenu.ContextMenuInfo getContextMenuInfo() {
|
||||
return mContextMenuInfo;
|
||||
return contextMenuInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,7 +152,7 @@ public class ExtendedRecyclerView extends RecyclerView {
|
||||
}
|
||||
final int position = getChildLayoutPosition(originalView);
|
||||
if (position == RecyclerView.NO_POSITION) return false;
|
||||
mContextMenuInfo = new ContextMenuInfo(getId(), position);
|
||||
contextMenuInfo = new ContextMenuInfo(getId(), position);
|
||||
return super.showContextMenuForChild(originalView);
|
||||
}
|
||||
|
||||
@ -160,18 +160,18 @@ public class ExtendedRecyclerView extends RecyclerView {
|
||||
* Ported from View.getVerticalScrollFactor.
|
||||
*/
|
||||
private float getScrollFactorBackport() {
|
||||
if (mScrollFactor == Float.MIN_VALUE) {
|
||||
if (scrollFactor == Float.MIN_VALUE) {
|
||||
TypedValue outValue = new TypedValue();
|
||||
if (getContext().getTheme().resolveAttribute(
|
||||
android.R.attr.listPreferredItemHeight, outValue, true)) {
|
||||
mScrollFactor = outValue.getDimension(
|
||||
scrollFactor = outValue.getDimension(
|
||||
getContext().getResources().getDisplayMetrics());
|
||||
} else {
|
||||
return 0; //listPreferredItemHeight is not defined, no generic scrolling
|
||||
}
|
||||
|
||||
}
|
||||
return mScrollFactor;
|
||||
return scrollFactor;
|
||||
}
|
||||
|
||||
public static class ContextMenuInfo implements ContextMenu.ContextMenuInfo {
|
||||
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.mariotaku.chameleon.view.ChameleonSwipeRefreshLayout;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/25.
|
||||
*/
|
||||
public class ExtendedSwipeRefreshLayout extends ChameleonSwipeRefreshLayout implements IExtendedView {
|
||||
|
||||
private TouchInterceptor mTouchInterceptor;
|
||||
private OnSizeChangedListener mOnSizeChangedListener;
|
||||
private OnFitSystemWindowsListener mOnFitSystemWindowsListener;
|
||||
|
||||
public ExtendedSwipeRefreshLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ExtendedSwipeRefreshLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispatchTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.dispatchTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onInterceptTouchEvent(final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onInterceptTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFitSystemWindowsListener(OnFitSystemWindowsListener listener) {
|
||||
mOnFitSystemWindowsListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOnSizeChangedListener(final OnSizeChangedListener listener) {
|
||||
mOnSizeChangedListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTouchInterceptor(final TouchInterceptor listener) {
|
||||
mTouchInterceptor = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected boolean fitSystemWindows(@NonNull Rect insets) {
|
||||
if (mOnFitSystemWindowsListener != null) {
|
||||
mOnFitSystemWindowsListener.onFitSystemWindows(insets);
|
||||
}
|
||||
return super.fitSystemWindows(insets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (mOnSizeChangedListener != null) {
|
||||
mOnSizeChangedListener.onSizeChanged(this, w, h, oldw, oldh);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView;
|
||||
|
||||
public class ProfileBannerImageView extends ForegroundImageView implements IExtendedView {
|
||||
|
||||
private OnSizeChangedListener mOnSizeChangedListener;
|
||||
private TouchInterceptor mTouchInterceptor;
|
||||
private OnFitSystemWindowsListener mOnFitSystemWindowsListener;
|
||||
private float mBannerAspectRatio;
|
||||
|
||||
public ProfileBannerImageView(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProfileBannerImageView);
|
||||
setBannerAspectRatio(a.getFraction(R.styleable.ProfileBannerImageView_bannerAspectRatio, 1, 1, 2f));
|
||||
a.recycle();
|
||||
setScaleType(ScaleType.CENTER_CROP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFitSystemWindowsListener(OnFitSystemWindowsListener listener) {
|
||||
mOnFitSystemWindowsListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOnSizeChangedListener(final OnSizeChangedListener listener) {
|
||||
mOnSizeChangedListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTouchInterceptor(final TouchInterceptor listener) {
|
||||
mTouchInterceptor = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
protected boolean fitSystemWindows(@NonNull Rect insets) {
|
||||
if (mOnFitSystemWindowsListener != null) {
|
||||
mOnFitSystemWindowsListener.onFitSystemWindows(insets);
|
||||
}
|
||||
return super.fitSystemWindows(insets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispatchTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.dispatchTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onTouchEvent(@NonNull final MotionEvent event) {
|
||||
if (mTouchInterceptor != null) {
|
||||
final boolean ret = mTouchInterceptor.onTouchEvent(this, event);
|
||||
if (ret) return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||
final int width = MeasureSpec.getSize(widthMeasureSpec),
|
||||
height = Math.round(width / mBannerAspectRatio);
|
||||
setMeasuredDimension(width, height);
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (mOnSizeChangedListener != null) {
|
||||
mOnSizeChangedListener.onSizeChanged(this, w, h, oldw, oldh);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBannerAspectRatio(final float bannerAspectRatio) {
|
||||
mBannerAspectRatio = bannerAspectRatio;
|
||||
}
|
||||
|
||||
public float getBannerAspectRatio() {
|
||||
return mBannerAspectRatio;
|
||||
}
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.WindowInsetsCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import org.mariotaku.chameleon.Chameleon;
|
||||
import org.mariotaku.chameleon.Chameleon.Theme.LightStatusBarMode;
|
||||
import org.mariotaku.chameleon.ChameleonUtils;
|
||||
import org.mariotaku.chameleon.ChameleonView;
|
||||
import org.mariotaku.chameleon.internal.SupportMethods;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.view.iface.TintedStatusLayout;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/11/26.
|
||||
*/
|
||||
public class TintedStatusFrameLayout extends ExtendedFrameLayout implements TintedStatusLayout,
|
||||
ChameleonView, ChameleonView.StatusBarThemeable {
|
||||
|
||||
private final Paint mColorPaint;
|
||||
private boolean mSetPadding;
|
||||
|
||||
private int mStatusBarHeight;
|
||||
private Rect mSystemWindowsInsets;
|
||||
private WindowInsetsListener mWindowInsetsListener;
|
||||
|
||||
public TintedStatusFrameLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TintedStatusFrameLayout(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public TintedStatusFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintedStatusLayout);
|
||||
setSetPaddingEnabled(a.getBoolean(R.styleable.TintedStatusLayout_setPadding, false));
|
||||
a.recycle();
|
||||
mColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mSystemWindowsInsets = new Rect();
|
||||
setWillNotDraw(false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_STABLE | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
|
||||
@Override
|
||||
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
|
||||
final int top = insets.getSystemWindowInsetTop();
|
||||
final int left = insets.getSystemWindowInsetLeft();
|
||||
final int right = insets.getSystemWindowInsetRight();
|
||||
final int bottom = insets.getSystemWindowInsetBottom();
|
||||
if (mSetPadding) {
|
||||
setPadding(left, top, right, bottom);
|
||||
}
|
||||
setStatusBarHeight(top);
|
||||
if (mWindowInsetsListener != null) {
|
||||
mWindowInsetsListener.onApplyWindowInsets(left, top, right, bottom);
|
||||
}
|
||||
return insets.consumeSystemWindowInsets();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setStatusBarColor(int color) {
|
||||
mColorPaint.setColor(0xFF000000 | color);
|
||||
mColorPaint.setAlpha(Color.alpha(color));
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSetPaddingEnabled(boolean enabled) {
|
||||
mSetPadding = enabled;
|
||||
}
|
||||
|
||||
public void setStatusBarHeight(int height) {
|
||||
mStatusBarHeight = height;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(@NonNull Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
canvas.drawRect(0, 0, canvas.getWidth(), mStatusBarHeight, mColorPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean fitSystemWindows(@NonNull Rect insets) {
|
||||
mSystemWindowsInsets.set(insets);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setWindowInsetsListener(WindowInsetsListener listener) {
|
||||
mWindowInsetsListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPostApplyTheme() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Appearance createAppearance(@NonNull Context context, @NonNull AttributeSet attributeSet, @NonNull Chameleon.Theme theme) {
|
||||
Appearance appearance = new Appearance();
|
||||
appearance.setStatusBarColor(theme.getStatusBarColor());
|
||||
appearance.setLightStatusBarMode(theme.getLightStatusBarMode());
|
||||
return appearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyAppearance(@NonNull ChameleonView.Appearance appearance) {
|
||||
Appearance a = (Appearance) appearance;
|
||||
final int statusBarColor = a.getStatusBarColor();
|
||||
setStatusBarColor(statusBarColor);
|
||||
final Activity activity = ChameleonUtils.getActivity(getContext());
|
||||
if (activity != null) {
|
||||
final Window window = activity.getWindow();
|
||||
SupportMethods.setStatusBarColor(window, Color.TRANSPARENT);
|
||||
ChameleonUtils.applyLightStatusBar(window, statusBarColor, a.getLightStatusBarMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatusBarColorHandled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class Appearance implements ChameleonView.Appearance {
|
||||
private int statusBarColor;
|
||||
@LightStatusBarMode
|
||||
private int lightStatusBarMode;
|
||||
|
||||
public int getStatusBarColor() {
|
||||
return statusBarColor;
|
||||
}
|
||||
|
||||
public void setStatusBarColor(int statusBarColor) {
|
||||
this.statusBarColor = statusBarColor;
|
||||
}
|
||||
|
||||
@LightStatusBarMode
|
||||
public int getLightStatusBarMode() {
|
||||
return lightStatusBarMode;
|
||||
}
|
||||
|
||||
public void setLightStatusBarMode(@LightStatusBarMode int lightStatusBarMode) {
|
||||
this.lightStatusBarMode = lightStatusBarMode;
|
||||
}
|
||||
}
|
||||
|
||||
public interface WindowInsetsListener {
|
||||
void onApplyWindowInsets(int left, int top, int right, int bottom);
|
||||
}
|
||||
}
|
@ -210,7 +210,7 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
|
||||
val refreshOnStart = preferences.getBoolean(SharedPreferenceConstants.KEY_REFRESH_ON_START, false)
|
||||
var tabDisplayOptionInt = Utils.getTabDisplayOptionInt(this)
|
||||
|
||||
homeContent.setOnFitSystemWindowsListener(this)
|
||||
homeContent.onFitSystemWindowsListener = this
|
||||
mainPager.adapter = pagerAdapter
|
||||
mainTabs.setViewPager(mainPager)
|
||||
mainTabs.setOnPageChangeListener(this)
|
||||
|
@ -70,6 +70,7 @@ import org.mariotaku.twidere.util.PermissionUtils
|
||||
import org.mariotaku.twidere.util.ThemeUtils
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.util.support.WindowSupport
|
||||
import org.mariotaku.twidere.view.TintedStatusFrameLayout
|
||||
import org.mariotaku.twidere.view.viewer.MediaSwipeCloseContainer
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
@ -154,10 +155,12 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
|
||||
swipeContainer.backgroundAlpha = 1f
|
||||
WindowSupport.setStatusBarColor(window, Color.TRANSPARENT)
|
||||
activityLayout.setStatusBarColor(overrideTheme.colorToolbar)
|
||||
activityLayout.setWindowInsetsListener { l, t, r, b ->
|
||||
val statusBarHeight = t - ThemeUtils.getActionBarHeight(this)
|
||||
activityLayout.windowInsetsListener = object : TintedStatusFrameLayout.WindowInsetsListener {
|
||||
override fun onApplyWindowInsets(left: Int, top: Int, right: Int, bottom: Int) {
|
||||
val statusBarHeight = top - ThemeUtils.getActionBarHeight(this@MediaViewerActivity)
|
||||
activityLayout.setStatusBarHeight(statusBarHeight)
|
||||
onFitSystemWindows(Rect(l, t, r, b))
|
||||
onFitSystemWindows(Rect(left, top, right, bottom))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
||||
accountSpinner.setSelection(index)
|
||||
}
|
||||
}
|
||||
mainContent.setOnFitSystemWindowsListener(this)
|
||||
mainContent.onFitSystemWindowsListener = this
|
||||
suggestionsList.adapter = SuggestionsAdapter(this)
|
||||
suggestionsList.onItemClickListener = this
|
||||
|
||||
|
@ -190,7 +190,7 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
recyclerView.setHasFixedSize(true)
|
||||
val swipeLayout = swipeLayout
|
||||
if (swipeLayout is ExtendedSwipeRefreshLayout) {
|
||||
swipeLayout.setTouchInterceptor(object : IExtendedView.TouchInterceptor {
|
||||
swipeLayout.touchInterceptor = object : IExtendedView.TouchInterceptor {
|
||||
override fun dispatchTouchEvent(view: View, event: MotionEvent): Boolean {
|
||||
scrollListener.touchListener.onTouch(view, event)
|
||||
return false
|
||||
@ -207,7 +207,7 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
||||
return false
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
} else {
|
||||
recyclerView.setOnTouchListener(scrollListener.touchListener)
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
|
||||
import org.mariotaku.twidere.view.TabPagerIndicator
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/16.
|
||||
@ -54,8 +55,8 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||
|
||||
addTabs(pagerAdapter)
|
||||
toolbarTabs.notifyDataSetChanged()
|
||||
|
||||
toolbarContainer.setOnSizeChangedListener { _, _, _, _, _ ->
|
||||
toolbarContainer.onSizeChangedListener = object : IExtendedView.OnSizeChangedListener {
|
||||
override fun onSizeChanged(view: View, w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
val pageLimit = viewPager.offscreenPageLimit
|
||||
val currentItem = viewPager.currentItem
|
||||
val count = pagerAdapter.count
|
||||
@ -69,6 +70,8 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
val initialTab = arguments?.getString(EXTRA_INITIAL_TAB)
|
||||
if (initialTab != null) {
|
||||
|
@ -145,6 +145,7 @@ import org.mariotaku.twidere.util.support.ViewSupport
|
||||
import org.mariotaku.twidere.util.support.WindowSupport
|
||||
import org.mariotaku.twidere.view.HeaderDrawerLayout.DrawerCallback
|
||||
import org.mariotaku.twidere.view.TabPagerIndicator
|
||||
import org.mariotaku.twidere.view.TintedStatusFrameLayout
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView.OnSizeChangedListener
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
@ -673,7 +674,8 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
})
|
||||
|
||||
|
||||
userFragmentView.setWindowInsetsListener { _, top, _, _ ->
|
||||
userFragmentView.windowInsetsListener = object : TintedStatusFrameLayout.WindowInsetsListener {
|
||||
override fun onApplyWindowInsets(left: Int, top: Int, right: Int, bottom: Int) {
|
||||
profileContentContainer.setPadding(0, top, 0, 0)
|
||||
profileBannerSpace.statusBarHeight = top
|
||||
|
||||
@ -685,12 +687,17 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
profileBannerSpace.toolbarHeight = toolbarHeight
|
||||
}
|
||||
}
|
||||
profileContentContainer.setOnSizeChangedListener { _, _, _, _, _ ->
|
||||
}
|
||||
|
||||
profileContentContainer.onSizeChangedListener = object : OnSizeChangedListener {
|
||||
override fun onSizeChanged(view: View, w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
val toolbarHeight = toolbar.measuredHeight
|
||||
userProfileDrawer.setPadding(0, toolbarHeight, 0, 0)
|
||||
profileBannerSpace.toolbarHeight = toolbarHeight
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userProfileDrawer.setDrawerCallback(this)
|
||||
|
||||
pagerAdapter = SupportTabsAdapter(activity, childFragmentManager)
|
||||
@ -710,7 +717,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
friendsContainer.setOnClickListener(this)
|
||||
errorIcon.setOnClickListener(this)
|
||||
urlContainer.setOnClickListener(this)
|
||||
profileBanner.setOnSizeChangedListener(this)
|
||||
profileBanner.onSizeChangedListener = this
|
||||
profileBannerSpace.setOnTouchListener(this)
|
||||
|
||||
userProfileSwipeLayout.setOnRefreshListener {
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.widget.FrameLayout
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
open class ExtendedFrameLayout(context: Context, attrs: AttributeSet? = null) :
|
||||
FrameLayout(context, attrs), IExtendedView {
|
||||
|
||||
override var touchInterceptor: IExtendedView.TouchInterceptor? = null
|
||||
override var onSizeChangedListener: IExtendedView.OnSizeChangedListener? = null
|
||||
override var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener? = null
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.dispatchTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.dispatchTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onInterceptTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onInterceptTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun fitSystemWindows(insets: Rect): Boolean {
|
||||
if (onFitSystemWindowsListener != null) {
|
||||
onFitSystemWindowsListener!!.onFitSystemWindows(insets)
|
||||
}
|
||||
return super.fitSystemWindows(insets)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
if (onSizeChangedListener != null) {
|
||||
onSizeChangedListener!!.onSizeChanged(this, w, h, oldw, oldh)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.support.v7.widget.AppCompatImageView
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
class ExtendedImageView(context: Context, attrs: AttributeSet? = null) :
|
||||
AppCompatImageView(context, attrs), IExtendedView {
|
||||
|
||||
override var onSizeChangedListener: IExtendedView.OnSizeChangedListener? = null
|
||||
override var touchInterceptor: IExtendedView.TouchInterceptor? = null
|
||||
override var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener? = null
|
||||
|
||||
|
||||
override fun fitSystemWindows(insets: Rect): Boolean {
|
||||
if (onFitSystemWindowsListener != null) {
|
||||
onFitSystemWindowsListener!!.onFitSystemWindows(insets)
|
||||
}
|
||||
return super.fitSystemWindows(insets)
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.dispatchTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.dispatchTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
if (onSizeChangedListener != null) {
|
||||
onSizeChangedListener!!.onSizeChanged(this, w, h, oldw, oldh)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.widget.LinearLayout
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
class ExtendedLinearLayout(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs), IExtendedView {
|
||||
|
||||
override var touchInterceptor: IExtendedView.TouchInterceptor? = null
|
||||
override var onSizeChangedListener: IExtendedView.OnSizeChangedListener? = null
|
||||
override var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener? = null
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.dispatchTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.dispatchTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onInterceptTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onInterceptTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun fitSystemWindows(insets: Rect): Boolean {
|
||||
if (onFitSystemWindowsListener != null) {
|
||||
onFitSystemWindowsListener!!.onFitSystemWindows(insets)
|
||||
}
|
||||
return super.fitSystemWindows(insets)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
if (onSizeChangedListener != null) {
|
||||
onSizeChangedListener!!.onSizeChanged(this, w, h, oldw, oldh)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -30,11 +30,12 @@ import android.widget.RelativeLayout
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
open class ExtendedRelativeLayout(context: Context, attrs: AttributeSet? = null) : RelativeLayout(context, attrs), IExtendedView {
|
||||
open class ExtendedRelativeLayout(context: Context, attrs: AttributeSet? = null) :
|
||||
RelativeLayout(context, attrs), IExtendedView {
|
||||
|
||||
private var touchInterceptor: IExtendedView.TouchInterceptor? = null
|
||||
private var onSizeChangedListener: IExtendedView.OnSizeChangedListener? = null
|
||||
private var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener? = null
|
||||
override var touchInterceptor: IExtendedView.TouchInterceptor? = null
|
||||
override var onSizeChangedListener: IExtendedView.OnSizeChangedListener? = null
|
||||
override var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener? = null
|
||||
private var usePaddingBackup: Boolean = false
|
||||
|
||||
private val paddingBackup = Rect()
|
||||
@ -65,18 +66,6 @@ open class ExtendedRelativeLayout(context: Context, attrs: AttributeSet? = null)
|
||||
return super.onInterceptTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun setOnFitSystemWindowsListener(listener: IExtendedView.OnFitSystemWindowsListener) {
|
||||
onFitSystemWindowsListener = listener
|
||||
}
|
||||
|
||||
override fun setOnSizeChangedListener(listener: IExtendedView.OnSizeChangedListener) {
|
||||
onSizeChangedListener = listener
|
||||
}
|
||||
|
||||
override fun setTouchInterceptor(listener: IExtendedView.TouchInterceptor) {
|
||||
touchInterceptor = listener
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Android")
|
||||
override fun fitSystemWindows(insets: Rect): Boolean {
|
||||
onFitSystemWindowsListener?.onFitSystemWindows(insets)
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
|
||||
import org.mariotaku.chameleon.view.ChameleonSwipeRefreshLayout
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/25.
|
||||
*/
|
||||
class ExtendedSwipeRefreshLayout(context: Context, attrs: AttributeSet? = null) :
|
||||
ChameleonSwipeRefreshLayout(context, attrs), IExtendedView {
|
||||
|
||||
override var touchInterceptor: IExtendedView.TouchInterceptor? = null
|
||||
override var onSizeChangedListener: IExtendedView.OnSizeChangedListener? = null
|
||||
override var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener? = null
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.dispatchTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.dispatchTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onInterceptTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onInterceptTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun fitSystemWindows(insets: Rect): Boolean {
|
||||
if (onFitSystemWindowsListener != null) {
|
||||
onFitSystemWindowsListener!!.onFitSystemWindows(insets)
|
||||
}
|
||||
return super.fitSystemWindows(insets)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
if (onSizeChangedListener != null) {
|
||||
onSizeChangedListener!!.onSizeChanged(this, w, h, oldw, oldh)
|
||||
}
|
||||
}
|
||||
}
|
@ -17,43 +17,34 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view;
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.content.Context
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
|
||||
public class ExtendedViewPager extends ViewPager {
|
||||
open class ExtendedViewPager(context: Context, attrs: AttributeSet? = null) : ViewPager(context, attrs) {
|
||||
|
||||
public ExtendedViewPager(final Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ExtendedViewPager(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (!isEnabled()) return false;
|
||||
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
||||
if (!isEnabled) return false
|
||||
try {
|
||||
return super.onTouchEvent(ev);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return super.onTouchEvent(ev)
|
||||
} catch (ex: IllegalArgumentException) {
|
||||
// Ignore
|
||||
}
|
||||
return false;
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (!isEnabled()) return false;
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
if (!isEnabled) return false
|
||||
try {
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return super.onInterceptTouchEvent(ev)
|
||||
} catch (ex: IllegalArgumentException) {
|
||||
// Ignore
|
||||
}
|
||||
return false;
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
class ProfileBannerImageView(context: Context, attrs: AttributeSet) :
|
||||
ForegroundImageView(context, attrs), IExtendedView {
|
||||
|
||||
override var onSizeChangedListener: IExtendedView.OnSizeChangedListener? = null
|
||||
override var touchInterceptor: IExtendedView.TouchInterceptor? = null
|
||||
override var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener? = null
|
||||
|
||||
var bannerAspectRatio: Float = 0.toFloat()
|
||||
|
||||
init {
|
||||
val a = context.obtainStyledAttributes(attrs, R.styleable.ProfileBannerImageView)
|
||||
bannerAspectRatio = a.getFraction(R.styleable.ProfileBannerImageView_bannerAspectRatio, 1, 1, 2f)
|
||||
a.recycle()
|
||||
scaleType = ImageView.ScaleType.CENTER_CROP
|
||||
}
|
||||
|
||||
@Deprecated("")
|
||||
override fun fitSystemWindows(insets: Rect): Boolean {
|
||||
if (onFitSystemWindowsListener != null) {
|
||||
onFitSystemWindowsListener!!.onFitSystemWindows(insets)
|
||||
}
|
||||
return super.fitSystemWindows(insets)
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.dispatchTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.dispatchTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (touchInterceptor != null) {
|
||||
val ret = touchInterceptor!!.onTouchEvent(this, event)
|
||||
if (ret) return true
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
val width = View.MeasureSpec.getSize(widthMeasureSpec)
|
||||
val height = Math.round(width / bannerAspectRatio)
|
||||
setMeasuredDimension(width, height)
|
||||
super.onMeasure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY))
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
if (onSizeChangedListener != null) {
|
||||
onSizeChangedListener!!.onSizeChanged(this, w, h, oldw, oldh)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Rect
|
||||
import android.os.Build
|
||||
import android.support.v4.view.ViewCompat
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import org.mariotaku.chameleon.Chameleon
|
||||
import org.mariotaku.chameleon.Chameleon.Theme.LightStatusBarMode
|
||||
import org.mariotaku.chameleon.ChameleonUtils
|
||||
import org.mariotaku.chameleon.ChameleonView
|
||||
import org.mariotaku.chameleon.internal.SupportMethods
|
||||
import org.mariotaku.twidere.R
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/11/26.
|
||||
*/
|
||||
class TintedStatusFrameLayout(context: Context, attrs: AttributeSet? = null) :
|
||||
ExtendedFrameLayout(context, attrs), TintedStatusLayout, ChameleonView,
|
||||
ChameleonView.StatusBarThemeable {
|
||||
|
||||
override var setPaddingEnabled: Boolean = false
|
||||
|
||||
private val colorPaint: Paint
|
||||
private var statusBarHeight: Int = 0
|
||||
private val systemWindowsInsets: Rect
|
||||
var windowInsetsListener: WindowInsetsListener? = null
|
||||
|
||||
init {
|
||||
val a = context.obtainStyledAttributes(attrs, R.styleable.TintedStatusLayout)
|
||||
setPaddingEnabled = a.getBoolean(R.styleable.TintedStatusLayout_setPadding, false)
|
||||
a.recycle()
|
||||
colorPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
systemWindowsInsets = Rect()
|
||||
setWillNotDraw(false)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
|
||||
val top = insets.systemWindowInsetTop
|
||||
val left = insets.systemWindowInsetLeft
|
||||
val right = insets.systemWindowInsetRight
|
||||
val bottom = insets.systemWindowInsetBottom
|
||||
if (setPaddingEnabled) {
|
||||
setPadding(left, top, right, bottom)
|
||||
}
|
||||
setStatusBarHeight(top)
|
||||
if (windowInsetsListener != null) {
|
||||
windowInsetsListener!!.onApplyWindowInsets(left, top, right, bottom)
|
||||
}
|
||||
insets.consumeSystemWindowInsets()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun setStatusBarColor(color: Int) {
|
||||
colorPaint.color = 0xFF000000.toInt() or color
|
||||
colorPaint.alpha = Color.alpha(color)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun setStatusBarHeight(height: Int) {
|
||||
statusBarHeight = height
|
||||
invalidate()
|
||||
}
|
||||
|
||||
override fun dispatchDraw(canvas: Canvas) {
|
||||
super.dispatchDraw(canvas)
|
||||
canvas.drawRect(0f, 0f, canvas.width.toFloat(), statusBarHeight.toFloat(), colorPaint)
|
||||
}
|
||||
|
||||
override fun fitSystemWindows(insets: Rect): Boolean {
|
||||
systemWindowsInsets.set(insets)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun isPostApplyTheme(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun createAppearance(context: Context, attributeSet: AttributeSet, theme: Chameleon.Theme): Appearance? {
|
||||
val appearance = Appearance()
|
||||
appearance.statusBarColor = theme.statusBarColor
|
||||
appearance.lightStatusBarMode = theme.lightStatusBarMode
|
||||
return appearance
|
||||
}
|
||||
|
||||
override fun applyAppearance(appearance: ChameleonView.Appearance) {
|
||||
val a = appearance as Appearance
|
||||
val statusBarColor = a.statusBarColor
|
||||
setStatusBarColor(statusBarColor)
|
||||
val activity = ChameleonUtils.getActivity(context)
|
||||
if (activity != null) {
|
||||
val window = activity.window
|
||||
SupportMethods.setStatusBarColor(window, Color.TRANSPARENT)
|
||||
ChameleonUtils.applyLightStatusBar(window, statusBarColor, a.lightStatusBarMode)
|
||||
}
|
||||
}
|
||||
|
||||
override fun isStatusBarColorHandled(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
class Appearance : ChameleonView.Appearance {
|
||||
var statusBarColor: Int = 0
|
||||
@LightStatusBarMode
|
||||
@get:LightStatusBarMode
|
||||
var lightStatusBarMode: Int = 0
|
||||
}
|
||||
|
||||
interface WindowInsetsListener {
|
||||
fun onApplyWindowInsets(left: Int, top: Int, right: Int, bottom: Int)
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -17,14 +17,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view.iface;
|
||||
package org.mariotaku.twidere.view
|
||||
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/27.
|
||||
*/
|
||||
public interface TintedStatusLayout extends IExtendedView {
|
||||
void setStatusBarColor(int color);
|
||||
interface TintedStatusLayout : IExtendedView {
|
||||
fun setStatusBarColor(color: Int)
|
||||
|
||||
void setSetPaddingEnabled(boolean enabled);
|
||||
var setPaddingEnabled: Boolean
|
||||
|
||||
}
|
@ -17,35 +17,33 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.view.iface;
|
||||
package org.mariotaku.twidere.view.iface
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.graphics.Rect
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
|
||||
public interface IExtendedView {
|
||||
interface IExtendedView {
|
||||
|
||||
void setOnFitSystemWindowsListener(final OnFitSystemWindowsListener listener);
|
||||
|
||||
void setOnSizeChangedListener(final OnSizeChangedListener listener);
|
||||
|
||||
void setTouchInterceptor(final TouchInterceptor listener);
|
||||
var touchInterceptor: IExtendedView.TouchInterceptor?
|
||||
var onSizeChangedListener: IExtendedView.OnSizeChangedListener?
|
||||
var onFitSystemWindowsListener: IExtendedView.OnFitSystemWindowsListener?
|
||||
|
||||
interface OnFitSystemWindowsListener {
|
||||
void onFitSystemWindows(Rect insets);
|
||||
fun onFitSystemWindows(insets: Rect)
|
||||
}
|
||||
|
||||
interface OnSizeChangedListener {
|
||||
void onSizeChanged(View view, int w, int h, int oldw, int oldh);
|
||||
fun onSizeChanged(view: View, w: Int, h: Int, oldw: Int, oldh: Int)
|
||||
}
|
||||
|
||||
interface TouchInterceptor {
|
||||
|
||||
boolean dispatchTouchEvent(View view, MotionEvent event);
|
||||
fun dispatchTouchEvent(view: View, event: MotionEvent): Boolean
|
||||
|
||||
boolean onInterceptTouchEvent(View view, MotionEvent event);
|
||||
fun onInterceptTouchEvent(view: View, event: MotionEvent): Boolean
|
||||
|
||||
boolean onTouchEvent(View view, MotionEvent event);
|
||||
fun onTouchEvent(view: View, event: MotionEvent): Boolean
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user