Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54be9bd7 authored by LorDClockaN's avatar LorDClockaN Committed by Steve Kondik
Browse files

Clean up code after ScreenType FWB commit

Change-Id: I07874c68802674695877c6bd0329c8973dd1c653
parent 7ee468c5
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.WindowManagerGlobal;

import com.android.internal.util.cm.ScreenType;

import com.android.settings.cyanogenmod.ButtonBacklightBrightness;

import com.android.settings.search.BaseSearchIndexProvider;
@@ -383,7 +385,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
            boolean hasNavBar = WindowManagerGlobal.getWindowManagerService().hasNavigationBar()
                    || forceNavbar;

            if (!Utils.isPhone(context)) {
            if (!ScreenType.isPhone(context)) {
                result.put(KEY_NAVIGATION_BAR_LEFT, CATEGORY_NAVBAR);
            }

@@ -579,7 +581,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (preference == mSwapVolumeButtons) {
            int value = mSwapVolumeButtons.isChecked()
                    ? (Utils.isTablet(getActivity()) ? 2 : 1) : 0;
                    ? (ScreenType.isTablet(getActivity()) ? 2 : 1) : 0;
            Settings.System.putInt(getActivity().getContentResolver(),
                    Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, value);
        } else if (preference == mDisableNavigationKeys) {
+0 −45
Original line number Diff line number Diff line
@@ -68,13 +68,10 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ListView;
import android.widget.TabWidget;

@@ -144,14 +141,6 @@ public final class Utils {
    private static final int SECONDS_PER_HOUR = 60 * 60;
    private static final int SECONDS_PER_DAY = 24 * 60 * 60;

    // Device types
    private static final int DEVICE_PHONE = 0;
    private static final int DEVICE_HYBRID = 1;
    private static final int DEVICE_TABLET = 2;

    // Device type reference
    private static int sDeviceType = -1;

    /**
     * Finds a matching activity for a preference's intent. If a matching
     * activity is not found, it will remove the preference.
@@ -743,40 +732,6 @@ public final class Utils {
        return um.getUserInfo(um.getUserHandle()).isRestricted();
    }

    private static int getScreenType(Context context) {
        if (sDeviceType == -1) {
            WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
           DisplayInfo outDisplayInfo = new DisplayInfo();
            wm.getDefaultDisplay().getDisplayInfo(outDisplayInfo);
            int shortSize = Math.min(outDisplayInfo.logicalHeight, outDisplayInfo.logicalWidth);
            int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT
                    / outDisplayInfo.logicalDensityDpi;
            if (shortSizeDp < 600) {
                // 0-599dp: "phone" UI with a separate status & navigation bar
                sDeviceType =  DEVICE_PHONE;
            } else if (shortSizeDp < 720) {
                // 600-719dp: "phone" UI with modifications for larger screens
                sDeviceType = DEVICE_HYBRID;
            } else {
                // 720dp: "tablet" UI with a single combined status & navigation bar
                sDeviceType = DEVICE_TABLET;
            }
        }
        return sDeviceType;
    }

    public static boolean isPhone(Context context) {
        return getScreenType(context) == DEVICE_PHONE;
    }

    public static boolean isHybrid(Context context) {
        return getScreenType(context) == DEVICE_HYBRID;
    }

    public static boolean isTablet(Context context) {
        return getScreenType(context) == DEVICE_TABLET;
    }

    /* returns whether the device has volume rocker or not. */
    public static boolean hasVolumeRocker(Context context) {
        final int deviceKeys = context.getResources().getInteger(
+3 −2
Original line number Diff line number Diff line
@@ -29,9 +29,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;

import com.android.internal.util.cm.ScreenType;

import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;

public class ProfilesList extends SettingsPreferenceFragment implements
        Preference.OnPreferenceChangeListener {
@@ -53,7 +54,7 @@ public class ProfilesList extends SettingsPreferenceFragment implements
        refreshList();

        // On tablet devices remove the padding
        if (Utils.isTablet(getActivity())) {
        if (ScreenType.isTablet(getActivity())) {
            getListView().setPadding(0, 0, 0, 0);
        }
    }
+3 −2
Original line number Diff line number Diff line
@@ -45,11 +45,12 @@ import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;

import com.android.internal.util.cm.ScreenType;

import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.SubSettings;
import com.android.settings.Utils;
import com.android.settings.cyanogenmod.BaseSystemSettingSwitchBar;

public class ProfilesSettings extends SettingsPreferenceFragment
@@ -136,7 +137,7 @@ public class ProfilesSettings extends SettingsPreferenceFragment
        updateProfilesEnabledState();

        // If running on a phone, remove padding around tabs
        if (!Utils.isTablet(getActivity())) {
        if (!ScreenType.isTablet(getActivity())) {
            mContainer.setPadding(0, 0, 0, 0);
        }
    }
+3 −2
Original line number Diff line number Diff line
@@ -37,10 +37,11 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.internal.util.cm.ScreenType;

import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.cyanogenmod.BaseSystemSettingSwitchBar;
import com.android.settings.cyanogenmod.ShortcutPickHelper;

@@ -136,7 +137,7 @@ public class VoiceWakeupSettings extends SettingsPreferenceFragment implements
        }

        // If running on a phone, remove padding around tabs
        if (!Utils.isTablet(getActivity())) {
        if (!ScreenType.isTablet(getActivity())) {
            mContainer.setPadding(0, 0, 0, 0);
        }
    }