Example usage for android.view Surface ROTATION_90

List of usage examples for android.view Surface ROTATION_90

Introduction

In this page you can find the example usage for android.view Surface ROTATION_90.

Prototype

int ROTATION_90

To view the source code for android.view Surface ROTATION_90.

Click Source Link

Document

Rotation constant: 90 degree rotation.

Usage

From source file:org.telegram.ui.ChatActivity.java

private void showEmojiPopup(boolean show) {
    if (parentActivity == null) {
        return;/*from w  w w  . j  av a  2  s.  com*/
    }
    InputMethodManager localInputMethodManager = (InputMethodManager) parentActivity
            .getSystemService("input_method");
    if (show) {
        if (emojiPopup == null) {
            createEmojiPopup();
        }
        int currentHeight;
        WindowManager manager = (WindowManager) ApplicationLoader.applicationContext
                .getSystemService(Activity.WINDOW_SERVICE);
        int rotation = manager.getDefaultDisplay().getRotation();
        if (keyboardHeight <= 0) {
            keyboardHeight = parentActivity.getSharedPreferences("emoji", 0).getInt("kbd_height",
                    Emoji.scale(200.0f));
        }
        if (keyboardHeightLand <= 0) {
            keyboardHeightLand = parentActivity.getSharedPreferences("emoji", 0).getInt("kbd_height_land3",
                    Emoji.scale(200.0f));
        }
        if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
            currentHeight = keyboardHeightLand;
        } else {
            currentHeight = keyboardHeight;
        }
        emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY));
        emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(contentView.getWidth(), View.MeasureSpec.EXACTLY));

        emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), 83, 0, 0);
        if (!keyboardVisible) {
            contentView.setPadding(0, 0, 0, currentHeight);
            emojiButton.setImageResource(R.drawable.ic_msg_panel_hide);
            return;
        }
        emojiButton.setImageResource(R.drawable.ic_msg_panel_kb);
        return;
    }
    if (emojiButton != null) {
        emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
    }
    if (emojiPopup != null) {
        emojiPopup.dismiss();
    }
    if (contentView != null) {
        contentView.post(new Runnable() {
            public void run() {
                if (contentView != null) {
                    contentView.setPadding(0, 0, 0, 0);
                }
            }
        });
    }
}

From source file:org.telegram.ui.ChatActivity.java

private void fixLayout() {
    if (chatListView != null) {
        ViewTreeObserver obs = chatListView.getViewTreeObserver();
        obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override//w w  w. jav  a 2 s  .c  o m
            public boolean onPreDraw() {
                if (parentActivity == null) {
                    chatListView.getViewTreeObserver().removeOnPreDrawListener(this);
                    return false;
                }
                WindowManager manager = (WindowManager) ApplicationLoader.applicationContext
                        .getSystemService(Activity.WINDOW_SERVICE);
                Display display = manager.getDefaultDisplay();
                int rotation = display.getRotation();
                int height;
                int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();

                if (currentActionBarHeight != Utilities.dp(48) && currentActionBarHeight != Utilities.dp(40)) {
                    height = currentActionBarHeight;
                } else {
                    height = Utilities.dp(48);
                    if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
                        height = Utilities.dp(40);
                    }
                }

                if (avatarImageView != null) {
                    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) avatarImageView
                            .getLayoutParams();
                    params.width = height;
                    params.height = height;
                    avatarImageView.setLayoutParams(params);
                }

                chatListView.getViewTreeObserver().removeOnPreDrawListener(this);

                if (currentEncryptedChat != null) {
                    TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title);
                    if (title == null) {
                        final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title",
                                "id", "android");
                        title = (TextView) parentActivity.findViewById(subtitleId);
                    }
                    if (title != null) {
                        title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
                        title.setCompoundDrawablePadding(Utilities.dp(4));
                    }
                }

                return false;
            }
        });
    }
}

From source file:com.android.launcher2.Launcher.java

private int mapConfigurationOriActivityInfoOri(int configOri) {
    final Display d = getWindowManager().getDefaultDisplay();
    int naturalOri = Configuration.ORIENTATION_LANDSCAPE;
    switch (d.getRotation()) {
    case Surface.ROTATION_0:
    case Surface.ROTATION_180:
        // We are currently in the same basic orientation as the natural orientation
        naturalOri = configOri;//  www .ja  va2  s. c  o  m
        break;
    case Surface.ROTATION_90:
    case Surface.ROTATION_270:
        // We are currently in the other basic orientation to the natural orientation
        naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ? Configuration.ORIENTATION_PORTRAIT
                : Configuration.ORIENTATION_LANDSCAPE;
        break;
    }

    int[] oriMap = { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE };
    // Since the map starts at portrait, we need to offset if this device's natural orientation
    // is landscape.
    int indexOffset = 0;
    if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
        indexOffset = 1;
    }
    return oriMap[(d.getRotation() + indexOffset) % 4];
}