Disable tab switching in media overview during multiselect.
Multiselect only applies to items in the "media" tab, so people shouldn't be able to switch tabs during multiselect.pull/1/head
parent
a0ab252bc9
commit
84c71fce16
@ -0,0 +1,41 @@
|
|||||||
|
package org.thoughtcrime.securesms.components;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.design.widget.TabLayout;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of {@link TabLayout} that disables taps when the view is disabled.
|
||||||
|
*/
|
||||||
|
public class ControllableTabLayout extends TabLayout {
|
||||||
|
|
||||||
|
private List<View> touchables;
|
||||||
|
|
||||||
|
public ControllableTabLayout(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllableTabLayout(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllableTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
if (isEnabled() && !enabled) {
|
||||||
|
touchables = getTouchables();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (View touchable : touchables) {
|
||||||
|
touchable.setClickable(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package org.thoughtcrime.securesms.components;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of {@link ViewPager} that disables swiping when the view is disabled.
|
||||||
|
*/
|
||||||
|
public class ControllableViewPager extends ViewPager {
|
||||||
|
|
||||||
|
public ControllableViewPager(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllableViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
|
return isEnabled() && super.onTouchEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
return isEnabled() && super.onInterceptTouchEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue