android.content.res.Configuration#SCREENLAYOUT_SIZE_NORMAL源码实例Demo

下面列出了android.content.res.Configuration#SCREENLAYOUT_SIZE_NORMAL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: boxing   文件: MediaItemLayout.java
private ScreenType getScreenType(Context context) {
    int type = context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    ScreenType result;
    switch (type) {
        case Configuration.SCREENLAYOUT_SIZE_SMALL:
            result = ScreenType.SMALL;
            break;
        case Configuration.SCREENLAYOUT_SIZE_NORMAL:
            result = ScreenType.NORMAL;
            break;
        case Configuration.SCREENLAYOUT_SIZE_LARGE:
            result = ScreenType.LARGE;
            break;
        default:
            result = ScreenType.NORMAL;
            break;
    }
    return result;
}
 
源代码2 项目: iGap-Android   文件: StartupActions.java
/**
 * detect and  initialize text size
 */
public static void textSizeDetection(SharedPreferences sharedPreferences) {
    userTextSize = sharedPreferences.getInt(SHP_SETTING.KEY_MESSAGE_TEXT_SIZE, 14);

    if (!G.context.getResources().getBoolean(R.bool.isTablet)) {

        int screenLayout = context.getResources().getConfiguration().screenLayout;
        screenLayout &= Configuration.SCREENLAYOUT_SIZE_MASK;

        switch (screenLayout) {
            case Configuration.SCREENLAYOUT_SIZE_SMALL:
                userTextSize = (userTextSize * 3) / 4;
                break;
            case Configuration.SCREENLAYOUT_SIZE_NORMAL:
                break;
            case Configuration.SCREENLAYOUT_SIZE_LARGE:
                userTextSize = (userTextSize * 3) / 2;
                break;
            case Configuration.SCREENLAYOUT_SIZE_XLARGE:// or 4
                userTextSize *= 2;
        }
    }
}
 
/**
 * Define required image quality. On really big screens is higher quality always requested.
 *
 * @param highResolution true for better quality.
 */
public void defineImagesQuality(boolean highResolution) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics();
    int densityDpi = dm.densityDpi;
    // On big screens and wifi connection load high res images always
    if (((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE)
            && MyApplication.getInstance().isWiFiConnection()) {
        loadHighRes = true;
    } else if (highResolution) {
        // Load high resolution images only on better screens.
        loadHighRes = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_NORMAL)
                && densityDpi >= DisplayMetrics.DENSITY_XHIGH;
    } else {
        // otherwise
        loadHighRes = false;
    }

    Timber.d("Image high quality selected: %s", loadHighRes);
    notifyDataSetChanged();
}
 
源代码4 项目: android-lockpattern   文件: UI.java
/**
 * Gets current screen size.
 * 
 * @param context
 *            the context.
 * @return current screen size.
 */
public static ScreenSize getCurrent(Context context) {
    switch (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) {
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        return SMALL;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        return NORMAL;
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        return LARGE;
    case Configuration.SCREENLAYOUT_SIZE_XLARGE:
        return XLARGE;
    default:
        return UNDEFINED;
    }
}
 
源代码5 项目: android-lockpattern   文件: UI.java
/**
 * Gets current screen size.
 * 
 * @param context
 *            the context.
 * @return current screen size.
 */
public static ScreenSize getCurrent(Context context) {
    switch (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) {
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        return SMALL;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        return NORMAL;
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        return LARGE;
    case Configuration.SCREENLAYOUT_SIZE_XLARGE:
        return XLARGE;
    default:
        return UNDEFINED;
    }
}
 
源代码6 项目: sms-ticket   文件: ProjectBaseActivity.java
private void printDebugInfo() {
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    DebugLog.i("Device density: " + displaymetrics.densityDpi);
    if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        DebugLog.i("Device size is: LARGE");
    }
    if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        DebugLog.i("Device size is: XLARGE");
    }
    if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        DebugLog.i("Device size is: NORMAL");
    }
    if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        DebugLog.i("Device size is: SMALL");
    }
    DebugLog.i("Device is tablet: " + UIUtils.isHoneycombTablet(this));
}
 
源代码7 项目: sms-ticket   文件: UIUtils.java
public static String getScreenSizeAsString(Context context) {
    String size = null;
    int screenLayout = context.getResources().getConfiguration().screenLayout;
    if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        size = "large";
    }
    if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        size = "xlarge";
    }
    if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        size = "normal";
    }
    if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        size = "small";
    }
    if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_UNDEFINED) {
        size = "undefined";
    }
    return size;
}
 
源代码8 项目: dynamic-support   文件: DynamicLayoutUtils.java
/**
 * Get the column count according to the current configuration.
 * <p>It will also consider multi-window mode on API 24 and above devices.
 *
 * <p>It is not recommended to do this calculation at runtime. So, please define all the
 * span counts in xml.
 *
 * @param context The context to get configuration.
 * @param defaultCount The default column count.
 * @param maxCount The maximum column count up to which we can scale.
 * @param compact {@code true} if the layout is compact and disable the auto increase of
 *                columns in multi-window mode.
 *
 * @return The column count according to the current device configurations.
 */
@TargetApi(Build.VERSION_CODES.N)
public static int getLayoutColumns(@NonNull Context context,
        int defaultCount, int maxCount, boolean compact) {
    int columns = defaultCount;
    int screenCategory = getScreenSizeCategory(context);

    switch (screenCategory) {
        case Configuration.SCREENLAYOUT_SIZE_SMALL:
            if (columns > 1) {
                columns = columns - 1;
            }
            break;
        case Configuration.SCREENLAYOUT_SIZE_NORMAL:
            break;
        case Configuration.SCREENLAYOUT_SIZE_LARGE:
            if (context.getResources().getConfiguration().orientation
                    != Configuration.ORIENTATION_LANDSCAPE) {
                break;
            }
        case Configuration.SCREENLAYOUT_SIZE_XLARGE:
            columns += 1;
            break;
    }

    if (context.getResources().getConfiguration().orientation
            == Configuration.ORIENTATION_LANDSCAPE){
        try {
            if (compact || !isInMultiWindowMode(context)) {
                columns *= 2;
            }
        } catch (Exception ignored) {
        }
    }

    return Math.min(columns, maxCount);
}
 
源代码9 项目: jpHolo   文件: StartActivity.java
private String checkScreenSize() {
	String screenSize;
	if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
		screenSize = "xlarge";
	} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
		screenSize = "large";
	} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
		screenSize = "normal";
	} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
		screenSize = "small";
	} else {
		screenSize = "normal";
	}
	return screenSize;
}
 
源代码10 项目: jpHolo   文件: StartActivityUri.java
private String checkScreenSize() {
	String screenSize = "normal";
	if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
		screenSize = "xlarge";
	} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
		screenSize = "large";
	} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
		screenSize = "normal";
	} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
		screenSize = "small";
	} else {
		screenSize = "normal";
	}
	return screenSize;
}
 
源代码11 项目: jpHolo   文件: PreferredScreenSize.java
private String checkScreenSize() {
	String screenSize = "normal";
	if ((cordova.getActivity().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
		screenSize = "xlarge";
	} else if ((cordova.getActivity().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
		screenSize = "large";
	} else if ((cordova.getActivity().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
		screenSize = "normal";
	} else if ((cordova.getActivity().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
		screenSize = "small";
	} else {
		screenSize = "normal";
	}
	return screenSize;
}
 
源代码12 项目: OffsetAnimator   文件: ScreenUtils.java
/**
 * @param context Context instance
 * @return [true] if the device has a normal screen, [false] otherwise.
 */
public static boolean hasNormalScreen(Context context) {
    if (context == null) return false;
    return getScreenSize(context) == Configuration.SCREENLAYOUT_SIZE_NORMAL;
}
 
源代码13 项目: iGap-Android   文件: SlidingTabLayout.java
protected TextView createDefaultTabView(Context context, int i) {

        TextView textView = new TextView(context);
        textView.setGravity(Gravity.CENTER);

        if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP * 2);
        } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (TAB_VIEW_TEXT_SIZE_SP * 1.5));
        } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        } else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float) (TAB_VIEW_TEXT_SIZE_SP * .75));
        } else {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        }

        //    textView.setTypeface(custom_font);
        textView.setTextColor(Color.WHITE);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {// allcaps is for api 14 and upper
            textView.setAllCaps(false);
        }

        if (i == 0) {
            textView.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 8.5f));
        } else if (i == 1) {
            textView.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 8.5f));
        } else if (i == 2) {
            textView.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 8.5f));
        } else {
            textView.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 8.5f));
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            TypedValue outValue = new TypedValue();
            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
            textView.setBackgroundResource(outValue.resourceId);
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style

        }

        float dp = getResources().getDisplayMetrics().density;
        textView.setPadding(2, (int) (20 * dp), 2, (int) (20 * dp));

        return textView;
    }
 
源代码14 项目: TheGreatAdapter   文件: ViewUtils.java
public static boolean isNormalScreen(Context context) {
    return getScreenSize(context) == Configuration.SCREENLAYOUT_SIZE_NORMAL;
}
 
源代码15 项目: PercentageChartView   文件: ScreenUtil.java
/**
 * @param context Context instance
 * @return [true] if the device has a normal screen, [false] otherwise.
 */
public static boolean hasNormalScreen(Context context) {
    return getScreenSize(context) == Configuration.SCREENLAYOUT_SIZE_NORMAL;
}