Slide 1

Slide 1 text

Extended Singapore Preparing apps for Android Q Saurabh Arora, Rakuten Viki @saurabh_arora90

Slide 2

Slide 2 text

Where are we? ➢ Decade of Android (10.0) ➢ Beta 4 ➢ Final API’s ➢ API Level 29

Slide 3

Slide 3 text

Extended Singapore What's New

Slide 4

Slide 4 text

Privacy & Security User Experience

Slide 5

Slide 5 text

Extended Singapore Privacy & Security

Slide 6

Slide 6 text

Background Activity Starts ➢ Affects - All apps running on Q (irrespective of target SDK) ➢ Exceptions: ○ Bound services such as accessibility, auto-fill, etc. ○ Receives a PendingIntent from system ○ App had SYSTEM_ALERT_WINDOW permission ○ App called finish() on activity very recently ➢ Recommended approach - Notification Triggered activity

Slide 7

Slide 7 text

val notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID) .... .setPriority(NotificationCompat.PRIORITY_HIGH) .setCategory(NotificationCompat.CATEGORY_CALL)

Slide 8

Slide 8 text

val fullScreenIntent = Intent(this, CallActivity::class.java) val fullScreenPendingIntent = PendingIntent.getActivity(this, 0, fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT) val notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID) .... .setPriority(NotificationCompat.PRIORITY_HIGH) .setCategory(NotificationCompat.CATEGORY_CALL) .setFullScreenIntent(fullScreenPendingIntent, true)

Slide 9

Slide 9 text

➢ Gotcha’s: ○ System decides b/w notification & activity ■ Notification - User using the device ■ Activity - Device Idle / when user interacts with notification ○ Declare USE_FULL_SCREEN_INTENT permission

Slide 10

Slide 10 text

Hardware Identifiers ➢ Affects - All apps running on Q (irrespective of target SDK) ○ Exception thrown if Target SDK is Q ○ null returned if Target SDK < Q ➢ Avoid: ○ IMEI - TelephonyManager.getDeviceId() ○ Mac Address ○ ANDROID_ID - Settings.Secure.ANDROID_ID

Slide 11

Slide 11 text

Hardware Identifiers ➢ Alternatives ○ Advertising ID ○ Instance ID - FirebaseInstanceId ○ Globally-unique IDs (GUIDs) - UUID.randomUUID().toString()

Slide 12

Slide 12 text

Background Location ➢ Distinguish b/w foreground & background ➢ Location permission has 3 options

Slide 13

Slide 13 text

Background Location Requests ➢ Affects - Depends

Slide 14

Slide 14 text

Background Location Requests ➢ Foreground Service ➢ Background Service

Slide 15

Slide 15 text

...

Slide 16

Slide 16 text

Slide 17

Slide 17 text

ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION), your-permission-request-code

Slide 18

Slide 18 text

➢ Gotcha’s: ○ System schedules reminders ○ User can revoke permission ○ Always check access

Slide 19

Slide 19 text

Extended Singapore User Experiences

Slide 20

Slide 20 text

Settings Panel ➢ Bottom sheet for system settings ➢ Encourage app engagement ➢ Currently Supported: ○ ACTION_INTERNET_CONNECTIVITY ○ ACTION_WIFI ○ ACTION_NFC ○ ACTION_VOLUME ➢ AndroidX wrapper

Slide 21

Slide 21 text

Gesture Navigation

Slide 22

Slide 22 text

Gesture Navigation ➢ Affects - All apps running on Q (irrespective of target SDK) ➢ Recommended approach ○ Draw Edge to Edge ○ Override system gestures

Slide 23

Slide 23 text

➢ Draw Behind Navigation Bar ➢ Draw behind Status bar ➢ Strongly recommended

Slide 24

Slide 24 text

...... <item name="android:navigationBarColor"> @android:color/transparent </item>

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

➢ Overlap with system UI? ➢ Use insets ○ WindowInsets

Slide 27

Slide 27 text

root.setOnApplyWindowInsetsListener { _, insets -> val fabLp = fab.layoutParams as CoordinatorLayout.LayoutParams fabLp.bottomMargin = fabOriginalBottomMargin + insets.systemWindowInsetBottom fab.layoutParams = fabLp insets.consumeSystemWindowInsets() }

Slide 28

Slide 28 text

➢ System Window Insets ➢ Clickable Views

Slide 29

Slide 29 text

➢ System Gesture Insets ○ New in Android Q ➢ Draggable Views Insets.getSystemGestureInsets()

Slide 30

Slide 30 text

root.setOnApplyWindowInsetsListener { _, insets -> val systemGestureInsets = insets.systemGestureInsets top.layoutParams = top.layoutParams.apply { height = systemGestureInsets.top } bottom.layoutParams = bottom.layoutParams.apply { height = systemGestureInsets.bottom } .... }

Slide 31

Slide 31 text

➢ Override system gestures ➢ App gets touch event first

Slide 32

Slide 32 text

View.setSystemGestureExclusionRects(List rects)

Slide 33

Slide 33 text

➢ Gotcha’s: ○ Seekar & Drawer Layout work of the box ○ Can opt out back gesture ○ Home is reserved WindowInsets.getMandatorySystemGestureInsets()

Slide 34

Slide 34 text

Dark Mode

Slide 35

Slide 35 text

Dark Mode ➢ A new System Setting ○ Under Settings->Display->Theme ○ A Quick tile ○ Battery Saver Mode ➢ Supported by 1.1 App Compat

Slide 36

Slide 36 text

<!--Material Components--> <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">

Slide 37

Slide 37 text

<!--values-night/themes.xml--> <style name="Theme.AppCompat.DayNight" parent="Theme.AppCompat">

Slide 38

Slide 38 text

Dark Mode ➢ AppCompatDelegate.setDefaultNightMode() ○ MODE_NIGHT_YES ○ MODE_NIGHT_NO ○ MODE_NIGHT_FOLLOW_SYSTEM ○ MODE_NIGHT_AUTO_BATTERY

Slide 39

Slide 39 text

➢ Gotcha’s

Slide 40

Slide 40 text

Slide 41

Slide 41 text

#ABABAB

Slide 42

Slide 42 text

#ABABAB #FAFAFA

Slide 43

Slide 43 text

➢ Gotcha’s: ○ Check drawables and provide night resources ○ Vectors tint

Slide 44

Slide 44 text

➢ Gotcha’s: ○ Test RemoteViews ○ Configuration Change - uiMode ■ UI will lose context if not handled properly ■ Caution single orientation apps ■ Media apps should handle to continue playback

Slide 45

Slide 45 text

Extended Singapore Not Covered

Slide 46

Slide 46 text

➢ Sharing improvements ➢ Audio Playback Capture ➢ Bubbles

Slide 47

Slide 47 text

➢ Non SDK Interfaces ➢ Sharing improvements ➢ Audio Playback Capture ➢ Bubbles

Slide 48

Slide 48 text

Extended Singapore Thank Q Questions?