Professional Documents
Culture Documents
Preparing Apps For Android Q: Extended
Preparing Apps For Android Q: Extended
Singapore
➢ Beta 4
➢ Final API’s
➢ API Level 29
Extended
Singapore
What's New
Privacy & User
Security Experience
Extended
Singapore
➢ Exceptions:
.setFullScreenIntent(fullScreenPendingIntent, true)
➢ Gotcha’s:
➢ Avoid:
○ IMEI - TelephonyManager.getDeviceId()
○ Mac Address
○ ANDROID_ID - Settings.Secure.ANDROID_ID
Hardware Identifiers
➢ Alternatives
○ Advertising ID
○ Instance ID - FirebaseInstanceId
○ Globally-unique IDs (GUIDs) - UUID.randomUUID().toString()
Background Location
➢ Distinguish b/w foreground &
background
➢ Background Service
<service
android:name="MyNavigationService"
android:foregroundServiceType="location" ... >
...
</service>
<manifest>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
/>
</manifest>
ActivityCompat.requestPermissions(this,
arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION),
your-permission-request-code
➢ Gotcha’s:
User Experiences
Settings Panel
➢ Bottom sheet for system settings
➢ Currently Supported:
○ ACTION_INTERNET_CONNECTIVITY
○ ACTION_WIFI
○ ACTION_NFC
○ ACTION_VOLUME
➢ AndroidX wrapper
Gesture Navigation
Gesture Navigation
➢ Affects - All apps running on Q (irrespective of target SDK)
➢ Recommended approach
➢ Strongly recommended
<style name="AppTheme">
......
<item name="android:navigationBarColor">
@android:color/transparent
</item>
</style>
view.systemUiVisibility =
//Layout as if the navigation bar was hidden
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or
//Layout as if the status bar was hidden
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or
//Layout at its most extreme
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
➢ Overlap with system UI?
➢ Use insets
○ WindowInsets
root.setOnApplyWindowInsetsListener { _, insets ->
val fabLp = fab.layoutParams as
CoordinatorLayout.LayoutParams
fabLp.bottomMargin = fabOriginalBottomMargin +
insets.systemWindowInsetBottom
fab.layoutParams = fabLp
insets.consumeSystemWindowInsets()
}
➢ System Window Insets
➢ Clickable Views
➢ System Gesture Insets
○ New in Android Q
➢ Draggable Views
Insets.getSystemGestureInsets()
root.setOnApplyWindowInsetsListener { _, insets ->
val systemGestureInsets = insets.systemGestureInsets
top.layoutParams = top.layoutParams.apply {
height = systemGestureInsets.top
}
bottom.layoutParams = bottom.layoutParams.apply {
height = systemGestureInsets.bottom
}
....
}
➢ Override system gestures
○ Home is reserved
WindowInsets.getMandatorySystemGestureInsets()
Dark Mode
Dark Mode
➢ A new System Setting
○ Under Settings->Display->Theme
○ A Quick tile
<!--Material Components-->
<style name="AppTheme"
parent="Theme.MaterialComponents.DayNight">
<!--values/themes.xml-->
<style name="Theme.AppCompat.DayNight"
parent="Theme.AppCompat.Light">
<!--values-night/themes.xml-->
<style name="Theme.AppCompat.DayNight"
parent="Theme.AppCompat">
Dark Mode
➢ AppCompatDelegate.setDefaultNightMode()
○ MODE_NIGHT_YES
○ MODE_NIGHT_NO
○ MODE_NIGHT_FOLLOW_SYSTEM
○ MODE_NIGHT_AUTO_BATTERY
➢ Gotcha’s
<ConstraintLayout ....
background="#ABABAB">
<TextView ....
textColor="#FFFFFF">
<ConstraintLayout ....
background="@color/foo">
<TextView ....
textColor="@color/bar">
<!--values/colors.xml-->
<color name="foo">#ABABAB</color>
<ConstraintLayout ....
background="@color/foo">
<TextView ....
textColor="@color/bar">
<!--values/colors.xml-->
<color name="foo">#ABABAB</color>
<!--values-night/colors.xml-->
<color name="foo">#FAFAFA</color>
➢ Gotcha’s:
○ Vectors tint
<vector....
android:tint="?attr/textColorNormal"/>
➢ Gotcha’s:
○ Test RemoteViews
Not Covered
➢ Sharing improvements
➢ Bubbles
➢ Sharing improvements
➢ Bubbles
Thank Q
Questions?