Use layout-sw600dp-land for tablets instead of refs.xml
This commit is contained in:
parent
120fe02a3c
commit
4f188ff74e
8 changed files with 111 additions and 141 deletions
|
@ -107,16 +107,9 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
|||
private FavIconHandler favIconHandler;
|
||||
|
||||
LayoutInflater inflater;
|
||||
boolean mIsTwoPane;
|
||||
public static boolean isTwoPane(Context context) {
|
||||
return context.getResources().getBoolean(R.bool.two_pane);
|
||||
//return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
||||
}
|
||||
|
||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnectionOrm dbConn, ListView listView)
|
||||
{
|
||||
mIsTwoPane = isTwoPane(mContext);
|
||||
|
||||
favIconHandler = new FavIconHandler(mContext);
|
||||
|
||||
this.inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
|
|
@ -48,6 +48,7 @@ import android.widget.Toast;
|
|||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import butterknife.Optional;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
||||
import de.luhmer.owncloudnewsreader.LoginDialogFragment.LoginSuccessfullListener;
|
||||
|
@ -93,7 +94,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
private static IReader _Reader;
|
||||
|
||||
@InjectView(R.id.toolbar) Toolbar toolbar;
|
||||
@InjectView(R.id.drawer_layout) protected DrawerLayout drawerLayout;
|
||||
@Optional @InjectView(R.id.drawer_layout) protected DrawerLayout drawerLayout;
|
||||
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
|
||||
|
@ -130,30 +131,33 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
.replace(R.id.left_drawer, newsReaderListFragment)
|
||||
.commit();
|
||||
|
||||
drawerToggle = new ActionBarDrawerToggle(this,drawerLayout, toolbar, R.string.empty_view_content,R.string.empty_view_content) {
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
super.onDrawerClosed(drawerView);
|
||||
togglePodcastVideoViewAnimation();
|
||||
if(drawerLayout != null) {
|
||||
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.empty_view_content, R.string.empty_view_content) {
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
super.onDrawerClosed(drawerView);
|
||||
togglePodcastVideoViewAnimation();
|
||||
|
||||
syncState();
|
||||
EventBus.getDefault().post(new FeedPanelSlideEvent(false));
|
||||
}
|
||||
syncState();
|
||||
EventBus.getDefault().post(new FeedPanelSlideEvent(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
super.onDrawerOpened(drawerView);
|
||||
togglePodcastVideoViewAnimation();
|
||||
reloadCountNumbersOfSlidingPaneAdapter();
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
super.onDrawerOpened(drawerView);
|
||||
togglePodcastVideoViewAnimation();
|
||||
reloadCountNumbersOfSlidingPaneAdapter();
|
||||
|
||||
syncState();
|
||||
}
|
||||
};
|
||||
syncState();
|
||||
}
|
||||
};
|
||||
|
||||
drawerLayout.setDrawerListener(drawerToggle);
|
||||
drawerLayout.setDrawerListener(drawerToggle);
|
||||
}
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
drawerToggle.syncState();
|
||||
if(drawerToggle != null)
|
||||
drawerToggle.syncState();
|
||||
|
||||
if(savedInstanceState == null)//When the app starts (no orientation change)
|
||||
{
|
||||
|
@ -226,9 +230,9 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
|
||||
|
||||
StartDetailFragment(savedInstanceState.getLong(OPTIONAL_FOLDER_ID),
|
||||
savedInstanceState.getBoolean(IS_FOLDER_BOOLEAN),
|
||||
savedInstanceState.getLong(ID_FEED_STRING),
|
||||
false);
|
||||
savedInstanceState.getBoolean(IS_FOLDER_BOOLEAN),
|
||||
savedInstanceState.getLong(ID_FEED_STRING),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,13 +250,15 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
@Override
|
||||
public void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
drawerToggle.syncState();
|
||||
if(drawerToggle != null)
|
||||
drawerToggle.syncState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
drawerToggle.onConfigurationChanged(newConfig);
|
||||
if(drawerToggle != null)
|
||||
drawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void reloadCountNumbersOfSlidingPaneAdapter() {
|
||||
|
@ -275,10 +281,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
super.onResume();
|
||||
}
|
||||
|
||||
public boolean shouldDrawerStayOpen() {
|
||||
return getResources().getBoolean(R.bool.two_pane);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
startSync();
|
||||
|
@ -290,7 +292,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
*/
|
||||
@Override
|
||||
public void onTopItemClicked(long idFeed, boolean isFolder, Long optional_folder_id) {
|
||||
if(!shouldDrawerStayOpen())
|
||||
if(drawerLayout != null)
|
||||
drawerLayout.closeDrawer(GravityCompat.START);
|
||||
|
||||
StartDetailFragment(idFeed, isFolder, optional_folder_id, true);
|
||||
|
@ -298,7 +300,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
|
||||
@Override
|
||||
public void onChildItemClicked(long idFeed, Long optional_folder_id) {
|
||||
if(!shouldDrawerStayOpen())
|
||||
if(drawerLayout != null)
|
||||
drawerLayout.closeDrawer(GravityCompat.START);
|
||||
|
||||
//StartDetailFragment(idSubscription, false, optional_folder_id);
|
||||
|
@ -404,10 +406,12 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
@Override
|
||||
public void onBackPressed() {
|
||||
if(handlePodcastBackPressed());
|
||||
if(drawerLayout.isDrawerOpen(GravityCompat.START))
|
||||
super.onBackPressed();
|
||||
else
|
||||
drawerLayout.openDrawer(GravityCompat.START);
|
||||
if(drawerLayout != null) {
|
||||
if (drawerLayout.isDrawerOpen(GravityCompat.START))
|
||||
super.onBackPressed();
|
||||
else
|
||||
drawerLayout.openDrawer(GravityCompat.START);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int RESULT_SETTINGS = 15642;
|
||||
|
@ -415,7 +419,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(drawerToggle.onOptionsItemSelected(item))
|
||||
if(drawerToggle != null && drawerToggle.onOptionsItemSelected(item))
|
||||
return true;
|
||||
switch (item.getItemId()) {
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.content.res.Resources;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
|
@ -426,17 +427,15 @@ public class PodcastFragmentActivity extends AppCompatActivity implements IPlayP
|
|||
public void togglePodcastVideoViewAnimation() {
|
||||
boolean isLeftSliderOpen = false;
|
||||
|
||||
if(this instanceof NewsReaderListActivity) {
|
||||
isLeftSliderOpen = ((NewsReaderListActivity) this).drawerLayout.isDrawerOpen(Gravity.LEFT);
|
||||
if(this instanceof NewsReaderListActivity && ((NewsReaderListActivity) this).drawerLayout != null) {
|
||||
isLeftSliderOpen = ((NewsReaderListActivity) this).drawerLayout.isDrawerOpen(GravityCompat.START);
|
||||
}
|
||||
|
||||
boolean isTabletView = SubscriptionExpandableListAdapter.isTwoPane(this);
|
||||
|
||||
int podcastMediaControlHeightDp = pxToDp((int) getResources().getDimension(R.dimen.podcast_media_control_height));
|
||||
|
||||
if(isTabletView && sliding_layout.getPanelState().equals(SlidingUpPanelLayout.PanelState.EXPANDED)) { //On Tablets
|
||||
if(sliding_layout.getPanelState().equals(SlidingUpPanelLayout.PanelState.EXPANDED)) { //On Tablets
|
||||
animateToPosition(podcastMediaControlHeightDp);
|
||||
} else if(!isTabletView && isLeftSliderOpen)
|
||||
} else if(isLeftSliderOpen)
|
||||
animateToPosition(0);
|
||||
else if(sliding_layout.getPanelState().equals(SlidingUpPanelLayout.PanelState.EXPANDED)) {
|
||||
animateToPosition(podcastMediaControlHeightDp);
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<de.luhmer.owncloudnewsreader.view.PodcastSlidingUpPanelLayout
|
||||
xmlns:sothree="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/tools"
|
||||
android:id="@+id/sliding_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
sothree:umanoPanelHeight="68dp"
|
||||
sothree:umanoParalaxOffset="100dp"
|
||||
sothree:umanoShadowHeight="4dp"> <!-- sothree:dragView="@+id/name" -->
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="@dimen/navigation_max_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start" />
|
||||
|
||||
<fragment
|
||||
class="de.luhmer.owncloudnewsreader.NewsReaderDetailFragment"
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?android:actionBarSize"
|
||||
app:layout="@layout/fragment_newsreader_detail" />
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar_layout"
|
||||
layout="@layout/toolbar_layout" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<de.luhmer.owncloudnewsreader.view.ZoomableRelativeLayout
|
||||
android:id="@+id/videoPodcastSurfaceWrapper"
|
||||
android:layout_width="@dimen/podcast_video_player_width"
|
||||
android:layout_height="100dp"
|
||||
android:background="#ff7c7c7c"
|
||||
android:padding="2dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginRight="@dimen/podcast_horizontal_margin"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin" >
|
||||
|
||||
</de.luhmer.owncloudnewsreader.view.ZoomableRelativeLayout>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/podcast_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</de.luhmer.owncloudnewsreader.view.PodcastSlidingUpPanelLayout>
|
|
@ -1,70 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar_layout" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/toolbar">
|
||||
|
||||
<android.support.v4.widget.SlidingPaneLayout
|
||||
android:id="@+id/sliding_pane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<!-- android:name="de.luhmer.owncloudnewsreader.NewsReaderListFragment" -->
|
||||
<FrameLayout
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="350dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start" />
|
||||
|
||||
<!-- android:name="de.luhmer.owncloudnewsreader.NewsReaderDetailFragment" -->
|
||||
|
||||
<de.luhmer.owncloudnewsreader.view.PodcastSlidingUpPanelLayout
|
||||
xmlns:sothree="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/sliding_layout"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="bottom"
|
||||
sothree:umanoPanelHeight="68dp"
|
||||
sothree:umanoShadowHeight="4dp"
|
||||
sothree:umanoParalaxOffset="100dp"> <!-- sothree:dragView="@+id/name" -->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/podcast_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</de.luhmer.owncloudnewsreader.view.PodcastSlidingUpPanelLayout>
|
||||
|
||||
|
||||
</android.support.v4.widget.SlidingPaneLayout>
|
||||
|
||||
<de.luhmer.owncloudnewsreader.view.ZoomableRelativeLayout
|
||||
android:id="@+id/videoPodcastSurfaceWrapper"
|
||||
android:layout_width="@dimen/podcast_video_player_width"
|
||||
android:layout_height="100dp"
|
||||
android:background="#ff7c7c7c"
|
||||
android:padding="2dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginRight="@dimen/podcast_horizontal_margin"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin" >
|
||||
|
||||
</de.luhmer.owncloudnewsreader.view.ZoomableRelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
|
@ -1,8 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw600dp devices (e.g. 7" tablets) here.
|
||||
-->
|
||||
|
||||
</resources>
|
|
@ -1,14 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Layout alias to replace the single-pane version of the layout with a
|
||||
two-pane version on Large screens.
|
||||
|
||||
For more on layout aliases, see:
|
||||
http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
|
||||
-->
|
||||
|
||||
|
||||
<item name="activity_newsreader" type="layout">@layout/activity_newsreader_twopane</item>
|
||||
<bool name="two_pane">true</bool>
|
||||
</resources>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="two_pane">false</bool>
|
||||
|
||||
<attr name="dividerLineColor" format="color" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue