Material You Color Previewer is a simple app that allows you to look through all Material You colors. It will also display the actual color ID, for you to easily use in your project.
2 |
You can also copy the full list of Monet Colors, as they are set on your device, in the following formats: XML list for Android app development, JSON object, set of CSS variables and a C# class for Unity.
3 |
Moreover, the app works on devices which run under API lower than 31 (Android 12). In such cases the app will use a fallback set of colors (blue-ish Monet theme, as the one used in apps like Google Dialer on devices running under API 30 and lower).
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_twotone_content_paste_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/res/drawable/css_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/data_object_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/smoothie/monetcolors/ColorEntry.java:
--------------------------------------------------------------------------------
1 | package com.smoothie.monetcolors;
2 |
3 | import android.content.Context;
4 |
5 | public class ColorEntry {
6 |
7 | public final int colorID;
8 | public final String name;
9 | public final String shortName;
10 |
11 | public int getColor(Context context) {
12 | return context.getColor(colorID);
13 | }
14 |
15 | public String getHEX(Context context) {
16 | return String.format("#%06X", (0xFFFFFF & context.getColor(colorID)));
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public String getShortName() {
24 | return shortName;
25 | }
26 |
27 | public ColorEntry(int id, String name) {
28 | this.colorID = id;
29 | this.name = name;
30 | this.shortName = name.substring("@android:color/system_".length());
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values-ru/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Previewer
5 | Monet Color Previewer
6 | Скопировано!
7 | Скопировать
8 | Варианты копирования
9 | Скопировать цвет
10 | Скопировать палитру целиком
11 | Скопировать код
12 | XML
13 | JSON
14 | Набор переменных CSS
15 | Класс C# для Unity
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
16 |
17 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/smoothie/monetcolors/BottomInsetAwareDialog.java:
--------------------------------------------------------------------------------
1 | package com.smoothie.monetcolors;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.view.View;
7 | import android.view.WindowInsets;
8 |
9 | import androidx.annotation.NonNull;
10 |
11 | public class BottomInsetAwareDialog extends Dialog {
12 |
13 | public BottomInsetAwareDialog(@NonNull Context context) {
14 | super(context, R.style.SimpleDialog);
15 | }
16 |
17 | @Override
18 | public void onAttachedToWindow() {
19 | super.onAttachedToWindow();
20 | View rootView = findViewById(R.id.dialog_root_view);
21 |
22 | int bottomInset;
23 | WindowInsets insets = getWindow().getDecorView().getRootWindowInsets();
24 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
25 | bottomInset = insets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()).bottom;
26 | else
27 | bottomInset = insets.getStableInsetBottom();
28 |
29 | rootView.setPadding(0, 0, 0, bottomInset);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 |
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | applicationId "com.smoothie.monetcolors"
11 | minSdk 23
12 | targetSdk 33
13 | versionCode 3
14 | versionName "1.2"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | compileOptions {
27 | sourceCompatibility JavaVersion.VERSION_11
28 | targetCompatibility JavaVersion.VERSION_11
29 | }
30 |
31 | namespace 'com.smoothie.monetcolors'
32 | buildToolsVersion '33.0.2'
33 |
34 | }
35 |
36 | dependencies {
37 |
38 | implementation 'androidx.appcompat:appcompat:1.6.1'
39 | implementation 'com.google.android.material:material:1.9.0'
40 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
41 |
42 | implementation(project(':android-maskable-layout:library'))
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 2-Clause License
2 |
3 | Copyright (c) 2022, -Smooth-E-
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Enables namespacing of each library's R class so that its R class includes only the
19 | # resources declared in the library itself and none from the library's dependencies,
20 | # thereby reducing the size of the R class for that library
21 | android.nonTransitiveRClass=true
22 | android.defaults.buildfeatures.buildconfig=true
23 | android.nonFinalResIds=false
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_twotone_color_lens_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_variants_entry.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
26 |
27 |
39 |
40 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
16 |
19 |
22 |
25 |
28 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-night/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
16 |
19 |
22 |
25 |
28 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Previewer
4 | Monet Color Previewer
5 | Copied!
6 | Copy
7 | Copy options
8 |
9 | Copy color
10 | Copy entire palette
11 | Copy code snippet
12 |
13 | XML
14 | <?xml version=\"1.0\" encoding=\"utf-8\"\?\>\n<resources>\n
15 | \ \ \ <color name=\"
16 | \">\n\ \ \ \ \ \
17 | \n\ \ \ </color>\n
18 | </resources>\n
19 |
20 | JSON
21 | {\n
22 | \ \ \ \"
23 | \":\ \"
24 | \",\n
25 | }
26 |
27 | CSS variable set
28 | .root {\n
29 | \ \ \ \ --
30 | \ =\
31 | ;\n
32 | }
33 |
34 | C# class for Unity
35 | public class ColorSet {\n
36 | \ \ \ \ public static Color\
37 | \ =\ new Color32(
38 | );\n
39 | }
40 |
41 |
42 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_copy_preview.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
30 |
31 |
40 |
41 |
51 |
52 |
53 |
54 |
60 |
61 |
70 |
71 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #FFFFFF
5 | #F9FCFF
6 | #E0F3FF
7 | #C1E8FF
8 | #76D1FF
9 | #4BB6E8
10 | #219BCC
11 | #007FAC
12 | #00668B
13 | #004C69
14 | #003549
15 | #001E2C
16 | #000000
17 | #FFFFFF
18 | #F9FCFF
19 | #E0F3FF
20 | #D1E5F4
21 | #B5CAD7
22 | #9AAEBB
23 | #8094A0
24 | #657985
25 | #4E616C
26 | #374955
27 | #20333D
28 | #091E28
29 | #000000
30 | #FFFFFF
31 | #FFFBFF
32 | #F5EEFF
33 | #E6DEFF
34 | #CAC1EA
35 | #AEA6CE
36 | #938CB1
37 | #787296
38 | #605A7C
39 | #484264
40 | #322C4C
41 | #1D1736
42 | #000000
43 | #FFFFFF
44 | #FCFCFF
45 | #F0F0F3
46 | #E1E3E5
47 | #C5C7C9
48 | #AAABAE
49 | #8F9193
50 | #747679
51 | #5C5F61
52 | #454749
53 | #2E3133
54 | #191C1E
55 | #000000
56 | #FFFFFF
57 | #F9FCFF
58 | #EBF1F8
59 | #DCE3E9
60 | #C0C7CD
61 | #A5ACB2
62 | #8A9297
63 | #70777C
64 | #585F65
65 | #40484D
66 | #2A3136
67 | #161C20
68 | #000000
69 |
70 |
71 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_variants_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
32 |
33 |
45 |
46 |
58 |
59 |
71 |
72 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | Use this simple app to view all available Material You colors. This app will also show you the actual color ID for you to easily use it in your project.
22 |
23 | You can also copy the full list of Monet Colors, as they are set on your device, in the following formats: XML list for Android app development, JSON object, set of CSS variables and a C# class for Unity.
24 |
25 | Moreover, the app now works on devices which run under API lower than 31 (Android 12). In such cases app will use a fallback set of colors (blue-ish Monet theme, as the one used in apps like Google Dialer on devices running API 30 and lower).
26 |
27 | ## Known issues
28 |
29 | ### Sudden crashes
30 |
31 | When changing the UI state on your device (e.g. switching from light to dark theme) the app will most likely crash. It may crash in some cases when you are changing its activity state (e.g. returning to the app from a home screen or "Recent applications" screen). The cause of these crashes is the [android-maskable-layout library](https://github.com/Smooth-E/android-maskable-layout) which I am using to cut inner UI elements of rounded-cornered dialogs and scrollable views. Since this library is very outdated (last update in 2020, migrated to AndroidX by me in early spring 2023) I am planning to either replace it with Android's new `ShapeableImageView` where possible or patch the existing library further to resolve mentioned crashes.
32 |
33 | ### Inconsistent experience on different Android versions
34 |
35 | Navigation bar looks differently on different API versions:
36 |
37 | - Android 6 - Android 9 - navigation bar has a blue background and light icons
38 | - Android 10 and Android 11 - navigation bar has a dimmed background and light icons
39 | - Android 12 and others (hopefully) - navigation bar background is blue with dark icons (intended behavior)
40 |
41 | It all started when I realized that Android has a very annoying bug in somewhat recent versions of it: when you want a window to slowly slide from below the screen on entrance and are making to interpolate it's Y position between -100% and 0%, it moves slightly higher (as if the top edge of the navigation bar was the bottom edge of the screen) and then immediately jumps back to where it should've stopped. It turned out that is I set the `android:windowIsFloating` flag to `true`, the animation will perform just fine. However. with this flag enabled, another problem appeared. It turns out, that on older API versions if the window is floating, then on API 23 the bottom inset for it is always 0, and on API 24 to 27 the navigation bar is dimmed. Then I made separate themes for different API versions, but didn't come up with a solution on how to remove dimness on Android 10 and Android 11.
42 |
43 | This is why you will get somewhat inconsistent experience on different Android versions. In future releases I am planning to reimplement these bottom dialogs with `ModalBottomSheet`s and overall redesign the app, since for now it is not really built with Material 3 guidelines in mind.
44 |
45 | > Stay tuned for the next release!
46 |
47 | ## Licensing and resources
48 |
49 | Monet Color Previewer is licensed under the [BSD 2-Clause License](./LICENSE). You can use it freely, but I do not give any warranties. Also, if you find this app useful, it will be nice of you to share it with others and not forget to give me a credit.
50 |
51 | This project also uses external resources and libraries:
52 | - [JetBrains Mono Font](https://www.jetbrains.com/lp/mono/)
53 | - [Google Material Icons](https://fonts.google.com/icons?icon.style=Two+tone&icon.set=Material+Icons)
54 | - [android-maskable-layout](https://github.com/Smooth-E/android-maskable-layout)
55 | - [Google Material](https://github.com/material-components/material-components-android)
56 | - [AndroidX Libraries](https://github.com/androidx/androidx)
57 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v31/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | @android:color/system_accent1_0
5 | @android:color/system_accent1_10
6 | @android:color/system_accent1_50
7 | @android:color/system_accent1_100
8 | @android:color/system_accent1_200
9 | @android:color/system_accent1_300
10 | @android:color/system_accent1_400
11 | @android:color/system_accent1_500
12 | @android:color/system_accent1_600
13 | @android:color/system_accent1_700
14 | @android:color/system_accent1_800
15 | @android:color/system_accent1_900
16 | @android:color/system_accent1_1000
17 |
18 | @android:color/system_accent2_0
19 | @android:color/system_accent2_10
20 | @android:color/system_accent2_50
21 | @android:color/system_accent2_100
22 | @android:color/system_accent2_200
23 | @android:color/system_accent2_300
24 | @android:color/system_accent2_400
25 | @android:color/system_accent2_500
26 | @android:color/system_accent2_600
27 | @android:color/system_accent2_700
28 | @android:color/system_accent2_800
29 | @android:color/system_accent2_900
30 | @android:color/system_accent2_1000
31 |
32 | @android:color/system_accent3_0
33 | @android:color/system_accent3_10
34 | @android:color/system_accent3_50
35 | @android:color/system_accent3_100
36 | @android:color/system_accent3_200
37 | @android:color/system_accent3_300
38 | @android:color/system_accent3_400
39 | @android:color/system_accent3_500
40 | @android:color/system_accent3_600
41 | @android:color/system_accent3_700
42 | @android:color/system_accent3_800
43 | @android:color/system_accent3_900
44 | @android:color/system_accent3_1000
45 |
46 | @android:color/system_neutral1_0
47 | @android:color/system_neutral1_10
48 | @android:color/system_neutral1_50
49 | @android:color/system_neutral1_100
50 | @android:color/system_neutral1_200
51 | @android:color/system_neutral1_300
52 | @android:color/system_neutral1_400
53 | @android:color/system_neutral1_500
54 | @android:color/system_neutral1_600
55 | @android:color/system_neutral1_700
56 | @android:color/system_neutral1_800
57 | @android:color/system_neutral1_900
58 | @android:color/system_neutral1_1000
59 |
60 | @android:color/system_neutral2_0
61 | @android:color/system_neutral2_10
62 | @android:color/system_neutral2_50
63 | @android:color/system_neutral2_100
64 | @android:color/system_neutral2_200
65 | @android:color/system_neutral2_300
66 | @android:color/system_neutral2_400
67 | @android:color/system_neutral2_500
68 | @android:color/system_neutral2_600
69 | @android:color/system_neutral2_700
70 | @android:color/system_neutral2_800
71 | @android:color/system_neutral2_900
72 | @android:color/system_neutral2_1000
73 |
74 |
75 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
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 | # https://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 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/com/smoothie/monetcolors/CopyEntryView.java:
--------------------------------------------------------------------------------
1 | package com.smoothie.monetcolors;
2 |
3 | import android.app.Dialog;
4 | import android.content.ClipData;
5 | import android.content.ClipboardManager;
6 | import android.content.Context;
7 | import android.content.res.TypedArray;
8 | import android.graphics.Color;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.Gravity;
12 | import android.view.View;
13 | import android.widget.ImageView;
14 | import android.widget.LinearLayout;
15 | import android.widget.TextView;
16 | import android.widget.Toast;
17 |
18 | public class CopyEntryView extends LinearLayout {
19 |
20 | private static final String TAG = "CopyEntryView";
21 |
22 | private int icon;
23 | private String name = "Copy as what?";
24 | private String fileStart = "defaultTemplate {\n";
25 | private String entryStart = " \"";
26 | private String entryMiddle = "\": \"";
27 | private String entryEnd = "\";\n";
28 | private String fileEnd = "}";
29 | private boolean rgbMode;
30 | private Dialog parentDialog;
31 |
32 | private static class OnCopyClickListener implements View.OnClickListener {
33 |
34 | private final CopyEntryView instance;
35 | private final Dialog listDialog;
36 | private final Dialog copyDialog;
37 |
38 | public OnCopyClickListener(CopyEntryView instance, Dialog listDialog, Dialog copyDialog) {
39 | this.instance = instance;
40 | this.listDialog = listDialog;
41 | this.copyDialog = copyDialog;
42 | }
43 |
44 | @Override
45 | public void onClick(View view) {
46 | Context context = instance.getContext();
47 |
48 | StringBuilder stringBuilder = new StringBuilder(instance.fileStart);
49 |
50 | for (int i = 0; i < MainActivity.getColors().length; i++)
51 | stringBuilder.append(instance.getStringForEntry(i));
52 |
53 | stringBuilder.append(instance.fileEnd);
54 |
55 | ClipboardManager clipboard =
56 | (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
57 |
58 | String label = "Monet Color Value";
59 | ClipData clip = ClipData.newPlainText(label, stringBuilder.toString());
60 | clipboard.setPrimaryClip(clip);
61 |
62 | String toastMessage = context.getString(R.string.result_copy);
63 | Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show();
64 |
65 | copyDialog.hide();
66 | listDialog.hide();
67 | }
68 | }
69 |
70 | public CopyEntryView(Context context, AttributeSet attrs) {
71 | super(context, attrs);
72 | BuildView(context, attrs);
73 | }
74 |
75 | public CopyEntryView(Context context) {
76 | super(context);
77 | BuildView(context, null);
78 | }
79 |
80 | public void setParentDialog(Dialog dialog) {
81 | this.parentDialog = dialog;
82 | }
83 |
84 | private String getStringForEntry(int entryID) {
85 | ColorEntry colorEntry = MainActivity.getColors()[entryID];
86 |
87 | StringBuilder stringBuilder = new StringBuilder(entryStart)
88 | .append(colorEntry.getShortName())
89 | .append(entryMiddle);
90 |
91 | if (rgbMode) {
92 | int color = colorEntry.getColor(getContext());
93 | stringBuilder.append(Color.red(color));
94 | stringBuilder.append(", ");
95 | stringBuilder.append(Color.green(color));
96 | stringBuilder.append(", ");
97 | stringBuilder.append(Color.blue(color));
98 | }
99 | else
100 | stringBuilder.append(colorEntry.getHEX(getContext()));
101 |
102 | stringBuilder.append(entryEnd);
103 |
104 | return stringBuilder.toString();
105 | }
106 |
107 | private void onClick() {
108 | Log.d(TAG, "OnClick()");
109 |
110 | Dialog dialog = new BottomInsetAwareDialog(getContext());
111 | dialog.setContentView(R.layout.dialog_copy_preview);
112 | dialog.setCancelable(true);
113 | dialog.setCanceledOnTouchOutside(true);
114 | dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
115 | dialog.getWindow().setGravity(Gravity.BOTTOM);
116 |
117 | StringBuilder templatePreview = new StringBuilder(fileStart)
118 | .append(getStringForEntry(0))
119 | .append(getStringForEntry(1))
120 | .append(" ...\n").append(fileEnd);
121 |
122 | ((TextView) dialog.findViewById(R.id.template_preview)).setText(templatePreview);
123 |
124 | ((TextView) dialog.findViewById(R.id.preview_header)).setText(name);
125 |
126 | OnCopyClickListener listener = new OnCopyClickListener(this, parentDialog, dialog);
127 | dialog.findViewById(R.id.button_copy_palette_parent).setOnClickListener(listener);
128 |
129 | dialog.show();
130 | }
131 |
132 | private String getString(TypedArray attributeSet, int resourceID, String defaultValue) {
133 | String string = attributeSet.getString(resourceID);
134 | return string == null ? defaultValue : string;
135 | }
136 |
137 | void BuildView(Context context, AttributeSet attributes) {
138 | inflate(context, R.layout.dialog_variants_entry, this);
139 |
140 | if (attributes != null) {
141 | TypedArray obtainedAttributes = context.getTheme().obtainStyledAttributes(
142 | attributes,
143 | R.styleable.CopyEntryView,
144 | 0,
145 | 0
146 | );
147 |
148 | icon = obtainedAttributes.getResourceId(
149 | R.styleable.CopyEntryView_entry_icon,
150 | R.drawable.ic_launcher_foreground
151 | );
152 |
153 | name = getString(obtainedAttributes, R.styleable.CopyEntryView_entry_name, name);
154 |
155 | fileStart = getString(
156 | obtainedAttributes,
157 | R.styleable.CopyEntryView_entry_file_start,
158 | fileStart
159 | );
160 |
161 | entryStart = getString(
162 | obtainedAttributes,
163 | R.styleable.CopyEntryView_entry_entry_start,
164 | entryStart
165 | );
166 |
167 | entryMiddle = getString(
168 | obtainedAttributes,
169 | R.styleable.CopyEntryView_entry_entry_middle,
170 | entryMiddle
171 | );
172 |
173 | entryEnd = getString(
174 | obtainedAttributes,
175 | R.styleable.CopyEntryView_entry_entry_end,
176 | entryEnd
177 | );
178 |
179 | fileEnd = getString(
180 | obtainedAttributes,
181 | R.styleable.CopyEntryView_entry_file_end,
182 | fileEnd
183 | );
184 |
185 | rgbMode = obtainedAttributes
186 | .getBoolean(R.styleable.CopyEntryView_use_rgb_pattern, false);
187 | }
188 |
189 | ((ImageView) findViewById(R.id.icon)).setImageResource(icon);
190 | ((TextView) findViewById(R.id.text)).setText(name);
191 |
192 | findViewById(R.id.clickable).setOnClickListener((View v) -> onClick());
193 | }
194 |
195 | }
196 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
24 |
25 |
36 |
37 |
44 |
45 |
46 |
47 |
56 |
57 |
65 |
66 |
75 |
76 |
85 |
86 |
87 |
88 |
89 |
90 |
99 |
100 |
109 |
110 |
119 |
120 |
121 |
122 |
123 |
124 |
135 |
136 |
144 |
145 |
153 |
154 |
162 |
163 |
164 |
165 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/app/src/main/java/com/smoothie/monetcolors/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.smoothie.monetcolors;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.annotation.SuppressLint;
6 | import android.app.Dialog;
7 | import android.content.ClipData;
8 | import android.content.ClipboardManager;
9 | import android.content.Context;
10 | import android.content.res.ColorStateList;
11 | import android.content.res.Configuration;
12 | import android.os.Bundle;
13 | import android.view.Gravity;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.FrameLayout;
18 | import android.widget.LinearLayout;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | public class MainActivity extends AppCompatActivity {
23 | private static final ColorEntry[] COLORS = new ColorEntry[] {
24 | new ColorEntry(R.color.accent1_0, "@android:color/system_accent1_0" ),
25 | new ColorEntry(R.color.accent1_10, "@android:color/system_accent1_10" ),
26 | new ColorEntry(R.color.accent1_50, "@android:color/system_accent1_50" ),
27 | new ColorEntry(R.color.accent1_100, "@android:color/system_accent1_100" ),
28 | new ColorEntry(R.color.accent1_200, "@android:color/system_accent1_200" ),
29 | new ColorEntry(R.color.accent1_300, "@android:color/system_accent1_300" ),
30 | new ColorEntry(R.color.accent1_400, "@android:color/system_accent1_400" ),
31 | new ColorEntry(R.color.accent1_500, "@android:color/system_accent1_500" ),
32 | new ColorEntry(R.color.accent1_600, "@android:color/system_accent1_600" ),
33 | new ColorEntry(R.color.accent1_700, "@android:color/system_accent1_700" ),
34 | new ColorEntry(R.color.accent1_800, "@android:color/system_accent1_800" ),
35 | new ColorEntry(R.color.accent1_900, "@android:color/system_accent1_900" ),
36 | new ColorEntry(R.color.accent1_1000, "@android:color/system_accent1_1000"),
37 |
38 | new ColorEntry(R.color.accent2_0, "@android:color/system_accent2_0" ),
39 | new ColorEntry(R.color.accent2_10, "@android:color/system_accent2_10" ),
40 | new ColorEntry(R.color.accent2_50, "@android:color/system_accent2_50" ),
41 | new ColorEntry(R.color.accent2_100, "@android:color/system_accent2_100" ),
42 | new ColorEntry(R.color.accent2_200, "@android:color/system_accent2_200" ),
43 | new ColorEntry(R.color.accent2_300, "@android:color/system_accent2_300" ),
44 | new ColorEntry(R.color.accent2_400, "@android:color/system_accent2_400" ),
45 | new ColorEntry(R.color.accent2_500, "@android:color/system_accent2_500" ),
46 | new ColorEntry(R.color.accent2_600, "@android:color/system_accent2_600" ),
47 | new ColorEntry(R.color.accent2_700, "@android:color/system_accent2_700" ),
48 | new ColorEntry(R.color.accent2_800, "@android:color/system_accent2_800" ),
49 | new ColorEntry(R.color.accent2_900, "@android:color/system_accent2_900" ),
50 | new ColorEntry(R.color.accent2_1000, "@android:color/system_accent2_1000"),
51 |
52 | new ColorEntry(R.color.accent3_0, "@android:color/system_accent3_0" ),
53 | new ColorEntry(R.color.accent3_10, "@android:color/system_accent3_10" ),
54 | new ColorEntry(R.color.accent3_50, "@android:color/system_accent3_50" ),
55 | new ColorEntry(R.color.accent3_100, "@android:color/system_accent3_100" ),
56 | new ColorEntry(R.color.accent3_200, "@android:color/system_accent3_200" ),
57 | new ColorEntry(R.color.accent3_300, "@android:color/system_accent3_300" ),
58 | new ColorEntry(R.color.accent3_400, "@android:color/system_accent3_400" ),
59 | new ColorEntry(R.color.accent3_500, "@android:color/system_accent3_500" ),
60 | new ColorEntry(R.color.accent3_600, "@android:color/system_accent3_600" ),
61 | new ColorEntry(R.color.accent3_700, "@android:color/system_accent3_700" ),
62 | new ColorEntry(R.color.accent3_800, "@android:color/system_accent3_800" ),
63 | new ColorEntry(R.color.accent3_900, "@android:color/system_accent3_900" ),
64 | new ColorEntry(R.color.accent3_1000, "@android:color/system_accent3_1000"),
65 |
66 | new ColorEntry(R.color.neutral1_0, "@android:color/system_neutral1_0" ),
67 | new ColorEntry(R.color.neutral1_10, "@android:color/system_neutral1_10" ),
68 | new ColorEntry(R.color.neutral1_50, "@android:color/system_neutral1_50" ),
69 | new ColorEntry(R.color.neutral1_100, "@android:color/system_neutral1_100" ),
70 | new ColorEntry(R.color.neutral1_200, "@android:color/system_neutral1_200" ),
71 | new ColorEntry(R.color.neutral1_300, "@android:color/system_neutral1_300" ),
72 | new ColorEntry(R.color.neutral1_400, "@android:color/system_neutral1_400" ),
73 | new ColorEntry(R.color.neutral1_500, "@android:color/system_neutral1_500" ),
74 | new ColorEntry(R.color.neutral1_600, "@android:color/system_neutral1_600" ),
75 | new ColorEntry(R.color.neutral1_700, "@android:color/system_neutral1_700" ),
76 | new ColorEntry(R.color.neutral1_800, "@android:color/system_neutral1_800" ),
77 | new ColorEntry(R.color.neutral1_900, "@android:color/system_neutral1_900" ),
78 | new ColorEntry(R.color.neutral1_1000, "@android:color/system_neutral1_1000"),
79 |
80 | new ColorEntry(R.color.neutral2_0, "@android:color/system_neutral2_0" ),
81 | new ColorEntry(R.color.neutral2_10, "@android:color/system_neutral2_10" ),
82 | new ColorEntry(R.color.neutral2_50, "@android:color/system_neutral2_50" ),
83 | new ColorEntry(R.color.neutral2_100, "@android:color/system_neutral2_100" ),
84 | new ColorEntry(R.color.neutral2_200, "@android:color/system_neutral2_200" ),
85 | new ColorEntry(R.color.neutral2_300, "@android:color/system_neutral2_300" ),
86 | new ColorEntry(R.color.neutral2_400, "@android:color/system_neutral2_400" ),
87 | new ColorEntry(R.color.neutral2_500, "@android:color/system_neutral2_500" ),
88 | new ColorEntry(R.color.neutral2_600, "@android:color/system_neutral2_600" ),
89 | new ColorEntry(R.color.neutral2_700, "@android:color/system_neutral2_700" ),
90 | new ColorEntry(R.color.neutral2_800, "@android:color/system_neutral2_800" ),
91 | new ColorEntry(R.color.neutral2_900, "@android:color/system_neutral2_900" ),
92 | new ColorEntry(R.color.neutral2_1000, "@android:color/system_neutral2_1000"),
93 | };
94 |
95 | private FrameLayout colorDroplet;
96 | private TextView colorName;
97 | private View backgroundView;
98 | private int selectedColorPosition;
99 |
100 | public static ColorEntry[] getColors() {
101 | return COLORS;
102 | }
103 |
104 | @SuppressLint("SetTextI18n")
105 | private void onColorClick(int position) {
106 | ColorEntry colorEntry = COLORS[position];
107 | backgroundView.setBackgroundTintList(ColorStateList.valueOf(getColor(colorEntry.colorID)));
108 | colorDroplet.setBackgroundTintList(ColorStateList.valueOf(getColor(colorEntry.colorID)));
109 | colorName.setText("system_" + colorEntry.getShortName());
110 | selectedColorPosition = position;
111 | }
112 |
113 | private void copyColor() {
114 | ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
115 | ColorEntry colorEntry = COLORS[selectedColorPosition];
116 | String colorCode = colorEntry.getHEX(this);
117 | String text = colorEntry.name + "\n" + colorCode;
118 |
119 | ClipData clip = ClipData.newPlainText("Monet Color Value", text);
120 | clipboard.setPrimaryClip(clip);
121 |
122 | String message = getResources().getString(R.string.result_copy) + " " + colorCode;
123 | Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
124 | }
125 |
126 | private void openSaveDialog() {
127 | Dialog dialog = new BottomInsetAwareDialog(this);
128 | dialog.setCanceledOnTouchOutside(true);
129 | dialog.setContentView(R.layout.dialog_variants_list);
130 | dialog.setCancelable(true);
131 | dialog.getWindow().setGravity(Gravity.BOTTOM);
132 | dialog.getWindow().setLayout(
133 | ViewGroup.LayoutParams.MATCH_PARENT,
134 | ViewGroup.LayoutParams.WRAP_CONTENT
135 | );
136 |
137 | LinearLayout dialogBox = dialog.findViewById(R.id.dialog_box);
138 | for (int i = 0; i < dialogBox.getChildCount(); i++) {
139 | View entry = dialogBox.getChildAt(i);
140 |
141 | if (entry instanceof CopyEntryView)
142 | ((CopyEntryView) entry).setParentDialog(dialog);
143 | }
144 |
145 | dialog.show();
146 | }
147 |
148 | @Override
149 | protected void onCreate(Bundle savedInstanceState) {
150 | super.onCreate(savedInstanceState);
151 | setContentView(R.layout.activity_main);
152 |
153 | colorDroplet = findViewById(R.id.color_droplet);
154 | colorName = findViewById(R.id.color_name_text_view);
155 | backgroundView = findViewById(R.id.background);
156 |
157 | LayoutInflater inflater = (LayoutInflater) getApplicationContext()
158 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
159 |
160 | LinearLayout parent = findViewById(R.id.color_list);
161 | for (int y = 0; y < 13; y++) {
162 |
163 | LinearLayout rowLayout = (LinearLayout) inflater
164 | .inflate(R.layout.layout_color_row, parent, false);
165 |
166 | for (int x = 0; x < 5; x++) {
167 | FrameLayout layout = (FrameLayout) inflater
168 | .inflate(R.layout.layout_color_entry, rowLayout, false);
169 |
170 | int position = x * 13 + y;
171 | int colorID = COLORS[position].colorID;
172 |
173 | ColorStateList tintList = ColorStateList.valueOf(getColor(colorID));
174 | layout.setBackgroundTintList(tintList);
175 | layout.setOnClickListener((View v) -> onColorClick(position));
176 | rowLayout.addView(layout);
177 | }
178 |
179 | parent.addView(rowLayout);
180 | }
181 |
182 | int uiMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
183 | boolean isLightMode = uiMode == Configuration.UI_MODE_NIGHT_NO;
184 | onColorClick(isLightMode ? 4 : 62);
185 |
186 | findViewById(R.id.button_copy_color).setOnClickListener((View v) -> copyColor());
187 | findViewById(R.id.button_copy_palette)
188 | .setOnClickListener((View v) -> openSaveDialog());
189 | }
190 |
191 | }
192 |
--------------------------------------------------------------------------------