Merge Density and DensityScope. Remove ambientDensity()
1) Renamed `DensityScope` to `Density` and bring the `density` and `fontScale` `val` properties into it directly
2) Provided a concrete implementation `DensityImpl` as a private data class
3) Provided a default factory `fun Density(...): Density` that returns a `DensityImpl`
4) Removed ambientDensity() in favour of using DensityAmbient.current directly
5) Removed withDensity(density) as now we can just use with(density)
A lot of tests are affected, but the changes there are just the replacements of the usage.
Relnote: Density and DensityScope were merged into one interface. Instead of ambientDensity() you can now use DensityAmbient.current. Instead of withDensity(density) just with(density)
Test: run all tests, demo app
Bug: 147672883
Bug: 148380287
Change-Id: I11cb1f069a95f32f4ecab631f49d38dc1c071a42
diff --git a/ui/ui-unit/api/0.1.0-dev05.txt b/ui/ui-unit/api/0.1.0-dev05.txt
index 905d27a0..95030e4 100644
--- a/ui/ui-unit/api/0.1.0-dev05.txt
+++ b/ui/ui-unit/api/0.1.0-dev05.txt
@@ -14,23 +14,9 @@
method public androidx.ui.unit.Dp getTop();
}
- public final class Density {
- ctor public Density(float density, float fontScale);
- method public float component1();
- method public float component2();
- method public androidx.ui.unit.Density copy(float density, float fontScale);
+ public interface Density {
method public float getDensity();
method public float getFontScale();
- }
-
- public final class DensityKt {
- method public static androidx.ui.unit.Density Density(android.content.Context context);
- method public static androidx.ui.unit.DensityScope DensityScope(androidx.ui.unit.Density density);
- method public static inline <R> R! withDensity(androidx.ui.unit.Density density, kotlin.jvm.functions.Function1<? super androidx.ui.unit.DensityScope,? extends R> block);
- }
-
- public interface DensityScope {
- method public androidx.ui.unit.Density getDensity();
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.TextUnit);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.Px);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.IntPx);
@@ -47,7 +33,13 @@
method public default androidx.ui.unit.TextUnit toSp(androidx.ui.unit.IntPx);
method public default androidx.ui.unit.TextUnit toSp(float);
method public default androidx.ui.unit.TextUnit toSp(int);
- property public abstract androidx.ui.unit.Density density;
+ property public abstract float density;
+ property public abstract float fontScale;
+ }
+
+ public final class DensityKt {
+ method public static androidx.ui.unit.Density Density(android.content.Context context);
+ method public static androidx.ui.unit.Density Density(float density, float fontScale = 1f);
}
public final class Dp implements java.lang.Comparable<androidx.ui.unit.Dp> {
diff --git a/ui/ui-unit/api/current.txt b/ui/ui-unit/api/current.txt
index 905d27a0..95030e4 100644
--- a/ui/ui-unit/api/current.txt
+++ b/ui/ui-unit/api/current.txt
@@ -14,23 +14,9 @@
method public androidx.ui.unit.Dp getTop();
}
- public final class Density {
- ctor public Density(float density, float fontScale);
- method public float component1();
- method public float component2();
- method public androidx.ui.unit.Density copy(float density, float fontScale);
+ public interface Density {
method public float getDensity();
method public float getFontScale();
- }
-
- public final class DensityKt {
- method public static androidx.ui.unit.Density Density(android.content.Context context);
- method public static androidx.ui.unit.DensityScope DensityScope(androidx.ui.unit.Density density);
- method public static inline <R> R! withDensity(androidx.ui.unit.Density density, kotlin.jvm.functions.Function1<? super androidx.ui.unit.DensityScope,? extends R> block);
- }
-
- public interface DensityScope {
- method public androidx.ui.unit.Density getDensity();
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.TextUnit);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.Px);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.IntPx);
@@ -47,7 +33,13 @@
method public default androidx.ui.unit.TextUnit toSp(androidx.ui.unit.IntPx);
method public default androidx.ui.unit.TextUnit toSp(float);
method public default androidx.ui.unit.TextUnit toSp(int);
- property public abstract androidx.ui.unit.Density density;
+ property public abstract float density;
+ property public abstract float fontScale;
+ }
+
+ public final class DensityKt {
+ method public static androidx.ui.unit.Density Density(android.content.Context context);
+ method public static androidx.ui.unit.Density Density(float density, float fontScale = 1f);
}
public final class Dp implements java.lang.Comparable<androidx.ui.unit.Dp> {
diff --git a/ui/ui-unit/api/public_plus_experimental_0.1.0-dev05.txt b/ui/ui-unit/api/public_plus_experimental_0.1.0-dev05.txt
index 905d27a0..95030e4 100644
--- a/ui/ui-unit/api/public_plus_experimental_0.1.0-dev05.txt
+++ b/ui/ui-unit/api/public_plus_experimental_0.1.0-dev05.txt
@@ -14,23 +14,9 @@
method public androidx.ui.unit.Dp getTop();
}
- public final class Density {
- ctor public Density(float density, float fontScale);
- method public float component1();
- method public float component2();
- method public androidx.ui.unit.Density copy(float density, float fontScale);
+ public interface Density {
method public float getDensity();
method public float getFontScale();
- }
-
- public final class DensityKt {
- method public static androidx.ui.unit.Density Density(android.content.Context context);
- method public static androidx.ui.unit.DensityScope DensityScope(androidx.ui.unit.Density density);
- method public static inline <R> R! withDensity(androidx.ui.unit.Density density, kotlin.jvm.functions.Function1<? super androidx.ui.unit.DensityScope,? extends R> block);
- }
-
- public interface DensityScope {
- method public androidx.ui.unit.Density getDensity();
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.TextUnit);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.Px);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.IntPx);
@@ -47,7 +33,13 @@
method public default androidx.ui.unit.TextUnit toSp(androidx.ui.unit.IntPx);
method public default androidx.ui.unit.TextUnit toSp(float);
method public default androidx.ui.unit.TextUnit toSp(int);
- property public abstract androidx.ui.unit.Density density;
+ property public abstract float density;
+ property public abstract float fontScale;
+ }
+
+ public final class DensityKt {
+ method public static androidx.ui.unit.Density Density(android.content.Context context);
+ method public static androidx.ui.unit.Density Density(float density, float fontScale = 1f);
}
public final class Dp implements java.lang.Comparable<androidx.ui.unit.Dp> {
diff --git a/ui/ui-unit/api/public_plus_experimental_current.txt b/ui/ui-unit/api/public_plus_experimental_current.txt
index 905d27a0..95030e4 100644
--- a/ui/ui-unit/api/public_plus_experimental_current.txt
+++ b/ui/ui-unit/api/public_plus_experimental_current.txt
@@ -14,23 +14,9 @@
method public androidx.ui.unit.Dp getTop();
}
- public final class Density {
- ctor public Density(float density, float fontScale);
- method public float component1();
- method public float component2();
- method public androidx.ui.unit.Density copy(float density, float fontScale);
+ public interface Density {
method public float getDensity();
method public float getFontScale();
- }
-
- public final class DensityKt {
- method public static androidx.ui.unit.Density Density(android.content.Context context);
- method public static androidx.ui.unit.DensityScope DensityScope(androidx.ui.unit.Density density);
- method public static inline <R> R! withDensity(androidx.ui.unit.Density density, kotlin.jvm.functions.Function1<? super androidx.ui.unit.DensityScope,? extends R> block);
- }
-
- public interface DensityScope {
- method public androidx.ui.unit.Density getDensity();
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.TextUnit);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.Px);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.IntPx);
@@ -47,7 +33,13 @@
method public default androidx.ui.unit.TextUnit toSp(androidx.ui.unit.IntPx);
method public default androidx.ui.unit.TextUnit toSp(float);
method public default androidx.ui.unit.TextUnit toSp(int);
- property public abstract androidx.ui.unit.Density density;
+ property public abstract float density;
+ property public abstract float fontScale;
+ }
+
+ public final class DensityKt {
+ method public static androidx.ui.unit.Density Density(android.content.Context context);
+ method public static androidx.ui.unit.Density Density(float density, float fontScale = 1f);
}
public final class Dp implements java.lang.Comparable<androidx.ui.unit.Dp> {
diff --git a/ui/ui-unit/api/restricted_0.1.0-dev05.txt b/ui/ui-unit/api/restricted_0.1.0-dev05.txt
index 905d27a0..95030e4 100644
--- a/ui/ui-unit/api/restricted_0.1.0-dev05.txt
+++ b/ui/ui-unit/api/restricted_0.1.0-dev05.txt
@@ -14,23 +14,9 @@
method public androidx.ui.unit.Dp getTop();
}
- public final class Density {
- ctor public Density(float density, float fontScale);
- method public float component1();
- method public float component2();
- method public androidx.ui.unit.Density copy(float density, float fontScale);
+ public interface Density {
method public float getDensity();
method public float getFontScale();
- }
-
- public final class DensityKt {
- method public static androidx.ui.unit.Density Density(android.content.Context context);
- method public static androidx.ui.unit.DensityScope DensityScope(androidx.ui.unit.Density density);
- method public static inline <R> R! withDensity(androidx.ui.unit.Density density, kotlin.jvm.functions.Function1<? super androidx.ui.unit.DensityScope,? extends R> block);
- }
-
- public interface DensityScope {
- method public androidx.ui.unit.Density getDensity();
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.TextUnit);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.Px);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.IntPx);
@@ -47,7 +33,13 @@
method public default androidx.ui.unit.TextUnit toSp(androidx.ui.unit.IntPx);
method public default androidx.ui.unit.TextUnit toSp(float);
method public default androidx.ui.unit.TextUnit toSp(int);
- property public abstract androidx.ui.unit.Density density;
+ property public abstract float density;
+ property public abstract float fontScale;
+ }
+
+ public final class DensityKt {
+ method public static androidx.ui.unit.Density Density(android.content.Context context);
+ method public static androidx.ui.unit.Density Density(float density, float fontScale = 1f);
}
public final class Dp implements java.lang.Comparable<androidx.ui.unit.Dp> {
diff --git a/ui/ui-unit/api/restricted_current.txt b/ui/ui-unit/api/restricted_current.txt
index 905d27a0..95030e4 100644
--- a/ui/ui-unit/api/restricted_current.txt
+++ b/ui/ui-unit/api/restricted_current.txt
@@ -14,23 +14,9 @@
method public androidx.ui.unit.Dp getTop();
}
- public final class Density {
- ctor public Density(float density, float fontScale);
- method public float component1();
- method public float component2();
- method public androidx.ui.unit.Density copy(float density, float fontScale);
+ public interface Density {
method public float getDensity();
method public float getFontScale();
- }
-
- public final class DensityKt {
- method public static androidx.ui.unit.Density Density(android.content.Context context);
- method public static androidx.ui.unit.DensityScope DensityScope(androidx.ui.unit.Density density);
- method public static inline <R> R! withDensity(androidx.ui.unit.Density density, kotlin.jvm.functions.Function1<? super androidx.ui.unit.DensityScope,? extends R> block);
- }
-
- public interface DensityScope {
- method public androidx.ui.unit.Density getDensity();
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.TextUnit);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.Px);
method public default androidx.ui.unit.Dp toDp(androidx.ui.unit.IntPx);
@@ -47,7 +33,13 @@
method public default androidx.ui.unit.TextUnit toSp(androidx.ui.unit.IntPx);
method public default androidx.ui.unit.TextUnit toSp(float);
method public default androidx.ui.unit.TextUnit toSp(int);
- property public abstract androidx.ui.unit.Density density;
+ property public abstract float density;
+ property public abstract float fontScale;
+ }
+
+ public final class DensityKt {
+ method public static androidx.ui.unit.Density Density(android.content.Context context);
+ method public static androidx.ui.unit.Density Density(float density, float fontScale = 1f);
}
public final class Dp implements java.lang.Comparable<androidx.ui.unit.Dp> {