Java Code Examples for android.content.res.Configuration#UI_MODE_TYPE_WATCH

The following examples show how to use android.content.res.Configuration#UI_MODE_TYPE_WATCH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidInfoModule.java    From react-native-GPay with MIT License 8 votes vote down vote up
/**
 * See: https://developer.android.com/reference/android/app/UiModeManager.html#getCurrentModeType()
 */
private String uiMode() {
  UiModeManager uiModeManager = (UiModeManager) getReactApplicationContext().getSystemService(UI_MODE_SERVICE);
  switch (uiModeManager.getCurrentModeType()) {
    case Configuration.UI_MODE_TYPE_TELEVISION:
      return "tv";
    case Configuration.UI_MODE_TYPE_CAR:
      return "car";
    case Configuration.UI_MODE_TYPE_DESK:
      return "desk";
    case Configuration.UI_MODE_TYPE_WATCH:
      return "watch";
    case Configuration.UI_MODE_TYPE_NORMAL:
      return "normal";
    default:
      return "unknown";
  }
}
 
Example 2
Source File: HorizontalScrollView.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public HorizontalScrollView(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    initScrollView();

    final TypedArray a = context.obtainStyledAttributes(
            attrs, android.R.styleable.HorizontalScrollView, defStyleAttr, defStyleRes);

    setFillViewport(a.getBoolean(android.R.styleable.HorizontalScrollView_fillViewport, false));

    a.recycle();

    if (context.getResources().getConfiguration().uiMode == Configuration.UI_MODE_TYPE_WATCH) {
        setRevealOnFocusHint(false);
    }
}
 
Example 3
Source File: Utils.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
/**
 * Returns true when running Android TV
 *
 * @param c Context to detect UI Mode.
 * @return true when device is running in tv mode, false otherwise.
 */
public static String getDeviceType(Context c) {
    UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
    int modeType = uiModeManager.getCurrentModeType();
    switch (modeType){
        case Configuration.UI_MODE_TYPE_TELEVISION:
            return "TELEVISION";
        case Configuration.UI_MODE_TYPE_WATCH:
            return "WATCH";
        case Configuration.UI_MODE_TYPE_NORMAL:
            String type = isTablet(c) ? "TABLET" : "PHONE";
            return type;
        case Configuration.UI_MODE_TYPE_UNDEFINED:
            return "UNKOWN";
        default:
            return "";
    }
}
 
Example 4
Source File: Utils.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
/**
 * Returns true when running Android TV
 *
 * @param c Context to detect UI Mode.
 * @return true when device is running in tv mode, false otherwise.
 */
public static String getDeviceType(Context c) {
    UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
    int modeType = uiModeManager.getCurrentModeType();
    switch (modeType){
        case Configuration.UI_MODE_TYPE_TELEVISION:
            return "TELEVISION";
        case Configuration.UI_MODE_TYPE_WATCH:
            return "WATCH";
        case Configuration.UI_MODE_TYPE_NORMAL:
            String type = isTablet(c) ? "TABLET" : "PHONE";
            return type;
        case Configuration.UI_MODE_TYPE_UNDEFINED:
            return "UNKOWN";
        default:
            return "";
    }
}
 
Example 5
Source File: ScrollView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public ScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    initScrollView();

    final TypedArray a = context.obtainStyledAttributes(
            attrs, com.android.internal.R.styleable.ScrollView, defStyleAttr, defStyleRes);

    setFillViewport(a.getBoolean(R.styleable.ScrollView_fillViewport, false));

    a.recycle();

    if (context.getResources().getConfiguration().uiMode == Configuration.UI_MODE_TYPE_WATCH) {
        setRevealOnFocusHint(false);
    }
}
 
Example 6
Source File: Utils.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true when running Android TV
 *
 * @param c Context to detect UI Mode.
 * @return true when device is running in tv mode, false otherwise.
 */
public static String getDeviceType(Context c) {
    UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
    int modeType = uiModeManager.getCurrentModeType();
    switch (modeType){
        case Configuration.UI_MODE_TYPE_TELEVISION:
            return "TELEVISION";
        case Configuration.UI_MODE_TYPE_WATCH:
            return "WATCH";
        case Configuration.UI_MODE_TYPE_NORMAL:
            String type = isTablet(c) ? "TABLET" : "PHONE";
            return type;
        case Configuration.UI_MODE_TYPE_UNDEFINED:
            return "UNKOWN";
        default:
            return "";
    }
}
 
Example 7
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("ObsoleteSdkInt")
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false;
    final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel())
            && ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH))
            || PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector));
    if (d) Log.d(TAG, "shouldServiceRun() returning: " + result);
    return result;
}
 
Example 8
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("ObsoleteSdkInt")
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false;
    final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel())
            && ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH))
            || PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector));
    if (d) Log.d(TAG, "shouldServiceRun() returning: " + result);
    return result;
}
 
Example 9
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("ObsoleteSdkInt")
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false;
    final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel())
            && ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH))
            || PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector));
    if (d) Log.d(TAG, "shouldServiceRun() returning: " + result);
    return result;
}
 
Example 10
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("ObsoleteSdkInt")
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false;
    final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel())
            && ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH))
            || PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector));
    if (d) Log.d(TAG, "shouldServiceRun() returning: " + result);
    return result;
}
 
Example 11
Source File: UiModeManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void updateConfigurationLocked() {
    int uiMode = mDefaultUiModeType;
    if (mUiModeLocked) {
        // no-op, keeps default one
    } else if (mTelevision) {
        uiMode = Configuration.UI_MODE_TYPE_TELEVISION;
    } else if (mWatch) {
        uiMode = Configuration.UI_MODE_TYPE_WATCH;
    } else if (mCarModeEnabled) {
        uiMode = Configuration.UI_MODE_TYPE_CAR;
    } else if (isDeskDockState(mDockState)) {
        uiMode = Configuration.UI_MODE_TYPE_DESK;
    } else if (mVrHeadset) {
        uiMode = Configuration.UI_MODE_TYPE_VR_HEADSET;
    }

    if (mNightMode == UiModeManager.MODE_NIGHT_AUTO) {
        if (mTwilightManager != null) {
            mTwilightManager.registerListener(mTwilightListener, mHandler);
        }
        updateComputedNightModeLocked();
        uiMode |= mComputedNightMode ? Configuration.UI_MODE_NIGHT_YES
                : Configuration.UI_MODE_NIGHT_NO;
    } else {
        if (mTwilightManager != null) {
            mTwilightManager.unregisterListener(mTwilightListener);
        }
        uiMode |= mNightMode << 4;
    }

    if (LOG) {
        Slog.d(TAG,
            "updateConfigurationLocked: mDockState=" + mDockState
            + "; mCarMode=" + mCarModeEnabled
            + "; mNightMode=" + mNightMode
            + "; uiMode=" + uiMode);
    }

    mCurUiMode = uiMode;
    if (!mHoldingConfiguration) {
        mConfiguration.uiMode = uiMode;
    }
}
 
Example 12
Source File: JoH.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static boolean areWeRunningOnAndroidWear() {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH
            && (xdrip.getAppContext().getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_WATCH;
}
 
Example 13
Source File: JoH.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static boolean areWeRunningOnAndroidWear() {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH
            && (xdrip.getAppContext().getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_WATCH;
}
 
Example 14
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static boolean areWeRunningOnAndroidWear() {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH
            && (xdrip.getAppContext().getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_WATCH;
}
 
Example 15
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static boolean areWeRunningOnAndroidWear() {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH
            && (xdrip.getAppContext().getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_WATCH;
}