73 |
74 |
75 |
--------------------------------------------------------------------------------
/docs/javadoc/jquery-ui.overrides.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | .ui-state-active,
27 | .ui-widget-content .ui-state-active,
28 | .ui-widget-header .ui-state-active,
29 | a.ui-button:active,
30 | .ui-button:active,
31 | .ui-button.ui-state-active:hover {
32 | /* Overrides the color of selection used in jQuery UI */
33 | background: #F8981D;
34 | border: 1px solid #F8981D;
35 | }
36 |
--------------------------------------------------------------------------------
/docs/javadoc/legal/ADDITIONAL_LICENSE_INFO:
--------------------------------------------------------------------------------
1 | Please see ..\java.base\ADDITIONAL_LICENSE_INFO
2 |
--------------------------------------------------------------------------------
/docs/javadoc/legal/ASSEMBLY_EXCEPTION:
--------------------------------------------------------------------------------
1 | Please see ..\java.base\ASSEMBLY_EXCEPTION
2 |
--------------------------------------------------------------------------------
/docs/javadoc/legal/LICENSE:
--------------------------------------------------------------------------------
1 | Please see ..\java.base\LICENSE
2 |
--------------------------------------------------------------------------------
/docs/javadoc/legal/jquery.md:
--------------------------------------------------------------------------------
1 | ## jQuery v3.6.0
2 |
3 | ### jQuery License
4 | ```
5 | jQuery v 3.6.0
6 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining
9 | a copy of this software and associated documentation files (the
10 | "Software"), to deal in the Software without restriction, including
11 | without limitation the rights to use, copy, modify, merge, publish,
12 | distribute, sublicense, and/or sell copies of the Software, and to
13 | permit persons to whom the Software is furnished to do so, subject to
14 | the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be
17 | included in all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 |
27 | ******************************************
28 |
29 | The jQuery JavaScript Library v3.6.0 also includes Sizzle.js
30 |
31 | Sizzle.js includes the following license:
32 |
33 | Copyright JS Foundation and other contributors, https://js.foundation/
34 |
35 | This software consists of voluntary contributions made by many
36 | individuals. For exact contribution history, see the revision history
37 | available at https://github.com/jquery/sizzle
38 |
39 | The following license applies to all parts of this software except as
40 | documented below:
41 |
42 | ====
43 |
44 | Permission is hereby granted, free of charge, to any person obtaining
45 | a copy of this software and associated documentation files (the
46 | "Software"), to deal in the Software without restriction, including
47 | without limitation the rights to use, copy, modify, merge, publish,
48 | distribute, sublicense, and/or sell copies of the Software, and to
49 | permit persons to whom the Software is furnished to do so, subject to
50 | the following conditions:
51 |
52 | The above copyright notice and this permission notice shall be
53 | included in all copies or substantial portions of the Software.
54 |
55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
58 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
59 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
60 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
61 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62 |
63 | ====
64 |
65 | All files located in the node_modules and external directories are
66 | externally maintained libraries used by this software which have their
67 | own licenses; we recommend you read them, as their terms may differ from
68 | the terms above.
69 |
70 | *********************
71 |
72 | ```
73 |
--------------------------------------------------------------------------------
/docs/javadoc/legal/jqueryUI.md:
--------------------------------------------------------------------------------
1 | ## jQuery UI v1.12.1
2 |
3 | ### jQuery UI License
4 | ```
5 | Copyright jQuery Foundation and other contributors, https://jquery.org/
6 |
7 | This software consists of voluntary contributions made by many
8 | individuals. For exact contribution history, see the revision history
9 | available at https://github.com/jquery/jquery-ui
10 |
11 | The following license applies to all parts of this software except as
12 | documented below:
13 |
14 | ====
15 |
16 | Permission is hereby granted, free of charge, to any person obtaining
17 | a copy of this software and associated documentation files (the
18 | "Software"), to deal in the Software without restriction, including
19 | without limitation the rights to use, copy, modify, merge, publish,
20 | distribute, sublicense, and/or sell copies of the Software, and to
21 | permit persons to whom the Software is furnished to do so, subject to
22 | the following conditions:
23 |
24 | The above copyright notice and this permission notice shall be
25 | included in all copies or substantial portions of the Software.
26 |
27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 |
35 | ====
36 |
37 | Copyright and related rights for sample code are waived via CC0. Sample
38 | code is defined as all source code contained within the demos directory.
39 |
40 | CC0: http://creativecommons.org/publicdomain/zero/1.0/
41 |
42 | ====
43 |
44 | All files located in the node_modules and external directories are
45 | externally maintained libraries used by this software which have their
46 | own licenses; we recommend you read them, as their terms may differ from
47 | the terms above.
48 |
49 | ```
50 |
--------------------------------------------------------------------------------
/docs/javadoc/module-search-index.js:
--------------------------------------------------------------------------------
1 | moduleSearchIndex = [];updateSearchResults();
--------------------------------------------------------------------------------
/docs/javadoc/overview-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | simpledialogfragments 3.9 API
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/javadoc/package-search-index.js:
--------------------------------------------------------------------------------
1 | packageSearchIndex = [{"l":"All Packages","u":"allpackages-index.html"},{"l":"eltos.simpledialogfragment"},{"l":"eltos.simpledialogfragment.color"},{"l":"eltos.simpledialogfragment.form"},{"l":"eltos.simpledialogfragment.input"},{"l":"eltos.simpledialogfragment.list"}];updateSearchResults();
--------------------------------------------------------------------------------
/docs/javadoc/resources/glass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/docs/javadoc/resources/glass.png
--------------------------------------------------------------------------------
/docs/javadoc/resources/x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/docs/javadoc/resources/x.png
--------------------------------------------------------------------------------
/docs/javadoc/script-dir/jquery-ui.min.css:
--------------------------------------------------------------------------------
1 | /*! jQuery UI - v1.13.1 - 2022-05-12
2 | * http://jqueryui.com
3 | * Includes: core.css, autocomplete.css, menu.css
4 | * Copyright jQuery Foundation and other contributors; Licensed MIT */
5 |
6 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;-ms-filter:"alpha(opacity=0)"}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}
--------------------------------------------------------------------------------
/docs/javadoc/tag-search-index.js:
--------------------------------------------------------------------------------
1 | tagSearchIndex = [{"l":"Constant Field Values","h":"","u":"constant-values.html"}];updateSearchResults();
--------------------------------------------------------------------------------
/docs/javadoc/type-search-index.js:
--------------------------------------------------------------------------------
1 | typeSearchIndex = [{"p":"eltos.simpledialogfragment.list","l":"AdvancedAdapter"},{"p":"eltos.simpledialogfragment.list","l":"AdvancedAdapter.AdvancedFilter"},{"p":"eltos.simpledialogfragment.list","l":"AdvancedSectionAdapter"},{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"eltos.simpledialogfragment","l":"SimpleImageDialog.BitmapCreator"},{"p":"eltos.simpledialogfragment.form","l":"Check"},{"p":"eltos.simpledialogfragment.list","l":"ClearableEditText"},{"p":"eltos.simpledialogfragment.color","l":"SimpleColorDialog.ColorAdapter"},{"p":"eltos.simpledialogfragment.form","l":"ColorField"},{"p":"eltos.simpledialogfragment.color","l":"ColorView"},{"p":"eltos.simpledialogfragment.color","l":"ColorWheelView"},{"p":"eltos.simpledialogfragment.list","l":"CustomListDialog"},{"p":"eltos.simpledialogfragment.form","l":"CustomSpinnerView"},{"p":"eltos.simpledialogfragment","l":"CustomViewDialog"},{"p":"eltos.simpledialogfragment.form","l":"DateTime"},{"p":"eltos.simpledialogfragment.form","l":"SimpleFormDialog.DialogActions"},{"p":"eltos.simpledialogfragment","l":"SimpleImageDialog.DrawableCreator"},{"p":"eltos.simpledialogfragment.form","l":"SimpleFormDialog.FocusActions"},{"p":"eltos.simpledialogfragment.form","l":"FormElement"},{"p":"eltos.simpledialogfragment.form","l":"FormElementViewHolder"},{"p":"eltos.simpledialogfragment","l":"FullscreenAlertDialog"},{"p":"eltos.simpledialogfragment.form","l":"Hint"},{"p":"eltos.simpledialogfragment","l":"SimpleImageDialog.IconCreator"},{"p":"eltos.simpledialogfragment.form","l":"Input"},{"p":"eltos.simpledialogfragment.form","l":"SimpleFormDialog.InputValidator"},{"p":"eltos.simpledialogfragment.input","l":"SimpleInputDialog.InputValidator"},{"p":"eltos.simpledialogfragment.list","l":"AdvancedAdapter.ItemIdentifier"},{"p":"eltos.simpledialogfragment.list","l":"ClearableEditText.Listener"},{"p":"eltos.simpledialogfragment.list","l":"ClearableEditText.Location"},{"p":"eltos.simpledialogfragment.color","l":"ColorWheelView.OnColorChangeListener"},{"p":"eltos.simpledialogfragment","l":"SimpleDialog.OnDialogResultListener"},{"p":"eltos.simpledialogfragment.form","l":"CustomSpinnerView.OnSpinnerOpenListener"},{"p":"eltos.simpledialogfragment","l":"SimpleImageDialog.Scale"},{"p":"eltos.simpledialogfragment","l":"SimpleCheckDialog"},{"p":"eltos.simpledialogfragment.color","l":"SimpleColorDialog"},{"p":"eltos.simpledialogfragment.color","l":"SimpleColorWheelDialog"},{"p":"eltos.simpledialogfragment","l":"SimpleDateDialog"},{"p":"eltos.simpledialogfragment","l":"SimpleDialog"},{"p":"eltos.simpledialogfragment.input","l":"SimpleEMailDialog"},{"p":"eltos.simpledialogfragment.form","l":"SimpleFormDialog"},{"p":"eltos.simpledialogfragment","l":"SimpleImageDialog"},{"p":"eltos.simpledialogfragment.input","l":"SimpleInputDialog"},{"p":"eltos.simpledialogfragment.list","l":"SimpleListDialog"},{"p":"eltos.simpledialogfragment.list","l":"SimpleListItem"},{"p":"eltos.simpledialogfragment.input","l":"SimplePinDialog"},{"p":"eltos.simpledialogfragment","l":"SimpleProgressDialog"},{"p":"eltos.simpledialogfragment","l":"SimpleProgressTask"},{"p":"eltos.simpledialogfragment","l":"SimpleTimeDialog"},{"p":"eltos.simpledialogfragment.form","l":"Spinner"},{"p":"eltos.simpledialogfragment.color","l":"ColorView.Style"},{"p":"eltos.simpledialogfragment.input","l":"TextInputAutoCompleteTextView"},{"p":"eltos.simpledialogfragment.form","l":"DateTime.Type"},{"p":"eltos.simpledialogfragment","l":"SimpleProgressDialog.Type"}];updateSearchResults();
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | android.useAndroidX=true
20 | android.defaults.buildfeatures.buildconfig=true
21 | android.nonTransitiveRClass=false
22 | android.nonFinalResIds=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Nov 04 11:57:33 CET 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lintchecks/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lintchecks/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 | apply plugin: 'com.android.lint'
3 |
4 | dependencies {
5 | // If the Gradle plugin version is X.Y.Z, then the Lint library version is X+23.Y.Z
6 | compileOnly 'com.android.tools.lint:lint-api:31.9.1'
7 | compileOnly 'com.android.tools.lint:lint-checks:31.9.1'
8 | }
9 |
10 | jar {
11 | manifest {
12 | // Only use the "-v2" key here if your checks have been updated to the
13 | // new 3.0 APIs (including UAST)
14 | attributes("Lint-Registry-v2": "eltos.lintchecks.SimpleDialogFragmentIssueRegistry")
15 | }
16 | }
--------------------------------------------------------------------------------
/lintchecks/src/main/java/eltos/lintchecks/DialogMethodCallLintDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Philipp Niedermayer (github.com/eltos)
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 eltos.lintchecks;
18 |
19 | import com.android.tools.lint.detector.api.Category;
20 | import com.android.tools.lint.detector.api.Detector;
21 | import com.android.tools.lint.detector.api.Implementation;
22 | import com.android.tools.lint.detector.api.Issue;
23 | import com.android.tools.lint.detector.api.JavaContext;
24 | import com.android.tools.lint.detector.api.Scope;
25 | import com.android.tools.lint.detector.api.Severity;
26 | import com.android.tools.lint.detector.api.TypeEvaluator;
27 | import com.intellij.psi.PsiClass;
28 | import com.intellij.psi.PsiClassType;
29 | import com.intellij.psi.PsiMethod;
30 | import com.intellij.psi.PsiType;
31 |
32 | import org.jetbrains.uast.UCallExpression;
33 | import org.jetbrains.uast.UExpression;
34 |
35 | import java.util.Collections;
36 | import java.util.List;
37 |
38 | /**
39 | * This code checks calls on SimpleDialogs methods for the issues listed below
40 | */
41 | @SuppressWarnings("UnstableApiUsage")
42 | public class DialogMethodCallLintDetector extends Detector implements Detector.UastScanner {
43 |
44 | private static String BUILD_CALL_MESSAGE = "%1$s does not implement a `build` method. " +
45 | "A **%2$s** will be created instead!\n" +
46 | "Implement the method in %1$s or call `%2$s.build()` instead.";
47 | public static final Issue BUILD_CALL = Issue.create("BuildNotImplemented",
48 | "Calling not implemented build",
49 | """
50 | This check checks for calls to static build methods on classes extending \
51 | `SimpleDialog` that do not implement the build method itself.
52 |
53 | This will create an instance of the superclass instead of the intended dialog.
54 | """,
55 | Category.CORRECTNESS, 6, Severity.ERROR,
56 | new Implementation(DialogMethodCallLintDetector.class, Scope.JAVA_FILE_SCOPE));
57 |
58 |
59 |
60 | @Override
61 | public List getApplicableMethodNames() {
62 | return Collections.singletonList("build");
63 | }
64 |
65 | @Override
66 | public void visitMethod(JavaContext context, UCallExpression node, PsiMethod method) {
67 |
68 | if (context.getEvaluator().isMemberInSubClassOf(method,
69 | "eltos.simpledialogfragment.SimpleDialog", false)) {
70 |
71 | PsiClass definingClass = method.getContainingClass();
72 | UExpression callingExpression = node.getReceiver();
73 |
74 | if (definingClass != null && callingExpression != null) {
75 |
76 | PsiType type = TypeEvaluator.evaluate(callingExpression);
77 | if (type instanceof PsiClassType) {
78 | // when called on instance of a class
79 | PsiClass callingClass = ((PsiClassType) type).resolve();
80 |
81 | if (!definingClass.equals(callingClass)) {
82 |
83 | context.report(BUILD_CALL, context.getLocation(node), String.format(
84 | BUILD_CALL_MESSAGE, callingClass.getName(), definingClass.getName()));
85 | }
86 |
87 | } else {
88 | // when called as static reference
89 | if (!callingExpression.asSourceString().equals(definingClass.getName())) {
90 | context.report(BUILD_CALL, context.getLocation(node), String.format(
91 | BUILD_CALL_MESSAGE, callingExpression.asSourceString(), definingClass.getName()));
92 | }
93 | }
94 |
95 | }
96 |
97 |
98 |
99 | }
100 |
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lintchecks/src/main/java/eltos/lintchecks/SimpleDialogFragmentIssueRegistry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Philipp Niedermayer (github.com/eltos)
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 eltos.lintchecks;
18 |
19 | import com.android.tools.lint.client.api.IssueRegistry;
20 | import com.android.tools.lint.detector.api.Issue;
21 |
22 | import org.jetbrains.annotations.NotNull;
23 |
24 | import java.util.Arrays;
25 | import java.util.List;
26 |
27 | /*
28 | * The list of issues that will be checked when running lint.
29 | */
30 | @SuppressWarnings("UnstableApiUsage")
31 | public class SimpleDialogFragmentIssueRegistry extends IssueRegistry {
32 | @NotNull
33 | @Override
34 | public List getIssues() {
35 | return Arrays.asList(
36 | DialogExtendLintDetector.BUILD_OVERWRITE,
37 | DialogExtendLintDetector.TAG,
38 | DialogMethodCallLintDetector.BUILD_CALL);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/media/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/media/logo.png
--------------------------------------------------------------------------------
/media/logo_named_bottom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/media/logo_named_bottom.png
--------------------------------------------------------------------------------
/media/logo_named_bottom_darkmode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/media/logo_named_bottom_darkmode.png
--------------------------------------------------------------------------------
/media/logo_named_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/media/logo_named_right.png
--------------------------------------------------------------------------------
/media/logo_named_right_darkmode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/media/logo_named_right_darkmode.png
--------------------------------------------------------------------------------
/media/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/media/screenshot.png
--------------------------------------------------------------------------------
/publish.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * Script for publishing
3 | * Source: https://getstream.io/blog/publishing-libraries-to-mavencentral-2021
4 | *
5 | *
6 | * If executed locally, create a local.properties files in the root directory
7 | * containing the required information below.
8 | * The secretKeyRingFile should be in binary format, e.g. gpg --export-secret-keys ID > ID.gpg
9 | * The PGP public key should be published, e.g. to https://keys.openpgp.org/
10 | */
11 |
12 | // Create variables with empty default values
13 | ext["signing.keyId"] = ''
14 | ext["signing.password"] = ''
15 | ext["signing.secretKeyRingFile"] = ''
16 | ext["ossrhUsername"] = ''
17 | ext["ossrhPassword"] = ''
18 | ext["sonatypeStagingProfileId"] = ''
19 |
20 | File secretPropsFile = project.rootProject.file('local.properties')
21 | if (secretPropsFile.exists()) {
22 | // Read local.properties file first if it exists
23 | Properties p = new Properties()
24 | new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
25 | p.each { name, value -> ext[name] = value }
26 | } else {
27 | // Use system environment variables (e.g. for CI)
28 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
29 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
30 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
31 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
32 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
33 | ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
34 | }
35 |
36 | // Set up Sonatype repository
37 | nexusPublishing {
38 | repositories {
39 | sonatype {
40 | stagingProfileId = sonatypeStagingProfileId
41 | username = ossrhUsername
42 | password = ossrhPassword
43 | // new sonatype infrastructure as of 2021-02-24
44 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
45 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
46 | }
47 | }
48 | }
49 |
50 | task updateVersionInReadme {
51 | doLast {
52 | ant.replaceregexp(match: '(eltos:simpledialogfragments:v?)\\d*(\\.\\d*)*', replace: '\\1'+VERSION, flags: 'g', byline: true) {
53 | fileset(dir: '.', includes: 'README.md')
54 | }
55 | }
56 | }
57 |
58 | task gitCommitAndTagVersion {
59 | doFirst {
60 | grgit.add(patterns: ['docs/javadoc', 'README.md', 'build.gradle'])
61 | grgit.commit(message: 'Release v'+VERSION, sign: false)
62 | grgit.tag.add(name:'v'+VERSION)
63 | }
64 | }
65 |
66 | task checkVersionAlreadyExists {
67 | doFirst {
68 | assert !grgit.tag.list().name.contains('v'+VERSION),
69 | "Version ${VERSION} defined in build.gradle already exists!"
70 | }
71 | }
72 |
73 | // Release pipeline
74 | task postRelease {
75 | dependsOn gitCommitAndTagVersion
76 | }
77 | task doRelease {
78 | dependsOn 'simpledialogfragments:javadoc'
79 | dependsOn 'simpledialogfragments:publishReleasePublicationToSonatypeRepository'
80 | dependsOn updateVersionInReadme
81 | finalizedBy postRelease
82 | }
83 | task preRelease {
84 | dependsOn checkVersionAlreadyExists
85 | finalizedBy doRelease
86 | }
87 |
88 | task release {
89 | dependsOn preRelease
90 | }
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':testApp', ':simpledialogfragments', ':lintchecks'
2 |
--------------------------------------------------------------------------------
/simpledialogfragments/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/simpledialogfragments/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | namespace 'eltos.simpledialogfragment'
5 |
6 | compileSdk 34
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 34
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles 'proguard-rules.pro'
16 | consumerProguardFiles 'proguard-rules.pro'
17 | }
18 | }
19 | lint {
20 | checkDependencies true
21 | disable 'MissingTranslation'
22 | }
23 | publishing {
24 | singleVariant('release') {
25 | withSourcesJar()
26 | withJavadocJar()
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | debugImplementation project(':lintchecks')
33 | lintChecks project(':lintchecks')
34 | lintPublish project(':lintchecks')
35 |
36 | testImplementation 'junit:junit:4.13.2'
37 | implementation 'androidx.appcompat:appcompat:1.7.0'
38 | implementation 'com.google.android.material:material:1.12.0'
39 | implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
40 | implementation 'com.alimuzaffar.lib:pinentryedittext:2.0.6'
41 | }
42 |
43 |
44 |
45 | // for publication to maven central via Sonatype nexus
46 | ext {
47 | PUBLISH_GROUP_ID = 'io.github.eltos'
48 | PUBLISH_ARTIFACT_ID = 'simpledialogfragments'
49 | PUBLISH_VERSION = rootProject.ext['VERSION']
50 | }
51 |
52 | apply from: 'publish.gradle'
53 |
54 |
55 | // Javadoc API documentation
56 | task javadoc(type: Javadoc) {
57 | source = android.sourceSets.main.java.srcDirs
58 | destinationDir = file("${rootProject.projectDir}/docs/javadoc")
59 | }
60 | afterEvaluate {
61 | // bootClasspath can only be used at execution time
62 | javadoc.classpath += files(android.bootClasspath)
63 | // adding this to the classpath fixes "cannot find annotations symbols" errors
64 | javadoc.classpath += files(android.libraryVariants.collect { variant ->
65 | variant.javaCompileProvider.get().classpath
66 | })
67 | // adding this to the classpath fixes "package R not found" errors
68 | javadoc.classpath += files(android.libraryVariants.collect { variant ->
69 | variant.javaCompileProvider.get().outputs.files
70 | })
71 | }
72 |
--------------------------------------------------------------------------------
/simpledialogfragments/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # Keep TAG field, so it can be found by the SimpleDialog.show() method
13 | -keepclassmembers class * extends eltos.simpledialogfragment.SimpleDialog {
14 | public static final java.lang.String TAG;
15 | }
--------------------------------------------------------------------------------
/simpledialogfragments/publish.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * Script for publishing the module
3 | * Source: https://getstream.io/blog/publishing-libraries-to-mavencentral-2021
4 | *
5 | *
6 | */
7 |
8 | apply plugin: 'maven-publish'
9 | apply plugin: 'signing'
10 | apply plugin: 'org.jetbrains.dokka'
11 |
12 | task androidSourcesJar(type: Jar) {
13 | archiveClassifier.set('sources')
14 | if (project.plugins.findPlugin("com.android.library")) {
15 | // For Android libraries
16 | from android.sourceSets.main.java.srcDirs
17 | //from android.sourceSets.main.kotlin.srcDirs
18 | } else {
19 | // For pure Kotlin libraries, in case you have them
20 | from sourceSets.main.java.srcDirs
21 | from sourceSets.main.kotlin.srcDirs
22 | }
23 | }
24 |
25 | tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
26 | pluginsMapConfiguration.set(
27 | ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
28 | )
29 | }
30 |
31 | task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
32 | archiveClassifier.set('javadoc')
33 | from dokkaJavadoc.outputDirectory
34 | }
35 |
36 | artifacts {
37 | archives androidSourcesJar
38 | archives javadocJar
39 | }
40 |
41 | group = PUBLISH_GROUP_ID
42 | version = PUBLISH_VERSION
43 |
44 | afterEvaluate {
45 | publishing {
46 | publications {
47 | release(MavenPublication) {
48 | // The coordinates of the library
49 | groupId PUBLISH_GROUP_ID
50 | artifactId PUBLISH_ARTIFACT_ID
51 | version PUBLISH_VERSION
52 |
53 | // Artifacts
54 | from components.release
55 |
56 | // Metadata
57 | pom {
58 | name = 'SimpleDialogFragments'
59 | description = 'A collection of easy to use and extendable DialogFragment\'s for Android'
60 | url = 'https://github.com/eltos/SimpleDialogFragments'
61 | developers {
62 | developer {
63 | id = 'eltos'
64 | name = 'Philipp Niedermayer'
65 | email = 'eltos@outlook.de'
66 | }
67 | }
68 | licenses {
69 | license {
70 | name = 'The Apache Software License, Version 2.0'
71 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
72 | }
73 | }
74 |
75 | // Version control info
76 | scm {
77 | connection = 'scm:git:github.com/eltos/SimpleDialogFragments.git'
78 | developerConnection = 'scm:git:ssh://github.com/eltos/SimpleDialogFragments.git'
79 | url = 'https://github.com/eltos/SimpleDialogFragments'
80 | }
81 | }
82 | }
83 | }
84 | }
85 | }
86 |
87 | // Signing
88 | ext["signing.keyId"] = rootProject.ext["signing.keyId"]
89 | ext["signing.password"] = rootProject.ext["signing.password"]
90 | ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
91 | signing {
92 | if (project.ext["signing.password"]?.trim()) { // sign only if we have the password
93 | sign publishing.publications
94 | }
95 | }
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/SimpleCheckDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment;
18 |
19 | import android.os.Bundle;
20 |
21 | import androidx.annotation.NonNull;
22 | import androidx.annotation.StringRes;
23 | import android.view.View;
24 | import android.widget.CheckBox;
25 |
26 | /**
27 | * An simple dialog with a checkbox that can be set as required before proceeding
28 | *
29 | * Created by eltos on 14.10.2015.
30 | */
31 | public class SimpleCheckDialog extends CustomViewDialog {
32 |
33 | public static final String TAG = "SimpleCheckDialog.";
34 |
35 | public static final String
36 | CHECKED = TAG + "CHECKED";
37 |
38 |
39 | public static SimpleCheckDialog build(){
40 | return new SimpleCheckDialog();
41 | }
42 |
43 |
44 | /**
45 | * Sets the initial check state
46 | *
47 | * @param preset checkbox initial state
48 | * @return this instance
49 | */
50 | public SimpleCheckDialog check(boolean preset){ return setArg(CHECKED, preset); }
51 |
52 | /**
53 | * Sets the checkbox's label
54 | *
55 | * @param checkBoxLabel the label as string
56 | * @return this instance
57 | */
58 | public SimpleCheckDialog label(CharSequence checkBoxLabel){ return setArg(CHECKBOX_LABEL, checkBoxLabel); }
59 |
60 | /**
61 | * Sets the checkbox's label
62 | *
63 | * @param checkBoxLabelResourceId the label as android string resource
64 | * @return this instance
65 | */
66 | public SimpleCheckDialog label(@StringRes int checkBoxLabelResourceId){ return setArg(CHECKBOX_LABEL, checkBoxLabelResourceId); }
67 |
68 | /**
69 | * Whether the check is required. The positive button will be disabled until the checkbox
70 | * got checked
71 | *
72 | * @param required whether checking the checkbox is required
73 | * @return this instance
74 | */
75 | public SimpleCheckDialog checkRequired(boolean required){ return setArg(CHECKBOX_REQUIRED, required); }
76 |
77 |
78 |
79 |
80 |
81 | protected static final String CHECKBOX_LABEL = "simpleCheckDialog.check_label";
82 | protected static final String CHECKBOX_REQUIRED = "simpleCheckDialog.check_required";
83 |
84 | private CheckBox mCheckBox;
85 |
86 |
87 | private boolean canGoAhead() {
88 | return mCheckBox.isChecked() || !getArgs().getBoolean(CHECKBOX_REQUIRED);
89 | }
90 |
91 | @Override
92 | public View onCreateContentView(Bundle savedInstanceState) {
93 | // inflate and set your custom view here
94 |
95 | View view = inflate(R.layout.simpledialogfragment_check_box);
96 | mCheckBox = view.findViewById(R.id.checkBox);
97 |
98 | mCheckBox.setText(getArgString(CHECKBOX_LABEL));
99 |
100 | if (savedInstanceState != null){
101 | mCheckBox.setChecked(savedInstanceState.getBoolean(CHECKED, false));
102 | } else {
103 | mCheckBox.setChecked(getArgs().getBoolean(CHECKED, false));
104 | }
105 |
106 | mCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> setPositiveButtonEnabled(canGoAhead()));
107 |
108 | return view;
109 | }
110 |
111 | @Override
112 | protected void onDialogShown() {
113 | setPositiveButtonEnabled(canGoAhead());
114 | }
115 |
116 | @Override
117 | public Bundle onResult(int which) {
118 | Bundle result = new Bundle();
119 | result.putBoolean(CHECKED, mCheckBox.isChecked());
120 | return result;
121 | }
122 |
123 | @Override
124 | public void onSaveInstanceState(@NonNull Bundle outState) {
125 | super.onSaveInstanceState(outState);
126 | outState.putBoolean(CHECKED, mCheckBox.isChecked());
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/SimpleProgressTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment;
18 |
19 | import android.os.AsyncTask;
20 | import android.util.Pair;
21 |
22 | import androidx.annotation.CallSuper;
23 |
24 | /**
25 | * An {@link AsyncTask} for use with {@link SimpleProgressDialog}
26 | *
27 | * Automatically reflects the task's states in the dialog.
28 | *
29 | * Created by eltos on 27.05.21.
30 | */
31 | public abstract class SimpleProgressTask extends AsyncTask {
32 |
33 | protected SimpleProgressDialog mDialog;
34 |
35 | protected void registerDialog(SimpleProgressDialog dialog){
36 | mDialog = dialog;
37 | }
38 |
39 | @Override
40 | @CallSuper
41 | protected void onPreExecute() {
42 | if (mDialog != null) {
43 | mDialog.updateIndeterminate();
44 | }
45 | }
46 |
47 | @Override
48 | @CallSuper
49 | protected void onPostExecute(Result result) {
50 | if (mDialog != null) {
51 | mDialog.updateFinished();
52 | }
53 | }
54 |
55 | /**
56 | * Updates the progress dialog by trying to guess the meaning of the supplied parameter(s):
57 | *
58 | * - if values is of numeric type
59 | * - if values[0] < 0, then progress is indeterminate
60 | * - if values[0] >= 0, then (int) values[0] is set as progress
61 | * - if values[1] > 0, then (int) values[1] is set as max, otherwise max defaults to 100
62 | * - if values[2] >= 0, then (int) values[2] is set as secondary progress
63 | * - if values is of CharSequence type, then values[0] is set as info text and progress to indeterminate
64 | * - if values is a {@link Pair} of a {@link Number} and a {@link String}, the above is applied to either value of the pair
65 | */
66 | @Override
67 | protected void onProgressUpdate(Progress... values) {
68 | if (mDialog != null && values.length > 0){
69 | int v0 = -1, v1 = -1, v2 = -1;
70 | String s0 = null;
71 |
72 | if (values instanceof Number[]){
73 | Number[] val = (Number[]) values;
74 | v0 = val[0].intValue();
75 | if (values.length > 1) v1 = val[1].intValue();
76 | if (values.length > 2) v2 = val[2].intValue();
77 | }
78 | if (values instanceof String[]){
79 | s0 = (String) values[0];
80 | mDialog.updateIndeterminate();
81 | }
82 | if (values instanceof Pair, ?>[]){
83 | Pair, ?>[] val = (Pair, ?>[]) values;
84 | Pair, ?> val0 = val[0];
85 | if (val0.first instanceof Number) v0 = ((Number) val0.first).intValue();
86 | if (val0.second instanceof String) s0 = (String) val0.second;
87 | if (val.length > 1){
88 | Pair, ?> val1 = val[1];
89 | if (val1.first instanceof Number) v1 = ((Number) val1.first).intValue();
90 | }
91 | if (val.length > 2){
92 | Pair, ?> val2 = val[2];
93 | if (val2.first instanceof Number) v2 = ((Number) val2.first).intValue();
94 | }
95 | }
96 |
97 | if (v0 >= 0) mDialog.updateProgress(v0);
98 | if (v0 < 0) mDialog.updateIndeterminate();
99 | if (v1 > 0) mDialog.updateMax(v1);
100 | if (v2 >= 0) mDialog.updateSecondaryProgress(v2);
101 | mDialog.updateInfoText(s0);
102 |
103 | }
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/SimpleTimeDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment;
18 |
19 | import android.os.Bundle;
20 | import android.text.format.DateFormat;
21 | import android.view.View;
22 | import android.widget.TimePicker;
23 |
24 | /**
25 | * A time-picker dialog
26 | *
27 | * Created by eltos on 02.02.2017.
28 | */
29 | public class SimpleTimeDialog extends CustomViewDialog
30 | implements TimePicker.OnTimeChangedListener {
31 |
32 | public static final String TAG = "SimpleTimeDialog.";
33 |
34 | public static final String
35 | HOUR = TAG + "HOUR",
36 | MINUTE = TAG + "MINUTE";
37 |
38 |
39 | public static SimpleTimeDialog build(){
40 | return new SimpleTimeDialog();
41 | }
42 |
43 |
44 | /**
45 | * Specify the initially set hour
46 | *
47 | * @param hour initial hour (0-23)
48 | * @return this instance
49 | */
50 | public SimpleTimeDialog hour(int hour){ return setArg(HOUR, hour); }
51 |
52 | /**
53 | * Specify the initially set minute
54 | *
55 | * @param minute initial minute (0-59)
56 | * @return this instance
57 | */
58 | public SimpleTimeDialog minute(int minute){ return setArg(MINUTE, minute); }
59 |
60 | /**
61 | * Changes the hour display mode between 24 and AM/PM
62 | *
63 | * @param view24Hour true to use 24 hour mode, false to use AM/PM
64 | * @return this instance
65 | */
66 | public SimpleTimeDialog set24HourView(boolean view24Hour){ return setArg(VIEW_24_HOUR, view24Hour); }
67 |
68 |
69 |
70 | protected static final String
71 | VIEW_24_HOUR = TAG + "VIEW_24_HOUR";
72 |
73 | private TimePicker picker;
74 |
75 |
76 | @SuppressWarnings("deprecation")
77 | @Override
78 | protected View onCreateContentView(Bundle savedInstanceState) {
79 |
80 | picker = new TimePicker(getContext());
81 |
82 | if (savedInstanceState != null){
83 | picker.setCurrentHour(savedInstanceState.getInt(HOUR));
84 | picker.setCurrentMinute(savedInstanceState.getInt(MINUTE));
85 |
86 | } else {
87 | if (getArgs().containsKey(HOUR)) {
88 | picker.setCurrentHour(getArgs().getInt(HOUR));
89 | }
90 | if (getArgs().containsKey(MINUTE)) {
91 | picker.setCurrentMinute(getArgs().getInt(MINUTE));
92 | }
93 | }
94 |
95 | if (getArgs().containsKey(VIEW_24_HOUR)) {
96 | picker.setIs24HourView(getArgs().getBoolean(VIEW_24_HOUR));
97 | } else {
98 | picker.setIs24HourView(DateFormat.is24HourFormat(getContext())); // system default
99 | }
100 | picker.setOnTimeChangedListener(this);
101 |
102 | return picker;
103 | }
104 |
105 |
106 | @Override
107 | public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
108 | // currently not used
109 | }
110 |
111 | @SuppressWarnings("deprecation")
112 | @Override
113 | public void onSaveInstanceState(Bundle outState) {
114 | outState.putInt(HOUR, picker.getCurrentHour());
115 | outState.putInt(MINUTE, picker.getCurrentMinute());
116 | super.onSaveInstanceState(outState);
117 | }
118 |
119 |
120 | @SuppressWarnings("deprecation")
121 | @Override
122 | protected Bundle onResult(int which) {
123 | Bundle results = new Bundle();
124 | results.putInt(HOUR, picker.getCurrentHour());
125 | results.putInt(MINUTE, picker.getCurrentMinute());
126 | return results;
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/form/Check.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.form;
18 |
19 | import android.content.Context;
20 | import android.os.Parcel;
21 | import androidx.annotation.BoolRes;
22 | import androidx.annotation.Nullable;
23 | import androidx.annotation.StringRes;
24 |
25 | import eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener;
26 |
27 | /**
28 | * An checkbox form element to be used with {@link SimpleFormDialog}
29 | *
30 | * This is a CheckBox - what else?
31 | *
32 | * This will add a Boolean to resource bundle containing the checked state.
33 | *
34 | * Created by eltos on 21.02.17.
35 | */
36 |
37 | public class Check extends FormElement {
38 |
39 | private String text = null;
40 | private int textResourceId = NO_ID;
41 | private Boolean preset = null;
42 | private int presetId = NO_ID;
43 |
44 | private Check(String resultKey) {
45 | super(resultKey);
46 | }
47 |
48 | /**
49 | * Factory method for a check field.
50 | *
51 | * @param key the key that can be used to receive the final state from the bundle in
52 | * {@link OnDialogResultListener#onResult}
53 | * @return this instance
54 | */
55 | public static Check box(String key){
56 | return new Check(key);
57 | }
58 |
59 |
60 | /**
61 | * Sets the initial state of the checkbox
62 | *
63 | * @param preset initial state
64 | * @return this instance
65 | */
66 | public Check check(boolean preset){
67 | this.preset = preset;
68 | return this;
69 | }
70 |
71 | /**
72 | * Sets the initial state of the checkbox
73 | *
74 | * @param preset initial state as boolean resource
75 | * @return this instance
76 | */
77 | public Check check(@BoolRes int preset){
78 | this.presetId = preset;
79 | return this;
80 | }
81 |
82 | /**
83 | * Sets the label
84 | *
85 | * @param text label text as string
86 | */
87 | public Check label(String text){
88 | this.text = text;
89 | return this;
90 | }
91 |
92 | /**
93 | * Sets the label
94 | *
95 | * @param textResourceId label text as android string resource
96 | */
97 | public Check label(@StringRes int textResourceId){
98 | this.textResourceId = textResourceId;
99 | return this;
100 | }
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | ///////////////////////////////////////////////////////////////////////////////////////////
115 |
116 | @Override
117 | public CheckViewHolder buildViewHolder() {
118 | return new CheckViewHolder(this);
119 | }
120 |
121 | ///////////////////////////////////////////////////////////////////////////////////////////
122 |
123 | @Nullable
124 | protected String getText(Context context){
125 | if (text != null) {
126 | return text;
127 | } else if (textResourceId != NO_ID){
128 | return context.getString(textResourceId);
129 | }
130 | return null;
131 | }
132 |
133 | protected boolean getInitialState(Context context){
134 | if (preset != null) {
135 | return preset;
136 | } else if (presetId != NO_ID){
137 | return context.getResources().getBoolean(presetId);
138 | }
139 | return false;
140 | }
141 |
142 |
143 |
144 |
145 | private Check(Parcel in) {
146 | super(in);
147 | text = in.readString();
148 | textResourceId = in.readInt();
149 | byte b = in.readByte();
150 | preset = b < 0 ? null : b != 0;
151 | presetId = in.readInt();
152 | }
153 |
154 | public static final Creator CREATOR = new Creator() {
155 | @Override
156 | public Check createFromParcel(Parcel in) {
157 | return new Check(in);
158 | }
159 |
160 | @Override
161 | public Check[] newArray(int size) {
162 | return new Check[size];
163 | }
164 | };
165 |
166 | @Override
167 | public int describeContents() {
168 | return 0;
169 | }
170 |
171 | @Override
172 | public void writeToParcel(Parcel dest, int flags) {
173 | super.writeToParcel(dest, flags);
174 | dest.writeString(text);
175 | dest.writeInt(textResourceId);
176 | dest.writeByte((byte) (preset == null ? -1 : (preset ? 1 : 0)));
177 | dest.writeInt(presetId);
178 | }
179 |
180 |
181 | }
182 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/form/CheckViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.form;
18 |
19 | import android.content.Context;
20 | import android.content.res.TypedArray;
21 | import android.graphics.Color;
22 | import android.os.Bundle;
23 | import android.util.TypedValue;
24 | import android.view.View;
25 | import android.widget.CheckBox;
26 |
27 | import eltos.simpledialogfragment.R;
28 |
29 | /**
30 | * The ViewHolder class for {@link Check}
31 | *
32 | * This class is used to create a CheckBox and to maintain it's functionality
33 | *
34 | * Created by eltos on 23.02.17.
35 | */
36 |
37 | class CheckViewHolder extends FormElementViewHolder {
38 |
39 | protected static final String SAVED_CHECK_STATE = "checked";
40 | private CheckBox checkBox;
41 |
42 | public CheckViewHolder(Check field) {
43 | super(field);
44 | }
45 |
46 | @Override
47 | protected int getContentViewLayout() {
48 | return R.layout.simpledialogfragment_form_item_check;
49 | }
50 |
51 | @Override
52 | protected void setUpView(View view, Context context, Bundle savedInstanceState,
53 | final SimpleFormDialog.DialogActions actions) {
54 |
55 | checkBox = view.findViewById(R.id.checkBox);
56 |
57 | // Label
58 | checkBox.setText(field.getText(context));
59 |
60 | // Check preset
61 | if (savedInstanceState != null) {
62 | checkBox.setChecked(savedInstanceState.getBoolean(SAVED_CHECK_STATE));
63 | } else {
64 | checkBox.setChecked(field.getInitialState(context));
65 | }
66 |
67 | // Positive button state for single element forms
68 | if (actions.isOnlyFocusableElement()) {
69 | checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> actions.updatePosButtonState());
70 | }
71 |
72 | }
73 |
74 |
75 | @Override
76 | protected void saveState(Bundle outState) {
77 | outState.putBoolean(SAVED_CHECK_STATE, checkBox.isChecked());
78 | }
79 |
80 |
81 | @Override
82 | protected void putResults(Bundle results, String key) {
83 | results.putBoolean(key, checkBox.isChecked());
84 | }
85 |
86 |
87 | @Override
88 | protected boolean focus(final SimpleFormDialog.FocusActions actions) {
89 | actions.hideKeyboard();
90 |
91 | // Temporary make this view focusable, so that we can scroll to it
92 | // and show a short flash of the box getting focused
93 | checkBox.setFocusableInTouchMode(true);
94 |
95 | checkBox.postDelayed(() -> {
96 | // finally remove focus
97 | checkBox.setFocusable(false);
98 | actions.clearCurrentFocus();
99 | }, 100);
100 |
101 | return checkBox.requestFocus();
102 | }
103 |
104 |
105 | @Override
106 | protected boolean posButtonEnabled(Context context) {
107 | return !field.required || checkBox.isChecked();
108 | }
109 |
110 |
111 | @Override
112 | protected boolean validate(Context context) {
113 | boolean valid = posButtonEnabled(context);
114 | if (valid) {
115 | TypedValue value = new TypedValue();
116 | checkBox.getContext().getTheme().resolveAttribute(android.R.attr.checkboxStyle, value, true);
117 | int[] attr = new int[] {android.R.attr.textColor};
118 | TypedArray a = context.obtainStyledAttributes(value.data, attr);
119 | checkBox.setTextColor(a.getColor(0, Color.BLACK));
120 | a.recycle();
121 |
122 | } else {
123 | //noinspection deprecation
124 | checkBox.setTextColor(context.getResources().getColor(R.color.simpledialogfragment_error_color));
125 | }
126 | // checkBox.setError(valid ? null : context.getString(R.string.required));
127 | return valid;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/form/CustomSpinnerView.java:
--------------------------------------------------------------------------------
1 | package eltos.simpledialogfragment.form;
2 |
3 |
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 | import androidx.appcompat.widget.AppCompatSpinner;
7 |
8 | public class CustomSpinnerView extends AppCompatSpinner {
9 | private OnSpinnerOpenListener mListener;
10 |
11 | public CustomSpinnerView(Context context, AttributeSet attrs, int defStyleAttr, int mode) {
12 | super(context, attrs, defStyleAttr, mode);
13 | }
14 |
15 | public CustomSpinnerView(Context context, AttributeSet attrs, int defStyleAttr) {
16 | super(context, attrs, defStyleAttr);
17 | }
18 |
19 | public CustomSpinnerView(Context context, AttributeSet attrs) {
20 | super(context, attrs);
21 | }
22 |
23 | public CustomSpinnerView(Context context, int mode) {
24 | super(context, mode);
25 | }
26 |
27 | public CustomSpinnerView(Context context) {
28 | super(context);
29 | }
30 |
31 | public interface OnSpinnerOpenListener {
32 | void onOpen();
33 | }
34 |
35 | @Override
36 | public boolean performClick() {
37 | if (mListener != null) {
38 | mListener.onOpen();
39 | }
40 | return super.performClick();
41 | }
42 |
43 | public void setSpinnerEventsListener(OnSpinnerOpenListener onSpinnerEventsListener) {
44 | mListener = onSpinnerEventsListener;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/form/FormElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.form;
18 |
19 | import android.content.Context;
20 | import android.os.Parcel;
21 | import android.os.Parcelable;
22 | import androidx.annotation.Nullable;
23 | import androidx.annotation.StringRes;
24 |
25 | /**
26 | * Base-class for form elements to be used with {@link SimpleFormDialog}
27 | *
28 | * Each form element holds a {@link FormElement#resultKey} that is used to receive element
29 | * specific results in {@link SimpleFormDialog#onResult}
30 | *
31 | * Created by eltos on 20.02.17.
32 | */
33 |
34 | @SuppressWarnings("WeakerAccess")
35 | public abstract class FormElement implements Parcelable {
36 |
37 | protected static final int NO_ID = -1;
38 |
39 | protected String resultKey;
40 | protected boolean required = false;
41 | private String text = null;
42 | private int textResourceId = NO_ID;
43 |
44 |
45 | protected FormElement(String resultKey){
46 | this.resultKey = resultKey;
47 | }
48 |
49 |
50 | /**
51 | * Return your custom implementation of {@link FormElementViewHolder} here
52 | *
53 | * @return The view holder that can represent this form element
54 | */
55 | public abstract V buildViewHolder();
56 |
57 |
58 | /**
59 | * Mark this Field as required.
60 | * See {@link FormElement#required(boolean)}
61 | *
62 | * @return this instance
63 | */
64 | public T required(){
65 | return required(true);
66 | }
67 |
68 | /**
69 | * Set the required flag for this field.
70 | * This has different meanings depending on the element type
71 | *
72 | * Input fields will display an error message if their input is empty.
73 | * Check fields will be required to be checked
74 | *
75 | * @param required whether this field is required
76 | * @return this instance
77 | */
78 | @SuppressWarnings("unchecked cast")
79 | public T required(boolean required){
80 | this.required = required;
81 | return (T) this;
82 | }
83 |
84 | /**
85 | * Sets the label
86 | *
87 | * @param text label text as string
88 | * @return this instance
89 | */
90 | @SuppressWarnings("unchecked cast")
91 | public T label(String text){
92 | this.text = text;
93 | return (T) this;
94 | }
95 |
96 | /**
97 | * Sets the label
98 | *
99 | * @param textResourceId label text as android string resource
100 | * @return this instance
101 | */
102 | @SuppressWarnings("unchecked cast")
103 | public T label(@StringRes int textResourceId){
104 | this.textResourceId = textResourceId;
105 | return (T) this;
106 | }
107 |
108 |
109 | ///////////////////////////////////////////////////////////////////////////////////////////
110 |
111 | @Nullable
112 | protected String getText(Context context){
113 | if (text != null) {
114 | return text;
115 | } else if (textResourceId != NO_ID){
116 | return context.getString(textResourceId);
117 | }
118 | return null;
119 | }
120 |
121 |
122 | // Parcel implementation
123 |
124 | protected FormElement(Parcel in) {
125 | resultKey = in.readString();
126 | required = in.readByte() != 0;
127 | text = in.readString();
128 | textResourceId = in.readInt();
129 | }
130 |
131 | @Override
132 | public int describeContents() {
133 | return 0;
134 | }
135 |
136 | @Override
137 | public void writeToParcel(Parcel dest, int flags) {
138 | dest.writeString(resultKey);
139 | dest.writeByte((byte) (required ? 1 : 0));
140 | dest.writeString(text);
141 | dest.writeInt(textResourceId);
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/form/FormElementViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.form;
18 |
19 | import android.content.Context;
20 | import android.os.Bundle;
21 | import androidx.annotation.LayoutRes;
22 | import android.view.View;
23 |
24 | import eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener;
25 |
26 | /**
27 | * The Base class for all ViewHolders
28 | *
29 | * This class is used to create the View that represents the corresponding {@link FormElement}
30 | * and to maintain it's functionality
31 | *
32 | * Created by eltos on 23.02.17.
33 | */
34 |
35 | @SuppressWarnings("WeakerAccess")
36 | public abstract class FormElementViewHolder {
37 |
38 | /**
39 | * The FormElement that this ViewHolder represents.
40 | */
41 | protected E field;
42 |
43 |
44 | protected FormElementViewHolder(E field){
45 | this.field = field;
46 | }
47 |
48 | /**
49 | * Implement this method to return a custom layout resource id for this view
50 | *
51 | * @return layout string resource
52 | */
53 | protected abstract @LayoutRes int getContentViewLayout();
54 |
55 | /**
56 | * Implement this method to setup your view for the first time or after a
57 | * {@link FormElementViewHolder#saveState}
58 | *
59 | * @param view The view that was inflated using the layout from
60 | * {@link FormElementViewHolder#getContentViewLayout()}
61 | * @param context The context of this view
62 | * @param savedInstanceState A bundle containing everything that was saved in
63 | * {@link FormElementViewHolder#saveState(Bundle)}
64 | * @param actions A callback for convenient methods. See {@link SimpleFormDialog.DialogActions}
65 | */
66 | protected abstract void setUpView(View view, Context context, Bundle savedInstanceState,
67 | SimpleFormDialog.DialogActions actions);
68 |
69 | /**
70 | * Method to save this elements state
71 | * Bundles are maintained on a per-view basis, so that keys can be arbitrary
72 | *
73 | * @param outState The bundle to save the state to
74 | */
75 | protected abstract void saveState(Bundle outState);
76 |
77 | /**
78 | * Method to publish results from this view in
79 | * {@link OnDialogResultListener#onResult}
80 | *
81 | * @param results The bundle to save the results to
82 | * @param key The key that has to be used when storing results in the bundle
83 | */
84 | protected abstract void putResults(Bundle results, String key);
85 |
86 | /**
87 | * Method to focus this element
88 | *
89 | * @param actions An object providing useful callbacks, see {@link SimpleFormDialog.FocusActions}
90 | *
91 | * @return Whether this view or one of its descendants actually took focus.
92 | */
93 | protected abstract boolean focus(SimpleFormDialog.FocusActions actions);
94 |
95 | /**
96 | * Method to check for empty input, (un-)checked state etc.
97 | * Only simple (and fast) checks here, no error displaying!
98 | * This is used only for single element forms.
99 | *
100 | * @param context A context
101 | *
102 | * @return true if positive button can be enabled
103 | */
104 | protected abstract boolean posButtonEnabled(Context context);
105 |
106 | /**
107 | * Method to validate input, state etc. and display an error message or indicator
108 | *
109 | * @param context A context
110 | *
111 | * @return true if the input, state etc. is valid, false otherwise
112 | */
113 | protected abstract boolean validate(Context context);
114 |
115 | }
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/form/Hint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.form;
18 |
19 | import android.os.Parcel;
20 |
21 | import androidx.annotation.StringRes;
22 |
23 |
24 | /**
25 | * A hint element to be used with {@link SimpleFormDialog}
26 | *
27 | * This is simple hint text
28 | *
29 | * Created by philipp on 06.07.2018
30 | */
31 |
32 | @SuppressWarnings({"unused", "WeakerAccess"})
33 | public class Hint extends FormElement {
34 |
35 | public Hint() {
36 | super((String) null);
37 | }
38 |
39 |
40 |
41 |
42 | /**
43 | * Factory method for a hint.
44 | *
45 | * @param hint the hint text
46 | * @return this instance
47 | */
48 | public static Hint plain(String hint){
49 | return new Hint().label(hint);
50 | }
51 | public static Hint plain(@StringRes int hint){
52 | return new Hint().label(hint);
53 | }
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | ///////////////////////////////////////////////////////////////////////////////////////////
62 |
63 | @Override
64 | public HintViewHolder buildViewHolder() {
65 | return new HintViewHolder(this);
66 | }
67 |
68 | ///////////////////////////////////////////////////////////////////////////////////////////
69 |
70 |
71 | protected Hint(Parcel in) {
72 | super(in);
73 | }
74 |
75 | @Override
76 | public void writeToParcel(Parcel dest, int flags) {
77 | super.writeToParcel(dest, flags);
78 | }
79 |
80 | @Override
81 | public int describeContents() {
82 | return 0;
83 | }
84 |
85 | public static final Creator CREATOR = new Creator() {
86 | @Override
87 | public Hint createFromParcel(Parcel in) {
88 | return new Hint(in);
89 | }
90 |
91 | @Override
92 | public Hint[] newArray(int size) {
93 | return new Hint[size];
94 | }
95 | };
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/form/HintViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.form;
18 |
19 | import android.content.Context;
20 | import android.os.Bundle;
21 |
22 | import android.view.View;
23 | import android.widget.TextView;
24 |
25 | import eltos.simpledialogfragment.R;
26 |
27 | /**
28 | * The ViewHolder class for {@link Hint}
29 | *
30 | * Created by eltos on 06.07.2018.
31 | */
32 |
33 | @SuppressWarnings("WeakerAccess")
34 | class HintViewHolder extends FormElementViewHolder {
35 |
36 | HintViewHolder(Hint field) {
37 | super(field);
38 | }
39 |
40 | @Override
41 | protected int getContentViewLayout() {
42 | return R.layout.simpledialogfragment_form_item_hint;
43 | }
44 |
45 | @Override
46 | protected void setUpView(View view, Context context, Bundle savedInstanceState,
47 | final SimpleFormDialog.DialogActions actions) {
48 |
49 | TextView label = view.findViewById(R.id.label);
50 | label.setHint(field.getText(context));
51 |
52 | }
53 |
54 |
55 |
56 |
57 | @Override
58 | protected void saveState(Bundle outState) {
59 | }
60 |
61 | @Override
62 | protected void putResults(Bundle results, String key) {
63 | }
64 |
65 | @Override
66 | protected boolean focus(SimpleFormDialog.FocusActions actions) {
67 | return false;
68 | }
69 |
70 | @Override
71 | protected boolean posButtonEnabled(Context context) {
72 | return true;
73 | }
74 |
75 | @Override
76 | protected boolean validate(Context context) {
77 | return true;
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/input/SimpleEMailDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.input;
18 |
19 | import androidx.annotation.Nullable;
20 | import android.text.InputType;
21 |
22 | import java.util.regex.Pattern;
23 |
24 | import eltos.simpledialogfragment.R;
25 |
26 | /**
27 | * An extension for the input dialog that will ensure the input is a valid email address
28 | *
32 | * Created by expos on 02.01.2017.
33 | */
34 | public class SimpleEMailDialog extends SimpleInputDialog {
35 |
36 | public static final String TAG = "SimpleEMailDialog.";
37 |
38 | public static final String
39 | EMAIL = TEXT;
40 |
41 |
42 | public static SimpleEMailDialog build() {
43 | return new SimpleEMailDialog();
44 | }
45 |
46 |
47 | protected static final String EMAIL_PATTERN =
48 | "^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-]+)*@"
49 | + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
50 |
51 | protected final Pattern pattern = Pattern.compile(EMAIL_PATTERN);
52 |
53 | public SimpleEMailDialog(){
54 | inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
55 | hint(R.string.email_address);
56 | }
57 |
58 | @Override
59 | protected String onValidateInput(@Nullable String input) {
60 | if (input != null && pattern.matcher(input).matches()){
61 | return super.onValidateInput(input);
62 | } else {
63 | return getString(R.string.invalid_email_address);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/input/TextInputAutoCompleteTextView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.input;
18 |
19 | import android.content.Context;
20 | import com.google.android.material.textfield.TextInputLayout;
21 | import com.google.android.material.textfield.MaterialAutoCompleteTextView;
22 | import android.util.AttributeSet;
23 | import android.view.View;
24 | import android.view.ViewParent;
25 | import android.view.inputmethod.EditorInfo;
26 | import android.view.inputmethod.InputConnection;
27 |
28 |
29 | /**
30 | * A special sub-class of {@link MaterialAutoCompleteTextView} designed for use
31 | * as a child of {@link TextInputLayout}.
32 | *
33 | * Using this class allows us to display a hint in the IME when in 'extract' mode.
34 | *
35 | * Created by eltos on 16.02.17 as suggested here: http://stackoverflow.com/a/41864063
36 | *
37 | */
38 | public class TextInputAutoCompleteTextView extends MaterialAutoCompleteTextView {
39 |
40 | public boolean doNotFilter = false;
41 |
42 | public TextInputAutoCompleteTextView(Context context) {
43 | super(context);
44 | }
45 |
46 | public TextInputAutoCompleteTextView(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | }
49 |
50 | public TextInputAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
51 | super(context, attrs, defStyleAttr);
52 | }
53 |
54 | @Override
55 | public boolean enoughToFilter() {
56 | return doNotFilter || super.enoughToFilter();
57 | }
58 |
59 | @Override
60 | protected void performFiltering(CharSequence text, int keyCode) {
61 | super.performFiltering(doNotFilter ? "" : text, keyCode);
62 | }
63 |
64 | @Override
65 | public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
66 | final InputConnection ic = super.onCreateInputConnection(outAttrs);
67 | if (ic != null && outAttrs.hintText == null) {
68 | // If we don't have a hint and our parent is a TextInputLayout, use it's hint for the
69 | // EditorInfo. This allows us to display a hint in 'extract mode'.
70 | ViewParent parent = getParent();
71 | while (parent instanceof View) {
72 | if (parent instanceof TextInputLayout) {
73 | outAttrs.hintText = ((TextInputLayout) parent).getHint();
74 | break;
75 | }
76 | parent = parent.getParent();
77 | }
78 | }
79 | return ic;
80 | }
81 | }
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/list/AdvancedSectionAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.list;
18 |
19 | import androidx.annotation.Nullable;
20 | import android.widget.SectionIndexer;
21 |
22 | import java.util.ArrayList;
23 |
24 | /**
25 | * An extension of AdvancedAdapter that provides a section indexer
26 | *
27 | * Created by eltos on 02.02.2017.
28 | */
29 | public abstract class AdvancedSectionAdapter extends AdvancedAdapter implements SectionIndexer {
30 |
31 | class Section {
32 | String title;
33 | int startingPosition;
34 |
35 | Section(String text, int pos){
36 | title = text;
37 | startingPosition = pos;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | return title;
43 | }
44 | }
45 |
46 | private ArrayList mSections = new ArrayList<>();
47 |
48 | @Override
49 | public void notifyDataSetChanged() {
50 | super.notifyDataSetChanged();
51 | updateAlphaIndexer();
52 | }
53 |
54 | @Override
55 | public int getPositionForSection(int section) {
56 | section = Math.max(0, Math.min(mSections.size() - 1, section));
57 | return mSections.get(section).startingPosition;
58 | }
59 |
60 | @Override
61 | public int getSectionForPosition(int position) {
62 | for (int i = mSections.size() - 1; i >= 0; i--) {
63 | if (position >= mSections.get(i).startingPosition){
64 | return i;
65 | }
66 | }
67 | return 0;
68 | }
69 |
70 | @Override
71 | public Object[] getSections() {
72 | return mSections.toArray();
73 | }
74 |
75 |
76 | /**
77 | * Overwrite this method to return the section title corresponding with the given object.
78 | * Equal and consecutive titles are automatically combined to sections
79 | *
80 | * @param object an object from the underlying data set
81 | * @return a title representing the objects section (e.g. its first letter)
82 | */
83 | @Nullable
84 | public abstract String getSectionTitle(T object);
85 |
86 |
87 | private void updateAlphaIndexer(){
88 | mSections.clear();
89 | String currentSection = null;
90 | for (int i = 0; i < getCount(); i++) {
91 | String title = getSectionTitle(getItem(i));
92 | if (title != null && !title.equals(currentSection)){
93 | mSections.add(new Section(title, i));
94 | currentSection = title;
95 | }
96 | }
97 |
98 | if (mSections.size() == 0){
99 | mSections.add(new Section(null, 0));
100 | }
101 |
102 | }
103 |
104 |
105 |
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/java/eltos/simpledialogfragment/list/SimpleListItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragment.list;
18 |
19 | import android.os.Parcel;
20 | import android.os.Parcelable;
21 | import android.widget.ListView;
22 |
23 | /**
24 | *
25 | * Created by eltos on 02.01.2017.
26 | */
27 | public class SimpleListItem implements Parcelable {
28 |
29 | private String string;
30 | private long id;
31 |
32 | @Override
33 | public String toString() {
34 | return getString();
35 | }
36 |
37 | protected SimpleListItem(String string){
38 | this(string, ListView.INVALID_ROW_ID);
39 | }
40 | protected SimpleListItem(String string, long id){
41 | this.string = string;
42 | this.id = id;
43 | }
44 |
45 |
46 | private SimpleListItem(Parcel in) {
47 | string = in.readString();
48 | }
49 | @Override
50 | public void writeToParcel(Parcel dest, int flags) {
51 | dest.writeString(string);
52 | }
53 | public static final Creator CREATOR = new Creator() {
54 | @Override
55 | public SimpleListItem createFromParcel(Parcel in) {
56 | return new SimpleListItem(in);
57 | }
58 |
59 | @Override
60 | public SimpleListItem[] newArray(int size) {
61 | return new SimpleListItem[size];
62 | }
63 | };
64 | @Override
65 | public int describeContents() {
66 | return 0;
67 | }
68 |
69 |
70 | public String getString() {
71 | return string;
72 | }
73 |
74 | public void setString(String string) {
75 | this.string = string;
76 | }
77 |
78 | public void setId(long id) {
79 | this.id = id;
80 | }
81 |
82 | public long getId() {
83 | return id;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/anim/zoom_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
15 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/anim/zoom_show.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
15 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/color/primary_color_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable-anydpi/ic_arrow_forward.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable-anydpi/ic_arrow_forward_accent.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable-anydpi/ic_check.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable-anydpi/ic_clear_search.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable-anydpi/ic_palette_color.xml:
--------------------------------------------------------------------------------
1 |
7 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable/arrow_mark.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable/tile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/simpledialogfragments/src/main/res/drawable/tile.png
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/drawable/tiles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/dialog_fullscreen.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
22 |
23 |
24 |
25 |
31 |
32 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simple_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simple_list_item_action.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simple_list_item_multiple_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simple_list_item_single_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_check_box.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_color_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
17 |
26 |
27 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_custom_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
19 |
20 |
25 |
26 |
34 |
35 |
36 |
37 |
38 |
43 |
44 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_form.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_form_item_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_form_item_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
24 |
28 |
29 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_form_item_datetime.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
23 |
24 |
25 |
26 |
33 |
34 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_form_item_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_form_item_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_form_item_spinner.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
23 |
24 |
32 |
33 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_image_hor_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
20 |
21 |
29 |
30 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_image_vert_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
20 |
21 |
29 |
30 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_pin.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
22 |
23 |
30 |
31 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_progress_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
24 |
25 |
34 |
35 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/menu/dialog_buttons.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-de/plurals.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Min 1 Zeichen
6 | Min %1$d Zeichen
7 |
8 |
9 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | E-Mail Adresse
4 | Ungültige E-Mail Adresse
5 | Transparenz
6 | Passwort
7 | Erforderlich
8 | Eingabe nicht gelistet
9 | Name
10 | Telefonnummer
11 | Anmelden
12 | Benutzer
13 | Muss eine Zahl, einen Groß- und Kleinbuchstaben und ein Sonderzeichen enthalten
14 | Nur Buchstaben (A-Z) erlaubt
15 | Nur alphanumerische Zeichen erlaubt
16 | PIN-Code
17 | Falsche PIN
18 | Datum
19 | Zeit
20 | Löschen
21 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-fr/plurals.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Au moins %1$d caractère
6 | Au moins %1$d caractères
7 |
8 |
9 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Transparence
4 | Adresse e-mail
5 | Adresse e-mail invalide
6 | Mot de passe
7 | Champs obligatoires
8 | Nom
9 | Numéro de téléphone
10 | Login
11 | Usager
12 | Ne peut contenir que des lettres (A-Z)
13 | Ne peut contenir que des lettres alphanumériques
14 | Il doit contenir un numéro, une lettre majuscule et à faible revenu et un caractère spécial
15 | Ne saisissez pas une option donnée
16 | Code PIN
17 | Faux code
18 | Date
19 | Temps
20 | Clair
21 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-ja/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | メールアドレスが無効
4 | メールアドレス
5 | 透明性
6 | 必須
7 | パスワード
8 | 指定されたオプションを入力しない
9 | 名前
10 | 電話番号
11 | ログイン
12 | ユーザー
13 | パスワードは、数字、小文字と大文字や特殊文字が含まれている必要があり
14 | アルファベットのみ
15 | 英数字のみ
16 | ピン
17 | 間違ったピン
18 |
19 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-nl/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Transparantie
4 | E-mail adres
5 | Ongeldig e-mail adres
6 | Verplicht
7 | Paswoord
8 | Gebruiker
9 | Login
10 | Telefoonnummer
11 | Naam
12 | Moet alleen alfanumerieke tekens bevatten
13 | Input niet een bepaalde optie
14 | Moet alleen letters A-Z bevatten
15 | Moet een nummer, een hoofdletter en een hoofdletter en een speciaal teken bevatten
16 | Pincode
17 | Pin verkeerd
18 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-pl/plurals.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | Minimalnie 1 znak
22 | Minimalnie %1$d znaki
23 | Minimalnie %1$d znaków
24 |
25 |
26 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values-pl/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Adres email
4 | Niepoprawny email
5 | Przezroczystość
6 | Hasło
7 | Wymagane
8 | Nieprawidłowa wartość
9 | Nazwa
10 | Numer telefonu
11 | Login
12 | Użytkownik
13 | Musi zawierać cyfrę, małą i wielką literę oraz znak specjalny
14 | Może zawierać jedynie litery (A-Z)
15 | Może zawierać tylko znaki alfanumeryczne
16 | Kod PIN
17 | Niepoprawny PIN
18 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #FFD50000
5 |
6 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values/color_pallets.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | #fff44336
8 | #ffe91e63
9 | #ff9c27b0
10 | #ff673ab7
11 | #ff3f51b5
12 | #ff2196f3
13 | #ff03a9f4
14 | #ff00bcd4
15 | #ff009688
16 | #ff4caf50
17 | #ff8bc34a
18 | #ffcddc39
19 | #ffffeb3b
20 | #ffffc107
21 | #ffff9800
22 | #ffff5722
23 | #ff795548
24 | #ff9e9e9e
25 | #ff607d8b
26 |
27 |
28 |
29 | #FFEF9A9A
30 | #FFF48FB1
31 | #FFCE93D8
32 | #FFB39DDB
33 | #FF9FA8DA
34 | #FF90CAF9
35 | #FF81D4FA
36 | #FF80DEEA
37 | #FF80CBC4
38 | #FFA5D6A7
39 | #FFC5E1A5
40 | #FFE6EE9C
41 | #FFFFF59D
42 | #FFFFE082
43 | #FFFFCC80
44 | #FFFFAB91
45 | #FFBCAAA4
46 | #FFEEEEEE
47 | #FFB0BEC5
48 |
49 |
50 |
51 | #FFB71C1C
52 | #FF880E4F
53 | #FF4A148C
54 | #FF311B92
55 | #FF1A237E
56 | #FF0D47A1
57 | #FF01579B
58 | #FF006064
59 | #FF004D40
60 | #FF1B5E20
61 | #FF33691E
62 | #FF827717
63 | #FFF57F17
64 | #FFFF6F00
65 | #FFE65100
66 | #FFBF360C
67 | #FF3E2723
68 | #FF212121
69 | #FF263238
70 |
71 |
72 |
73 | #ffb06660
74 | #ffd9a88f
75 | #ffeac3b8
76 | #ffab9c73
77 | #ffd2be96
78 | #ffe3dcc0
79 | #ff5e7703
80 | #ff9baf8e
81 | #ffc1cc89
82 | #ffb4a851
83 | #ffdfd27c
84 | #ffe7e3b5
85 | #ff405980
86 | #ff6a7d8e
87 | #ffaebbc7
88 | #ffc1d2d6
89 | #ff846d74
90 | #ffb7a6ad
91 | #ffd3c9ce
92 | #ffd9b8a2
93 | #ffbf8686
94 | #ffb33050
95 |
96 |
97 |
98 | #ffff8c9d
99 | #ffffd08c
100 | #fffff78c
101 | #ffc0ff8c
102 | #ff8ceaff
103 | #ffff00a0
104 | #fffe9507
105 | #fffbff00
106 | #ff00ff61
107 | #ff00a0ff
108 | #ffc12552
109 | #ffff6000
110 | #fff5c700
111 | #ff6a961f
112 | #ff1d7fb9
113 | #ffb36435
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 16dp
6 | 16dp
7 |
8 | 50dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values/plurals.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Min 1 char
6 | Min %1$d chars
7 |
8 |
9 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Invalid email address
4 | Email address
5 | HEX:
6 | Transparency
7 | Required
8 | Password
9 | Input not a given option
10 | Name
11 | Phone number
12 | Login
13 | User
14 | Must contain a number, a lower- and uppercase letter and a special character
15 | May only contain letters (A-Z)
16 | May only contain alphanumerical chars
17 | RRGGBB
18 | Pin code
19 | Wrong pin
20 | Date
21 | Time
22 | Clear
23 | Color picker
24 | Clear color
25 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
10 |
11 |
12 |
16 |
17 |
18 |
22 |
25 |
26 |
27 |
31 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
45 |
46 |
47 |
53 |
54 |
55 |
61 |
62 |
--------------------------------------------------------------------------------
/testApp/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/testApp/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | namespace 'eltos.simpledialogfragments'
8 |
9 | compileSdk 34
10 |
11 | defaultConfig {
12 | applicationId 'eltos.simpledialogfragments.test'
13 | minSdkVersion 21
14 | targetSdkVersion 34
15 | versionCode rootProject.ext['VERSION_NR']
16 | versionName rootProject.ext['VERSION']
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | repositories {
27 | //mavenLocal()
28 | //maven { url 'https://jitpack.io' }
29 | }
30 |
31 | dependencies {
32 | testImplementation 'junit:junit:4.13.2'
33 | implementation 'androidx.appcompat:appcompat:1.7.0'
34 | implementation 'com.google.android.material:material:1.12.0'
35 | implementation 'com.google.android.flexbox:flexbox:3.0.0'
36 | implementation 'com.google.zxing:core:3.5.2'
37 |
38 | // sonatype maven
39 | //implementation 'io.github.eltos:simpledialogfragments:3.5.1'
40 |
41 | // jitpack
42 | //implementation 'com.github.eltos:simpledialogfragments:v3.5'
43 |
44 | // local project
45 | api project(path: ':simpledialogfragments')
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/testApp/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/testApp/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/testApp/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/testApp/src/main/java/eltos/simpledialogfragments/ClipboardCopyDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragments;
18 |
19 | import android.content.ClipData;
20 | import android.content.ClipboardManager;
21 | import android.content.Context;
22 | import android.os.Build;
23 | import android.os.Bundle;
24 | import android.text.Html;
25 | import android.view.View;
26 | import android.view.ViewStub;
27 | import android.widget.Toast;
28 |
29 | import eltos.simpledialogfragment.CustomViewDialog;
30 |
31 | public class ClipboardCopyDialog extends CustomViewDialog {
32 |
33 | public static ClipboardCopyDialog build(){
34 | return new ClipboardCopyDialog()
35 | .neut(R.string.copy);
36 | }
37 |
38 | @Override
39 | protected void onNeutralButtonClick() {
40 | ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
41 | ClipData clip;
42 | if (getArgs().getBoolean(HTML) && getMessage() instanceof String){
43 | // HTML dialog message
44 | String plainText = Html.fromHtml((String) getMessage()).toString();
45 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
46 | clip = ClipData.newHtmlText(getTitle(), plainText, (String) getMessage());
47 | } else {
48 | clip = ClipData.newPlainText(getTitle(), plainText);
49 | }
50 | } else {
51 | // Plain text dialog message
52 | clip = ClipData.newPlainText(getTitle(), getMessage());
53 | }
54 | clipboard.setPrimaryClip(clip);
55 | Toast.makeText(getContext(), R.string.copied, Toast.LENGTH_SHORT).show();
56 | }
57 |
58 | @Override
59 | protected View onCreateContentView(Bundle savedInstanceState) {
60 | return new ViewStub(getContext()); // no special content required
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/testApp/src/main/java/eltos/simpledialogfragments/FlatColorFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragments;
18 |
19 |
20 | import android.os.Bundle;
21 |
22 | import androidx.annotation.NonNull;
23 | import androidx.annotation.Nullable;
24 | import android.view.LayoutInflater;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 |
28 | import eltos.simpledialogfragment.color.SimpleColorDialog;
29 |
30 | /**
31 | * Wrapper class to use the contents of a dialog as a normal ("flat") fragment
32 | * somewhere in an activity
33 | *
34 | */
35 | public class FlatColorFragment extends SimpleColorDialog {
36 |
37 | @Override
38 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
39 | return extractContentView(savedInstanceState);
40 | }
41 |
42 | public boolean callResultListener() {
43 | return super.callResultListener(BUTTON_POSITIVE, null);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/testApp/src/main/java/eltos/simpledialogfragments/FlatFragmentActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragments;
18 |
19 | import android.graphics.Color;
20 | import android.graphics.drawable.ColorDrawable;
21 | import android.os.Build;
22 | import androidx.annotation.ColorInt;
23 | import androidx.annotation.NonNull;
24 | import androidx.fragment.app.FragmentManager;
25 | import androidx.appcompat.app.AppCompatActivity;
26 | import android.os.Bundle;
27 | import android.text.Spannable;
28 | import android.text.SpannableString;
29 | import android.text.style.ForegroundColorSpan;
30 |
31 | import eltos.simpledialogfragment.SimpleDialog;
32 | import eltos.simpledialogfragment.color.SimpleColorDialog;
33 |
34 | public class FlatFragmentActivity extends AppCompatActivity implements SimpleDialog.OnDialogResultListener {
35 |
36 | private static final String COLOR_FRAGMENT = "color_fragment";
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_flat_fragment);
42 |
43 |
44 | /**
45 | * This example shows how one could re-use the views from a dialog
46 | * in an activity, using a wrapper class like {@link FlatColorFragment}
47 | *
48 | */
49 |
50 | FragmentManager fragmentManager = getSupportFragmentManager();
51 | final FlatColorFragment fragment;
52 |
53 | if (savedInstanceState == null){
54 |
55 | // instantiate and configure properties
56 | fragment = new FlatColorFragment();
57 | fragment.allowCustom(true);
58 | fragment.colorPreset(0xFFCF4747);
59 |
60 | fragmentManager.beginTransaction().add(R.id.frame, fragment, COLOR_FRAGMENT).commit();
61 |
62 | } else {
63 | fragment = (FlatColorFragment) fragmentManager.findFragmentByTag(COLOR_FRAGMENT);
64 | }
65 |
66 | // call result listener
67 | findViewById(R.id.ok).setOnClickListener(v -> fragment.callResultListener());
68 |
69 | }
70 |
71 | // == R E S U L T S ==
72 |
73 |
74 | /**
75 | * Let the hosting fragment or activity implement this interface
76 | * to receive results from the dialog
77 | *
78 | * @param dialogTag the tag passed to {@link SimpleDialog#show}
79 | * @param which result type, one of {@link #BUTTON_POSITIVE}, {@link #BUTTON_NEGATIVE},
80 | * {@link #BUTTON_NEUTRAL} or {@link #CANCELED}
81 | * @param extras the extras passed to {@link SimpleDialog#extra(Bundle)}
82 | * @return true if the result was handled, false otherwise
83 | */
84 | @Override
85 | public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {
86 |
87 | // handle results as usual
88 | if (COLOR_FRAGMENT.equals(dialogTag) && which == BUTTON_POSITIVE) {
89 | @ColorInt int color = extras.getInt(SimpleColorDialog.COLOR);
90 |
91 | // Sets action bar colors
92 | if (getSupportActionBar() != null) {
93 | getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFF000000 | color));
94 |
95 | boolean dark = Color.red(color) * 0.299 + Color.green(color) * 0.587 + Color.blue(color) * 0.114 < 180;
96 | SpannableString s = new SpannableString(getSupportActionBar().getTitle());
97 | s.setSpan(new ForegroundColorSpan(dark ? Color.WHITE : Color.BLACK), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
98 | getSupportActionBar().setTitle(s);
99 | }
100 |
101 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
102 | float[] hsv = new float[3];
103 | Color.colorToHSV(color, hsv);
104 | hsv[2] *= 0.75f;
105 | getWindow().setStatusBarColor(Color.HSVToColor(hsv));
106 | }
107 |
108 | return true;
109 | }
110 | return false;
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/testApp/src/main/java/eltos/simpledialogfragments/KotlinActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Philipp Niedermayer (github.com/eltos)
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 | package eltos.simpledialogfragments
17 |
18 | import android.os.Bundle
19 | import android.os.SystemClock
20 | import android.util.Log
21 | import android.view.View
22 | import android.widget.Toast
23 | import androidx.appcompat.app.AppCompatActivity
24 | import eltos.simpledialogfragment.SimpleDialog
25 | import eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener
26 | import eltos.simpledialogfragment.SimpleProgressDialog
27 | import eltos.simpledialogfragment.SimpleProgressTask
28 |
29 | @Suppress("UNUSED_PARAMETER")
30 | class KotlinActivity : AppCompatActivity(), OnDialogResultListener {
31 |
32 | fun showInfo(view: View?) {
33 | SimpleDialog.build()
34 | .title(R.string.message)
35 | .msg(R.string.hello_world)
36 | .show(this)
37 | }
38 |
39 | @Suppress("Unused")
40 | fun lintTest(){
41 | // The following produces a lint error
42 | //TestLintDialog.build().show(this)
43 | }
44 |
45 |
46 | fun showProgressTask(view: View?) {
47 | val task = MyProgressTask()
48 | task.execute()
49 | SimpleProgressDialog.buildBar()
50 | .title(R.string.login)
51 | .msg(R.string.creating_user_profile_wait)
52 | .task(task, true, false)
53 | .show(this, PROGRESS_DIALOG)
54 | }
55 |
56 | internal class MyProgressTask : SimpleProgressTask() {
57 | override fun doInBackground(vararg params: Void?): Void? {
58 | SystemClock.sleep(500)
59 | var i = 0
60 | while (!isCancelled && i < 100) {
61 | publishProgress(i + 25, 150)
62 | SystemClock.sleep(10)
63 | i += 1
64 | }
65 | return null
66 | }
67 | }
68 |
69 |
70 | // == R E S U L T S ==
71 | /**
72 | * Let the hosting fragment or activity implement this interface
73 | * to receive results from the dialog
74 | *
75 | * @param dialogTag the tag passed to [SimpleDialog.show]
76 | * @param which result type, one of [.BUTTON_POSITIVE], [.BUTTON_NEGATIVE],
77 | * [.BUTTON_NEUTRAL] or [.CANCELED]
78 | * @param extras the extras passed to [SimpleDialog.extra]
79 | * @return true if the result was handled, false otherwise
80 | */
81 | override fun onResult(dialogTag: String, which: Int, extras: Bundle): Boolean {
82 | Log.d("onResult", "Dialog with tag '" + dialogTag + "' has result: " + which + " (" +
83 | (if (which == OnDialogResultListener.BUTTON_POSITIVE) "BUTTON_POSITIVE" else if (which == OnDialogResultListener.BUTTON_NEUTRAL) "BUTTON_NEUTRAL" else if (which == OnDialogResultListener.BUTTON_NEGATIVE) "BUTTON_NEGATIVE" else if (which == OnDialogResultListener.CANCELED) "CANCELED" else "?") + ")")
84 |
85 |
86 | if (PROGRESS_DIALOG == dialogTag) {
87 | when (which) {
88 | SimpleProgressDialog.COMPLETED -> {
89 | Toast.makeText(this, R.string.completed, Toast.LENGTH_SHORT).show()
90 | return true
91 | }
92 | }
93 | }
94 |
95 | return false
96 | }
97 |
98 | companion object {
99 | private const val PROGRESS_DIALOG = "dialogProgress"
100 | }
101 | }
--------------------------------------------------------------------------------
/testApp/src/main/java/eltos/simpledialogfragments/RecursiveDialog.java:
--------------------------------------------------------------------------------
1 | package eltos.simpledialogfragments;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.NonNull;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.LinearLayout;
8 | import android.widget.Toast;
9 |
10 | import eltos.simpledialogfragment.CustomViewDialog;
11 | import eltos.simpledialogfragment.SimpleDialog;
12 |
13 | /**
14 | *
15 | * Created by eltos on 02.02.2017.
16 | */
17 | public class RecursiveDialog extends CustomViewDialog
18 | implements SimpleDialog.OnDialogResultListener {
19 |
20 |
21 | private static final String I = "recursiveDialog.i";
22 | private static final String RECURSIVE_DIALOG = "recursiveDialog";
23 |
24 | public static RecursiveDialog build(){
25 | return new RecursiveDialog();
26 | }
27 |
28 | private RecursiveDialog i(int i){ return setArg(I, i); }
29 |
30 |
31 | @Override
32 | public void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | title("# " + getArgs().getInt(I, 1));
35 | }
36 |
37 | @Override
38 | protected View onCreateContentView(Bundle savedInstanceState) {
39 | LinearLayout main = new LinearLayout(getContext());
40 | Button b = new Button(getContext());
41 | b.setText(R.string.popup);
42 | b.setOnClickListener(v -> RecursiveDialog.build()
43 | .i(getArgs().getInt(I, 1)+1)
44 | .neg()
45 | .show(RecursiveDialog.this, RECURSIVE_DIALOG));
46 | main.addView(b);
47 |
48 | Button b2 = new Button(getContext());
49 | b2.setText(R.string.replace);
50 | b2.setOnClickListener(v -> {
51 | RecursiveDialog.build()
52 | .i(getArgs().getInt(I, 1)+1)
53 | .neg()
54 | .show(getTargetFragment(), RECURSIVE_DIALOG, RECURSIVE_DIALOG);
55 | // We don't use RecursiveDialog.this here as this dialog will be replaced
56 | });
57 | main.addView(b2);
58 |
59 | return main;
60 | }
61 |
62 |
63 | @Override
64 | public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {
65 | if (RECURSIVE_DIALOG.equals(dialogTag)){
66 | Toast.makeText(getContext(), "# "+getArgs().getInt(I, 1)+": "+
67 | (which == BUTTON_POSITIVE ? "+":"-"), Toast.LENGTH_SHORT).show();
68 | // do not return true here, so that the result is passed through to the activity
69 | }
70 | return false;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/testApp/src/main/java/eltos/simpledialogfragments/TestLintDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Philipp Niedermayer (github.com/eltos)
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 eltos.simpledialogfragments;
18 |
19 | import android.os.Bundle;
20 | import android.view.View;
21 |
22 | import eltos.simpledialogfragment.CustomViewDialog;
23 |
24 | public class TestLintDialog extends CustomViewDialog {
25 |
26 | //public static String TAG = "my-tag";
27 |
28 | //public static TestLintDialog build(){
29 | // return new TestLintDialog();
30 | //}
31 |
32 | @Override
33 | protected View onCreateContentView(Bundle savedInstanceState) {
34 | return null;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/testApp/src/main/res/drawable/ic_info.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
--------------------------------------------------------------------------------
/testApp/src/main/res/drawable/image_sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/drawable/image_sample.png
--------------------------------------------------------------------------------
/testApp/src/main/res/drawable/tall_image_sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/drawable/tall_image_sample.png
--------------------------------------------------------------------------------
/testApp/src/main/res/drawable/wide_image_sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/drawable/wide_image_sample.png
--------------------------------------------------------------------------------
/testApp/src/main/res/layout/activity_flat_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
28 |
29 |
34 |
35 |
36 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/testApp/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/testApp/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/testApp/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/testApp/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/testApp/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eltos/SimpleDialogFragments/6779c9b141a5d9279f3ae10e456b3d826744a3de/testApp/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/testApp/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #7986CB
4 | #9FA8DA
5 |
--------------------------------------------------------------------------------
/testApp/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/testApp/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Excellent choice
5 | Even better choice
6 | Best choice
7 | Ultimate choice
8 | A choice with a very long text that will span multiple lines. This choice is of unknown nature and will remain mysterious. Choose wise.
9 |
10 |
11 |
12 | Once a day
13 | Once a week
14 | Once a month
15 | Once a year
16 |
17 |
18 |
19 | Pick image
20 | Pick video
21 | Open camera
22 |
23 |
24 |
25 | Archaeology and Anthropology
26 | Architecture
27 | Art
28 | Beaches
29 | Bed and Breakfasts
30 | Biking
31 | Birds
32 | Business
33 | Cruises
34 | Eco-Tourism
35 | Family
36 | Fishing
37 | Food and Wine
38 | Gardens
39 | Golf
40 | Hiking
41 | History
42 | Kayaking and Canoeing
43 | Music
44 | National Parks
45 | Road Trips
46 | Shopping
47 | Skiing
48 | Snorkeling and Diving
49 | Surfing
50 | Wildlife
51 |
52 |
53 |
54 | Male
55 | Female
56 | Binary
57 | Non-Binary
58 | Genderfluid
59 | Agender
60 | Bigender
61 | Polygender
62 | Neutrois
63 | Gender Apathetic
64 | Androgyne
65 | Intergender
66 | Demigender
67 | Greygender
68 | Aporagender
69 | Maverique
70 | Novigender
71 | Designated gender
72 | Transitioning
73 | Intersex
74 | Dyadic
75 |
76 |
77 | red
78 | magenta
79 | purple
80 | deep purple
81 | indigo
82 | blue
83 | light blue
84 | cyan
85 | teal
86 | green
87 | light green
88 | lime
89 | yellow
90 | amber
91 | orange
92 | deep orange
93 | brown
94 | gray
95 | blue gray
96 |
97 |
--------------------------------------------------------------------------------
/testApp/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #ff9800
6 |
7 |
--------------------------------------------------------------------------------
/testApp/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/testApp/src/main/res/values/plurals.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %1$d selected
6 | %1$d selected
7 |
8 |
9 |
10 | Delete one message?
11 | Delete %1$d messages?
12 |
13 |
14 |
--------------------------------------------------------------------------------
/testApp/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
30 |
31 |
32 |
38 |
42 |
45 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
66 |
69 |
72 |
77 |
78 |
80 |
85 |
88 |
89 |
90 |
--------------------------------------------------------------------------------