diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/WelcomeFragmentSignIn.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/WelcomeFragmentSignIn.java index d1541f48eb92..4f9010ca1185 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/WelcomeFragmentSignIn.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/WelcomeFragmentSignIn.java @@ -177,7 +177,7 @@ private void setSecondaryButtonVisible(boolean visible) { private void moveBottomButtons() { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mBottomButtonsLayout.setOrientation(LinearLayout.HORIZONTAL); - if (getResources().getInteger(R.integer.isTablet) == 0) { + if (getResources().getInteger(R.integer.isSW600DP) == 0) { setSecondaryButtonVisible(true); } else { setSecondaryButtonVisible(false); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index bb26d4cbd1c9..0ba3b8bbaf66 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -3,6 +3,9 @@ import android.app.ActionBar; import android.app.AlertDialog; import android.app.AlertDialog.Builder; +import android.app.Fragment; +import android.app.FragmentManager; +import android.app.FragmentTransaction; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; @@ -10,9 +13,6 @@ import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Bundle; -import android.app.Fragment; -import android.app.FragmentManager; -import android.app.FragmentTransaction; import android.text.TextUtils; import android.view.ActionMode; import android.view.Gravity; @@ -41,10 +41,9 @@ import org.wordpress.android.ui.media.MediaGridFragment.Filter; import org.wordpress.android.ui.media.MediaGridFragment.MediaGridListener; import org.wordpress.android.ui.media.MediaItemFragment.MediaItemFragmentCallback; +import org.wordpress.android.ui.media.services.MediaDeleteService; import org.wordpress.android.ui.posts.EditPostActivity; import org.wordpress.android.ui.posts.EditPostContentFragment; -import org.wordpress.android.ui.media.services.MediaDeleteService; -import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.widgets.WPAlertDialogFragment; import org.xmlrpc.android.ApiHelper; import org.xmlrpc.android.ApiHelper.GetFeatures.Callback; @@ -308,12 +307,13 @@ public void onBlogChanged() { @Override public void onMediaItemSelected(String mediaId) { - if (mSearchView != null) + if (mSearchView != null) { mSearchView.clearFocus(); + } - // collapse the search menu on phone - if (mSearchMenuItem != null && !DisplayUtils.isTablet(this)) + if (mSearchMenuItem != null) { mSearchMenuItem.collapseActionView(); + } FragmentManager fm = getFragmentManager(); @@ -443,7 +443,6 @@ public void onClick(DialogInterface dialog, int which) { @Override public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_delete).setVisible(DisplayUtils.isTablet(this)); return super.onPrepareOptionsMenu(menu); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGalleryActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGalleryActivity.java index dc2b00476836..c1422f600bd5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGalleryActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGalleryActivity.java @@ -17,7 +17,6 @@ import org.wordpress.android.WordPress; import org.wordpress.android.models.MediaGallery; import org.wordpress.android.ui.media.MediaGallerySettingsFragment.MediaGallerySettingsCallback; -import org.wordpress.android.util.BlogUtils; import org.wordpress.android.util.DisplayUtils; import java.util.ArrayList; @@ -175,15 +174,11 @@ private void handleSaveMedia() { @Override public void onBackPressed() { - if (DisplayUtils.isTablet(this)) { - super.onBackPressed(); + if (mSlidingPanelLayout != null && !mIsPanelCollapsed) { + mSlidingPanelLayout.collapsePane(); } else { - if (mSlidingPanelLayout != null && !mIsPanelCollapsed) - mSlidingPanelLayout.collapsePane(); - else - super.onBackPressed(); + super.onBackPressed(); } - } @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGallerySettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGallerySettingsFragment.java index 2b706c771521..2530124603b9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGallerySettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGallerySettingsFragment.java @@ -18,8 +18,6 @@ import org.wordpress.android.R; import org.wordpress.android.ui.ExpandableHeightGridView; -import org.wordpress.android.util.BlogUtils; -import org.wordpress.android.util.DisplayUtils; import java.util.ArrayList; @@ -121,9 +119,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mScrollView = (ScrollView) view.findViewById(R.id.media_gallery_settings_content_container); mTitleView = (TextView) view.findViewById(R.id.media_gallery_settings_title); - if (!DisplayUtils.isTablet(view.getContext())) // show the arrow initially as collapsed when on phone - onPanelCollapsed(); - mNumColumnsContainer = view.findViewById(R.id.media_gallery_settings_num_columns_container); int visible = (mType == GalleryType.DEFAULT) ? View.VISIBLE : View.GONE; mNumColumnsContainer.setVisibility(visible); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsActivity.java index 7f5f24a1d4ce..69f6ddeaf3fb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsActivity.java @@ -3,6 +3,7 @@ import android.app.ActionBar; import android.app.AlertDialog; import android.app.Dialog; +import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.app.ProgressDialog; @@ -600,4 +601,11 @@ public void onBlogChanged() { public void setRefreshing(boolean refreshing) { mPostList.setRefreshing(refreshing); } + + + public boolean isDualPane() { + FragmentManager fm = getFragmentManager(); + Fragment fragment = fm.findFragmentById(R.id.postDetail); + return fragment != null && fragment.isVisible(); + } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java index e084911fc7c2..e07d191455da 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java @@ -22,9 +22,8 @@ import org.wordpress.android.models.Blog; import org.wordpress.android.models.Post; import org.wordpress.android.models.PostsListPost; -import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.ui.posts.adapters.PostsListAdapter; -import org.wordpress.android.util.DisplayUtils; +import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ToastUtils.Duration; import org.wordpress.android.util.ptr.PullToRefreshHelper; @@ -155,7 +154,7 @@ public void onPostsLoaded(int postCount) { getListView().setItemChecked(0, true); } } - } else if (isAdded() && DisplayUtils.isTablet(getActivity())) { + } else if (isAdded() && ((PostsActivity) getActivity()).isDualPane()) { // Reload the last selected position, if available int selectedPosition = getListView().getCheckedItemPosition(); if (selectedPosition != ListView.INVALID_POSITION && selectedPosition < mPostsListAdapter.getCount()) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsTagsAndCategoriesFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsTagsAndCategoriesFragment.java index 8fe10a98c752..eefe97f6c730 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsTagsAndCategoriesFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/StatsTagsAndCategoriesFragment.java @@ -16,8 +16,6 @@ import org.wordpress.android.datasets.StatsTagsAndCategoriesTable; import org.wordpress.android.models.StatsTagsandCategories.Type; import org.wordpress.android.providers.StatsContentProvider; -import org.wordpress.android.util.BlogUtils; -import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.util.FormatUtils; import java.util.Locale; @@ -34,10 +32,8 @@ public class StatsTagsAndCategoriesFragment extends StatsAbsViewFragment impleme public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.stats_pager_fragment, container, false); - if (DisplayUtils.isTablet(view.getContext())) { - TextView tv = (TextView) view.findViewById(R.id.stats_pager_title); - tv.setText(getTitle().toUpperCase(Locale.getDefault())); - } + TextView tv = (TextView) view.findViewById(R.id.stats_pager_title); + tv.setText(getTitle().toUpperCase(Locale.getDefault())); FragmentManager fm = getFragmentManager(); diff --git a/WordPress/src/main/res/values-sw600dp/integers.xml b/WordPress/src/main/res/values-sw600dp/integers.xml index a4be3f786843..127923ce339d 100644 --- a/WordPress/src/main/res/values-sw600dp/integers.xml +++ b/WordPress/src/main/res/values-sw600dp/integers.xml @@ -2,6 +2,6 @@ 1 @integer/visible - 1 - 600 + 1 + 600 diff --git a/WordPress/src/main/res/values/integers.xml b/WordPress/src/main/res/values/integers.xml index d67578f1c823..ec904318347e 100644 --- a/WordPress/src/main/res/values/integers.xml +++ b/WordPress/src/main/res/values/integers.xml @@ -5,7 +5,7 @@ 0 2 @integer/gone - 0 + 0 320 diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/DisplayUtils.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/DisplayUtils.java index 034669ed0500..fd4cbb5df5be 100644 --- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/DisplayUtils.java +++ b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/DisplayUtils.java @@ -20,10 +20,6 @@ public static boolean isLandscape(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; } - public static boolean isLandscapeTablet(Context context) { - return isLandscape(context) && isTablet(context); - } - public static Point getDisplayPixelSize(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); @@ -43,7 +39,8 @@ public static int getDisplayPixelHeight(Context context) { } public static int dpToPx(Context context, int dp) { - float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); + float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, + context.getResources().getDisplayMetrics()); return (int) px; } @@ -52,20 +49,11 @@ public static int pxToDp(Context context, int px) { return (int) ((px/displayMetrics.density)+0.5); } - /** - * Deprecated method, returns true on some phones. - */ - @Deprecated - public static boolean isTablet(Context context) { - // http://stackoverflow.com/a/8427523/1673548 - if (context == null) - return false; - return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; - } - public static boolean isXLarge(Context context) { - if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) + if ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) + == Configuration.SCREENLAYOUT_SIZE_XLARGE) { return true; + } return false; }