Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1821: remove DisplayUtis.isTablet() method #1860

Merged
merged 1 commit into from
Sep 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
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;
import android.database.Cursor;
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions WordPress/src/main/res/values-sw600dp/integers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<resources>
<integer name="media_grid_num_columns">1</integer>
<integer name="media_editor_save_button_visibility">@integer/visible</integer>
<integer name="isTablet">1</integer>
<integer name="smallest_width_dp">600</integer>
<integer name="isSW600DP">1</integer>
<integer name="smallest_width_dp">600</integer>
</resources>
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values/integers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<integer name="visible">0</integer>
<integer name="gone">2</integer>
<integer name="media_editor_save_button_visibility">@integer/gone</integer>
<integer name="isTablet">0</integer>
<integer name="isSW600DP">0</integer>
<integer name="smallest_width_dp">320</integer>

<!-- max #chars user can type when adding a new topic to the native reader -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down