Search in sources :

Example 26 with Window

use of android.view.Window in project material-camera by afollestad.

the class BaseCaptureActivity method onCreate.

@Override
protected final void onCreate(Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    super.onCreate(savedInstanceState);
    if (!CameraUtil.hasCamera(this)) {
        new MaterialDialog.Builder(this).title(R.string.mcam_error).content(R.string.mcam_video_capture_unsupported).positiveText(android.R.string.ok).dismissListener(new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                finish();
            }
        }).show();
        return;
    }
    setContentView(R.layout.mcam_activity_videocapture);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final int primaryColor = getIntent().getIntExtra(CameraIntentKey.PRIMARY_COLOR, 0);
        final boolean isPrimaryDark = CameraUtil.isColorDark(primaryColor);
        final Window window = getWindow();
        window.setStatusBarColor(CameraUtil.darkenColor(primaryColor));
        window.setNavigationBarColor(isPrimaryDark ? primaryColor : Color.BLACK);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            final View view = window.getDecorView();
            int flags = view.getSystemUiVisibility();
            flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            view.setSystemUiVisibility(flags);
        }
    }
    if (null == savedInstanceState) {
        checkPermissions();
        mLengthLimit = getIntent().getLongExtra(CameraIntentKey.LENGTH_LIMIT, -1);
    } else {
        mCameraPosition = savedInstanceState.getInt("camera_position", -1);
        mRequestingPermission = savedInstanceState.getBoolean("requesting_permission", false);
        mRecordingStart = savedInstanceState.getLong("recording_start", -1);
        mRecordingEnd = savedInstanceState.getLong("recording_end", -1);
        mLengthLimit = savedInstanceState.getLong(CameraIntentKey.LENGTH_LIMIT, -1);
        if (savedInstanceState.containsKey("front_camera_id_str")) {
            mFrontCameraId = savedInstanceState.getString("front_camera_id_str");
            mBackCameraId = savedInstanceState.getString("back_camera_id_str");
        } else {
            mFrontCameraId = savedInstanceState.getInt("front_camera_id_int");
            mBackCameraId = savedInstanceState.getInt("back_camera_id_int");
        }
        mFlashMode = savedInstanceState.getInt("flash_mode");
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Also used : Window(android.view.Window) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogInterface(android.content.DialogInterface) View(android.view.View)

Example 27 with Window

use of android.view.Window in project Android-Terminal-Emulator by jackpal.

the class Term method updatePrefs.

private void updatePrefs() {
    mUseKeyboardShortcuts = mSettings.getUseKeyboardShortcutsFlag();
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mViewFlipper.updatePrefs(mSettings);
    for (View v : mViewFlipper) {
        ((EmulatorView) v).setDensity(metrics);
        ((TermView) v).updatePrefs(mSettings);
    }
    if (mTermSessions != null) {
        for (TermSession session : mTermSessions) {
            ((GenericTermSession) session).updatePrefs(mSettings);
        }
    }
    {
        Window win = getWindow();
        WindowManager.LayoutParams params = win.getAttributes();
        final int FULLSCREEN = WindowManager.LayoutParams.FLAG_FULLSCREEN;
        int desiredFlag = mSettings.showStatusBar() ? 0 : FULLSCREEN;
        if (desiredFlag != (params.flags & FULLSCREEN) || (AndroidCompat.SDK >= 11 && mActionBarMode != mSettings.actionBarMode())) {
            if (mAlreadyStarted) {
                // Can't switch to/from fullscreen after
                // starting the activity.
                restart();
            } else {
                win.setFlags(desiredFlag, FULLSCREEN);
                if (mActionBarMode == TermSettings.ACTION_BAR_MODE_HIDES) {
                    if (mActionBar != null) {
                        mActionBar.hide();
                    }
                }
            }
        }
    }
    int orientation = mSettings.getScreenOrientation();
    int o = 0;
    if (orientation == 0) {
        o = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    } else if (orientation == 1) {
        o = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    } else if (orientation == 2) {
        o = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    } else {
    /* Shouldn't be happened. */
    }
    setRequestedOrientation(o);
}
Also used : Window(android.view.Window) EmulatorView(jackpal.androidterm.emulatorview.EmulatorView) TermSession(jackpal.androidterm.emulatorview.TermSession) DisplayMetrics(android.util.DisplayMetrics) View(android.view.View) TextView(android.widget.TextView) EmulatorView(jackpal.androidterm.emulatorview.EmulatorView)

Example 28 with Window

use of android.view.Window in project SystemBarTint by jgilfelt.

the class MatchActionBarActivity method setTranslucentStatus.

@TargetApi(19)
private void setTranslucentStatus(boolean on) {
    Window win = getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if (on) {
        winParams.flags |= bits;
    } else {
        winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
}
Also used : Window(android.view.Window) WindowManager(android.view.WindowManager) TargetApi(android.annotation.TargetApi)

Example 29 with Window

use of android.view.Window in project okhttp-OkGo by jeasonlzy.

the class BaseActivity method initSystemBarTint.

/** 设置状态栏颜色 */
protected void initSystemBarTint() {
    Window window = getWindow();
    if (translucentStatusBar()) {
        // 设置状态栏全透明
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        return;
    }
    // 沉浸式状态栏
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //5.0以上使用原生方法
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(setStatusBarColor());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //4.4-5.0使用三方工具类,有些4.4的手机有问题,这里为演示方便,不使用沉浸式
        //            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(setStatusBarColor());
    }
}
Also used : Window(android.view.Window) SystemBarTintManager(com.lzy.imagepicker.view.SystemBarTintManager)

Example 30 with Window

use of android.view.Window in project okhttp-OkGo by jeasonlzy.

the class BaseDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }
    getDelegate().setContentView(R.layout.activity_base);
    Window window = getWindow();
    requestState = (TextView) window.findViewById(R.id.requestState);
    requestHeaders = (TextView) window.findViewById(R.id.requestHeaders);
    responseData = (TextView) window.findViewById(R.id.responseData);
    responseHeader = (TextView) window.findViewById(R.id.responseHeader);
    rootContent = (FrameLayout) window.findViewById(R.id.content);
    onActivityCreate(savedInstanceState);
}
Also used : Window(android.view.Window)

Aggregations

Window (android.view.Window)310 View (android.view.View)69 WindowManager (android.view.WindowManager)56 TextView (android.widget.TextView)34 TargetApi (android.annotation.TargetApi)26 ImageView (android.widget.ImageView)25 Activity (android.app.Activity)17 Dialog (android.app.Dialog)17 ViewGroup (android.view.ViewGroup)17 ColorDrawable (android.graphics.drawable.ColorDrawable)16 AdapterView (android.widget.AdapterView)16 PhoneWindow (com.android.internal.policy.PhoneWindow)15 Intent (android.content.Intent)11 Context (android.content.Context)10 LayoutInflater (android.view.LayoutInflater)10 WindowDecorActionBar (com.android.internal.app.WindowDecorActionBar)10 RemoteException (android.os.RemoteException)9 DisplayMetrics (android.util.DisplayMetrics)9 LinearLayout (android.widget.LinearLayout)9 PopupWindow (android.widget.PopupWindow)8