17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/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_image_hor_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
20 |
21 |
29 |
30 |
--------------------------------------------------------------------------------
/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-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/layout/simpledialogfragment_form_item_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/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/layout/simpledialogfragment_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
23 |
24 |
32 |
33 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/simpledialogfragment_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Upload_to_Sonatype.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/javadoc/legal/jquery.md:
--------------------------------------------------------------------------------
1 | ## jQuery v3.7.1
2 |
3 | ### jQuery License
4 | ```
5 | jQuery v 3.7.1
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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/simpledialogfragments/src/main/res/layout/dialog_fullscreen.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
22 |
23 |
24 |
25 |
31 |
32 |
--------------------------------------------------------------------------------
/testApp/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | namespace 'eltos.simpledialogfragments'
8 |
9 |
10 | defaultConfig {
11 | applicationId 'eltos.simpledialogfragments.test'
12 | compileSdkVersion 36
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.1'
34 | implementation 'com.google.android.material:material:1.13.0'
35 | implementation 'com.google.android.flexbox:flexbox:3.0.0'
36 | implementation 'com.google.zxing:core:3.5.3'
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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Release_new_version.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Die Hilfeseite enthält eine Einführung in den Umfang und die Syntax der JavaDoc-Suche.
56 |
Sie können die <STRG>- oder <CMD>-Taste zusammen mit den Pfeiltasten nach links und rechts verwenden, um zwischen Ergebnisregisterkarten auf dieser Seite zu wechseln.
57 |
Mit der URL-Vorlage unten können Sie diese Seite als Suchmaschine in Browsern konfigurieren, die dieses Feature unterstützen. Das Feature wurde erfolgreich mit Google Chrome und Mozilla Firefox getestet. Beachten Sie, dass andere Browser dieses Feature möglicherweise nicht unterstützen oder ein anderes URL-Format erfordern.
58 | link
59 |
60 |
61 |
62 |
63 |
Suchindex wird geladen...
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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/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 | *