Fix per-conversation themeing

This commit is contained in:
Moez Bhatti
2016-04-17 17:36:22 -04:00
parent 448d744406
commit 5c40323ce0
3 changed files with 26 additions and 9 deletions
@@ -24,6 +24,10 @@ import java.util.List;
public class SwipeBackLayout extends FrameLayout {
private final String TAG = "SwipeBackLayout";
public interface ScrollChangedListener {
void onScrollChanged(float scrollPercent);
}
private static final int MIN_FLING_VELOCITY = 400; // dips per second
private static final int DEFAULT_SCRIM_COLOR = 0x99000000;
private static final int FULL_ALPHA = 255;
@@ -68,9 +72,9 @@ public class SwipeBackLayout extends FrameLayout {
* The set of listeners to be sent events through.
*/
private List<SwipeListener> mListeners;
private ScrollChangedListener mScrollChangedListener;
private Drawable mShadowLeft;
private Drawable mShadowRight;
private Drawable mShadowBottom;
private float mScrimOpacity;
@@ -183,6 +187,10 @@ public class SwipeBackLayout extends FrameLayout {
mListeners.remove(listener);
}
public void setScrollChangedListener(ScrollChangedListener listener) {
mScrollChangedListener = listener;
}
public interface SwipeListener {
/**
* Invoke when state change
@@ -423,12 +431,15 @@ public class SwipeBackLayout extends FrameLayout {
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
super.onViewPositionChanged(changedView, left, top, dx, dy);
if ((mTrackingEdge & EDGE_LEFT) != 0) {
mScrollPercent = Math.abs((float) left
/ (mContentView.getWidth() + mShadowLeft.getIntrinsicWidth()));
mScrollPercent = Math.abs((float) left / (mContentView.getWidth() + mShadowLeft.getIntrinsicWidth()));
} else if ((mTrackingEdge & EDGE_BOTTOM) != 0) {
mScrollPercent = Math.abs((float) top
/ (mContentView.getHeight() + mShadowBottom.getIntrinsicHeight()));
mScrollPercent = Math.abs((float) top / (mContentView.getHeight() + mShadowBottom.getIntrinsicHeight()));
}
if (mScrollChangedListener != null) {
mScrollChangedListener.onScrollChanged(mScrollPercent);
}
mContentLeft = left;
mContentTop = top;
invalidate();
@@ -74,6 +74,7 @@ public class MessageListActivity extends QKSwipeBackActivity {
if (mThreadId != -1) {
Log.v(TAG, "Opening thread: " + mThreadId);
MessageListFragment fragment = MessageListFragment.getInstance(mThreadId, mRowId, mHighlight, mShowImmediate);
mSwipeBackLayout.setScrollChangedListener(fragment);
getFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, fragment)
@@ -45,6 +45,7 @@ import com.moez.QKSMS.common.CIELChEvaluator;
import com.moez.QKSMS.common.ConversationPrefsHelper;
import com.moez.QKSMS.common.DialogHelper;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.ui.SwipeBackLayout;
import com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog;
import com.moez.QKSMS.enums.QKPreference;
import com.moez.QKSMS.common.utils.KeyboardUtils;
@@ -80,7 +81,7 @@ import java.util.HashSet;
import java.util.List;
public class MessageListFragment extends QKContentFragment implements ActivityLauncher, SensorEventListener,
LoaderManager.LoaderCallbacks<Cursor>, RecyclerCursorAdapter.MultiSelectListener,
LoaderManager.LoaderCallbacks<Cursor>, RecyclerCursorAdapter.MultiSelectListener, SwipeBackLayout.ScrollChangedListener,
RecyclerCursorAdapter.ItemClickListener<MessageItem> {
private final String TAG = "MessageListFragment";
@@ -641,9 +642,6 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
@Override
public void onMenuChanging(float percentOpen) {
if (mConversationPrefs != null) {
ThemeManager.setActiveColor(mCIELChEvaluator.evaluate(percentOpen));
}
}
@Override
@@ -706,6 +704,13 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
}
@Override
public void onScrollChanged(float scrollPercent) {
if (mConversationPrefs != null) {
ThemeManager.setActiveColor(mCIELChEvaluator.evaluate(scrollPercent));
}
}
private class DeleteMessageListener implements DialogInterface.OnClickListener {
private final MessageItem mMessageItem;