Search in sources :

Example 41 with WindowManager

use of android.view.WindowManager in project materialistic by hidroh.

the class AppUtils method getDisplayHeight.

public static int getDisplayHeight(Context context) {
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point point = new Point();
        display.getSize(point);
        return point.y;
    } else {
        //noinspection deprecation
        return display.getHeight();
    }
}
Also used : Point(android.graphics.Point) Display(android.view.Display) WindowManager(android.view.WindowManager)

Example 42 with WindowManager

use of android.view.WindowManager in project ScrollableTabHost-for-Android by honcheng.

the class ScrollableTabActivity method commit.

public void commit() {
    bottomRadioGroup.removeAllViews();
    int optimum_visible_items_in_portrait_mode = 5;
    try {
        WindowManager window = getWindowManager();
        Display display = window.getDefaultDisplay();
        int window_width = display.getWidth();
        optimum_visible_items_in_portrait_mode = (int) (window_width / 64.0);
    } catch (Exception e) {
        optimum_visible_items_in_portrait_mode = 5;
    }
    int screen_width = getWindowManager().getDefaultDisplay().getWidth();
    int width;
    if (intentList.size() <= optimum_visible_items_in_portrait_mode) {
        width = screen_width / intentList.size();
    } else {
        //width = screen_width/5;
        width = 320 / 5;
    }
    RadioStateDrawable.width = width;
    RadioStateDrawable.screen_width = screen_width;
    buttonLayoutParams = new RadioGroup.LayoutParams(width, RadioGroup.LayoutParams.WRAP_CONTENT);
    for (int i = 0; i < intentList.size(); i++) {
        TabBarButton tabButton = new TabBarButton(this);
        int[] iconStates = (int[]) states.get(i);
        if (iconStates.length == 1)
            tabButton.setState(titleList.get(i).toString(), iconStates[0]);
        else if (iconStates.length == 2)
            tabButton.setState(titleList.get(i).toString(), iconStates[0], iconStates[1]);
        else if (iconStates.length == 3)
            tabButton.setState(titleList.get(i).toString(), iconStates[0], iconStates[1], iconStates[2]);
        tabButton.setId(i);
        tabButton.setGravity(Gravity.CENTER);
        bottomRadioGroup.addView(tabButton, i, buttonLayoutParams);
    }
    setCurrentTab(0);
}
Also used : RadioGroup(android.widget.RadioGroup) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 43 with WindowManager

use of android.view.WindowManager in project AndroidAutoLayout by hongyangAndroid.

the class ScreenUtils method getScreenSize.

public static int[] getScreenSize(Context context, boolean useDeviceSize) {
    int[] size = new int[2];
    WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display d = w.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    d.getMetrics(metrics);
    // since SDK_INT = 1;
    int widthPixels = metrics.widthPixels;
    int heightPixels = metrics.heightPixels;
    if (!useDeviceSize) {
        size[0] = widthPixels;
        size[1] = heightPixels - getStatusBarHeight(context);
        return size;
    }
    // includes window decorations (statusbar bar/menu bar)
    if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17)
        try {
            widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d);
            heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d);
        } catch (Exception ignored) {
        }
    // includes window decorations (statusbar bar/menu bar)
    if (Build.VERSION.SDK_INT >= 17)
        try {
            Point realSize = new Point();
            Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize);
            widthPixels = realSize.x;
            heightPixels = realSize.y;
        } catch (Exception ignored) {
        }
    size[0] = widthPixels;
    size[1] = heightPixels;
    return size;
}
Also used : Point(android.graphics.Point) DisplayMetrics(android.util.DisplayMetrics) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 44 with WindowManager

use of android.view.WindowManager in project android-percent-support-extend by hongyangAndroid.

the class PercentLayoutHelper method getScreenSize.

private void getScreenSize() {
    WindowManager wm = (WindowManager) mHost.getContext().getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(outMetrics);
    mWidthScreen = outMetrics.widthPixels;
    mHeightScreen = outMetrics.heightPixels;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Example 45 with WindowManager

use of android.view.WindowManager in project AndroidTraining by mixi-inc.

the class DefaultModule method configure.

@SuppressWarnings("unchecked")
protected void configure() {
    bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
    bind(Context.class).toProvider(ContextProvider.class);
    bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
    bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
    bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
    bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
    bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
    bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
    bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
    bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
    bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
    bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
    bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
    bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
    bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
    bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
    bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
    bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
    bind(ObserverManager.class);
    bindProviderListener(new ObserverRegister());
    bind(StateManager.class).in(ApplicationScoped.class);
    bind(StateEventObserver.class);
    bindFieldListener(RetainState.class, new RetainStateListener());
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) InputMethodManager(android.view.inputmethod.InputMethodManager) ActivityManager(android.app.ActivityManager) WindowManager(android.view.WindowManager) PowerManager(android.os.PowerManager) AudioManager(android.media.AudioManager) StateManager(proton.inject.state.StateManager) TelephonyManager(android.telephony.TelephonyManager) Context(android.content.Context) LocationManager(android.location.LocationManager) ApplicationProvider(proton.inject.provider.ApplicationProvider) NotificationManager(android.app.NotificationManager) HandlerProvider(proton.inject.provider.HandlerProvider) RetainStateListener(proton.inject.state.RetainStateListener) SensorManager(android.hardware.SensorManager) AlarmManager(android.app.AlarmManager) Vibrator(android.os.Vibrator) KeyguardManager(android.app.KeyguardManager) ObserverRegister(proton.inject.observer.ObserverRegister)

Aggregations

WindowManager (android.view.WindowManager)411 Display (android.view.Display)186 Point (android.graphics.Point)129 DisplayMetrics (android.util.DisplayMetrics)104 View (android.view.View)43 IWindowManager (android.view.IWindowManager)37 Context (android.content.Context)36 Resources (android.content.res.Resources)25 ImageView (android.widget.ImageView)24 SuppressLint (android.annotation.SuppressLint)20 Configuration (android.content.res.Configuration)20 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 Rect (android.graphics.Rect)16 RemoteException (android.os.RemoteException)15 LayoutParams (android.view.WindowManager.LayoutParams)15 TextView (android.widget.TextView)15 Dialog (android.app.Dialog)14 Method (java.lang.reflect.Method)12 PackageManager (android.content.pm.PackageManager)11