Java Code Examples for android.view.Window

The following are top voted examples for showing how to use android.view.Window. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: VideoRecorder-master   File: FFmpegRecorderActivity.java   View source code 7 votes vote down vote up
@Override
protected void onPreExecute() {
    isFinalizing = true;
    recordFinish = true;
    runAudioThread = false;

    //创建处理进度条
    creatingProgress = new Dialog(FFmpegRecorderActivity.this, R.style.Dialog_loading_noDim);
    Window dialogWindow = creatingProgress.getWindow();
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.width = (int) (getResources().getDisplayMetrics().density * 240);
    lp.height = (int) (getResources().getDisplayMetrics().density * 80);
    lp.gravity = Gravity.CENTER;
    dialogWindow.setAttributes(lp);
    creatingProgress.setCanceledOnTouchOutside(false);
    creatingProgress.setContentView(R.layout.activity_recorder_progress);

    progress = (TextView) creatingProgress.findViewById(R.id.recorder_progress_progresstext);
    bar = (ProgressBar) creatingProgress.findViewById(R.id.recorder_progress_progressbar);
    creatingProgress.show();


    //txtTimer.setVisibility(View.INVISIBLE);
    //handler.removeCallbacks(mUpdateTimeTask);
    super.onPreExecute();
}
 
Example 2
Project: ProgressManager   File: a.java   View source code 6 votes vote down vote up
/**
 * Default implementation of
 * {@link android.view.Window.Callback#onPanelClosed(int, Menu)} for
 * activities. This calls through to {@link #onOptionsMenuClosed(Menu)}
 * method for the {@link android.view.Window#FEATURE_OPTIONS_PANEL} panel,
 * so that subclasses of Activity don't need to deal with feature codes.
 * For context menus ({@link Window#FEATURE_CONTEXT_MENU}), the
 * {@link #onContextMenuClosed(Menu)} will be called.
 */
public void onPanelClosed(int featureId, Menu menu) {
    switch (featureId) {
        case Window.FEATURE_OPTIONS_PANEL:
            mFragments.dispatchOptionsMenuClosed(menu);
            onOptionsMenuClosed(menu);
            break;

        case Window.FEATURE_CONTEXT_MENU:
            onContextMenuClosed(menu);
            break;

        case Window.FEATURE_ACTION_BAR:
            initWindowDecorActionBar();
            mActionBar.dispatchMenuVisibilityChanged(false);
            break;
    }
}
 
Example 3
Project: BilibiliClient   File: SystemBarHelper.java   View source code 6 votes vote down vote up
/**
 * Android4.4以上的状态栏着色(针对于DrawerLayout)
 * 注:
 * 1.如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性,尤其是DrawerLayout的fitsSystemWindows属性
 * 2.可以版本判断在5.0以上不调用该方法,使用系统自带
 *
 * @param activity Activity对象
 * @param drawerLayout DrawerLayout对象
 * @param statusBarColor 状态栏颜色
 * @param alpha 透明栏透明度[0.0-1.0]
 */
public static void tintStatusBarForDrawer(Activity activity, DrawerLayout drawerLayout,
                                          @ColorInt int statusBarColor,
                                          @FloatRange(from = 0.0, to = 1.0) float alpha) {

  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return;
  }

  Window window = activity.getWindow();
  ViewGroup decorView = (ViewGroup) window.getDecorView();
  ViewGroup drawContent = (ViewGroup) drawerLayout.getChildAt(0);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(Color.TRANSPARENT);
    drawerLayout.setStatusBarBackgroundColor(statusBarColor);

    int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
    systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
    systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    window.getDecorView().setSystemUiVisibility(systemUiVisibility);
  } else {
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  }

  setStatusBar(decorView, statusBarColor, true, true);
  setTranslucentView(decorView, alpha);

  drawerLayout.setFitsSystemWindows(false);
  drawContent.setFitsSystemWindows(true);
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawer.setFitsSystemWindows(false);
}
 
Example 4
Project: AppServiceRestFul   File: BaseDialog.java   View source code 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
Project: MTweaks-KernelAdiutorMOD   File: BaseActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    Utils.DARK_THEME = Prefs.getBoolean("darktheme", false, this);
    int theme;
    String accent = Prefs.getString("accent_color", "pink_accent", this);
    if (Utils.DARK_THEME) {
        theme = sAccentDarkColors.get(accent);
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
    } else {
        theme = sAccentColors.get(accent);
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
    }
    setTheme(theme);
    super.onCreate(savedInstanceState);
    if (Prefs.getBoolean("forceenglish", false, this)) {
        Utils.setLocale("en_US", this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(statusBarColor());
    }
}
 
Example 6
Project: DailyZhiHu   File: DetaiContentActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    initTheme();
    setContentView(R.layout.detail_layout);
    //将状态栏透明
    if(Build.VERSION.SDK_INT>=21){
        View decorView = getWindow().getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    init();
    fillContent();
}
 
Example 7
Project: TFG-SmartU-La-red-social   File: SplashScreenActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //me subscribo a las notificaciones
    mFCMInteractor.subscribeToTopic("/topics/notificaciones");
    //Para cuando es llamado desde una notificacion
    Bundle bundle = getIntent().getExtras();
    // Oculto la barra de título para que no se vea en el Splash
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    //Establezco el contenido de la View al layout correspondiente
    setContentView(R.layout.activity_splash_screen);
    //Cargo las preferencias guardadas por el usuario, tipo de sesión, sesion y si es la primera vez
    ControladorPreferencias.cargarPreferencias(this);
    hPublicaciones = new HPublicaciones(SplashScreenActivity.this);
    hPublicaciones.sethPublicaciones(hPublicaciones);
    //Esto es porque vengo de una notificacion
    if(bundle!=null){
        hPublicaciones.setNotificacion("notificacion");
    }
    hPublicaciones.execute();
}
 
Example 8
Project: GitHub   File: StatusBar.java   View source code 6 votes vote down vote up
/**
 * 此方法需在setContentView之前调用
 *
 * @param activity Activity
 * @param rootView setContentView的内容
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void translucent(Activity activity, View rootView) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        //Android4.4以下不支持沉浸式状态栏
        return;
    }
    LogUtils.verbose("let status bar immersion");
    Window window = activity.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);//通知状态栏半透明
    //使用FitsSystemWindows和ClipToPadding来避免状态栏上移,配合沉浸
    rootView.setFitsSystemWindows(true);
    if (rootView instanceof ViewGroup) {
        ((ViewGroup) rootView).setClipToPadding(true);
    }
}
 
Example 9
Project: Phoenix-for-VK   File: StatusbarUtil.java   View source code 6 votes vote down vote up
private static boolean setMiuiStatusBarDarkMode(Activity activity, boolean darkmode) {
    Class<? extends Window> clazz = activity.getWindow().getClass();
    try {
        int darkModeFlag;
        Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");

        Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
        darkModeFlag = field.getInt(layoutParams);
        Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
        extraFlagField.invoke(activity.getWindow(), darkmode ? darkModeFlag : 0, darkModeFlag);
        return true;
    } catch (Exception ignored) {

    }

    return false;
}
 
Example 10
Project: siiMobilityAppKit   File: StatusBar.java   View source code 6 votes vote down vote up
private void setStatusBarTransparent(final boolean transparent) {
    if (Build.VERSION.SDK_INT >= 21) {
        final Window window = cordova.getActivity().getWindow();
        if (transparent) {
            window.getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
            window.setStatusBarColor(Color.TRANSPARENT);
        }
        else {
            window.getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_VISIBLE);
        }
    }
}
 
Example 11
Project: AndFast   File: EyesLollipop.java   View source code 6 votes vote down vote up
static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
    Window window = activity.getWindow();
    //添加Flag把状态栏设为可绘制模式
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    if (hideStatusBarBackground) {
        //如果为全透明模式,取消设置Window半透明的Flag
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //设置状态栏为透明
        window.setStatusBarColor(Color.TRANSPARENT);
        //设置window的状态栏不可见
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    } else {
        //如果为半透明模式,添加设置Window半透明的Flag
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //设置系统状态栏处于可见状态
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
    }
    //view不根据系统窗口来调整自己的布局
    ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
    View mChildView = mContentView.getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setFitsSystemWindows(mChildView, false);
        ViewCompat.requestApplyInsets(mChildView);
    }
}
 
Example 12
Project: android_nextgis_mobile   File: StyledDialogFragment.java   View source code 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html

    Dialog dialog = new Dialog(mContext);

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;
}
 
Example 13
Project: PlayAndroid   File: RevealEffectUtil.java   View source code 6 votes vote down vote up
public void createExitRevealEffect(final Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final View rootView = ((ViewGroup)activity.findViewById(Window.ID_ANDROID_CONTENT)).getChildAt(0);
        Animator revealEffect = createRevealEffect(rootView, Status.EXIT);
        revealEffect.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                rootView.setVisibility(View.INVISIBLE);
                activity.recreate();
            }
        });
        revealEffect.start();
    } else {
        activity.recreate();
    }
}
 
Example 14
Project: MultiScrollDemo   File: StatusBarUtil.java   View source code 6 votes vote down vote up
/**
 * 设置MIUI6+的状态栏是否为darkMode,darkMode时候字体颜色及icon变黑
 * http://dev.xiaomi.com/doc/p=4769/
 */
public static boolean darkModeForMIUI6(Window window, boolean darkmode) {
    Class<? extends Window> clazz = window.getClass();
    try {
        int darkModeFlag = 0;
        Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
        Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
        darkModeFlag = field.getInt(layoutParams);
        Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
        extraFlagField.invoke(window, darkmode ? darkModeFlag : 0, darkModeFlag);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
Example 15
Project: CCDownload   File: MediaPlayActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// 隐藏标题
	requestWindowFeature(Window.FEATURE_NO_TITLE);

	setContentView(R.layout.new_ad_media_play);
	
	sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

	wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
	cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
	
	detector = new GestureDetector(this, new MyGesture());
	
	initView();

	initPlayHander();

	initPlayInfo();
	
	if (!isLocalPlay) {
		initNetworkTimerTask();
	}
	videoId = getIntent().getStringExtra("videoId");
}
 
Example 16
Project: AC2RD   File: ListPreferenceThemeManager.java   View source code 6 votes vote down vote up
@Override
protected void showDialog(Bundle state)
{
	super.showDialog(state);
	final Resources res = getContext().getResources();
	final Window window = getDialog().getWindow();
	final int color = res.getColor(themeManager.getColorTheme(getContext()));

	// Title
	final int titleId = res.getIdentifier("alertTitle", "id", "android");
	final View title = window.findViewById(titleId);
	if (title != null)
	{
		((TextView) title).setTextColor(color);
	}
	
	// Title divider
	final int titleDividerId = res.getIdentifier("titleDivider", "id", "android");
	final View titleDivider = window.findViewById(titleDividerId);
	if (titleDivider != null)
	{
		titleDivider.setBackgroundColor(color);
	}
}
 
Example 17
Project: KotlinStudy   File: TtsSettings.java   View source code 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	super.onCreate(savedInstanceState);
	// 指定保存文件名字
	getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
	addPreferencesFromResource(R.xml.tts_setting);
	mSpeedPreference = (EditTextPreference)findPreference("speed_preference");
	mSpeedPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mSpeedPreference,0,200));
	
	mPitchPreference = (EditTextPreference)findPreference("pitch_preference");
	mPitchPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mPitchPreference,0,100));
	
	mVolumePreference = (EditTextPreference)findPreference("volume_preference");
	mVolumePreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mVolumePreference,0,100));
	
}
 
Example 18
Project: Xndroid   File: BrowserActivity.java   View source code 6 votes vote down vote up
/**
 * This method sets whether or not the activity will display
 * in full-screen mode (i.e. the ActionBar will be hidden) and
 * whether or not immersive mode should be set. This is used to
 * set both parameters correctly as during a full-screen video,
 * both need to be set, but other-wise we leave it up to user
 * preference.
 *
 * @param enabled   true to enable full-screen, false otherwise
 * @param immersive true to enable immersive mode, false otherwise
 */
private void setFullscreen(boolean enabled, boolean immersive) {
    mIsFullScreen = enabled;
    mIsImmersive = immersive;
    Window window = getWindow();
    View decor = window.getDecorView();
    if (enabled) {
        if (immersive) {
            decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        } else {
            decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        }
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
    }
}
 
Example 19
Project: login   File: TouchHelper.java   View source code 6 votes vote down vote up
public void startSlide() {
    preActivity = ((MyApplication) getContext().getApplicationContext()).getHelper().getPreActivity();
    if (preActivity == null) {
        return;
    }

    preContentView = (ViewGroup) preActivity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
    preView = (ViewGroup) preContentView.getChildAt(0);
    preContentView.removeView(preView);
    curContentView=(ViewGroup) mWindow.findViewById(Window.ID_ANDROID_CONTENT);
    curView= (ViewGroup) curContentView.getChildAt(0);
    preView.setX(-preView.getWidth() / 3);
    curContentView.addView(preView, 0);

    if (mShadowView == null) {
        mShadowView = new ShadowView(getContext());
    }
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(SHADOW_WIDTH, FrameLayout.LayoutParams.MATCH_PARENT);
    curContentView.addView(mShadowView, 1, params);
    mShadowView.setX(-SHADOW_WIDTH);
}
 
Example 20
Project: MyFire   File: MDAlertDialog.java   View source code 6 votes vote down vote up
public MDAlertDialog(Builder builder) {

        mBuilder = builder;
        mDialog = new Dialog(mContext, R.style.MyDialogStyle);
        mDialogView = View.inflate(mContext, R.layout.widget_md_dialog, null);
        mTitle = (TextView) mDialogView.findViewById(R.id.md_dialog_title);
        mContent = (TextView) mDialogView.findViewById(R.id.md_dialog_content);
        mLeftBtn = (TextView) mDialogView.findViewById(R.id.md_dialog_leftbtn);
        mRightBtn = (TextView) mDialogView.findViewById(R.id.md_dialog_rightbtn);
        mDialogView.setMinimumHeight((int) (ScreenSizeUtils.getInstance(mContext).getScreenHeight
                () * builder.getHeight()));
        mDialog.setContentView(mDialogView);

        Window dialogWindow = mDialog.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = (int) (ScreenSizeUtils.getInstance(mContext).getScreenWidth() * builder.getWidth());
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.gravity = Gravity.CENTER;
        dialogWindow.setAttributes(lp);
        initDialog();

    }
 
Example 21
Project: atlas   File: LocalActivityManager.java   View source code 5 votes vote down vote up
/**
 * Destroy the activity associated with a particular id.  This activity
 * will go through the normal lifecycle events and fine onDestroy(), and
 * then the id removed from the group.
 *
 * @param id Unique identifier of the activity to be destroyed
 * @param finish If true, this activity will be finished, so its id and
 * all state are removed from the group.
 *
 * @return Returns the window that was used to display the activity, or
 * null if there was none.
 */
public Window destroyActivity(String id, boolean finish) {
    LocalActivityRecord r = mActivities.get(id);
    Window win = null;
    if (r != null) {
        win = performDestroy(r, finish);
        if (finish) {
            mActivities.remove(id);
            mActivityArray.remove(r);
        }
    }
    return win;
}
 
Example 22
Project: Sofia   File: Utils.java   View source code 5 votes vote down vote up
/**
 * Set the navigation bar color.
 */
public static void setNavigationBarColor(Activity activity, int navigationBarColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = activity.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setNavigationBarColor(navigationBarColor);
    }
}
 
Example 23
Project: TibetanPersonalityTest   File: Result.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_result);

    sp = PreferenceManager.getDefaultSharedPreferences(this);

    adView = (AdView) findViewById(R.id.avViewr);
    tv1 = (TextView) findViewById(R.id.tv1);
    tv2 = (TextView) findViewById(R.id.tv2);
    tv3 = (TextView) findViewById(R.id.tv3);

    Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
    toolbar.setTitle("Result");
    setSupportActionBar(toolbar);

    displayAnswer1();
    displayAnswer2();
    displayAnswer3();

    initAds();

    mInterAd = new InterstitialAd(this);
    mInterAd.setAdUnitId(getResources().getString(R.string.finish_inter_ad_id));
    mInterAd.loadAd(new AdRequest.Builder().build());
    mInterAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            super.onAdClosed();
            finish();
        }
    });

}
 
Example 24
Project: HutHelper   File: StatusBarUtils.java   View source code 5 votes vote down vote up
private static boolean AndroidMStatusBarLightMode(Window window, boolean isDeepColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isDeepColor) {
        //必须清除这个flag
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        window.setStatusBarColor(Color.TRANSPARENT);
        return true;
    }
    return false;
}
 
Example 25
Project: Discover   File: JZUtils.java   View source code 5 votes vote down vote up
public static Window getWindow(Context context) {
    if (JZUtils.getAppCompActivity(context) != null) {
        return JZUtils.getAppCompActivity(context).getWindow();
    } else {
        return JZUtils.scanForActivity(context).getWindow();
    }
}
 
Example 26
Project: AndFast   File: Eyes.java   View source code 5 votes vote down vote up
public static void setStatusBarLightMode(Activity activity, int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //判断是否为小米或魅族手机,如果是则将状态栏文字改为黑色
        if (MIUISetStatusBarLightMode(activity, true) || FlymeSetStatusBarLightMode(activity, true)) {
            //设置状态栏为指定颜色
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0
                activity.getWindow().setStatusBarColor(color);
            } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4
                //调用修改状态栏颜色的方法
                setStatusBarColor(activity, color);
            }
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            //如果是6.0以上将状态栏文字改为黑色,并设置状态栏颜色
            activity.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            activity.getWindow().setStatusBarColor(color);

            //fitsSystemWindow 为 false, 不预留系统栏位置.
            ViewGroup mContentView = (ViewGroup) activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
            View mChildView = mContentView.getChildAt(0);
            if (mChildView != null) {
                ViewCompat.setFitsSystemWindows(mChildView, true);
                ViewCompat.requestApplyInsets(mChildView);
            }
        }
    }
}
 
Example 27
Project: NanCanOlympic   File: BottomDialog.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    getDialog().setCanceledOnTouchOutside(getCancelOutside());

    View v = inflater.inflate(getLayoutRes(), container, false);
    bindView(v);
    return v;
}
 
Example 28
Project: TextReader   File: ScreenUtils.java   View source code 5 votes vote down vote up
/**
 * 设置Activity的亮度
 *
 * @param paramInt
 * @param mActivity
 */
public static void setScreenBrightness(int paramInt, Activity mActivity) {
    if (paramInt <= 5) {
        paramInt = 5;
    }
    Window localWindow = mActivity.getWindow();
    WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes();
    float f = paramInt / 100.0F;
    localLayoutParams.screenBrightness = f;
    localWindow.setAttributes(localLayoutParams);
}
 
Example 29
Project: Tutors   File: Tutors.java   View source code 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    final Window window = getDialog().getWindow();
    if (window != null) {
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setDimAmount(0f);
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    }
}
 
Example 30
Project: civify-app   File: SplashActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sStart = System.currentTimeMillis();

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setupLang();

    checkNetwork();
}
 
Example 31
Project: BilibiliClient   File: SystemBarHelper.java   View source code 5 votes vote down vote up
/**
 * Android4.4以上的沉浸式全屏模式
 * 注:
 * 1.删除fitsSystemWindows属性:Android5.0以上使用该方法如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性
 * 或者调用forceFitsSystemWindows方法
 * 2.不删除fitsSystemWindows属性:也可以区别处理,Android5.0以上使用自己的方式实现,不调用该方法
 *
 * @param window 一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment
 * @param alpha 透明栏透明度[0.0-1.0]
 */
public static void immersiveStatusBar(Window window,
                                      @FloatRange(from = 0.0, to = 1.0) float alpha) {

  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return;
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(Color.TRANSPARENT);

    int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
    systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
    systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    window.getDecorView().setSystemUiVisibility(systemUiVisibility);
  } else {
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  }

  ViewGroup decorView = (ViewGroup) window.getDecorView();
  ViewGroup contentView = (ViewGroup) window.getDecorView()
      .findViewById(Window.ID_ANDROID_CONTENT);
  View rootView = contentView.getChildAt(0);
  int statusBarHeight = getStatusBarHeight(window.getContext());
  if (rootView != null) {
    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams();
    ViewCompat.setFitsSystemWindows(rootView, true);
    lp.topMargin = -statusBarHeight;
    rootView.setLayoutParams(lp);
  }

  setTranslucentView(decorView, alpha);
}
 
Example 32
Project: OpenHomeAnalysis   File: OhaEnergyUseLogFilterFragment.java   View source code 5 votes vote down vote up
@Override
public void onResume() {
    //Definir o tamanho da janela conforme percentual definido no dimens.xml:
    Window window = getDialog().getWindow();
    Point size = new Point();
    Display display = window.getWindowManager().getDefaultDisplay();
    display.getSize(size);
    double percentWidth = getResources().getInteger(R.integer.energy_use_log_filter_fragment_width_percent) / 100.00;
    double percentHeight = getResources().getInteger(R.integer.energy_use_log_filter_fragment_height_percent) / 100.00;
    window.setLayout((int) (size.x * percentWidth), (int) (size.y * percentHeight));
    window.setGravity(Gravity.CENTER);
    super.onResume();
}
 
Example 33
Project: HeadlineNews   File: StatusBarUtil.java   View source code 5 votes vote down vote up
/**
 * 设置Flyme4+的darkMode,darkMode时候字体颜色及icon变黑
 * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
 */
public static boolean darkModeForFlyme4(Window window, boolean dark) {
    boolean result = false;
    if (window != null) {
        try {
            WindowManager.LayoutParams e = window.getAttributes();
            Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
            Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
            darkFlag.setAccessible(true);
            meizuFlags.setAccessible(true);
            int bit = darkFlag.getInt(null);
            int value = meizuFlags.getInt(e);
            if (dark) {
                value |= bit;
            } else {
                value &= ~bit;
            }

            meizuFlags.setInt(e, value);
            window.setAttributes(e);
            result = true;
        } catch (Exception var8) {
            Log.e("StatusBar", "darkIcon: failed");
        }
    }

    return result;
}
 
Example 34
Project: live_master   File: BeforeWatchLiveActivity.java   View source code 5 votes vote down vote up
@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);
}
 
Example 35
Project: FastAndroid   File: ContactDetailActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.rc_ac_contact_detail);
    getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    initView();
    initData();
}
 
Example 36
Project: exciting-app   File: PopTextStickerDialog.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.dialog_edit_nd);
    getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    initView();
}
 
Example 37
Project: AssistantBySDK   File: RemindEditAheadDialog.java   View source code 5 votes vote down vote up
@Override
public void show() {
	Window dialogWindow =getWindow();
       LayoutParams lp = dialogWindow.getAttributes();
       dialogWindow.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.TOP);
       WindowManager m = context.getWindowManager();
       Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
       lp.width = (int) (d.getWidth() * 0.8);
       lp.y = 80; // 新位置Y坐标
       dialogWindow.setAttributes(lp);
	super.show();
}
 
Example 38
Project: WhatsAppStatusSaver   File: MainActivity.java   View source code 5 votes vote down vote up
private void showHelpPopup(final Activity context) {
    // Inflate the popup_layout.xml
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.help_popup_layout);
    dialog.show();
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.copyFrom(dialog.getWindow().getAttributes());
    dialog.getWindow().setAttributes(lp);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.getWindow().setDimAmount(0);
    // Creating the PopupWindow

    // Clear the default translucent background

    // Displaying the popup at the specified location, + offsets.

    // Getting a reference to Close button, and close the popup when clicked.
    FloatingActionButton close = (FloatingActionButton) dialog.findViewById(R.id.close_help_popup_button);
    close.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.cancel();
        }
    });
}
 
Example 39
Project: DUnit   File: StatusBarUtils.java   View source code 5 votes vote down vote up
public static void setWindowStatusBarColor(Activity activity, int colorResId) {
	try {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			Window window = activity.getWindow();
			window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
			window.setStatusBarColor(activity.getResources().getColor(colorResId));

			//底部导航栏
			//window.setNavigationBarColor(activity.getResources().getColor(colorResId));
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 40
Project: baselibrary-master   File: BaseActivity.java   View source code 5 votes vote down vote up
/**
     * onCreate
     *
     * @param savedInstanceState 状态保存.
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (mAllowFullScreen) {
            requestWindowFeature(Window.FEATURE_NO_TITLE); // 取消标题
        }
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//            this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
//        }
//        //最终方案
//        else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            //5.0 全透明实现
//            //getWindow.setStatusBarColor(Color.TRANSPARENT)
//            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);
//        }

        mContext = this;

        AppManager.getAppManager().addActivity(this);

        onCreate(savedInstanceState, "");

        logTag = setLogTag();//设置log日志tag

    }