diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2019-01-07 15:13:39 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2019-01-07 15:26:21 -0800 |
commit | 5bc1846375b43fe17b9b23bf8a1e4ffa8dbaf029 (patch) | |
tree | c55afb9bbb19d89cea99b1764c67d2f9763d9778 /src/com/android/launcher3/InvariantDeviceProfile.java | |
parent | 108c6e74cafa03b191979f6159d53f9ee547effb (diff) | |
download | android_packages_apps_Trebuchet-5bc1846375b43fe17b9b23bf8a1e4ffa8dbaf029.tar.gz android_packages_apps_Trebuchet-5bc1846375b43fe17b9b23bf8a1e4ffa8dbaf029.tar.bz2 android_packages_apps_Trebuchet-5bc1846375b43fe17b9b23bf8a1e4ffa8dbaf029.zip |
Adding support for putting arbitary attributes in InvariantDeviceProfile
This would allow derivative projects to profile profile specific
customization options
Change-Id: Id4703dc54d649a8d8a930f72c836c4ec23ffc45d
Diffstat (limited to 'src/com/android/launcher3/InvariantDeviceProfile.java')
-rw-r--r-- | src/com/android/launcher3/InvariantDeviceProfile.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 5c842a57d..935dda609 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -30,12 +30,16 @@ import android.text.TextUtils; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; +import android.util.SparseArray; +import android.util.TypedValue; import android.util.Xml; import android.view.Display; import android.view.WindowManager; import com.android.launcher3.util.ConfigMonitor; +import com.android.launcher3.util.IntArray; import com.android.launcher3.util.MainThreadInitializedObject; +import com.android.launcher3.util.Themes; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -44,6 +48,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; public class InvariantDeviceProfile { @@ -91,6 +96,8 @@ public class InvariantDeviceProfile { public int fillResIconDpi; public float iconTextSize; + private SparseArray<TypedValue> mExtraAttrs; + /** * Number of icons inside the hotseat area. */ @@ -122,6 +129,7 @@ public class InvariantDeviceProfile { numHotseatIcons = p.numHotseatIcons; defaultLayoutId = p.defaultLayoutId; demoModeLayoutId = p.demoModeLayoutId; + mExtraAttrs = p.mExtraAttrs; } @TargetApi(23) @@ -171,6 +179,8 @@ public class InvariantDeviceProfile { demoModeLayoutId = closestProfile.demoModeLayoutId; numFolderRows = closestProfile.numFolderRows; numFolderColumns = closestProfile.numFolderColumns; + mExtraAttrs = closestProfile.extraAttrs; + if (!closestProfile.name.equals(gridName)) { Utilities.getPrefs(context).edit() .putString(KEY_IDP_GRID_NAME, closestProfile.name).apply(); @@ -210,6 +220,11 @@ public class InvariantDeviceProfile { } } + @Nullable + public TypedValue getAttrValue(int attr) { + return mExtraAttrs == null ? null : mExtraAttrs.get(attr); + } + public void addOnChangeListener(OnIDPChangeListener listener) { mChangeListeners.add(listener); } @@ -436,6 +451,8 @@ public class InvariantDeviceProfile { private final int defaultLayoutId; private final int demoModeLayoutId; + private final SparseArray<TypedValue> extraAttrs; + GridOption(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.GridDisplayOption); @@ -454,6 +471,9 @@ public class InvariantDeviceProfile { numFolderColumns = a.getInt( R.styleable.GridDisplayOption_numFolderColumns, numColumns); a.recycle(); + + extraAttrs = Themes.createValueMap(context, attrs, + IntArray.wrap(R.styleable.GridDisplayOption)); } } |