diff options
author | LorDClockaN <davor@losinj.com> | 2015-01-23 15:48:57 +0100 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2015-11-30 02:12:16 +0200 |
commit | c9503e0919ddeae38da404fbec6772bba52e0626 (patch) | |
tree | 9a7ce2cfbacf1ae6654d39c78a6005c074ea59c5 /src | |
parent | afc48d714f82b5fc702660cabf126c604f01d316 (diff) | |
download | packages_apps_Settings-c9503e0919ddeae38da404fbec6772bba52e0626.zip packages_apps_Settings-c9503e0919ddeae38da404fbec6772bba52e0626.tar.gz packages_apps_Settings-c9503e0919ddeae38da404fbec6772bba52e0626.tar.bz2 |
Use ScreenType util from cmsdk
Change-Id: I07874c68802674695877c6bd0329c8973dd1c653
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/ButtonSettings.java | 14 | ||||
-rw-r--r-- | src/com/android/settings/Utils.java | 46 | ||||
-rw-r--r-- | src/com/android/settings/profiles/ProfilesList.java | 8 | ||||
-rw-r--r-- | src/com/android/settings/profiles/ProfilesSettings.java | 13 | ||||
-rw-r--r-- | src/com/android/settings/voicewakeup/VoiceWakeupSettings.java | 5 |
5 files changed, 28 insertions, 58 deletions
diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java index 68ced22..5886a3f 100644 --- a/src/com/android/settings/ButtonSettings.java +++ b/src/com/android/settings/ButtonSettings.java @@ -43,16 +43,18 @@ import android.view.KeyEvent; import android.view.WindowManagerGlobal; import com.android.internal.logging.MetricsLogger; + +import com.android.settings.cyanogenmod.ButtonBacklightBrightness; import com.android.settings.R; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; -import com.android.settings.cyanogenmod.ButtonBacklightBrightness; +import cyanogenmod.hardware.CMHardwareManager; import cyanogenmod.providers.CMSettings; -import com.android.settings.search.BaseSearchIndexProvider; -import com.android.settings.search.Indexable; -import cyanogenmod.hardware.CMHardwareManager; +import org.cyanogenmod.internal.util.ScreenType; import java.util.List; @@ -391,7 +393,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements boolean hasNavBar = WindowManagerGlobal.getWindowManagerService().hasNavigationBar() || forceNavbar; - if (!Utils.isPhone(getActivity())) { + if (!ScreenType.isPhone(getActivity())) { mNavigationPreferencesCat.removePreference(mNavigationBarLeftPref); } @@ -698,7 +700,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; CMSettings.System.putInt(getActivity().getContentResolver(), CMSettings.System.SWAP_VOLUME_KEYS_ON_ROTATION, value); } else if (preference == mVolumeControlRingStream) { diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 34a27fa..b18e27c 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -84,16 +84,12 @@ import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; -import android.view.DisplayInfo; import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; -import android.util.DisplayMetrics; -import android.view.DisplayInfo; -import android.view.WindowManager; import android.widget.ListView; import android.widget.TabWidget; @@ -165,14 +161,6 @@ public final class Utils { private static SparseArray<Bitmap> sDarkDefaultUserBitmapCache = new SparseArray<Bitmap>(); - // 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. @@ -726,40 +714,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( diff --git a/src/com/android/settings/profiles/ProfilesList.java b/src/com/android/settings/profiles/ProfilesList.java index 34e53a0..4a384dc 100644 --- a/src/com/android/settings/profiles/ProfilesList.java +++ b/src/com/android/settings/profiles/ProfilesList.java @@ -35,7 +35,8 @@ import android.widget.ListView; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; -import com.android.settings.Utils; + +import org.cyanogenmod.internal.util.ScreenType; public class ProfilesList extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener { @@ -60,6 +61,11 @@ public class ProfilesList extends SettingsPreferenceFragment implements public void onResume() { super.onResume(); refreshList(); + + // On tablet devices remove the padding + if (ScreenType.isTablet(getActivity())) { + getListView().setPadding(0, 0, 0, 0); + } } @Override diff --git a/src/com/android/settings/profiles/ProfilesSettings.java b/src/com/android/settings/profiles/ProfilesSettings.java index 957cf82..2de2d95 100644 --- a/src/com/android/settings/profiles/ProfilesSettings.java +++ b/src/com/android/settings/profiles/ProfilesSettings.java @@ -42,17 +42,19 @@ import android.widget.Switch; import android.widget.TextView; import com.android.internal.logging.MetricsLogger; -import cyanogenmod.app.Profile; -import cyanogenmod.app.ProfileManager; 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.CMBaseSystemSettingSwitchBar; + +import cyanogenmod.app.Profile; +import cyanogenmod.app.ProfileManager; import cyanogenmod.providers.CMSettings; +import org.cyanogenmod.internal.util.ScreenType; + import java.util.UUID; public class ProfilesSettings extends SettingsPreferenceFragment @@ -143,6 +145,11 @@ public class ProfilesSettings extends SettingsPreferenceFragment // check if we are enabled updateProfilesEnabledState(); + + // If running on a phone, remove padding around tabs + if (!ScreenType.isTablet(getActivity())) { + mContainer.setPadding(0, 0, 0, 0); + } } @Override diff --git a/src/com/android/settings/voicewakeup/VoiceWakeupSettings.java b/src/com/android/settings/voicewakeup/VoiceWakeupSettings.java index e3698ef..3db5530 100644 --- a/src/com/android/settings/voicewakeup/VoiceWakeupSettings.java +++ b/src/com/android/settings/voicewakeup/VoiceWakeupSettings.java @@ -42,10 +42,11 @@ import com.android.internal.logging.MetricsLogger; 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; +import org.cyanogenmod.internal.util.ScreenType; + public class VoiceWakeupSettings extends SettingsPreferenceFragment implements OnPreferenceChangeListener, ShortcutPickHelper.OnPickListener, BaseSystemSettingSwitchBar.SwitchBarChangeCallback { @@ -138,7 +139,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); } } |