590 - add check for large screens/tablet mode, also some cleanup

This commit is contained in:
Daniel 2018-12-12 21:43:26 +01:00
parent d57ef6e0f7
commit df91d3ab67
2 changed files with 13 additions and 19 deletions

View file

@ -463,10 +463,14 @@ public class NewsReaderDetailFragment extends Fragment {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if(minLeftEdgeDistance == -1) { // if not initialized
// TODO check if tablet..
// TODO if tablet, use 0 as minLeftEdgeDistance.. right?
minLeftEdgeDistance = ((NewsReaderListActivity) getActivity()).getEdgeSizeOfDrawer();
if (minLeftEdgeDistance == -1) { // if not initialized
// for large screens (left menu bar always visible), don't need min left distance
if (SettingsActivity.isLargeScreen(getActivity().getApplicationContext())) {
minLeftEdgeDistance = 0;
} else { // otherwise (pull-menu on smaller/regular screens), min distance from left edge needed for mark read gesture
minLeftEdgeDistance = ((NewsReaderListActivity) getActivity()).getEdgeSizeOfDrawer();
}
Log.d(TAG, "" + minLeftEdgeDistance);
}
@ -477,7 +481,6 @@ public class NewsReaderDetailFragment extends Fragment {
return true;
}
return false;
//return super.onScroll(e1, e2, distanceX, distanceY);
}
}

View file

@ -173,7 +173,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
*/
@SuppressWarnings("deprecation")
private void setupSimplePreferencesScreen() {
if (!isSimplePreferences(this)) {
if (isLargeScreen(this)) {
return;
}
@ -249,7 +249,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
/** {@inheritDoc} */
@Override
public boolean onIsMultiPane() {
return isXLargeTablet(this) && !isSimplePreferences(this);
return isLargeScreen(this);
}
/**
@ -257,30 +257,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
* example, 10" tablets are extra-large.
*/
@SuppressLint("InlinedApi")
private static boolean isXLargeTablet(Context context) {
public static boolean isLargeScreen(Context context) {
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Determines whether the simplified settings UI should be shown. This is
* true if device doesn't have newer APIs like {@link PreferenceFragment}, or
* the device doesn't have an extra-large screen. In these cases, a single-pane
* "simplified" settings UI should be shown.
*/
private static boolean isSimplePreferences(Context context) {
return !isXLargeTablet(context);
}
/** {@inheritDoc} */
@Override
public void onBuildHeaders(List<Header> target) {
super.onBuildHeaders(target);
if (!isSimplePreferences(this)) {
if (isLargeScreen(this)) {
loadHeadersFromResource(R.xml.pref_headers, target);
}
// below workaround is only necessary in tablet mode
if (isXLargeTablet(this)) {
if (isLargeScreen(this)) {
/* Fix settings page header ("breadcrumb") text color for dark mode
* Thank you Stackoverflow: https://stackoverflow.com/a/27078485