Java Code Examples for android.view.Window#addFlags()

The following examples show how to use android.view.Window#addFlags() . 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: StatusBarUtils.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public static void setNavigationBarColor(Activity activity, int color) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = activity.getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            if (color == Color.TRANSPARENT) {
                window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            } else {
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            }

            //底部导航栏
            window.setNavigationBarColor(color);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: AppUtils.java    From AndroidNavigation with MIT License 6 votes vote down vote up
public static void setStatusBarTranslucent(Window window, boolean translucent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setRenderContentInShortEdgeCutoutAreas(window, translucent);

        View decorView = window.getDecorView();
        if (translucent) {
            decorView.setOnApplyWindowInsetsListener((v, insets) -> {
                WindowInsets defaultInsets = v.onApplyWindowInsets(insets);
                return defaultInsets.replaceSystemWindowInsets(
                        defaultInsets.getSystemWindowInsetLeft(),
                        0,
                        defaultInsets.getSystemWindowInsetRight(),
                        defaultInsets.getSystemWindowInsetBottom());
            });
        } else {
            decorView.setOnApplyWindowInsetsListener(null);
        }

        ViewCompat.requestApplyInsets(decorView);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (translucent) {
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        } else {
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        ViewCompat.requestApplyInsets(window.getDecorView());
    }
}
 
Example 3
Source File: ImageViewPagerActivity.java    From Girls with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//实现半透明状态栏
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    }
    setContentView(R.layout.activity_image_view_pager);
    mImageList = getIntent().getParcelableArrayListExtra("imagelist");
    mPosition = getIntent().getIntExtra("position", 0);
    if (mImageList == null || mImageList.isEmpty()) {
        finish();
        return;
    }
    initView();
    initListener();
}
 
Example 4
Source File: BaseDialog.java    From AppServiceRestFul with GNU General Public License v3.0 6 votes vote down vote up
public BaseDialog(Context context, int style) {
        super(context, style);
        this.context = context;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0 全透明实现
            Window window = getWindow();
            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) {//4.4全透明
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        }

    }
 
Example 5
Source File: MainActivity.java    From Paideia with MIT License 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

  setContentView(R.layout.activity_camera);

  tts=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
    @Override
    public void onInit(int status) {
        if(status != TextToSpeech.ERROR) {
            tts.setLanguage(Locale.US);
        }
    }
  });
  if (null == savedInstanceState) {
    getFragmentManager()
        .beginTransaction()
        .replace(R.id.container, CameraConnectionFragment.newInstance())
        .commit();
  }
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.setStatusBarColor(baseColor);
}
 
Example 6
Source File: LoginActivity.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
private void setStatusBar(){
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    }
}
 
Example 7
Source File: DecoderActivity.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.decoder);
    Log.v(TAG, "onCreate()");

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    handler = null;
    hasSurface = false;
}
 
Example 8
Source File: WelcomeActivity.java    From MangoBloggerAndroidApp with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Making notification bar transparent
 */
private void changeStatusBarColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }
}
 
Example 9
Source File: JzvdStd.java    From imsdk-android with MIT License 5 votes vote down vote up
public Dialog createDialogWithView(View localView) {
    Dialog dialog = new Dialog(getContext(), R.style.jz_style_dialog_progress);
    dialog.setContentView(localView);
    Window window = dialog.getWindow();
    window.addFlags(Window.FEATURE_ACTION_BAR);
    window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
    window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
    window.setLayout(-2, -2);
    WindowManager.LayoutParams localLayoutParams = window.getAttributes();
    localLayoutParams.gravity = Gravity.CENTER;
    window.setAttributes(localLayoutParams);
    return dialog;
}
 
Example 10
Source File: TitleBarView.java    From UIWidget with Apache License 2.0 5 votes vote down vote up
/**
 * 设置沉浸式状态栏,4.4以上系统支持
 *
 * @param activity
 * @param immersible       是否沉浸
 * @param isTransStatusBar 是否透明状态栏 --xml未设置statusBackground 属性才会执行
 * @param isPlusStatusBar  是否增加状态栏高度--用于控制底部有输入框 (设置false/xml背景色必须保持和状态栏一致)
 */
public TitleBarView setImmersible(Activity activity, boolean immersible, boolean isTransStatusBar, boolean isPlusStatusBar) {
    this.mImmersible = immersible;
    this.mStatusBarPlusEnable = isPlusStatusBar;
    mStatusBarHeight = getNeedStatusBarHeight();
    if (activity == null) {
        return this;
    }
    //透明状态栏
    Window window = activity.getWindow();
    //Android 4.4以上
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mVStatus.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, mStatusBarHeight));
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //Android 5.1以上
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            int now = window.getDecorView().getSystemUiVisibility();
            int systemUi = mImmersible ?
                    now | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN :
                    (now & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN ? now ^ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN : now;
            window.getDecorView().setSystemUiVisibility(systemUi);
            if (mImmersible) {
                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            }
            window.setStatusBarColor(!mImmersible ? Color.BLACK : Color.TRANSPARENT);
        }
    }
    StatusBarUtil.fitsNotchScreen(window, mImmersible);
    setStatusAlpha(immersible ? isTransStatusBar ? 0 : 102 : 255);
    return this;
}
 
Example 11
Source File: UserProfileActivity.java    From Capstone-Project with MIT License 5 votes vote down vote up
private void applyTheme() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    }
}
 
Example 12
Source File: Dialog.java    From MDPreference with Apache License 2.0 5 votes vote down vote up
/**
 * Set the dim amount of the region outside this Dialog.
 *
 * @param amount The dim amount in [0..1].
 * @return The Dialog for chaining methods.
 */
public Dialog dimAmount(float amount) {
    Window window = getWindow();
    if (amount > 0f) {
        window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.dimAmount = amount;
        window.setAttributes(lp);
    } else
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    return this;
}
 
Example 13
Source File: RMBTTermsActivity.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    boolean showTermsAndConditions = true;
    
    if (getIntent().getExtras() != null) {
    	final String checkTypeName = getIntent().getExtras().getString(EXTRA_KEY_CHECK_TYPE, null);
    	if (checkTypeName != null) {
    		checkType = CheckType.valueOf(checkTypeName);
    	}
    	
    	showTermsAndConditions = getIntent().getExtras().getBoolean(EXTRA_KEY_CHECK_TERMS_AND_COND, true);
    }
    
    final Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
    window.addFlags(WindowManager.LayoutParams.FLAG_DITHER);
    
    if (savedInstanceState == null)
    {
        if (showTermsAndConditions) {
        	showTermsCheck();
        }
        else {
        	continueWorkflow();
        }
    }
}
 
Example 14
Source File: InAppChatActivity.java    From mobile-messaging-sdk-android with Apache License 2.0 5 votes vote down vote up
private void setStatusBarColor(int statusBarColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = this.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(statusBarColor);
    }
}
 
Example 15
Source File: AndroidUIGuidelinesBridge.java    From CrossMobile with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void setTranslucentStatusBar() {
    Window window = MainActivity.current.getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        // or this code, use both to be safe?
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.setStatusBarColor(Color.TRANSPARENT);
    } else
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
 
Example 16
Source File: SystemBar.java    From Album with Apache License 2.0 4 votes vote down vote up
/**
 * Set the navigation bar color.
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void setNavigationBarColor(Window window, int navigationBarColor) {
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setNavigationBarColor(navigationBarColor);
}
 
Example 17
Source File: ChannelActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
private Target getLightThemeTarget() {
	return new Target() {
		@Override
		public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
			streamerImage.setImageBitmap(bitmap);

			Palette palette = 		Palette.from(bitmap).generate();
			int defaultColor = 		Service.getColorAttribute(R.attr.colorPrimary, R.color.primary, getBaseContext());
			int defaultDarkColor = 	Service.getColorAttribute(R.attr.colorPrimaryDark, R.color.primaryDark, getBaseContext());

			int vibrant = 		palette.getVibrantColor(defaultColor);
			int vibrantDark = 	palette.getDarkVibrantColor(defaultColor);
			int vibrantLight = 	palette.getLightVibrantColor(defaultColor);

			int muted = 	 palette.getMutedColor(defaultColor);
			int mutedDark =  palette.getDarkMutedColor(defaultColor);
			int mutedLight = palette.getLightMutedColor(defaultColor);

			Palette.Swatch swatch = null;

			if (vibrant != defaultColor) {
				swatch = palette.getVibrantSwatch();
			} else if (vibrantDark != defaultColor) {
				swatch = palette.getDarkVibrantSwatch();
			} else if (vibrantLight != defaultColor){
				swatch = palette.getLightVibrantSwatch();
			} else if (muted != defaultColor) {
				swatch = palette.getMutedSwatch();
			} else if (mutedDark != defaultColor) {
				swatch = palette.getDarkMutedSwatch();
			} else {
				swatch = palette.getLightMutedSwatch();
			}

			if (swatch != null) {
				float[] swatchValues = swatch.getHsl();
				float[] newSwatch = {swatchValues[0], (float) 0.85, (float) 0.85};
				float[] newSwatchComposite = {(swatchValues[0] + 180) % 360, newSwatch[1], newSwatch[2]};
				float[] newSwatchDark = {newSwatch[0], newSwatch[1], (float) 0.6};

				int newColorDark = Color.HSVToColor(newSwatchDark);
				int newColor = Color.HSVToColor(newSwatch);
				int compositeNewColor = Color.HSVToColor(newSwatchComposite);

				int primaryColor = Service.getBackgroundColorFromView(toolbar, defaultColor);
				int primaryColorDark = Service.getBackgroundColorFromView(mTabs, defaultDarkColor);

				Service.animateBackgroundColorChange(toolbar, newColor, primaryColor, COLOR_FADE_DURATION);
				Service.animateBackgroundColorChange(additionalToolbar, newColor, primaryColor, COLOR_FADE_DURATION);
				Service.animateBackgroundColorChange(mTabs, newColorDark, primaryColorDark, COLOR_FADE_DURATION);
				mFab.setBackgroundTintList(ColorStateList.valueOf(compositeNewColor));
				mTabs.setSelectedTabIndicatorColor(compositeNewColor);

				if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
					Window window = getWindow();
					window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
					window.setStatusBarColor(newColorDark);
				}
			}
		}

		@Override
		public void onBitmapFailed(Drawable errorDrawable) {}

		@Override
		public void onPrepareLoad(Drawable placeHolderDrawable) {}
	};
}
 
Example 18
Source File: ViewUtil.java    From BaseProject with Apache License 2.0 4 votes vote down vote up
/**
     * 代码的方式来设置沉浸式界面
     * @param curActivity 当前Activity
     * @param needFullScreen 是否需要全屏:一般为false
     * @param translucentNavBar 是否需要透明导航栏:一般为true
     * @param hideNavigation 是否要隐藏导航栏: 一般为true
     * @param drawStatusBarBg 是否需要在Android 5.0及以上 接管状态栏背景绘制,用于指定 状态栏背景颜色
     * @param statusBarColor 想要的状态栏颜色
     * @param isLightStatusBar 是否需要在Android 6.0及以上 启用状态栏的灰色文字和图标
     */
    public static void immersiveScreen(Activity curActivity,boolean needFullScreen,
                                       boolean translucentNavBar,boolean hideNavigation,
                                       boolean drawStatusBarBg, int statusBarColor,boolean isLightStatusBar) {
        if (curActivity != null) {
            Window window = curActivity.getWindow();
            if (window != null) {
                WindowManager.LayoutParams windowParams = window.getAttributes();
                if (windowParams != null) {
                    //已经存在的 可见性参数
                    int mayExistVisibility = windowParams.systemUiVisibility;
//                    int mayExistFlags = windowParams.flags;
                    int curSdkInt = Build.VERSION.SDK_INT;
                    if (needFullScreen) {
//                        mayExistFlags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
                        window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                    }

                    if (curSdkInt >= 19) {//Android 4.4后才有沉浸式
                        if (translucentNavBar) {
//                            mayExistFlags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
                            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                        }
                        //默认的实现沉浸式flag
                        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

                        if (curSdkInt >= 21) {
                            if (drawStatusBarBg) {//如果需要 代替绘制状态栏的背景,则需要清除 FLAG_TRANSLUCENT_STATUS
                                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                            }
                            if (statusBarColor != -1) {
                                window.setStatusBarColor(statusBarColor);
                            }
                            if (curSdkInt >= 23) {//Android 6.0以上 实现状态栏字色和图标浅黑色
                                if (isLightStatusBar) {
                                    mayExistVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
                                }
                            }
                        }
                        if (hideNavigation) {//隐藏导航栏
                            mayExistVisibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                                    | View.SYSTEM_UI_FLAG_IMMERSIVE
                                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                            ;
                            windowParams.systemUiVisibility = mayExistVisibility;
                            window.setAttributes(windowParams);
                        }
                    }//curSdkInt >= 19 end
                }
            }
        }
    }
 
Example 19
Source File: WalletActivity.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
 protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     RelativeLayout navBarView = findViewById(R.id.nav_bar);
     navBarView.setVisibility(View.GONE);


//     Utils.setLocale(this, "fa");

     WebBase.apiKey = Web.API_KEY;
     WebBase.isDebug = true;
     WebBase.onResponseListener = new OnWebResponseListener() {
         @Override
         public boolean onResponse(Context context, Response response) {
             /*if (context instanceof NavigationBarActivity) {
                 if (response.code() == 401 || response.code() == 403) {
                     Utils.signOutAndGoLogin((NavigationBarActivity) context);
                     return false;
                 }
             }*/
             return true;
         }
     };

     Raad.init(getApplicationContext());
     intent = getIntent();
     String phone = intent.getStringExtra("Mobile");
     String language = intent.getStringExtra("Language");
     boolean isP2P = intent.getBooleanExtra("IsP2P", false);
     Payment payment = (Payment) intent.getSerializableExtra("Payment");
     primaryColor = intent.getStringExtra("PrimaryColor");
     darkPrimaryColor = intent.getStringExtra("DarkPrimaryColor");
     selectedLanguage = intent.getStringExtra(LANGUAGE);
     isDarkTheme = intent.getBooleanExtra(IS_DARK_THEME, false);
     progressColor = intent.getStringExtra(PROGRESSBAR);
     lineBorder = intent.getStringExtra(LINE_BORDER);
     backgroundTheme = intent.getStringExtra(BACKGROUND);
     backgroundTheme_2 = intent.getStringExtra(BACKGROUND_2);
     textTitleTheme = intent.getStringExtra(TEXT_TITLE);
     textSubTheme = intent.getStringExtra(TEXT_SUB_TITLE);

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
         Window window = getWindow();
         window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
         window.setStatusBarColor(Color.parseColor(WalletActivity.darkPrimaryColor));
     }
     if (selectedLanguage != null) {
         Utils.setLocale(this, selectedLanguage);
     }

     FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

     if (isP2P && payment != null) {
         ft.add(R.id.content_container, CardsFragment.newInstance(payment));

     } else {
         ft.add(R.id.content_container, new CardsFragment());
     }
     ft.commit();
 }
 
Example 20
Source File: DefaultErrorActivity.java    From crashx with Apache License 2.0 4 votes vote down vote up
@SuppressLint("PrivateResource")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {

    setTheme(R.style.Theme_AppCompat_Light_NoActionBar);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window w = getWindow();
        w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }

    super.onCreate(savedInstanceState);

    TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme);
    if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) {
        setTheme(R.style.Theme_AppCompat_Light_DarkActionBar);
    }
    a.recycle();

    setContentView(R.layout.crash_default_error_activity);
    Button restartButton = findViewById(R.id.crash_error_activity_restart_button);

    final CrashConfig config = CrashActivity.getConfigFromIntent(getIntent());

    if (config == null) {
        finish();
        return;
    }

    if (config.isShowRestartButton() && config.getRestartActivityClass() != null) {
        restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app);
        restartButton.setOnClickListener(v -> CrashActivity.restartApplication(DefaultErrorActivity.this, config));
    } else {
        restartButton.setOnClickListener(v -> CrashActivity.closeApplication(DefaultErrorActivity.this, config));
    }

    Button moreInfoButton = findViewById(R.id.crash_error_activity_more_info_button);

    if (config.isShowErrorDetails()) {
        moreInfoButton.setOnClickListener(v -> {
            AlertDialog dialog = new AlertDialog.Builder(DefaultErrorActivity.this)
                    .setTitle(R.string.customactivityoncrash_error_activity_error_details_title)
                    .setMessage(CrashActivity.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent()))
                    .setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null)
                    .setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy,
                            (dialog1, which) -> copyErrorToClipboard())
                    .show();
            TextView textView = dialog.findViewById(android.R.id.message);
            if (textView != null) {
                textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
            }
        });
    } else {
        moreInfoButton.setVisibility(View.GONE);
    }

    Integer defaultErrorActivityDrawableId = config.getErrorDrawable();
    ImageView errorImageView = findViewById(R.id.crash_error_activity_image);

    if (defaultErrorActivityDrawableId != null) {
        errorImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme()));
    }
}