├── settings.gradle
├── kotlinApp
├── settings.gradle
├── screenshots
│ ├── icon-web.png
│ ├── screenshot-1.png
│ ├── screenshot-2.png
│ └── screenshot-3.png
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── app
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── preloaded_fonts.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── font_certs.xml
│ │ │ │ └── family_names.xml
│ │ │ ├── font
│ │ │ │ └── lobster_two.xml
│ │ │ └── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── bottom_sheet_font_query.xml
│ │ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── android
│ │ │ │ └── downloadablefonts
│ │ │ │ ├── Constants.kt
│ │ │ │ ├── QueryBuilder.kt
│ │ │ │ └── MainActivity.kt
│ │ │ └── AndroidManifest.xml
│ └── build.gradle
├── build.gradle
├── NOTICE
├── .google
│ └── packaging.yaml
├── CONTRIBUTING.md
├── gradlew.bat
├── README.md
└── gradlew
├── screenshots
├── icon-web.png
├── screenshot-1.png
├── screenshot-2.png
└── screenshot-3.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── app
├── src
│ └── main
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── preloaded_fonts.xml
│ │ │ ├── styles.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ ├── font_certs.xml
│ │ │ └── family_names.xml
│ │ ├── font
│ │ │ └── lobster_two.xml
│ │ └── layout
│ │ │ ├── activity_main.xml
│ │ │ └── bottom_sheet_font_query.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── android
│ │ │ └── downloadablefonts
│ │ │ ├── Constants.java
│ │ │ ├── QueryBuilder.java
│ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
└── build.gradle
├── README.md
├── NOTICE
├── .google
└── packaging.yaml
├── CONTRIBUTING.md
├── gradlew.bat
├── gradlew
└── LICENSE
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/kotlinApp/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/screenshots/icon-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/screenshots/icon-web.png
--------------------------------------------------------------------------------
/screenshots/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/screenshots/screenshot-1.png
--------------------------------------------------------------------------------
/screenshots/screenshot-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/screenshots/screenshot-2.png
--------------------------------------------------------------------------------
/screenshots/screenshot-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/screenshots/screenshot-3.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/kotlinApp/screenshots/icon-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/screenshots/icon-web.png
--------------------------------------------------------------------------------
/kotlinApp/screenshots/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/screenshots/screenshot-1.png
--------------------------------------------------------------------------------
/kotlinApp/screenshots/screenshot-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/screenshots/screenshot-2.png
--------------------------------------------------------------------------------
/kotlinApp/screenshots/screenshot-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/screenshots/screenshot-3.png
--------------------------------------------------------------------------------
/kotlinApp/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-DownloadableFonts/master/kotlinApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Android DownloadableFonts Sample
3 | ================================
4 |
5 | This repo has been migrated to [github.com/android/user-interface][1]. Please check that repo for future updates. Thank you!
6 |
7 | [1]: https://github.com/android/user-interface
8 |
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Aug 09 11:54:51 JST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/kotlinApp/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 10 17:45:17 JST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-4.0-20170406000015+0000-all.zip
7 |
--------------------------------------------------------------------------------
/kotlinApp/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | ext.kotlin_version = '1.1.3-2'
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.0.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | jcenter()
17 | google()
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 |
2 | This sample uses the following software:
3 |
4 | Copyright 2018 The Android Open Source Project
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 |
--------------------------------------------------------------------------------
/kotlinApp/NOTICE:
--------------------------------------------------------------------------------
1 |
2 | This sample uses the following software:
3 |
4 | Copyright 2017 The Android Open Source Project
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 |
--------------------------------------------------------------------------------
/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 |
2 | # GOOGLE SAMPLE PACKAGING DATA
3 | #
4 | # This file is used by Google as part of our samples packaging process.
5 | # End users may safely ignore this file. It has no relevance to other systems.
6 | ---
7 | status: PUBLISHED
8 | technologies: [Android]
9 | categories: [UI]
10 | languages: [Java]
11 | solutions: [Mobile]
12 | github: android-DownloadableFonts
13 | level: INTERMEDIATE
14 | icon: screenshots/icon-web.png
15 | apiRefs:
16 | - android:android.provider.FontRequest
17 | - android:android.support.v4.provider.FontRequest
18 | - android:android.provider.FontsContractCompat
19 | - android:android.support.v4.provider.FontsContractCompat
20 | license: apache2
21 |
--------------------------------------------------------------------------------
/kotlinApp/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 |
2 | # GOOGLE SAMPLE PACKAGING DATA
3 | #
4 | # This file is used by Google as part of our samples packaging process.
5 | # End users may safely ignore this file. It has no relevance to other systems.
6 | ---
7 | status: DRAFTED
8 | technologies: [Android]
9 | categories: [UI, Android O Preview]
10 | languages: [Kotlin]
11 | solutions: [Mobile]
12 | github: android-DownloadableFonts
13 | level: INTERMEDIATE
14 | icon: screenshots/icon-web.png
15 | apiRefs:
16 | - android:android.provider.FontRequest
17 | - android:android.support.v4.provider.FontRequest
18 | - android:android.provider.FontsContractCompat
19 | - android:android.support.v4.provider.FontsContractCompat
20 | license: apache2
21 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | ext {
4 | supportLibVersion = '26.0.1'
5 | }
6 |
7 | android {
8 | compileSdkVersion 26
9 | buildToolsVersion "26.0.1"
10 |
11 | defaultConfig {
12 | applicationId "com.example.android.downloadablefonts"
13 | minSdkVersion 14
14 | targetSdkVersion 26
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
21 | }
22 | }
23 |
24 | dependencies {
25 | compile "com.android.support:appcompat-v7:$supportLibVersion"
26 | compile "com.android.support:design:$supportLibVersion"
27 | compile "com.android.support:cardview-v7:$supportLibVersion"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | #3F51B5
19 | #303F9F
20 | #FF4081
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/preloaded_fonts.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | - @font/lobster_two
20 |
21 |
22 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | #3F51B5
19 | #303F9F
20 | #FF4081
21 |
22 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/values/preloaded_fonts.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | - @font/lobster_two
20 |
21 |
22 |
--------------------------------------------------------------------------------
/kotlinApp/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | ext {
5 | supportLibVersion = '26.0.1'
6 | }
7 |
8 | android {
9 | compileSdkVersion 26
10 | buildToolsVersion "26.0.1"
11 |
12 | defaultConfig {
13 | applicationId "com.example.android.downloadablefonts"
14 | minSdkVersion 14
15 | targetSdkVersion 26
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
22 | }
23 | }
24 |
25 | dependencies {
26 | compile "com.android.support:appcompat-v7:$supportLibVersion"
27 | compile "com.android.support:design:$supportLibVersion"
28 | compile "com.android.support:cardview-v7:$supportLibVersion"
29 | }
30 | }
31 |
32 | repositories {
33 | mavenCentral()
34 | }
35 | dependencies {
36 | compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com/example/android/downloadablefonts/Constants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.downloadablefonts
18 |
19 | /**
20 | * Constants class
21 | */
22 | internal object Constants {
23 |
24 | val WIDTH_DEFAULT = 100
25 | val WIDTH_MAX = 1000
26 | val WIDTH_MIN = 0
27 |
28 | val WEIGHT_DEFAULT = 400
29 | val WEIGHT_MAX = 1000
30 | val WEIGHT_MIN = 0
31 |
32 | val ITALIC_DEFAULT = 0f
33 | val ITALIC_MAX = 1f
34 | val ITALIC_MIN = 0f
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 | 4dp
20 | 4dp
21 | 8dp
22 | 16dp
23 | 32dp
24 |
25 | 48dp
26 | 96dp
27 |
28 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 | 4dp
20 | 4dp
21 | 8dp
22 | 16dp
23 | 32dp
24 |
25 | 48dp
26 | 96dp
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/downloadablefonts/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.downloadablefonts;
18 |
19 | /**
20 | * Constants class
21 | */
22 | class Constants {
23 |
24 | static final int WIDTH_DEFAULT = 100;
25 | static final int WIDTH_MAX = 1000;
26 | static final int WIDTH_MIN = 0;
27 |
28 | static final int WEIGHT_DEFAULT = 400;
29 | static final int WEIGHT_MAX = 1000;
30 | static final int WEIGHT_MIN = 0;
31 |
32 | static final float ITALIC_DEFAULT = 0f;
33 | static final float ITALIC_MAX = 1f;
34 | static final float ITALIC_MIN = 0f;
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/font/lobster_two.xml:
--------------------------------------------------------------------------------
1 |
16 |
26 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/font/lobster_two.xml:
--------------------------------------------------------------------------------
1 |
16 |
26 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your sample apps and patches! Before we can take them, we
6 | have to jump a couple of legal hurdles.
7 |
8 | Please fill out either the individual or corporate Contributor License Agreement (CLA).
9 |
10 | * If you are an individual writing original source code and you're sure you
11 | own the intellectual property, then you'll need to sign an [individual CLA]
12 | (https://cla.developers.google.com).
13 | * If you work for a company that wants to allow you to contribute your work,
14 | then you'll need to sign a [corporate CLA]
15 | (https://cla.developers.google.com).
16 |
17 | Follow either of the two links above to access the appropriate CLA and
18 | instructions for how to sign and return it. Once we receive it, we'll be able to
19 | accept your pull requests.
20 |
21 | ## Contributing A Patch
22 |
23 | 1. Submit an issue describing your proposed change to the repo in question.
24 | 1. The repo owner will respond to your issue promptly.
25 | 1. If your proposed change is accepted, and you haven't already done so, sign a
26 | Contributor License Agreement (see details above).
27 | 1. Fork the desired repo, develop and test your code changes.
28 | 1. Ensure that your code adheres to the existing style in the sample to which
29 | you are contributing. Refer to the
30 | [Android Code Style Guide]
31 | (https://source.android.com/source/code-style.html) for the
32 | recommended coding standards for this organization.
33 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
34 | 1. Submit a pull request.
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/kotlinApp/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your sample apps and patches! Before we can take them, we
6 | have to jump a couple of legal hurdles.
7 |
8 | Please fill out either the individual or corporate Contributor License Agreement (CLA).
9 |
10 | * If you are an individual writing original source code and you're sure you
11 | own the intellectual property, then you'll need to sign an [individual CLA]
12 | (https://cla.developers.google.com).
13 | * If you work for a company that wants to allow you to contribute your work,
14 | then you'll need to sign a [corporate CLA]
15 | (https://cla.developers.google.com).
16 |
17 | Follow either of the two links above to access the appropriate CLA and
18 | instructions for how to sign and return it. Once we receive it, we'll be able to
19 | accept your pull requests.
20 |
21 | ## Contributing A Patch
22 |
23 | 1. Submit an issue describing your proposed change to the repo in question.
24 | 1. The repo owner will respond to your issue promptly.
25 | 1. If your proposed change is accepted, and you haven't already done so, sign a
26 | Contributor License Agreement (see details above).
27 | 1. Fork the desired repo, develop and test your code changes.
28 | 1. Ensure that your code adheres to the existing style in the sample to which
29 | you are contributing. Refer to the
30 | [Android Code Style Guide]
31 | (https://source.android.com/source/code-style.html) for the
32 | recommended coding standards for this organization.
33 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
34 | 1. Submit a pull request.
35 |
36 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com/example/android/downloadablefonts/QueryBuilder.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.downloadablefonts
18 |
19 | /**
20 | * Builder class for constructing a query for downloading a font.
21 | */
22 | internal class QueryBuilder(val familyName: String,
23 | val width: Float? = null,
24 | val weight: Int? = null,
25 | val italic: Float? = null,
26 | val besteffort: Boolean? = null) {
27 |
28 | fun build(): String {
29 | if (weight == null && width == null && italic == null && besteffort == null) {
30 | return familyName
31 | }
32 | val builder = StringBuilder()
33 | builder.append("name=").append(familyName)
34 | weight?.let { builder.append("&weight=").append(weight) }
35 | width?.let { builder.append("&width=").append(width) }
36 | italic?.let { builder.append("&italic=").append(italic) }
37 | besteffort?.let { builder.append("&besteffort=").append(besteffort) }
38 | return builder.toString()
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | Downloadable fonts sample
19 | request
20 | Not a valid Family Name
21 | Invalid inputs exist
22 | Family Name
23 | Weight
24 | Width
25 | Italic
26 | Best Effort (Nearest match)
27 | The pre-downloaded font is used for this part to avoid the overhead of the time until the requested font is downloaded. See "src/main/res/font" directory for usage.
28 | Typeface of this part is going to be changed when a new font is downloaded. To request a new font, fill the \"Family Name\" (and optionally change other attributes such as width, weight, italic), then tap the \"Request\" button
29 | Font request failed with reason code: %1$d
30 |
31 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | Downloadable fonts sample
19 | request
20 | Not a valid Family Name
21 | Invalid inputs exist
22 | Family Name
23 | Weight
24 | Width
25 | Italic
26 | Best Effort (Nearest match)
27 | The pre-downloaded font is used for this part to avoid the overhead of the time until the requested font is downloaded. See "src/main/res/font" directory for usage.
28 | Typeface of this part is going to be changed when a new font is downloaded. To request a new font, fill the \"Family Name\" (and optionally change other attributes such as width, weight, italic), then tap the \"Request\" button
29 | Font request failed with reason code: %1$d
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
23 |
24 |
30 |
31 |
37 |
38 |
39 |
46 |
47 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
23 |
24 |
30 |
31 |
37 |
38 |
39 |
46 |
47 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/kotlinApp/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/downloadablefonts/QueryBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.downloadablefonts;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.support.annotation.Nullable;
21 |
22 | /**
23 | * Builder class for constructing a query for downloading a font.
24 | */
25 | class QueryBuilder {
26 |
27 | @NonNull
28 | private String mFamilyName;
29 |
30 | @Nullable
31 | private Float mWidth = null;
32 |
33 | @Nullable
34 | private Integer mWeight = null;
35 |
36 | @Nullable
37 | private Float mItalic = null;
38 |
39 | @Nullable
40 | private Boolean mBesteffort = null;
41 |
42 | QueryBuilder(@NonNull String familyName) {
43 | mFamilyName = familyName;
44 | }
45 |
46 | QueryBuilder withFamilyName(@NonNull String familyName) {
47 | mFamilyName = familyName;
48 | return this;
49 | }
50 |
51 | QueryBuilder withWidth(float width) {
52 | if (width <= Constants.WIDTH_MIN) {
53 | throw new IllegalArgumentException("Width must be more than 0");
54 | }
55 | mWidth = width;
56 | return this;
57 | }
58 |
59 | QueryBuilder withWeight(int weight) {
60 | if (weight <= Constants.WEIGHT_MIN || weight >= Constants.WEIGHT_MAX) {
61 | throw new IllegalArgumentException(
62 | "Weight must be between 0 and 1000 (exclusive)");
63 | }
64 | mWeight = weight;
65 | return this;
66 | }
67 |
68 | QueryBuilder withItalic(float italic) {
69 | if (italic < Constants.ITALIC_MIN || italic > Constants.ITALIC_MAX) {
70 | throw new IllegalArgumentException("Italic must be between 0 and 1 (inclusive)");
71 | }
72 | mItalic = italic;
73 | return this;
74 | }
75 |
76 | QueryBuilder withBestEffort(boolean bestEffort) {
77 | mBesteffort = bestEffort;
78 | return this;
79 | }
80 |
81 | String build() {
82 | if (mWeight == null && mWidth == null && mItalic == null && mBesteffort == null) {
83 | return mFamilyName;
84 | }
85 | StringBuilder builder = new StringBuilder();
86 | builder.append("name=").append(mFamilyName);
87 | if (mWeight != null) {
88 | builder.append("&weight=").append(mWeight);
89 | }
90 | if (mWidth != null) {
91 | builder.append("&width=").append(mWidth);
92 | }
93 | if (mItalic != null) {
94 | builder.append("&italic=").append(mItalic);
95 | }
96 | if (mBesteffort != null) {
97 | builder.append("&besteffort=").append(mBesteffort);
98 | }
99 | return builder.toString();
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/res/values/font_certs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | - @array/com_google_android_gms_fonts_certs_dev
20 | - @array/com_google_android_gms_fonts_certs_prod
21 |
22 |
23 | -
24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xiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/values/font_certs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | - @array/com_google_android_gms_fonts_certs_dev
20 | - @array/com_google_android_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sdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/kotlinApp/README.md:
--------------------------------------------------------------------------------
1 | Android DownloadableFonts Sample (Kotlin)
2 | ===================================
3 |
4 | This sample demonstrates how to use the Downloadable Fonts feature introduced in Android O.
5 | Downloadable Fonts is a feature that allows apps to request a certain font from a provider
6 | instead of bundling it or downloading it themselves. This means, there is no need to bundle the
7 | font as an asset.
8 |
9 | Introduction
10 | ------------
11 |
12 | There are two ways of requesting a font to download.
13 | To request a font to download from Java code, you need to create a [FontRequest][1] class first like
14 | this:
15 | ```java
16 | FontRequest request = new FontRequest(
17 | "com.google.android.gms.fonts", // ProviderAuthority
18 | "com.google.android.gms", // ProviderPackage
19 | query, // Query
20 | R.array.com_google_android_gms_fonts_certs); // Certificates
21 | ```
22 | The parameters `ProviderAuthority`, `ProviderPackage` are given by a font provider, in the case
23 | above uses Google Play Services as a font provider.
24 | The third parameter is a query string about the requested font. The syntax of the query is defined
25 | by the font provider.
26 |
27 | Then pass the request instance to the `requestFont` method in the [FontsContractCompat][2].
28 | ```java
29 | FontsContractCompat.requestFont(context, request, callback, handler);
30 | ```
31 | The downloaded font or an error code if the request failed will be passed to the callback.
32 | The example above assumes you are using the classes from the support library. There are
33 | corresponding classes in the framework, but the feature is available back to API level 14 if you
34 | use the support library.
35 |
36 | You can declare a downloaded font in an XML file and let the system download it for you and use it
37 | in layouts.
38 | ```xml
39 |
44 |
45 | ```
46 | By defining the requested font in an XML file and putting the `preloaded_fonts` array and the
47 | meta-data tag in the AndroidManifest, you can avoid the delay until the font is downloaded by the
48 | first attempt.
49 | ```xml
50 |
51 |
52 | - @font/lobster_two
53 |
54 |
55 | ```
56 |
57 | ```xml
58 |
59 | ...
60 |
61 | ...
62 |
63 | ```
64 |
65 | Note that the sample uses Google Play Services as a font provider, which requires pre-released
66 | version of Google Play Services.
67 | You can sign up for the beta program so that the beta version of Google Play Services is
68 | downloaded to your device. https://developers.google.com/android/guides/beta-program
69 | If you have Google Play Services whose version number is equal or above 11.x.x, that means you
70 | have the compatible version installed. (You can confirm by navigating to
71 | Settings -> Apps -> Google Play Services)
72 |
73 | [1]: https://developer.android.com/reference/android/support/v4/provider/FontRequest.html
74 | [2]: https://developer.android.com/reference/android/support/v4/provider/FontsContractCompat.html
75 |
76 | Pre-requisites
77 | --------------
78 |
79 | - Android SDK 25
80 | - Android Build Tools v25.0.3
81 | - Android Support Repository
82 |
83 | Screenshots
84 | -------------
85 |
86 |
87 |
88 | Getting Started
89 | ---------------
90 |
91 | This sample uses the Gradle build system. To build this project, use the
92 | "gradlew build" command or use "Import Project" in Android Studio.
93 |
94 | Support
95 | -------
96 |
97 | - Google+ Community: https://plus.google.com/communities/105153134372062985968
98 | - Stack Overflow: http://stackoverflow.com/questions/tagged/android
99 |
100 | If you've found an error in this sample, please file an issue:
101 | https://github.com/googlesamples/android-DownloadableFonts
102 |
103 | Patches are encouraged, and may be submitted by forking this project and
104 | submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
105 |
106 | License
107 | -------
108 |
109 | Copyright 2017 The Android Open Source Project, Inc.
110 |
111 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
112 | license agreements. See the NOTICE file distributed with this work for
113 | additional information regarding copyright ownership. The ASF licenses this
114 | file to you under the Apache License, Version 2.0 (the "License"); you may not
115 | use this file except in compliance with the License. You may obtain a copy of
116 | the License at
117 |
118 | http://www.apache.org/licenses/LICENSE-2.0
119 |
120 | Unless required by applicable law or agreed to in writing, software
121 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
122 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
123 | License for the specific language governing permissions and limitations under
124 | the License.
125 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/kotlinApp/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/bottom_sheet_font_query.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
25 |
26 |
30 |
31 |
37 |
38 |
47 |
48 |
53 |
54 |
61 |
62 |
63 |
67 |
68 |
74 |
75 |
76 |
77 |
86 |
87 |
95 |
96 |
101 |
102 |
107 |
108 |
116 |
117 |
118 |
119 |
128 |
129 |
137 |
138 |
143 |
144 |
149 |
150 |
158 |
159 |
160 |
161 |
170 |
171 |
179 |
180 |
185 |
186 |
191 |
192 |
200 |
201 |
202 |
203 |
213 |
214 |
215 |
216 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/res/layout/bottom_sheet_font_query.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
25 |
26 |
30 |
31 |
37 |
38 |
47 |
48 |
53 |
54 |
61 |
62 |
63 |
67 |
68 |
74 |
75 |
76 |
77 |
86 |
87 |
95 |
96 |
101 |
102 |
107 |
108 |
116 |
117 |
118 |
119 |
128 |
129 |
137 |
138 |
143 |
144 |
149 |
150 |
158 |
159 |
160 |
161 |
170 |
171 |
179 |
180 |
185 |
186 |
191 |
192 |
200 |
201 |
202 |
203 |
213 |
214 |
215 |
216 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com/example/android/downloadablefonts/MainActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.downloadablefonts
18 |
19 | import android.graphics.Typeface
20 | import android.os.Bundle
21 | import android.os.Handler
22 | import android.os.HandlerThread
23 | import android.support.design.widget.TextInputLayout
24 | import android.support.v4.provider.FontRequest
25 | import android.support.v4.provider.FontsContractCompat
26 | import android.support.v4.util.ArraySet
27 | import android.support.v7.app.AppCompatActivity
28 | import android.text.Editable
29 | import android.text.TextWatcher
30 | import android.util.Log
31 | import android.view.View
32 | import android.widget.ArrayAdapter
33 | import android.widget.AutoCompleteTextView
34 | import android.widget.Button
35 | import android.widget.CheckBox
36 | import android.widget.ProgressBar
37 | import android.widget.SeekBar
38 | import android.widget.TextView
39 | import android.widget.Toast
40 |
41 | import java.util.Arrays
42 |
43 | import com.example.android.downloadablefonts.Constants.ITALIC_DEFAULT
44 | import com.example.android.downloadablefonts.Constants.WEIGHT_DEFAULT
45 | import com.example.android.downloadablefonts.Constants.WEIGHT_MAX
46 | import com.example.android.downloadablefonts.Constants.WIDTH_DEFAULT
47 | import com.example.android.downloadablefonts.Constants.WIDTH_MAX
48 |
49 | class MainActivity : AppCompatActivity() {
50 |
51 | lateinit private var mHandler: Handler
52 |
53 | lateinit private var mDownloadableFontTextView: TextView
54 | lateinit private var mWidthSeekBar: SeekBar
55 | lateinit private var mWeightSeekBar: SeekBar
56 | lateinit private var mItalicSeekBar: SeekBar
57 | lateinit private var mBestEffort: CheckBox
58 | lateinit private var mRequestDownloadButton: Button
59 |
60 | lateinit private var mFamilyNameSet: ArraySet
61 |
62 | override fun onCreate(savedInstanceState: Bundle?) {
63 | super.onCreate(savedInstanceState)
64 | setContentView(R.layout.activity_main)
65 |
66 | val handlerThread = HandlerThread("fonts")
67 | handlerThread.start()
68 | mHandler = Handler(handlerThread.looper)
69 | initializeSeekBars()
70 | mFamilyNameSet = ArraySet()
71 | mFamilyNameSet.addAll(Arrays.asList(*resources.getStringArray(R.array.family_names)))
72 |
73 | mDownloadableFontTextView = findViewById(R.id.textview)
74 | val adapter = ArrayAdapter(this,
75 | android.R.layout.simple_dropdown_item_1line,
76 | resources.getStringArray(R.array.family_names))
77 | val familyNameInput = findViewById(R.id.auto_complete_family_name_input)
78 | val autoCompleteFamilyName = findViewById(R.id.auto_complete_family_name)
79 | autoCompleteFamilyName.setAdapter>(adapter)
80 | autoCompleteFamilyName.addTextChangedListener(object : TextWatcher {
81 | override fun beforeTextChanged(charSequence: CharSequence, start: Int, count: Int,
82 | after: Int) {
83 | // No op
84 | }
85 |
86 | override fun onTextChanged(charSequence: CharSequence, start: Int, count: Int, after: Int) {
87 | if (isValidFamilyName(charSequence.toString())) {
88 | familyNameInput.isErrorEnabled = false
89 | familyNameInput.error = ""
90 | } else {
91 | familyNameInput.isErrorEnabled = true
92 | familyNameInput.error = getString(R.string.invalid_family_name)
93 | }
94 | }
95 |
96 | override fun afterTextChanged(editable: Editable) {
97 | // No op
98 | }
99 | })
100 |
101 | mRequestDownloadButton = findViewById