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

The following examples show how to use android.content.res.Configuration#ORIENTATION_UNDEFINED . 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: MainActivity.java    From Android-9-Development-Cookbook with MIT License 6 votes vote down vote up
public void checkOrientation(View view){
    int orientation = getResources()
            .getConfiguration().orientation;
    switch (orientation) {
        case Configuration.ORIENTATION_LANDSCAPE:
            Toast.makeText(MainActivity.this, "ORIENTATION_LANDSCAPE",
                    Toast.LENGTH_SHORT).show();
            break;
        case Configuration.ORIENTATION_PORTRAIT:
            Toast.makeText(MainActivity.this, "ORIENTATION_PORTRAIT",
                    Toast.LENGTH_SHORT).show();
            break;
        case Configuration.ORIENTATION_UNDEFINED:
            Toast.makeText(MainActivity.this, "ORIENTATION_UNDEFINED",
                    Toast.LENGTH_SHORT).show();
            break;
    }
}
 
Example 2
Source File: CameraActivity.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration config)
{
    super.onConfigurationChanged(config);
    Log.v(TAG, "onConfigurationChanged");
    if (config.orientation == Configuration.ORIENTATION_UNDEFINED)
    {
        return;
    }

    if (mLastLayoutOrientation != config.orientation)
    {
        mLastLayoutOrientation = config.orientation;
        mCurrentModule.onLayoutOrientationChanged(mLastLayoutOrientation == Configuration.ORIENTATION_LANDSCAPE);
    }
}
 
Example 3
Source File: ProxyEnvironment.java    From GPT with Apache License 2.0 6 votes vote down vote up
/**
 * createTargetResource
 */
private void createTargetResource() {
    try {
        AssetManager am = (AssetManager) AssetManager.class.newInstance();
        JavaCalls.callMethod(am, "addAssetPath", new Object[]{apkFile.getAbsolutePath()});
        targetAssetManager = am;
    } catch (Exception e) {
        if (DEBUG) {
            e.printStackTrace();
        }
    }

    // 解决一个HTC ONE X上横竖屏会黑屏的问题
    Resources hostRes = mHostAppContext.getResources();
    Configuration config = new Configuration();
    config.setTo(hostRes.getConfiguration());
    config.orientation = Configuration.ORIENTATION_UNDEFINED;
    targetResources = new ResourcesProxy(targetAssetManager, hostRes.getDisplayMetrics(), config, hostRes);
    targetTheme = targetResources.newTheme();
    targetTheme.setTo(mHostAppContext.getTheme());
    targetTheme.applyStyle(targetMapping.getTheme(), true);
}
 
Example 4
Source File: DisplayUtils.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
public static int getScreenOrientation(Context context)
{
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();

    int orientation = Configuration.ORIENTATION_UNDEFINED;
    if(display.getWidth()==display.getHeight()){
        orientation = Configuration.ORIENTATION_SQUARE;
    } else{
        if(display.getWidth() < display.getHeight()){
            orientation = Configuration.ORIENTATION_PORTRAIT;
        }else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
        }
    }
    return orientation;
}
 
Example 5
Source File: AppRenderer.java    From VuforiaLibGDX with MIT License 6 votes vote down vote up
private void updateActivityOrientation()
{
    Configuration config = mActivityRef.get().getResources().getConfiguration();

    switch (config.orientation)
    {
        case Configuration.ORIENTATION_PORTRAIT:
            mIsPortrait = true;
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            mIsPortrait = false;
            break;
        case Configuration.ORIENTATION_UNDEFINED:
        default:
            break;
    }

    Log.i(LOGTAG, "Activity is in "
            + (mIsPortrait ? "PORTRAIT" : "LANDSCAPE"));
}
 
Example 6
Source File: DisplayUtils.java    From smartcoins-wallet with MIT License 6 votes vote down vote up
public static int getScreenOrientation(Context context)
{
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();

    int orientation = Configuration.ORIENTATION_UNDEFINED;
    if(display.getWidth()==display.getHeight()){
        orientation = Configuration.ORIENTATION_SQUARE;
    } else{
        if(display.getWidth() < display.getHeight()){
            orientation = Configuration.ORIENTATION_PORTRAIT;
        }else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
        }
    }
    return orientation;
}
 
Example 7
Source File: ApplicationSession.java    From cordova-plugin-vuforia with MIT License 6 votes vote down vote up
private void updateActivityOrientation()
{
    Configuration config = mActivity.getResources().getConfiguration();

    switch (config.orientation)
    {
        case Configuration.ORIENTATION_PORTRAIT:
            mIsPortrait = true;
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            mIsPortrait = false;
            break;
        case Configuration.ORIENTATION_UNDEFINED:
        default:
            break;
    }

    Log.i(LOGTAG, "Activity is in "
        + (mIsPortrait ? "PORTRAIT" : "LANDSCAPE"));
}
 
Example 8
Source File: DeviceOrientations.java    From sentry-android with MIT License 5 votes vote down vote up
/**
 * Get the device's current screen orientation.
 *
 * @return the device's current screen orientation, or null if unknown
 */
@SuppressWarnings("deprecation")
public static @Nullable Device.DeviceOrientation getOrientation(int orientation) {
  switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
      return Device.DeviceOrientation.LANDSCAPE;
    case Configuration.ORIENTATION_PORTRAIT:
      return Device.DeviceOrientation.PORTRAIT;
    case Configuration.ORIENTATION_SQUARE:
    case Configuration.ORIENTATION_UNDEFINED:
    default:
      return null;
  }
}
 
Example 9
Source File: NavigationView.java    From Sofia with Apache License 2.0 5 votes vote down vote up
/**
 * Whether landscape screen.
 */
protected boolean isLandscape() {
    switch (mConfiguration.orientation) {
        case Configuration.ORIENTATION_LANDSCAPE: {
            return true;
        }
        case Configuration.ORIENTATION_UNDEFINED:
        case Configuration.ORIENTATION_PORTRAIT:
        default: {
            return false;
        }
    }
}
 
Example 10
Source File: VideoUnit.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
public void onConfigurationChanged(Configuration newConfig) {
	if (newConfig.orientation != Configuration.ORIENTATION_UNDEFINED) {
		if (layoutConfiguration != -1) {
			recreateVideoControls();
		}
	}
}
 
Example 11
Source File: Utils.java    From BatteryFu with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reliably get orientation. Return values are one of
 * Configuration.ORIENTATION_XXXXX
 * 
 * @return
 */
public int getScreenOrientation(Activity context) {
   Display getOrient = context.getWindowManager().getDefaultDisplay();
   int orientation = Configuration.ORIENTATION_UNDEFINED;
   if (getOrient.getWidth() == getOrient.getHeight()) {
      orientation = Configuration.ORIENTATION_SQUARE;
   } else {
      if (getOrient.getWidth() < getOrient.getHeight()) {
         orientation = Configuration.ORIENTATION_PORTRAIT;
      } else {
         orientation = Configuration.ORIENTATION_LANDSCAPE;
      }
   }
   return orientation;
}
 
Example 12
Source File: MRAIDImplementation.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"UnusedDeclaration", "UnusedAssignment"})
private void setOrientationProperties(ArrayList<Pair<String, String>> parameters) {
    boolean allow_orientation_change = true;
    AdActivity.OrientationEnum orientation = AdActivity.OrientationEnum.none;

    for (Pair<String, String> bnvp : parameters) {
        if (bnvp.first.equals("allow_orientation_change")) {
            allow_orientation_change = Boolean.parseBoolean(bnvp.second);
        } else if (bnvp.first.equals("force_orientation")) {
            orientation = parseForceOrientation(bnvp.second);
        }
    }

    // orientationProperties only affects expanded state
    if (expanded || owner.adView.isInterstitial()) {
        Activity containerActivity = owner.isFullScreen
                ? getFullscreenActivity() : (Activity) owner.getContextFromMutableContext();
        if (allow_orientation_change) {
            AdActivity.unlockOrientation(containerActivity);
        } else {
            int androidOrientation = Configuration.ORIENTATION_UNDEFINED;
            switch (orientation) {
                case landscape:
                    androidOrientation = Configuration.ORIENTATION_LANDSCAPE;
                    break;
                case portrait:
                    androidOrientation = Configuration.ORIENTATION_PORTRAIT;
                    break;
                case none:
                default:
                    break;
            }
            AdActivity.lockToConfigOrientation(containerActivity, androidOrientation);
        }
    }
}
 
Example 13
Source File: ActivityManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
/**
 * Resets this info state to the initial state.
 * @hide
 */
public void reset() {
    taskWidth = 0;
    taskHeight = 0;
    screenOrientation = Configuration.ORIENTATION_UNDEFINED;
}
 
Example 14
Source File: ActionMenuConfigurator.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
public void onConfigurationChanged(Configuration newConfig) {
	if (newConfig.orientation != Configuration.ORIENTATION_UNDEFINED && lastMenu != null) {
		onAfterPrepareOptionsMenu(lastMenu);
	}
}
 
Example 15
Source File: ListUnit.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
public void onConfigurationChanged(Configuration newConfig) {
	if (newConfig.orientation != Configuration.ORIENTATION_UNDEFINED) {
		updateGridMetrics(false, newConfig);
	}
}