Permalink
Browse files

used SlidingPanel from Superuser app instead of my own implemention.

  • Loading branch information...
mariotaku committed Nov 17, 2012
1 parent 10c1db9 commit e8d145f3e00a3c2e6f7a8ca05f6cad0b76536dd6
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <LinearLayout
+ android:id="@+id/main_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <org.mariotaku.twidere.view.ExtendedFrameLayout
+ android:id="@+id/panel_anchor"
+ android:layout_width="@dimen/pane_left_width"
+ android:layout_height="match_parent"
+ android:layout_weight="0">
+
+ <org.mariotaku.twidere.view.ExtendedViewPager
+ android:id="@+id/main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+ <FrameLayout
+ android:id="@+id/fragment_container_left"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+ </org.mariotaku.twidere.view.ExtendedFrameLayout>
+
+ <FrameLayout
+ android:id="@+id/fragment_container_right"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"/>
+ </LinearLayout>
+
+ <ImageButton
+ android:id="@+id/button_compose"
+ android:layout_width="56dp"
+ android:layout_height="56dp"
+ android:layout_gravity="bottom|right"
+ android:contentDescription="@string/compose"
+ android:onClick="onClick"
+ android:src="@drawable/ic_menu_tweet"/>
+
+</merge>
View
@@ -2,7 +2,7 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<org.mariotaku.twidere.view.ExtendedViewPager
- android:id="@+id/pager"
+ android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
@@ -1,52 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:twidere="http://schemas.android.com/apk/res/org.mariotaku.twidere">
- <FrameLayout
+ <org.mariotaku.twidere.view.SlidingPanel
android:id="@+id/main_container"
android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:id="@+id/left_pane_layer"
+ android:layout_height="match_parent"
+ twidere:anchor="@+id/panel_anchor"
+ twidere:button="@+id/panel_button"
+ twidere:content="@+id/fragment_container_right"
+ twidere:openOverlap="4dp"
+ twidere:closedLimit="@dimen/pane_closed_limit">
+
+ <Button
+ android:id="@+id/panel_button"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="horizontal">
-
- <org.mariotaku.twidere.view.ExtendedFrameLayout
- android:id="@+id/left_pane_container"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="@integer/pane_left_content_weight">
-
- <FrameLayout
- android:id="@+id/main"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <org.mariotaku.twidere.view.ExtendedViewPager
- android:id="@+id/pager"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
- </FrameLayout>
-
- <FrameLayout
- android:id="@+id/left_pane"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
- </org.mariotaku.twidere.view.ExtendedFrameLayout>
+ android:layout_height="64dp"/>
+
+ <org.mariotaku.twidere.view.ExtendedFrameLayout
+ android:id="@+id/panel_anchor"
+ android:layout_width="@dimen/pane_left_width"
+ android:layout_height="match_parent">
+
+ <org.mariotaku.twidere.view.ExtendedViewPager
+ android:id="@+id/main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+ <FrameLayout
+ android:id="@+id/fragment_container_left"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
<View
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="@integer/pane_left_shadow_weight"/>
- </LinearLayout>
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+ </org.mariotaku.twidere.view.ExtendedFrameLayout>
- <org.mariotaku.twidere.view.SlidePane
- android:id="@+id/right_pane_layer"
+ <FrameLayout
+ android:id="@+id/fragment_container_right"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
- </FrameLayout>
+ </org.mariotaku.twidere.view.SlidingPanel>
<ImageButton
android:id="@+id/button_compose"
View
@@ -9,7 +9,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
- <FrameLayout
+ <org.mariotaku.twidere.view.ExtendedFrameLayout
android:id="@+id/status_container"
android:layout_width="match_parent"
android:layout_height="0dp"
@@ -30,4 +30,4 @@
android:layout_gravity="center"
android:visibility="gone"/>
-</FrameLayout>
+</FrameLayout>
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <dimen name="pane_left_width">420dp</dimen>
+
+</resources>
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <dimen name="pane_left_width">375dp</dimen>
+ <dimen name="pane_closed_limit">150dp</dimen>
+
+</resources>
View
@@ -11,5 +11,13 @@
<attr name="tabTextStyle" format="reference"/>
<attr name="tabBackground" format="reference"/>
</declare-styleable>
+ <declare-styleable name="SlidingPanel">
+ <attr name="button" format="reference" />
+ <attr name="anchor" format="reference" />
+ <attr name="content" format="reference" />
+ <attr name="openOverlap" format="dimension" />
+ <attr name="closedLimit" format="dimension" />
+ </declare-styleable>
+
</resources>
View
@@ -10,5 +10,7 @@
<dimen name="notification_large_icon_width">64dp</dimen>
<!-- The width of the big icons in notifications. -->
<dimen name="notification_large_icon_height">64dp</dimen>
+ <dimen name="pane_left_width">300dp</dimen>
+ <dimen name="pane_closed_limit">120dp</dimen>
</resources>
@@ -471,9 +471,8 @@
public static final String DIR_NAME_PROFILE_IMAGES = "profile_images";
public static final String DIR_NAME_CACHED_THUMBNAILS = "cached_thumbnails";
- public static final int PANE_LEFT = R.id.left_pane;
- public static final int PANE_LEFT_CONTAINER = R.id.left_pane_container;
- public static final int PANE_RIGHT = R.id.right_pane;
+ public static final int PANE_LEFT = R.id.fragment_container_left;
+ public static final int PANE_RIGHT = R.id.fragment_container_right;
public static final int PANE_RIGHT_CONTAINER = R.id.right_pane_container;
public static final int NOTIFICATION_ID_HOME_TIMELINE = 1;
@@ -22,7 +22,6 @@
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.Panes;
import org.mariotaku.twidere.view.ExtendedFrameLayout;
-import org.mariotaku.twidere.view.ExtendedFrameLayout.TouchInterceptor;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -41,41 +40,30 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import org.mariotaku.twidere.view.SlidePane;
@SuppressLint("Registered")
public class DualPaneActivity extends BaseActivity implements OnBackStackChangedListener {
private SharedPreferences mPreferences;
- private FrameLayout mLeftPaneContainer, mRightPaneContainer;
- private ViewGroup mLeftPaneLayer, mRightPaneLayer;
+ private FrameLayout mFragmentContainerLeft, mFragmentContainerRight;
private Fragment mDetailsFragment;
private boolean mDualPaneInPortrait, mDualPaneInLandscape;
public final void bringLeftPaneToFront() {
- if (mRightPaneLayer instanceof SlidePane) {
- ((SlidePane)mRightPaneLayer).close();
- }
}
public final void bringRightPaneToFront() {
- if (mRightPaneLayer instanceof SlidePane) {
- ((SlidePane)mRightPaneLayer).open();
- }
}
public Fragment getDetailsFragment() {
return mDetailsFragment;
}
public final boolean isDualPaneMode() {
- if (!(findViewById(PANE_LEFT_CONTAINER) instanceof ViewGroup && findViewById(PANE_RIGHT_CONTAINER) instanceof ViewGroup))
- return false;
- final View main_container = findViewById(R.id.main_container);
- return main_container != null && main_container instanceof FrameLayout;
+ return findViewById(PANE_LEFT) instanceof ViewGroup && findViewById(PANE_RIGHT) instanceof ViewGroup;
}
@Override
@@ -104,9 +92,8 @@ public void onBackStackChanged() {
bringRightPaneToFront();
}
}
- mRightPaneContainer.setBackgroundResource(getPaneBackground());
if (main_view != null) {
- main_view.setVisibility(left_pane_used ? View.GONE : View.VISIBLE);
+ //main_view.setVisibility(left_pane_used ? View.GONE : View.VISIBLE);
}
}
}
@@ -115,13 +102,8 @@ public void onBackStackChanged() {
public void onContentChanged() {
super.onContentChanged();
if (isDualPaneMode()) {
- mLeftPaneContainer = (FrameLayout) findViewById(R.id.left_pane_container);
- mLeftPaneLayer = (ViewGroup) findViewById(R.id.left_pane_layer);
- mRightPaneContainer = (FrameLayout) findViewById(R.id.right_pane_container);
- mRightPaneLayer = (ViewGroup) findViewById(R.id.right_pane_layer);
- if (mRightPaneLayer instanceof SlidePane) {
- ((SlidePane)mRightPaneLayer).closeNoAnimation();
- }
+ mFragmentContainerLeft = (FrameLayout) findViewById(PANE_LEFT);
+ mFragmentContainerRight = (FrameLayout) findViewById(PANE_RIGHT);
}
}
@@ -146,8 +128,8 @@ public void onCreate(final Bundle savedInstanceState) {
break;
}
setContentView(layout);
- if (mRightPaneContainer != null) {
- mRightPaneContainer.setBackgroundResource(getPaneBackground());
+ if (mFragmentContainerRight != null) {
+ mFragmentContainerRight.setBackgroundResource(getPaneBackground());
}
getSupportFragmentManager().addOnBackStackChangedListener(this);
}
@@ -165,7 +165,7 @@ public void onClick(final View v) {
@Override
public void onContentChanged() {
super.onContentChanged();
- mViewPager = (ExtendedViewPager) findViewById(R.id.pager);
+ mViewPager = (ExtendedViewPager) findViewById(R.id.main);
mComposeButton = (ImageButton) findViewById(R.id.button_compose);
}
@@ -65,6 +65,7 @@
import org.mariotaku.twidere.util.SynchronizedStateSavedList;
import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.view.ColorLabelRelativeLayout;
+import org.mariotaku.twidere.view.ExtendedFrameLayout;
import twitter4j.Relationship;
import twitter4j.Twitter;
@@ -96,8 +97,6 @@
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
-import android.view.ViewTreeObserver;
-import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -155,7 +154,7 @@
private Gallery mGallery;
private View mStatusView;
private View mLoadImagesIndicator;
- private FrameLayout mStatusContainer;
+ private ExtendedFrameLayout mStatusContainer;
private ListView mListView;
private ParcelableStatus mStatus;
@@ -428,14 +427,15 @@ public boolean onMenuItemClick(final MenuItem item) {
}
};
- private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() {
+ private final ExtendedFrameLayout.OnSizeChangedListener mOnSizeChangedListener = new ExtendedFrameLayout.OnSizeChangedListener() {
+
@Override
- public void onGlobalLayout() {
- // mMainContent.getViewTreeObserver().removeGlobalOnLayoutListener(this);
+ public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
if (getActivity() == null) return;
final float density = getResources().getDisplayMetrics().density;
- mStatusView.setMinimumHeight((int) (mStatusContainer.getHeight() - density * 2));
+ mStatusView.setMinimumHeight(h - (int) (density * 2));
}
+
};
public void displayStatus(final ParcelableStatus status) {
@@ -638,14 +638,11 @@ public void onClick(final View view) {
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.status, null, false);
mMainContent = view.findViewById(R.id.content);
- final ViewTreeObserver observer = mMainContent.getViewTreeObserver();
- if (observer.isAlive()) {
- observer.addOnGlobalLayoutListener(mOnGlobalLayoutListener);
- }
mStatusLoadProgress = (ProgressBar) view.findViewById(R.id.status_load_progress);
mMenuBar = (MenuBar) view.findViewById(R.id.menu_bar);
- mStatusContainer = (FrameLayout) view.findViewById(R.id.status_container);
+ mStatusContainer = (ExtendedFrameLayout) view.findViewById(R.id.status_container);
mStatusContainer.addView(super.onCreateView(inflater, container, savedInstanceState));
+ mStatusContainer.setOnSizeChangedListener(mOnSizeChangedListener);
mStatusView = inflater.inflate(R.layout.status_content, null, false);
mImagesPreviewContainer = mStatusView.findViewById(R.id.images_preview);
mLocationView = (TextView) mStatusView.findViewById(R.id.location_view);
@@ -0,0 +1,24 @@
+package org.mariotaku.twidere.util;
+
+import android.view.MotionEvent;
+import android.view.View;
+
+public interface ExtendedViewInterface {
+
+ public void setOnSizeChangedListener(final OnSizeChangedListener listener);
+
+ public void setTouchInterceptor(final TouchInterceptor listener);
+
+ public static interface OnSizeChangedListener {
+ void onSizeChanged(View view, int w, int h, int oldw, int oldh);
+ }
+
+ public static interface TouchInterceptor {
+
+ boolean onInterceptTouchEvent(View view, MotionEvent event);
+
+ boolean onTouchEvent(View view, MotionEvent event);
+
+ }
+
+}
Oops, something went wrong.

0 comments on commit e8d145f

Please sign in to comment.