aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-09-10 17:21:57 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-09-10 17:21:57 +0000
commitddb9444be0a584646eda4939be5bb0503092393f (patch)
treedc14d3d116fe072cbfd245e73567c9d2eaf42384
parentd951dc8e2917efc9f8f6dda675da18ff7456ee33 (diff)
parent06c3564fac37abafbafd2950a2c855a8c8cbe9f2 (diff)
downloadandroid-ddb9444be0a584646eda4939be5bb0503092393f.tar.gz
Merge "Merge Android R"
-rw-r--r--content/SharingShortcuts/Application/src/main/java/com/example/android/sharingshortcuts/MainActivity.java7
-rw-r--r--content/SharingShortcuts/template-params.xml2
-rw-r--r--notification/Bubbles/app/src/main/java/com/example/android/bubbles/data/NotificationHelper.kt34
-rw-r--r--projects.txt118
-rw-r--r--ui/DarkTheme/Application/.gitignore16
-rw-r--r--ui/DarkTheme/Application/proguard-project.txt20
-rw-r--r--ui/DarkTheme/Application/src/main/AndroidManifest.xml42
-rw-r--r--ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ColorUtils.java45
-rw-r--r--ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/DarkThemeApplication.java33
-rw-r--r--ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/MainActivity.java121
-rw-r--r--ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/PreferencesFragment.java38
-rw-r--r--ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/SettingsFragment.java47
-rw-r--r--ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ThemeHelper.java49
-rw-r--r--ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/WelcomeFragment.java38
-rw-r--r--ui/DarkTheme/Application/src/main/res/color/color_on_primary_mask.xml25
-rw-r--r--ui/DarkTheme/Application/src/main/res/drawable/bottom_nav_item_background.xml21
-rw-r--r--ui/DarkTheme/Application/src/main/res/drawable/ic_brightness.xml26
-rw-r--r--ui/DarkTheme/Application/src/main/res/drawable/ic_brightness_2.xml30
-rw-r--r--ui/DarkTheme/Application/src/main/res/drawable/ic_dashboard.xml26
-rw-r--r--ui/DarkTheme/Application/src/main/res/drawable/ic_home.xml26
-rw-r--r--ui/DarkTheme/Application/src/main/res/drawable/ic_more_vert.xml26
-rw-r--r--ui/DarkTheme/Application/src/main/res/drawable/ic_settings.xml26
-rw-r--r--ui/DarkTheme/Application/src/main/res/layout/activity_main.xml59
-rw-r--r--ui/DarkTheme/Application/src/main/res/layout/fragment_preferences.xml98
-rw-r--r--ui/DarkTheme/Application/src/main/res/layout/fragment_welcome.xml46
-rw-r--r--ui/DarkTheme/Application/src/main/res/menu/main_menu.xml25
-rw-r--r--ui/DarkTheme/Application/src/main/res/menu/navigation.xml35
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 1279 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher_round.pngbin0 -> 3249 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 890 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher_round.pngbin0 -> 1951 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 1662 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher_round.pngbin0 -> 4448 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 2869 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher_round.pngbin0 -> 7212 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 4093 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher_round.pngbin0 -> 10846 bytes
-rw-r--r--ui/DarkTheme/Application/src/main/res/values-night/colors.xml25
-rw-r--r--ui/DarkTheme/Application/src/main/res/values-v28/arrays.xml32
-rw-r--r--ui/DarkTheme/Application/src/main/res/values/arrays.xml32
-rw-r--r--ui/DarkTheme/Application/src/main/res/values/colors.xml25
-rw-r--r--ui/DarkTheme/Application/src/main/res/values/dimens.xml24
-rw-r--r--ui/DarkTheme/Application/src/main/res/values/strings.xml33
-rw-r--r--ui/DarkTheme/Application/src/main/res/values/styles.xml28
-rw-r--r--ui/DarkTheme/Application/src/main/res/xml/preferences.xml35
-rw-r--r--ui/DarkTheme/build.gradle16
-rw-r--r--ui/DarkTheme/buildSrc/build.gradle17
-rw-r--r--ui/DarkTheme/gradle.properties22
-rw-r--r--ui/DarkTheme/gradle/wrapper/gradle-wrapper.jarbin0 -> 49896 bytes
-rw-r--r--ui/DarkTheme/gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xui/DarkTheme/gradlew164
-rw-r--r--ui/DarkTheme/gradlew.bat90
-rw-r--r--ui/DarkTheme/screenshots/dark_1_welcome.pngbin0 -> 49992 bytes
-rw-r--r--ui/DarkTheme/screenshots/dark_3_settings.pngbin0 -> 42312 bytes
-rw-r--r--ui/DarkTheme/screenshots/dark_4_theme_options.pngbin0 -> 66537 bytes
-rw-r--r--ui/DarkTheme/screenshots/light_1_welcome.pngbin0 -> 49157 bytes
-rw-r--r--ui/DarkTheme/screenshots/light_2_preferences.pngbin0 -> 88942 bytes
-rw-r--r--ui/DarkTheme/screenshots/light_3_settings.pngbin0 -> 40991 bytes
-rw-r--r--ui/DarkTheme/screenshots/light_4_theme_options.pngbin0 -> 69448 bytes
-rw-r--r--ui/DarkTheme/screenshots/smart_dark_2_preferences.pngbin0 -> 89866 bytes
-rw-r--r--ui/DarkTheme/settings.gradle2
-rw-r--r--ui/DarkTheme/template-params.xml171
62 files changed, 1653 insertions, 148 deletions
diff --git a/content/SharingShortcuts/Application/src/main/java/com/example/android/sharingshortcuts/MainActivity.java b/content/SharingShortcuts/Application/src/main/java/com/example/android/sharingshortcuts/MainActivity.java
index 17dfdc9f..285c09a5 100644
--- a/content/SharingShortcuts/Application/src/main/java/com/example/android/sharingshortcuts/MainActivity.java
+++ b/content/SharingShortcuts/Application/src/main/java/com/example/android/sharingshortcuts/MainActivity.java
@@ -23,6 +23,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.widget.EditText;
@@ -39,6 +40,8 @@ import java.io.IOException;
*/
public class MainActivity extends Activity {
+ private static final String TAG = "MainActivity";
+
// Domain authority for our app FileProvider
private static final String FILE_PROVIDER_AUTHORITY =
"com.example.android.sharingshortcuts.fileprovider";
@@ -113,10 +116,10 @@ public class MainActivity extends Activity {
Uri contentUri = saveImageThumbnail();
return ClipData.newUri(getContentResolver(), null, contentUri);
} catch (FileNotFoundException e) {
- e.printStackTrace();
+ Log.e(TAG, e.getLocalizedMessage());
return null;
} catch (IOException e) {
- e.printStackTrace();
+ Log.e(TAG, e.getLocalizedMessage());
return null;
}
}
diff --git a/content/SharingShortcuts/template-params.xml b/content/SharingShortcuts/template-params.xml
index 5bf56268..e8ca1746 100644
--- a/content/SharingShortcuts/template-params.xml
+++ b/content/SharingShortcuts/template-params.xml
@@ -40,7 +40,7 @@ some options directly in the list of share intent candidates and launcher shortc
<metadata>
<!-- Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED} -->
- <status>DRAFT</status>
+ <status>PUBLISHED</status>
<categories>Content</categories>
<technologies>Android</technologies>
<languages>Java</languages>
diff --git a/notification/Bubbles/app/src/main/java/com/example/android/bubbles/data/NotificationHelper.kt b/notification/Bubbles/app/src/main/java/com/example/android/bubbles/data/NotificationHelper.kt
index 825489c3..be81e9c8 100644
--- a/notification/Bubbles/app/src/main/java/com/example/android/bubbles/data/NotificationHelper.kt
+++ b/notification/Bubbles/app/src/main/java/com/example/android/bubbles/data/NotificationHelper.kt
@@ -22,17 +22,10 @@ import android.app.PendingIntent
import android.app.Person
import android.content.Context
import android.content.Intent
-import android.graphics.Bitmap
import android.graphics.BitmapFactory
-import android.graphics.BlendMode
-import android.graphics.Color
-import android.graphics.Paint
-import android.graphics.Rect
import android.graphics.drawable.Icon
import android.net.Uri
-import androidx.annotation.DrawableRes
import androidx.annotation.WorkerThread
-import androidx.core.graphics.applyCanvas
import com.example.android.bubbles.BubbleActivity
import com.example.android.bubbles.MainActivity
import com.example.android.bubbles.R
@@ -71,7 +64,12 @@ class NotificationHelper(private val context: Context) {
@WorkerThread
fun showNotification(chat: Chat, fromUser: Boolean) {
- val icon = Icon.createWithBitmap(roundIcon(context, chat.contact.icon))
+ val icon = Icon.createWithAdaptiveBitmap(
+ BitmapFactory.decodeResource(
+ context.resources,
+ chat.contact.icon
+ )
+ )
val person = Person.Builder()
.setName(chat.contact.name)
.setIcon(icon)
@@ -173,23 +171,3 @@ class NotificationHelper(private val context: Context) {
return notificationManager.areBubblesAllowed() && channel.canBubble()
}
}
-
-@WorkerThread
-private fun roundIcon(context: Context, @DrawableRes id: Int): Bitmap {
- val original = BitmapFactory.decodeResource(context.resources, id)
- val width = original.width
- val height = original.height
- val rect = Rect(0, 0, width, height)
- val icon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
- val paint = Paint().apply {
- isAntiAlias = true
- color = Color.BLACK
- }
- icon.applyCanvas {
- drawARGB(0, 0, 0, 0)
- drawOval(0f, 0f, width.toFloat(), height.toFloat(), paint)
- paint.blendMode = BlendMode.SRC_IN
- drawBitmap(original, rect, rect, paint)
- }
- return icon
-}
diff --git a/projects.txt b/projects.txt
index 6fa29dce..88c55319 100644
--- a/projects.txt
+++ b/projects.txt
@@ -1,118 +1,2 @@
-security/keystore/BasicAndroidKeyStore
-connectivity/sync/BasicSyncAdapter
-connectivity/network/NetworkConnect
-connectivity/network/BasicNetworking
-connectivity/bluetooth/BluetoothLeGatt
-content/multiuser/AppRestrictions
-content/contacts/BasicContactables
-content/documentsUi/StorageClient
-content/documentsUi/StorageProvider
-views/TextLinkify
-input/gestures/BasicGestureDetect
-input/multitouch/BasicMultitouch
-testing/ActivityInstrumentation
-media/MediaRecorder
-media/BasicMediaRouter
-media/BasicMediaDecoder
-ui/holo/BorderlessButtons
-ui/accessibility/BasicAccessibility
-ui/lists/CustomChoiceList
-ui/views/TextSwitcher
-ui/views/HorizontalPaging
-ui/actionbarcompat/ActionBarCompat-Basic
-ui/actionbarcompat/ActionBarCompat-Styled
-ui/actionbarcompat/ActionBarCompat-ListPopupMenu
-notification/BasicNotifications
-notification/CustomNotifications
-ui/actionbar/DoneBar
-ui/graphics/PdfRendererBasic
-ui/window/BasicImmersiveMode
-ui/window/AdvancedImmersiveMode
-ui/window/ImmersiveMode
-background/alarms/RepeatingAlarm
-renderScript/BasicRenderScript
-renderScript/RenderScriptIntrinsic
-ui/views/SlidingTabs/SlidingTabsBasic
-ui/views/SlidingTabs/SlidingTabsColors
-connectivity/nfc/BeamLargeFiles
-connectivity/nfc/CardEmulation
-connectivity/nfc/CardReader
-sensors/BatchStepSensor
-ui/graphics/DisplayingBitmaps
-ui/transition/BasicTransition
-ui/transition/CustomTransition
-ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic
-ui/views/SwipeRefreshLayout/SwipeRefreshListFragment
-ui/views/SwipeRefreshLayout/SwipeRefreshMultipleViews
-media/MediaBrowserService
-media/MediaRouter
-media/MediaEffects
-admin/BasicManagedProfile
-media/Camera2Basic
-media/Camera2Video
-ui/activityscenetransition/ActivitySceneTransitionBasic
-ui/views/NavigationDrawer
-ui/views/Elevation/ElevationBasic
-ui/views/Elevation/ElevationDrag
-ui/views/Clipping/ClippingBasic
-ui/views/FloatingActionButton/FloatingActionButtonBasic
-ui/views/RevealEffect/RevealEffectBasic
-background/JobScheduler
-ui/views/RecyclerView
-ui/views/CardView
-notification/LNotifications
-notification/MessagingService
-ui/DrawableTinting
-ui/Interpolator
-media/HdrViewfinder
-ui/activitytasks/DocumentCentricApps
-ui/activitytasks/DocumentCentricRelinquishIdentity
-admin/AppRestrictionEnforcer
-admin/AppRestrictionSchema
-connectivity/bluetooth/BluetoothChat
-wearable/wear/DataLayer
-wearable/wear/JumpingJack
-wearable/wear/SpeedTracker
-wearable/wear/WatchFace
-content/webview/PermissionRequest
-content/documentsUi/DirectorySelection
system/AppUsageStatistics
-media/ScreenCapture
-admin/NfcProvisioning
-admin/DeviceOwner
-wearable/wear/XYZTouristAttractions
-connectivity/bluetooth/BluetoothAdvertisements
-wearable/wear/AlwaysOn
-security/ConfirmCredential
-security/FingerprintDialog
-system/RuntimePermissions
-system/RuntimePermissionsBasic
-wearable/wear/RuntimePermissionsWear
-notification/ActiveNotifications
-media/Camera2Raw
-content/AutoBackupForApps
-ui/window/MultiWindowPlayground
-content/documentsUi/ScopedDirectoryAccess
-security/DirectBoot
-content/DirectShare
-media/MidiScope
-media/MidiSynth
-security/AsymmetricFingerprintDialog
-wearable/wear/WearSpeakerSample
-wearable/wear/WearDrawers
-ui/window/DragAndDropAcrossApps
-wearable/wear/WearNotifications
-system/AppShortcuts
-input/keyboard/CommitContentSampleApp
-input/keyboard/CommitContentSampleIME
-content/ShareActionProvider
-wearable/wear/WearVerifyRemoteApp
-wearable/wear/WearHighBandwidthNetworking
-content/documentsUi/ContentProviderPaging
-notification/NotificationChannels
-media/PictureInPicture
-input/autofill/AutofillFramework
-views/EmojiCompat
-ui/fonts/DownloadableFonts
-wearable/wear/WearComplicationProvidersTestSuite
-content/SharingShortcuts
+testing/ActivityInstrumentation
diff --git a/ui/DarkTheme/Application/.gitignore b/ui/DarkTheme/Application/.gitignore
new file mode 100644
index 00000000..6eb878d4
--- /dev/null
+++ b/ui/DarkTheme/Application/.gitignore
@@ -0,0 +1,16 @@
+# Copyright 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+src/template/
+src/common/
+build.gradle
diff --git a/ui/DarkTheme/Application/proguard-project.txt b/ui/DarkTheme/Application/proguard-project.txt
new file mode 100644
index 00000000..f2fe1559
--- /dev/null
+++ b/ui/DarkTheme/Application/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/ui/DarkTheme/Application/src/main/AndroidManifest.xml b/ui/DarkTheme/Application/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..8bbf003a
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.darktheme"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <application
+ android:name=".DarkThemeApplication"
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/DarkThemeApp">
+
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+
+</manifest> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ColorUtils.java b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ColorUtils.java
new file mode 100644
index 00000000..4c87262d
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ColorUtils.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.darktheme;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Color;
+
+import androidx.annotation.AttrRes;
+import androidx.annotation.ColorInt;
+import androidx.annotation.NonNull;
+
+public class ColorUtils {
+
+ /**
+ * Queries the theme of the given {@code context} for a theme color.
+ *
+ * @param context the context holding the current theme.
+ * @param attrResId the theme color attribute to resolve.
+ * @return the theme color
+ */
+ @ColorInt
+ public static int getThemeColor(@NonNull Context context, @AttrRes int attrResId) {
+ TypedArray a = context.obtainStyledAttributes(null, new int[]{attrResId});
+ try {
+ return a.getColor(0, Color.MAGENTA);
+ } finally {
+ a.recycle();
+ }
+ }
+}
diff --git a/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/DarkThemeApplication.java b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/DarkThemeApplication.java
new file mode 100644
index 00000000..086c591a
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/DarkThemeApplication.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.darktheme;
+
+import android.app.Application;
+import android.content.SharedPreferences;
+
+import androidx.preference.PreferenceManager;
+
+public class DarkThemeApplication extends Application {
+
+ public void onCreate() {
+ super.onCreate();
+ SharedPreferences sharedPreferences =
+ PreferenceManager.getDefaultSharedPreferences(this);
+ String themePref = sharedPreferences.getString("themePref", ThemeHelper.DEFAULT_MODE);
+ ThemeHelper.applyTheme(themePref);
+ }
+}
diff --git a/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/MainActivity.java b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/MainActivity.java
new file mode 100644
index 00000000..64f04f8b
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/MainActivity.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.darktheme;
+
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import com.google.android.material.bottomnavigation.BottomNavigationView;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.graphics.drawable.DrawableCompat;
+import androidx.fragment.app.Fragment;
+
+public class MainActivity extends AppCompatActivity {
+
+ private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationListener
+ = new BottomNavigationView.OnNavigationItemSelectedListener() {
+
+ @Override
+ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.navigation_home:
+ showFragment(WelcomeFragment.TAG);
+ return true;
+ case R.id.navigation_preferences:
+ showFragment(PreferencesFragment.TAG);
+ return true;
+ case R.id.navigation_settings:
+ showFragment(SettingsFragment.TAG);
+ return true;
+ }
+ return false;
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
+
+ BottomNavigationView navigation = findViewById(R.id.navigation);
+ navigation.setOnNavigationItemSelectedListener(mOnNavigationListener);
+
+ if (savedInstanceState == null) {
+ showFragment(WelcomeFragment.TAG);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main_menu, menu);
+
+ // This demonstrates how to programmatically tint a drawable
+ MenuItem item = menu.findItem(R.id.action_more);
+ Drawable drawableWrap = DrawableCompat.wrap(item.getIcon()).mutate();
+ DrawableCompat.setTint(drawableWrap, ColorUtils.getThemeColor(this, R.attr.colorOnPrimary));
+ item.setIcon(drawableWrap);
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ if (id == R.id.action_more) {
+ // TODO
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void showFragment(@NonNull String tag) {
+ Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
+ if (fragment == null) {
+ switch (tag) {
+ case WelcomeFragment.TAG: {
+ fragment = new WelcomeFragment();
+ break;
+ }
+ case PreferencesFragment.TAG: {
+ fragment = new PreferencesFragment();
+ break;
+ }
+ case SettingsFragment.TAG: {
+ fragment = new SettingsFragment();
+ break;
+ }
+ default: {
+ fragment = new WelcomeFragment();
+ break;
+ }
+ }
+ }
+
+ getSupportFragmentManager()
+ .beginTransaction()
+ .replace(R.id.fragment_layout, fragment, tag)
+ .commit();
+ }
+}
diff --git a/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/PreferencesFragment.java b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/PreferencesFragment.java
new file mode 100644
index 00000000..c5f65f5b
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/PreferencesFragment.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.darktheme;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+public class PreferencesFragment extends Fragment {
+
+ static final String TAG = "PreferencesFragmentTag";
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_preferences, container, false);
+ }
+}
diff --git a/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/SettingsFragment.java b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/SettingsFragment.java
new file mode 100644
index 00000000..6402249b
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/SettingsFragment.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.darktheme;
+
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+
+public class SettingsFragment extends PreferenceFragmentCompat {
+
+ static final String TAG = "SettingsFragmentTag";
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ setPreferencesFromResource(R.xml.preferences, rootKey);
+
+ ListPreference themePreference = findPreference("themePref");
+ if (themePreference != null) {
+ themePreference.setOnPreferenceChangeListener(
+ new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ String themeOption = (String) newValue;
+ ThemeHelper.applyTheme(themeOption);
+ return true;
+ }
+ });
+ }
+ }
+}
diff --git a/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ThemeHelper.java b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ThemeHelper.java
new file mode 100644
index 00000000..812067ce
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/ThemeHelper.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.darktheme;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatDelegate;
+import androidx.core.os.BuildCompat;
+
+public class ThemeHelper {
+
+ public static final String LIGHT_MODE = "light";
+ public static final String DARK_MODE = "dark";
+ public static final String DEFAULT_MODE = "default";
+
+ public static void applyTheme(@NonNull String themePref) {
+ switch (themePref) {
+ case LIGHT_MODE: {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
+ break;
+ }
+ case DARK_MODE: {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
+ break;
+ }
+ default: {
+ if (BuildCompat.isAtLeastQ()) {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
+ } else {
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/WelcomeFragment.java b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/WelcomeFragment.java
new file mode 100644
index 00000000..780ed2e7
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/java/com/example/android/darktheme/WelcomeFragment.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.darktheme;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+public class WelcomeFragment extends Fragment {
+
+ static final String TAG = "VectorDrawableFragmentTag";
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_welcome, container, false);
+ }
+}
diff --git a/ui/DarkTheme/Application/src/main/res/color/color_on_primary_mask.xml b/ui/DarkTheme/Application/src/main/res/color/color_on_primary_mask.xml
new file mode 100644
index 00000000..9122f5ee
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/color/color_on_primary_mask.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ Apply variations to a color using ColorStateList.
+ Instead of creating a new color with an alpha in hexadecimal values,
+ we reuse the color and specify the alpha with a percentage number.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:alpha="0.80" android:color="?attr/colorOnPrimary" />
+</selector>
diff --git a/ui/DarkTheme/Application/src/main/res/drawable/bottom_nav_item_background.xml b/ui/DarkTheme/Application/src/main/res/drawable/bottom_nav_item_background.xml
new file mode 100644
index 00000000..cceb114c
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/drawable/bottom_nav_item_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_checked="true" android:color="?attr/colorPrimary" />
+ <item android:state_checked="false" android:color="?attr/colorOnSurface" />
+</selector> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/drawable/ic_brightness.xml b/ui/DarkTheme/Application/src/main/res/drawable/ic_brightness.xml
new file mode 100644
index 00000000..9c434add
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/drawable/ic_brightness.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="52dp"
+ android:height="52dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M20,8.69L20,4h-4.69L12,0.69 8.69,4L4,4v4.69L0.69,12 4,15.31L4,20h4.69L12,23.31 15.31,20L20,20v-4.69L23.31,12 20,8.69zM12,18c-3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6 6,2.69 6,6 -2.69,6 -6,6zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4z" />
+</vector>
diff --git a/ui/DarkTheme/Application/src/main/res/drawable/ic_brightness_2.xml b/ui/DarkTheme/Application/src/main/res/drawable/ic_brightness_2.xml
new file mode 100644
index 00000000..e5466549
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/drawable/ic_brightness_2.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="52dp"
+ android:height="52dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?attr/colorPrimary">
+ <!-- Use the android:tint attribute to tint the vectors -->
+ <!-- For the tint to work on API 19 and below, remember to use app:srcCompat in the view widget
+ and vectorDrawables.useSupportLibrary = true in your build.gradle file -->
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M10,2c-1.82,0 -3.53,0.5 -5,1.35C7.99,5.08 10,8.3 10,12s-2.01,6.92 -5,8.65C6.47,21.5 8.18,22 10,22c5.52,0 10,-4.48 10,-10S15.52,2 10,2z" />
+</vector>
diff --git a/ui/DarkTheme/Application/src/main/res/drawable/ic_dashboard.xml b/ui/DarkTheme/Application/src/main/res/drawable/ic_dashboard.xml
new file mode 100644
index 00000000..f24e04c2
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/drawable/ic_dashboard.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" />
+</vector>
diff --git a/ui/DarkTheme/Application/src/main/res/drawable/ic_home.xml b/ui/DarkTheme/Application/src/main/res/drawable/ic_home.xml
new file mode 100644
index 00000000..8796f6f9
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/drawable/ic_home.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
+</vector>
diff --git a/ui/DarkTheme/Application/src/main/res/drawable/ic_more_vert.xml b/ui/DarkTheme/Application/src/main/res/drawable/ic_more_vert.xml
new file mode 100644
index 00000000..fea1a30e
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/drawable/ic_more_vert.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
+</vector>
diff --git a/ui/DarkTheme/Application/src/main/res/drawable/ic_settings.xml b/ui/DarkTheme/Application/src/main/res/drawable/ic_settings.xml
new file mode 100644
index 00000000..3a534093
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/drawable/ic_settings.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
+</vector>
diff --git a/ui/DarkTheme/Application/src/main/res/layout/activity_main.xml b/ui/DarkTheme/Application/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..ecfa68b9
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/layout/activity_main.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity">
+
+ <androidx.appcompat.widget.Toolbar
+ style="@style/Widget.MaterialComponents.Toolbar.Primary"
+ android:id="@+id/toolbar"
+ android:layout_width="0dp"
+ android:layout_height="?android:actionBarSize"
+ android:elevation="@dimen/toolbar_elevation"
+ android:title="@string/app_name"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <FrameLayout
+ android:id="@+id/fragment_layout"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:layout_constraintBottom_toTopOf="@+id/navigation"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/toolbar" />
+
+ <com.google.android.material.bottomnavigation.BottomNavigationView
+ android:id="@+id/navigation"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ app:itemBackground="?attr/colorSurface"
+ app:itemIconTint="@drawable/bottom_nav_item_background"
+ app:itemTextColor="?attr/colorOnBackground"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:menu="@menu/navigation" />
+
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/layout/fragment_preferences.xml b/ui/DarkTheme/Application/src/main/res/layout/fragment_preferences.xml
new file mode 100644
index 00000000..b6ed021d
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/layout/fragment_preferences.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!--
+ The colours in this file are hardcoded to showcase the Android Q Force Dark feature.
+ The system provide and "automatic" conversion of light apps/screens/views to dark.
+ We're setting android:forceDarkAllowed="true" in the layout above to make the
+ system force this layout to be dark-mode suitable automatically.
+-->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:padding="@dimen/margin_medium"
+ android:forceDarkAllowed="true"
+ android:background="#FFFFFF"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/margin_small"
+ android:textColor="#212121"
+ android:text="@string/preferences_explanation"/>
+
+ <TextView
+ style="?attr/textAppearanceHeadline6"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/margin_medium"
+ android:textColor="#212121"
+ android:text="@string/preferences"/>
+
+ <EditText
+ android:id="@+id/editText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:inputType="textPersonName"
+ android:layout_margin="@dimen/margin_small"
+ android:textColor="#212121"
+ android:textColorHint="#44212121"
+ android:hint="@string/your_name" />
+
+ <RadioGroup
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/margin_small">
+
+ <RadioButton
+ android:id="@+id/radioButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textColor="#212121"
+ android:text="@string/developer" />
+
+ <RadioButton
+ android:id="@+id/radioButton2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textColor="#212121"
+ android:text="@string/designer" />
+ </RadioGroup>
+
+ <Switch
+ android:id="@+id/switch1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/margin_small"
+ android:textColor="#212121"
+ android:text="@string/offline" />
+
+ <Button
+ android:id="@+id/button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/margin_small"
+ android:textColor="#FFFFFF"
+ android:background="#1976D2"
+ android:text="@string/save" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/layout/fragment_welcome.xml b/ui/DarkTheme/Application/src/main/res/layout/fragment_welcome.xml
new file mode 100644
index 00000000..384c1e8c
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/layout/fragment_welcome.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ android:gravity="center">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/welcome"/>
+
+ <!-- @drawable/ic_brightness is using hard-coded colours.
+ We set the tint to this drawable using the android:tint attribute -->
+ <ImageView
+ android:id="@+id/icon_light"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/margin_medium"
+ app:srcCompat="@drawable/ic_brightness"
+ android:tint="?attr/colorSecondary"/>
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/margin_medium"
+ app:srcCompat="@drawable/ic_brightness_2" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/menu/main_menu.xml b/ui/DarkTheme/Application/src/main/res/menu/main_menu.xml
new file mode 100644
index 00000000..47d9cafe
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/menu/main_menu.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/action_more"
+ android:icon="@drawable/ic_more_vert"
+ android:title="@string/more_action"
+ app:showAsAction="ifRoom" />
+</menu>
diff --git a/ui/DarkTheme/Application/src/main/res/menu/navigation.xml b/ui/DarkTheme/Application/src/main/res/menu/navigation.xml
new file mode 100644
index 00000000..9773b1d6
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/menu/navigation.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/navigation_home"
+ android:icon="@drawable/ic_home"
+ android:title="@string/title_home" />
+
+ <item
+ android:id="@+id/navigation_preferences"
+ android:icon="@drawable/ic_dashboard"
+ android:title="@string/title_preferences" />
+
+ <item
+ android:id="@+id/navigation_settings"
+ android:icon="@drawable/ic_settings"
+ android:title="@string/title_settings" />
+
+</menu>
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher.png b/ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 00000000..5d2672f7
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher_round.png b/ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 00000000..9ab38fca
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-hdpi/ic_launcher_round.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher.png b/ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 00000000..2fad7d22
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher_round.png b/ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 00000000..03c77f39
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-mdpi/ic_launcher_round.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher.png b/ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 00000000..0354d61c
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 00000000..20b354ef
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher.png b/ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 00000000..27d1742e
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 00000000..dba9bcc2
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 00000000..c778c5de
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 00000000..c095b4ce
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/ui/DarkTheme/Application/src/main/res/values-night/colors.xml b/ui/DarkTheme/Application/src/main/res/values-night/colors.xml
new file mode 100644
index 00000000..b61c0a63
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/values-night/colors.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+
+ <!-- app palette -->
+ <color name="primary">#64B5F6</color> <!-- Blue 300 -->
+ <color name="secondary">#FFCC80</color> <!-- Orange 200 -->
+ <color name="error">#Ef9A9A</color> <!-- Red 200 -->
+
+</resources>
diff --git a/ui/DarkTheme/Application/src/main/res/values-v28/arrays.xml b/ui/DarkTheme/Application/src/main/res/values-v28/arrays.xml
new file mode 100644
index 00000000..8e98063c
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/values-v28/arrays.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+
+ <string-array name="themeListArray">
+ <item>Light</item>
+ <item>Dark</item>
+ <item>System default</item>
+ </string-array>
+
+ <string-array name="themeEntryArray">
+ <item>light</item>
+ <item>dark</item>
+ <item>default</item>
+ </string-array>
+
+</resources> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/values/arrays.xml b/ui/DarkTheme/Application/src/main/res/values/arrays.xml
new file mode 100644
index 00000000..19c0e417
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/values/arrays.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+
+ <string-array name="themeListArray">
+ <item>Light</item>
+ <item>Dark</item>
+ <item>Set by Battery Saver</item>
+ </string-array>
+
+ <string-array name="themeEntryArray">
+ <item>light</item>
+ <item>dark</item>
+ <item>default</item>
+ </string-array>
+
+</resources> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/values/colors.xml b/ui/DarkTheme/Application/src/main/res/values/colors.xml
new file mode 100644
index 00000000..07fb9142
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/values/colors.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+
+ <!-- app palette -->
+ <color name="primary">#1976D2</color> <!-- Blue 700 -->
+ <color name="secondary">#F57C00</color> <!-- Orange 700 -->
+ <color name="error">#E53935</color> <!-- Red 600 -->
+
+</resources> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/values/dimens.xml b/ui/DarkTheme/Application/src/main/res/values/dimens.xml
new file mode 100644
index 00000000..2528955a
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/values/dimens.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+ <dimen name="toolbar_elevation">4dp</dimen>
+</resources>
diff --git a/ui/DarkTheme/Application/src/main/res/values/strings.xml b/ui/DarkTheme/Application/src/main/res/values/strings.xml
new file mode 100644
index 00000000..3cff1904
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/values/strings.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+
+ <string name="more_action">More</string>
+ <string name="title_home">Home</string>
+ <string name="title_preferences">Preferences</string>
+ <string name="title_settings">Settings</string>
+ <string name="welcome">Welcome to the Dark Theme code sample</string>
+ <string name="save">Save</string>
+ <string name="offline">Offline mode</string>
+ <string name="your_name">Your name</string>
+ <string name="developer">Developer</string>
+ <string name="designer">Designer</string>
+ <string name="preferences">Select your preferences</string>
+ <string name="preferences_explanation">Disclaimer: This screen will only be dark when Dark Mode is forced in the OS settings in Android Q and above.</string>
+
+</resources>
diff --git a/ui/DarkTheme/Application/src/main/res/values/styles.xml b/ui/DarkTheme/Application/src/main/res/values/styles.xml
new file mode 100644
index 00000000..9d3f2104
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/values/styles.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+
+ <style name="DarkThemeApp" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
+ <item name="colorPrimary">@color/primary</item>
+ <item name="colorPrimaryDark">@color/primary</item>
+ <item name="colorSecondary">@color/secondary</item>
+ <item name="colorError">@color/error</item>
+ <item name="android:textColor">?attr/colorOnBackground</item>
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/ui/DarkTheme/Application/src/main/res/xml/preferences.xml b/ui/DarkTheme/Application/src/main/res/xml/preferences.xml
new file mode 100644
index 00000000..6de6b33e
--- /dev/null
+++ b/ui/DarkTheme/Application/src/main/res/xml/preferences.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<androidx.preference.PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <PreferenceCategory
+ app:key="theme_category"
+ app:title="Theme">
+
+ <ListPreference
+ app:key="themePref"
+ app:title="Choose theme"
+ app:defaultValue="default"
+ app:dialogTitle="Choose theme"
+ app:entries="@array/themeListArray"
+ app:entryValues="@array/themeEntryArray"
+ app:useSimpleSummaryProvider="true"/>
+
+ </PreferenceCategory>
+
+</androidx.preference.PreferenceScreen>
diff --git a/ui/DarkTheme/build.gradle b/ui/DarkTheme/build.gradle
new file mode 100644
index 00000000..4628271c
--- /dev/null
+++ b/ui/DarkTheme/build.gradle
@@ -0,0 +1,16 @@
+
+
+// BEGIN_EXCLUDE
+import com.example.android.samples.build.SampleGenPlugin
+apply plugin: SampleGenPlugin
+
+samplegen {
+ pathToBuild "../../../../build"
+ pathToSamplesCommon "../../common"
+}
+apply from: "../../../../build/build.gradle"
+// END_EXCLUDE
+
+if(hasProperty('target') && target == 'android') {
+ android.vectorDrawables.useSupportLibrary = true
+} \ No newline at end of file
diff --git a/ui/DarkTheme/buildSrc/build.gradle b/ui/DarkTheme/buildSrc/build.gradle
new file mode 100644
index 00000000..75b00eeb
--- /dev/null
+++ b/ui/DarkTheme/buildSrc/build.gradle
@@ -0,0 +1,17 @@
+
+repositories {
+ google()
+ jcenter()
+}
+dependencies {
+ implementation 'org.freemarker:freemarker:2.3.20'
+}
+
+sourceSets {
+ main {
+ groovy {
+ srcDir new File(rootDir, "../../../../../build/buildSrc/src/main/groovy")
+ }
+ }
+}
+
diff --git a/ui/DarkTheme/gradle.properties b/ui/DarkTheme/gradle.properties
new file mode 100644
index 00000000..94f84728
--- /dev/null
+++ b/ui/DarkTheme/gradle.properties
@@ -0,0 +1,22 @@
+
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Settings specified in this file will override any Gradle settings
+# configured through the IDE.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/ui/DarkTheme/gradle/wrapper/gradle-wrapper.jar b/ui/DarkTheme/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..8c0fb64a
--- /dev/null
+++ b/ui/DarkTheme/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/DarkTheme/gradle/wrapper/gradle-wrapper.properties b/ui/DarkTheme/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..e623645e
--- /dev/null
+++ b/ui/DarkTheme/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Mar 26 16:16:53 CET 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
diff --git a/ui/DarkTheme/gradlew b/ui/DarkTheme/gradlew
new file mode 100755
index 00000000..91a7e269
--- /dev/null
+++ b/ui/DarkTheme/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/ui/DarkTheme/gradlew.bat b/ui/DarkTheme/gradlew.bat
new file mode 100644
index 00000000..aec99730
--- /dev/null
+++ b/ui/DarkTheme/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ui/DarkTheme/screenshots/dark_1_welcome.png b/ui/DarkTheme/screenshots/dark_1_welcome.png
new file mode 100644
index 00000000..a3a0c660
--- /dev/null
+++ b/ui/DarkTheme/screenshots/dark_1_welcome.png
Binary files differ
diff --git a/ui/DarkTheme/screenshots/dark_3_settings.png b/ui/DarkTheme/screenshots/dark_3_settings.png
new file mode 100644
index 00000000..127d0a40
--- /dev/null
+++ b/ui/DarkTheme/screenshots/dark_3_settings.png
Binary files differ
diff --git a/ui/DarkTheme/screenshots/dark_4_theme_options.png b/ui/DarkTheme/screenshots/dark_4_theme_options.png
new file mode 100644
index 00000000..18b897e0
--- /dev/null
+++ b/ui/DarkTheme/screenshots/dark_4_theme_options.png
Binary files differ
diff --git a/ui/DarkTheme/screenshots/light_1_welcome.png b/ui/DarkTheme/screenshots/light_1_welcome.png
new file mode 100644
index 00000000..27f98115
--- /dev/null
+++ b/ui/DarkTheme/screenshots/light_1_welcome.png
Binary files differ
diff --git a/ui/DarkTheme/screenshots/light_2_preferences.png b/ui/DarkTheme/screenshots/light_2_preferences.png
new file mode 100644
index 00000000..966b3b17
--- /dev/null
+++ b/ui/DarkTheme/screenshots/light_2_preferences.png
Binary files differ
diff --git a/ui/DarkTheme/screenshots/light_3_settings.png b/ui/DarkTheme/screenshots/light_3_settings.png
new file mode 100644
index 00000000..38ea7a2b
--- /dev/null
+++ b/ui/DarkTheme/screenshots/light_3_settings.png
Binary files differ
diff --git a/ui/DarkTheme/screenshots/light_4_theme_options.png b/ui/DarkTheme/screenshots/light_4_theme_options.png
new file mode 100644
index 00000000..53ab0cff
--- /dev/null
+++ b/ui/DarkTheme/screenshots/light_4_theme_options.png
Binary files differ
diff --git a/ui/DarkTheme/screenshots/smart_dark_2_preferences.png b/ui/DarkTheme/screenshots/smart_dark_2_preferences.png
new file mode 100644
index 00000000..6d61f15d
--- /dev/null
+++ b/ui/DarkTheme/screenshots/smart_dark_2_preferences.png
Binary files differ
diff --git a/ui/DarkTheme/settings.gradle b/ui/DarkTheme/settings.gradle
new file mode 100644
index 00000000..0a5c310b
--- /dev/null
+++ b/ui/DarkTheme/settings.gradle
@@ -0,0 +1,2 @@
+
+include 'Application'
diff --git a/ui/DarkTheme/template-params.xml b/ui/DarkTheme/template-params.xml
new file mode 100644
index 00000000..2a8f75c5
--- /dev/null
+++ b/ui/DarkTheme/template-params.xml
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<sample>
+ <name>DarkTheme</name>
+ <group>UI</group>
+ <package>com.example.android.darktheme</package>
+
+ <minSdk>14</minSdk>
+ <dependency>com.google.android.material:material:1.1.0-alpha06</dependency>
+ <dependency>androidx.appcompat:appcompat:1.1.0-alpha05</dependency>
+ <dependency>androidx.constraintlayout:constraintlayout:2.0.0-beta1</dependency>
+ <dependency>androidx.preference:preference:1.1.0-alpha05</dependency>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ Sample demonstrating the different ways to support Dark Mode on Android.
+ Uses the Material Design Components Library.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base" />
+ <androidX>true</androidX>
+
+ <metadata>
+ <status>PUBLISHED</status>
+
+ <categories>UI</categories>
+ <technologies>Android</technologies>
+ <languages>Java</languages>
+ <solutions>Mobile</solutions>
+
+ <screenshots>
+ <img>screenshots/light_1_welcome.png</img>
+ <img>screenshots/light_2_preferences.png</img>
+ <img>screenshots/light_3_settings.png</img>
+ <img>screenshots/light_4_theme_options.png</img>
+ <img>screenshots/dark_1_welcome.png</img>
+ <img>screenshots/smart_dark_2_preferences.png</img>
+ <img>screenshots/dark_3_settings.png</img>
+ <img>screenshots/dark_4_theme_options.png</img>
+ </screenshots>
+
+ <description>
+ Sample demonstrating the different ways to support Dark Mode on Android.
+ Uses the Material Design Components Library.
+ </description>
+
+ <intro>
+Android Q has explicit user support for Dark Mode, allowing users to choose
+whether the device theme is dark or not. There are multiple ways you can allow
+Dark Mode in your app:
+
+### Night mode in AppCompat and Material Components
+
+AppCompat has had "night mode" APIs for a number of years now. It allows developers to
+implement dark mode in their apps using the -night resource qualifier. The [Material Design
+Components library][1] builds upon AppCompat and exposes its own DayNight themes.
+
+The DayNight theme in the AndroidX Material Components library provides Dark Theme backwards
+compatibility down to API 14. The theme we use in the app (specified in
+`AndroidManifest.xml#L23`) extends from DayNight (`values/styles.xml#L16`).
+
+Use theme-defined colours when defining colours for your drawables. For example, we use
+`?attr/colorOnBackground` for the generic text color of the app (`values/styles.xml#35`).
+
+When it's not possible to use theme-defined colours, you can use the -night qualifier to
+extract hard-coded values and switch them out when the configuration changes to night mode.
+For example, we use a different primary colour in dark mode. Check `values-night/colors.xml`
+for more details. You can also specify custom drawables creating a drawable-night folder.
+
+Tell AppCompat what mode to use by calling [`AppCompatDelegate.setDefaultNightMode()`][2] or
+`getDelegate().setLocalNightMode()`. It can take different values:
+- MODE_NIGHT_YES. Always use the dark theme.
+- MODE_NIGHT_NO. Always use the light theme (Smart Dark can override it).
+- MODE_NIGHT_FOLLOW_SYSTEM. Follows the current system setting
+- MODE_NIGHT_AUTO_BATTERY. Dark when battery saver is enabled, light otherwise.
+
+In the code sample, you can find the code related to this in the `ThemeHelper` class.
+
+### Smart Dark
+
+Smart Dark is a new feature in Android Q which can automatically theme a light app to
+dark by dynamically re-coloring the app being drawn at runtime. It has no direct developer
+APIs. It is made for apps which do not have explicit Dark Theme support yet.
+
+Smart Dark applies to any theme whose value of `android:isLightTheme=true`. This is set on
+all of the `Theme.*.Light.*` variants, including those from AppCompat. You can opt-in and opt-out at
+both a theme and view level. Opt-in by setting `android:forceDarkAllowed="true"`
+in the view or theme. Alternatively, you can enable/disable it in the code by calling
+`View#setForceDarkAllowed(boolean)`.
+
+This feature is implemented in the `PreferencesFragment`. As you can see in the
+`layout/fragment_preferences.xml` file, all colours are hard-coded to be light-theme suitable.
+To make it use Smart Dark, the parent view sets `android:forceDarkAllowed="true"`
+(you can see it in `layout/fragment_preferences.xml#L19`). In this case, when Smart Dark is
+active, this screen will be automatically themed to be dark-mode friendly. The system will
+change most of the colours to make that happen.
+
+## Dark Mode in the code sample
+
+The user can decide which theme to use within the app. In the Settings screen, the user
+can choose the Light theme, Dark theme, or System Default (when the app is running on
+Android Q+) or Set by Battery Saver (when running on Android P or earlier). When using the
+System Default option, the system decides the theme based on the Platform System Settings
+introduced in Android Q.
+
+These options, that are also listed above, are the settings that Google recommends.
+Also, it recommends that this user choice is stored and applied whenever the user opens
+the app again. In the code sample, the user preference is automatically stored in
+`SharedPreferences` because we use the androidX preference library. Check `SettingsFragment`
+and `preferences.xml` for more information about it. In the `DarkThemeApplication` class,
+we retrieve and apply the user theme preference when the user opens the app.
+
+Notice that the PreferencesFragment will be only in Dark Mode when the Smart Dark is active.
+You can force it by running `adb shell setprop debug.hwui.force_dark true` on your terminal console.
+
+## Hands on
+
+In the sample, we make views Dark-Mode friendly in different ways:
+
+- *Vectors using tints*. `drawable/ic_brightness_2.xml` is Dark-Mode friendly by
+using the `android:tint` attribute.
+
+- *Vectors using hard-coded colours*. `drawable/ic_brightness.xml` is Dark-Mode friendly by
+setting its View tint in `fragment_welcome.xml#L38`. Also, you can set it programmatically
+as we do with the tinted menu icon `R.id.action_more`.
+
+- *Tinted menu icons*. `R.id.action_more` is tinted programmatically in `MainActivity.java#L85`.
+
+- *Different colorPrimary/colorsecondary for light/dark mode*. We define the primary color
+in `values/styles.xml#L21` where we set "colorPrimary" to `@color/primary`.
+`@color/primary` is defined in both `values/colors.xml` and `values-night/colors.xml`.
+
+- *Text color*. Same way as we did before, the text color is defined in `values/styles.xml`
+with the `"android:textColorPrimary"` attribute.
+
+- *Window background*. The window background is set in `values/styles.xml` with the
+`"android:windowBackground"` attribute. The value is set to `@color/background` so if
+Dark Mode is enabled the splash screen is black instead of white.
+
+- *Apply variations to a color using ColorStateList*. Check out `color/color_on_primary_mask.xml`.
+Instead of creating a new color with an alpha in hexadecimal values, we reuse the color and specify
+the alpha with a percentage number.
+
+- *Enable Smart Dark*. The `PreferenceFragment` is not Dark-Mode friendly. It has all colours
+hard-coded to be suitable for light mode. To opt the Fragment in for Smart Dark, we set
+`android:forceDarkAllowed="true"` in the root View of the Fragment. You can find the code
+in `layout/fragment_preferences.xml#19`.
+
+[1]: https://material.io/develop/android/docs/getting-started/
+[2]: https://developer.android.com/reference/android/support/v7/app/AppCompatDelegate#setdefaultnightmode
+ </intro>
+ </metadata>
+</sample>