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);
}
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);
}
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);
}
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());
}
}
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);
}
Aggregations