List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:android.support.v7.app.ThemedAppCompatDelegate.java
/** * Create a {@link android.support.v7.app.AppCompatDelegate} to use with {@code activity}. * * @param callback An optional callback for AppCompat specific events *//*from w ww. j a va2s .c o m*/ public static AppCompatDelegate create(IThemedActivity themed, AppCompatCallback callback) { final Activity activity = (Activity) themed; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { return new ThemedAppCompatDelegateImplV11(themed, activity, activity.getWindow(), callback); } else { throw new UnsupportedOperationException(); } }
From source file:com.pyamsoft.dontsuckmp.main.MainActivity.java
public static void colorStatusbar(@NonNull Activity activity, @ColorInt int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(color); }/* w ww.j a va 2s.c om*/ }
From source file:Main.java
public static void initialize(Activity activity, int layout) { // Do all sorts of common task for your activities here including: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); activity.setContentView(layout);//w ww . j a va 2 s. co m activity.getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); activity.getActionBar().setDisplayOptions( ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }
From source file:Main.java
public static void setKeepScreenOn(Activity activity, boolean setkeepScreenOn) { if (null == activity) return;/*from www . j a va 2 s . c o m*/ // activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, // WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:Main.java
public static void setBrightness(Activity activity, float brightness) { // Settings.System.putInt(activity.getContentResolver(), // Settings.System.SCREEN_BRIGHTNESS_MODE, // Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); // some ROM may ANF if set brightness to 0 lp.screenBrightness = Math.max(brightness, 0.01f); activity.getWindow().setAttributes(lp); }
From source file:com.hzx.androidtransitionanimationdemo.TransitionHelper.java
/** * Active Transition ??UI//w w w .j a v a 2 s.co m * * @param activity ?transtionactivity * @param includeStatusBar false, status bar ? transition * @return transition ViewList. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // 1??UI: View decor = activity.getWindow().getDecorView(); View statusBar = null; if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); // 2 transition pair?. List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // 3?otherParticipants??participants if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } // 4translation return participants.toArray(new Pair[participants.size()]); }
From source file:Main.java
/** * Automatic showing keyboard and set focus * @param EditText editText/*from www. j a va 2s. co m*/ * @param Activity activity */ public static void showKeyboard(EditText editText, final Activity activity) { editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { activity.getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); editText.requestFocus(); }
From source file:android.support.v7.app.ThemedAppCompatDelegateFactory.java
/** * Create a {@link android.support.v7.app.AppCompatDelegate} to use with {@code activity}. * * @param callback An optional callback for AppCompat specific events *//*from w w w . j a v a2 s . com*/ public static ThemedAppCompatDelegate create(@NonNull final IThemedActivity themed, @NonNull final AppCompatCallback callback) { final Activity activity = (Activity) themed; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { return new ThemedAppCompatDelegate(themed, activity, activity.getWindow(), callback); } else { throw new UnsupportedOperationException(); } }
From source file:im.ene.ribbon.MiscUtils.java
/** * Returns true if the current theme has declared the botton navigation as translucent * * @param activity context//from w w w.j av a2 s . c o m * @return true if the activity has the translucent navigation enabled */ static boolean hasTranslucentNavigationBar(@Nullable final Activity activity) { return activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && ((activity.getWindow().getAttributes().flags & LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); }
From source file:Main.java
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // Avoid system UI glitches as described here: // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = null;//from www. j ava2 s .co m if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); // Create pair of transition participants. List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } return participants.toArray(new Pair[participants.size()]); }