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

The following examples show how to use android.content.res.Configuration#ORIENTATION_LANDSCAPE . 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: TimeMainActivity.java    From kAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {//横屏
        llStatus.setVisibility(View.GONE);
        minuteChartView.setGridRows(6);
        minuteChartView.setGridColumns(5);
        minuteChartView.setGridChildRows(4);
        viewLeftMessage.setVisibility(View.VISIBLE);
        lineView.setVisibility(View.VISIBLE);

    } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {//竖屏
        llStatus.setVisibility(View.VISIBLE);
        minuteChartView.setGridRows(6);
        minuteChartView.setGridColumns(5);
        minuteChartView.setGridChildRows(4);;
        viewLeftMessage.setVisibility(View.GONE);
        lineView.setVisibility(View.GONE);
    }
}
 
Example 2
Source File: MonthPickerDialog.java    From MonthAndYearPicker with MIT License 6 votes vote down vote up
@Override
public void show() {

    if (view != null) {
        if (this.getContext().getResources().getConfiguration().orientation ==
                Configuration.ORIENTATION_LANDSCAPE) {
            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            if (getWindow() != null) {
                lp.copyFrom(getWindow().getAttributes());
                lp.width = (int) (this.getContext().getResources().getDisplayMetrics().widthPixels * 0.94);
                lp.height = (int) (this.getContext().getResources().getDisplayMetrics().heightPixels * 0.94);
                // show the dialog as per super implementation
                super.show();
                // now dialog attached to window so apply the size
                getWindow().setLayout(lp.width, lp.height);
            }

            return;
        }else {
            dismiss();
        }
    }
    super.show();
}
 
Example 3
Source File: ListPlayActivity.java    From PlayerBase with Apache License 2.0 6 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    isLandScape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE;
    if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
        mPlayerContainer.setBackgroundColor(Color.BLACK);
        ListPlayer.get().attachContainer(mPlayerContainer, false);
        ListPlayer.get().setReceiverConfigState(this, ISPayer.RECEIVER_GROUP_CONFIG_FULL_SCREEN_STATE);
    }else{
        mPlayerContainer.setBackgroundColor(Color.TRANSPARENT);
        mRecycler.post(new Runnable() {
            @Override
            public void run() {
                ListAdapter.VideoItemHolder currentHolder = mAdapter.getCurrentHolder();
                if(currentHolder!=null){
                    ListPlayer.get().attachContainer(currentHolder.layoutContainer, false);
                    ListPlayer.get().setReceiverConfigState(
                            ListPlayActivity.this, ISPayer.RECEIVER_GROUP_CONFIG_LIST_STATE);
                }
            }
        });
    }
    ListPlayer.get().updateGroupValue(DataInter.Key.KEY_CONTROLLER_TOP_ENABLE, isLandScape);
    ListPlayer.get().updateGroupValue(DataInter.Key.KEY_IS_LANDSCAPE, isLandScape);
}
 
Example 4
Source File: DrawerLayoutEx.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
void setup(Configuration config, View drawerContainer, ActionBarDrawerToggle drawerToggle) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
    boolean landscape = prefs.getBoolean("landscape", true);
    boolean landscape3 = prefs.getBoolean("landscape3", false);

    if (normal && landscape && landscape3 &&
            config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setScrimColor(Color.TRANSPARENT);
        openDrawer(drawerContainer, false);
        drawerToggle.onDrawerOpened(drawerContainer);
    } else {
        setScrimColor(Helper.resolveColor(getContext(), R.attr.colorDrawerScrim));
        closeDrawer(drawerContainer, false);
        drawerToggle.onDrawerClosed(drawerContainer);
    }
}
 
Example 5
Source File: ActionBarLayer.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
private void positionLogoImage(int height) {
    if (logoImageView != null) {
        LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams();
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            layoutParams.width = (int) (logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
            layoutParams.height = (int) (logoImageView.getDrawable().getIntrinsicHeight() / 1.3f);
            layoutParams.setMargins(OSUtilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
        } else {
            layoutParams.width = logoImageView.getDrawable().getIntrinsicWidth();
            layoutParams.height = logoImageView.getDrawable().getIntrinsicHeight();
            layoutParams.setMargins(OSUtilities.dp(12), (height - layoutParams.width) / 2, 0, 0);
        }
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        logoImageView.setLayoutParams(layoutParams);
    }
}
 
Example 6
Source File: Utils.java    From KickAssSlidingMenu with Apache License 2.0 6 votes vote down vote up
public static int getDrawerWidth(Resources res, int ownDP) {
    if (ownDP == 0) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {

            if (res.getConfiguration().smallestScreenWidthDp >= 600 || res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                // device is a tablet
                return (int) (320 * res.getDisplayMetrics().density);
            } else {
                return (int) (res.getDisplayMetrics().widthPixels - (56 * res.getDisplayMetrics().density));
            }
        } else { // for devices without smallestScreenWidthDp reference calculate if device screen is over 600 dp
            if ((res.getDisplayMetrics().widthPixels / res.getDisplayMetrics().density) >= 600 || res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
                return (int) (320 * res.getDisplayMetrics().density);
            else
                return (int) (res.getDisplayMetrics().widthPixels - (56 * res.getDisplayMetrics().density));
        }
    } else {
        return ownDP;
    }
}
 
Example 7
Source File: TagFilterActivity.java    From NClientV2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        changeLayout(true);
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        changeLayout(false);
    }
}
 
Example 8
Source File: DeviceControlActivity.java    From BLEConnect with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
	super.onConfigurationChanged(newConfig);
	// setContentView(R.layout.heartrate);
	if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
		Log.i(TAG, "ORIENTATION_LANDSCAPE");
	} else {
		Log.i(TAG, "ORIENTATION_PORTRAIT");
	}
}
 
Example 9
Source File: DeviceLinkFragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfiguration) {
  super.onConfigurationChanged(newConfiguration);
  if (newConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
    container.setOrientation(LinearLayout.HORIZONTAL);
  } else {
    container.setOrientation(LinearLayout.VERTICAL);
  }
}
 
Example 10
Source File: VodDisplayActivity.java    From KSYMediaPlayer_Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    WindowManager.LayoutParams params = getWindow().getAttributes();
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (landscape_content.getVisibility() == View.VISIBLE) {
                    landscape_content.setVisibility(View.GONE);
                    hideStatusBar();
                    isPanelShowing_Landscape = false;
                }
            }
        }, 5000);
        params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        getWindow().setAttributes(params);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        showLandscapePanel();
        ViewTreeObserver vto2 = content.getViewTreeObserver();
        vto2.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                content.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                full_screen_height = content.getHeight();
                full_screen_width = content.getWidth();
            }
        });
        currentState = 1;
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().setAttributes(params);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        showPortraitPanel();
        Display.setLight(this, currentBrighrness, this.getWindow().getAttributes());
        full_screen_height = 0;
        full_screen_width = 0;
        currentState = 0;
    }
}
 
Example 11
Source File: DynamicAppWidgetProvider.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Update widget width and height according to the current orientation.
 *
 * @param context The context associated with this widget provider.
 * @param appWidgetManager The app widget manager.
 * @param appWidgetId The app widget id to update the dimensions.
 */
protected void updateWidgetDimensions(@NonNull Context context,
        @NonNull AppWidgetManager appWidgetManager, int appWidgetId) {
    if (DynamicSdkUtils.is16()) {
        Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
        if (context.getResources().getConfiguration().orientation
                == Configuration.ORIENTATION_LANDSCAPE) {
            mWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH);
            mHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
        } else {
            mWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
            mHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT);
        }
    }
}
 
Example 12
Source File: HighlightImageView.java    From QuranAndroid with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Function fire in repaint
 *
 * @param canvas View canvas
 */
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    //show popup in touch selection mood if there is no running activities
    if (mRects.size() != 0
            && selectionFromTouch
            && !Settings.isMyServiceRunning(context, AudioService.class)) {
        //check the display configuration
        if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            displayPopupWindow((int) (xImageOffset + (float) (mRects.get(0).left * scaleRatio))
                    , (int) (yImageOffset + (float) (mRects.get(0).top * scaleRatio)));
        } else {
            displayPopupWindow((int) (xImageOffset + (float) (mRects.get(mRects.size() - 1).left * scaleRatio))
                    , (int) (yImageOffset + (float) (mRects.get(mRects.size() - 1).bottom * scaleRatio)));
        }
    }

    //Draw rectangles on image
    for (RectF rect : mRects) {
        float rTop = yImageOffset + (float) (rect.top * scaleRatio);
        float rBottom = yImageOffset + (float) (rect.bottom * scaleRatio);
        float rLeft = xImageOffset + (float) (rect.left * scaleRatio);
        float rRight = xImageOffset + (float) (rect.right * scaleRatio);
        canvas.drawRect(new RectF(rLeft, rTop, rRight, rBottom), mPaint);
    }
}
 
Example 13
Source File: ProfileFragment.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getSpanCount() {
    int span = Utils.isTablet(getActivity()) ? Utils.getOrientation(getActivity()) ==
            Configuration.ORIENTATION_LANDSCAPE ? 4 : 3 : Utils.getOrientation(getActivity()) ==
            Configuration.ORIENTATION_LANDSCAPE ? 3 : 2;
    if (itemsSize() != 0 && span > itemsSize()) {
        span = itemsSize();
    }
    return span;
}
 
Example 14
Source File: BaseFragment.java    From Pixiv-Shaft with MIT License 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = requireContext();
    mActivity = requireActivity();

    Bundle bundle = getArguments();
    if (bundle != null) {
        initBundle(bundle);
    }

    Intent intent = mActivity.getIntent();
    if (intent != null) {
        Bundle activityBundle = intent.getExtras();
        if (activityBundle != null) {
            initActivityBundle(bundle);
        }
    }


    if (eventBusEnable()) {
        EventBus.getDefault().register(this);
    }

    //获取屏幕方向
    int ori = getResources().getConfiguration().orientation;
    if (ori == Configuration.ORIENTATION_LANDSCAPE) {
        isVertical = false;
    } else if (ori == Configuration.ORIENTATION_PORTRAIT) {
        isVertical = true;
    }
}
 
Example 15
Source File: RecyclerViewFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
public int getSpanCount() {
    Activity activity;
    if ((activity = getActivity()) != null) {
        int span = Utils.isTablet(activity) ? Utils.getOrientation(activity) ==
                Configuration.ORIENTATION_LANDSCAPE ? 3 : 2 : Utils.getOrientation(activity) ==
                Configuration.ORIENTATION_LANDSCAPE ? 2 : 1;
        if (itemsSize() != 0 && span > itemsSize()) {
            span = itemsSize();
        }
        return span;
    }
    return 1;
}
 
Example 16
Source File: ButtonHandler.java    From SublimePicker with Apache License 2.0 5 votes vote down vote up
public ButtonHandler(@NonNull SublimePicker sublimePicker) {
    Context context = sublimePicker.getContext();

    mIsInLandscapeMode = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    if (mIsInLandscapeMode) {
        initializeForLandscape(sublimePicker);
    } else {
        // Takes care of initialization
        mPortraitButtonHandler = (ButtonLayout) sublimePicker.findViewById(R.id.button_layout);
    }
}
 
Example 17
Source File: ReqMenuDialog.java    From NanoIconPack with Apache License 2.0 4 votes vote down vote up
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);

    Bundle bundle = getArguments();
    pos = bundle.getInt("pos");
    bean = (AppBean) bundle.getSerializable("bean");

    contentView = View.inflate(getContext(), R.layout.fragment_req_menu, null);
    dialog.setContentView(contentView);

    ((TextView) contentView.findViewById(R.id.tv_title)).setText(bean.getLabel());
    if (bean.isMark()) {
        contentView.findViewById(R.id.view_menu_mark).setVisibility(View.GONE);
        contentView.findViewById(R.id.view_menu_undo_mark).setOnClickListener(this);
        contentView.findViewById(R.id.view_hint_undo_mark)
                .setVisibility(bean.isHintUndoMark() ? View.VISIBLE : View.GONE);
    } else {
        contentView.findViewById(R.id.view_menu_undo_mark).setVisibility(View.GONE);
        contentView.findViewById(R.id.view_menu_mark).setOnClickListener(this);
        contentView.findViewById(R.id.view_hint_mark)
                .setVisibility(bean.isHintMark() ? View.VISIBLE : View.GONE);
    }
    contentView.findViewById(R.id.view_hint_lost)
            .setVisibility(bean.isHintLost() ? View.VISIBLE : View.GONE);
    contentView.findViewById(R.id.view_menu_goto_market).setOnClickListener(this);
    contentView.findViewById(R.id.view_menu_copy_code).setOnClickListener(this);

    BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior
            .from((View) contentView.getParent());
    if (bean.isHintLost()) {
        // In landscape, STATE_EXPANDED doesn't make sheet expanded.
        // Maybe it's a bug. So do this to fix it.
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            contentView.measure(0, 0);
            bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight());
        }
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    } else {
        bottomSheetBehavior.setPeekHeight(getResources()
                .getDimensionPixelSize(R.dimen.req_bottom_menu_height));
    }
}
 
Example 18
Source File: UserSettingsCommon.java    From edslite with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isWideScreenLayout(SettingsCommon settings, Activity activity)
{
	return !settings.disableLargeSceenLayouts() && activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
 
Example 19
Source File: ScreenUtil.java    From PercentageChartView with Apache License 2.0 4 votes vote down vote up
/**
 * @param context Context instance
 * @return [true] if the device is in landscape orientation, [false] otherwise.
 */
public static boolean isInLandscapeOrientation(Context context) {
    Configuration configuration = context.getResources().getConfiguration();
    return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE;
}
 
Example 20
Source File: MainFragment.java    From InviZible with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.main_fragment, container, false);

    btnStartMainFragment = view.findViewById(R.id.btnStartMainFragment);
    btnStartMainFragment.setOnClickListener(this);

    chbHideIpMainFragment = view.findViewById(R.id.chbHideIpMainFragment);

    chbProtectDnsMainFragment = view.findViewById(R.id.chbProtectDnsMainFragment);

    chbAccessITPMainFragment = view.findViewById(R.id.chbAccessITPMainFragment);

    tvDNSMainFragment = view.findViewById(R.id.tvDNSMainFragment);
    tvTorMainFragment = view.findViewById(R.id.tvTorMainFragment);
    tvITPDMainFragment = view.findViewById(R.id.tvITPDMainFragment);

    pbDNSMainFragment = view.findViewById(R.id.pbDNSMainFragment);
    pbTorMainFragment = view.findViewById(R.id.pbTorMainFragment);
    pbITPDMainFragment = view.findViewById(R.id.pbITPDMainFragment);

    if (getActivity() == null) {
        return view;
    }

    orientationLandscape = Utils.INSTANCE.getScreenOrientation(getActivity()) == Configuration.ORIENTATION_LANDSCAPE;

    boolean hideIp = new PrefManager(getActivity()).getBoolPref("HideIp");
    boolean protectDns = new PrefManager(getActivity()).getBoolPref("ProtectDns");
    boolean accessITP = new PrefManager(getActivity()).getBoolPref("AccessITP");

    if (!hideIp && !protectDns && !accessITP) {
        new PrefManager(getActivity()).setBoolPref("HideIp", true);
        new PrefManager(getActivity()).setBoolPref("ProtectDns", true);
        new PrefManager(getActivity()).setBoolPref("AccessITP", false);
    } else {
        chbHideIpMainFragment.setChecked(hideIp);
        chbProtectDnsMainFragment.setChecked(protectDns);
        chbAccessITPMainFragment.setChecked(accessITP);
    }

    chbHideIpMainFragment.setOnCheckedChangeListener(this);
    chbProtectDnsMainFragment.setOnCheckedChangeListener(this);
    chbAccessITPMainFragment.setOnCheckedChangeListener(this);

    return view;
}