├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── gmail │ │ └── samehadar │ │ └── iosdialog_sample │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── gmail │ │ │ └── samehadar │ │ │ └── iosdialog_sample │ │ │ ├── IOSDialogActivity.java │ │ │ └── WithCamomileSpinnerActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── with_spinner_activity.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── gmail │ └── samehadar │ └── iosdialog_sample │ └── ExampleUnitTest.java ├── build.gradle ├── gif1.gif ├── gif2.gif ├── gif3.gif ├── gif4.gif ├── gradle.properties ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── iosdialog ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── gmail │ │ └── samehadar │ │ └── iosdialog │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── gmail │ │ │ └── samehadar │ │ │ └── iosdialog │ │ │ ├── CamomileSpinner.java │ │ │ ├── DialogInit.java │ │ │ ├── IOSDialog.java │ │ │ └── utils │ │ │ └── DialogUtils.java │ └── res │ │ ├── drawable │ │ ├── progress_hud_bg.xml │ │ ├── spinner.xml │ │ ├── spinner_0.png │ │ ├── spinner_1.png │ │ ├── spinner_10.png │ │ ├── spinner_11.png │ │ ├── spinner_2.png │ │ ├── spinner_3.png │ │ ├── spinner_4.png │ │ ├── spinner_5.png │ │ ├── spinner_6.png │ │ ├── spinner_7.png │ │ ├── spinner_8.png │ │ └── spinner_9.png │ │ ├── layout │ │ └── ios_progress_dialog.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── gmail │ └── samehadar │ └── iosdialog │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | 43 | # Keystore files 44 | *.jks 45 | 46 | # External native build folder generated in Android Studio 2.2 and later 47 | .externalNativeBuild 48 | 49 | # Google Services (e.g. APIs or Firebase) 50 | google-services.json 51 | 52 | # Freeline 53 | freeline.py 54 | freeline/ 55 | freeline_project_description.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Samehadar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IOSDialog 2 | The IOSDialog is a library, which allows to use an dialog and spinner elements as in IOS 3 | 4 | I decided to do this because, it was necessary to me in one project. And then I decided to share with community. 5 | 6 | Now the library has all necessary functions for implementation in your project. I will be engaged in its development further, but the main API will not change. And also you can contribute new idea to me. 7 | 8 | 9 | 10 | ## Adding IOSDialog to your project 11 | 12 | ### Gradle 13 | 14 | Include this in your module ```build.gradle``` 15 | ``` 16 | dependencies { 17 | compile 'com.gmail.samehadar:iosdialog:1.0' 18 | } 19 | ``` 20 | ### Maven 21 | 22 | Include this in your ```pom file``` 23 | ``` 24 | 25 | com.gmail.samehadar 26 | iosdialog 27 | 1.0 28 | pom 29 | 30 | ``` 31 | ### Style example 1: 32 | 33 | ![alt text][gif1] 34 | 35 | ### Style example 2: 36 | 37 | ![][gif2] 38 | 39 | ### Style example 3: 40 | 41 | ![][gif3] 42 | 43 | ### Only CamomileSpinner example: 44 | 45 | ![][gif4] 46 | 47 | Code of examples you can find in "app" folder. 48 | 49 | [gif1]: https://github.com/Samehadar/IOSDialog/blob/master/gif1.gif "gif1" 50 | [gif2]: https://github.com/Samehadar/IOSDialog/blob/master/gif2.gif "gif2" 51 | [gif3]: https://github.com/Samehadar/IOSDialog/blob/master/gif3.gif "gif3" 52 | [gif4]: https://github.com/Samehadar/IOSDialog/blob/master/gif4.gif "gif4" 53 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.gmail.samehadar.iosdialog_sample" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(':iosdialog') 30 | } 31 | -------------------------------------------------------------------------------- /app/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:\Users\Vitalu\AppData\Local\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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/gmail/samehadar/iosdialog_sample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog_sample; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.gmail.samehadar.iosdialog_sample", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/gmail/samehadar/iosdialog_sample/IOSDialogActivity.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog_sample; 2 | 3 | import android.content.DialogInterface; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.Gravity; 7 | 8 | import com.gmail.samehadar.iosdialog.IOSDialog; 9 | 10 | 11 | /** 12 | * IOSDialog examples 13 | */ 14 | public class IOSDialogActivity extends AppCompatActivity { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_main); 20 | 21 | final IOSDialog dialog0 = new IOSDialog.Builder(IOSDialogActivity.this) 22 | .setTitle("Default IOS bar") 23 | .setTitleColorRes(R.color.gray) 24 | .build(); 25 | 26 | final IOSDialog dialog1 = new IOSDialog.Builder(IOSDialogActivity.this) 27 | .setOnCancelListener(new DialogInterface.OnCancelListener() { 28 | @Override 29 | public void onCancel(DialogInterface dialog) { 30 | dialog0.show(); 31 | } 32 | }) 33 | .setDimAmount(3) 34 | .setSpinnerColorRes(R.color.colorGreen) 35 | .setMessageColorRes(R.color.colorAccent) 36 | .setTitle(R.string.standard_title) 37 | .setTitleColorRes(R.color.colorPrimary) 38 | .setMessageContent("My message") 39 | .setCancelable(true) 40 | .setMessageContentGravity(Gravity.END) 41 | .build(); 42 | 43 | IOSDialog dialog2 = new IOSDialog.Builder(IOSDialogActivity.this) 44 | .setOnCancelListener(new DialogInterface.OnCancelListener() { 45 | @Override 46 | public void onCancel(DialogInterface dialog) { 47 | dialog1.show(); 48 | } 49 | }) 50 | .setSpinnerColorRes(R.color.ios_gray_text) 51 | .setMessageColorRes(R.color.primaryDark) 52 | .setTitleColorRes(R.color.accent) 53 | .setMessageContent("My message") 54 | .setCancelable(true) 55 | .setSpinnerClockwise(false) 56 | .setSpinnerDuration(120) 57 | .setMessageContentGravity(Gravity.END) 58 | .setOneShot(false) 59 | .build(); 60 | dialog2.show(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/gmail/samehadar/iosdialog_sample/WithCamomileSpinnerActivity.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog_sample; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.ViewGroup; 7 | import android.widget.LinearLayout; 8 | 9 | import com.gmail.samehadar.iosdialog.CamomileSpinner; 10 | import com.gmail.samehadar.iosdialog.utils.DialogUtils; 11 | 12 | /** 13 | * CamomileSpinner examples 14 | */ 15 | 16 | public class WithCamomileSpinnerActivity extends AppCompatActivity { 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.with_spinner_activity); 22 | 23 | LinearLayout activity_main = (LinearLayout) findViewById(R.id.rootView); 24 | 25 | //Creation from xml 26 | CamomileSpinner spinner1 = (CamomileSpinner) findViewById(R.id.spinner1); 27 | spinner1.start(); 28 | CamomileSpinner spinner2 = (CamomileSpinner) findViewById(R.id.spinner2); 29 | spinner2.start(); 30 | 31 | //Change properties on the fly 32 | CamomileSpinner spinner3 = (CamomileSpinner) findViewById(R.id.spinner3); 33 | spinner3.start(); 34 | spinner3.recreateWithParams( 35 | WithCamomileSpinnerActivity.this, 36 | DialogUtils.getColor(this, R.color.colorYellow), 37 | 120, 38 | true 39 | ); 40 | 41 | //Creation programmatically 42 | CamomileSpinner spinner4 = new CamomileSpinner( 43 | WithCamomileSpinnerActivity.this, 44 | DialogUtils.getColor(this, R.color.colorGreen), 45 | CamomileSpinner.DEFAULT_DURATION, 46 | false 47 | ); 48 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 49 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 50 | params.setMargins( 51 | (int) getResources().getDimension(R.dimen.camomile_spinner_margin), 52 | (int) getResources().getDimension(R.dimen.camomile_spinner_margin), 53 | (int) getResources().getDimension(R.dimen.camomile_spinner_margin), 54 | (int) getResources().getDimension(R.dimen.camomile_spinner_margin)); 55 | } 56 | spinner4.setLayoutParams(params); 57 | spinner4.start(); 58 | activity_main.addView(spinner4); 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/with_spinner_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 19 | 20 | 28 | 29 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #ffd231 7 | #00ff00 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | IOSDialog 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/gmail/samehadar/iosdialog_sample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog_sample; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gif1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/gif1.gif -------------------------------------------------------------------------------- /gif2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/gif2.gif -------------------------------------------------------------------------------- /gif3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/gif3.gif -------------------------------------------------------------------------------- /gif4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/gif4.gif -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /iosdialog/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | ext { 4 | PUBLISH_GROUP_ID = 'com.gmail.samehadar' 5 | PUBLISH_ARTIFACT_ID = 'iosdialog' 6 | PUBLISH_VERSION = '1.0' 7 | } 8 | 9 | android { 10 | compileSdkVersion 25 11 | buildToolsVersion "25.0.2" 12 | 13 | defaultConfig { 14 | minSdkVersion 9 15 | targetSdkVersion 25 16 | versionCode 1 17 | versionName "1.0" 18 | 19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 20 | 21 | } 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | } 29 | 30 | dependencies { 31 | compile fileTree(dir: 'libs', include: ['*.jar']) 32 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 33 | exclude group: 'com.android.support', module: 'support-annotations' 34 | }) 35 | compile 'com.android.support:appcompat-v7:25.3.1' 36 | testCompile 'junit:junit:4.12' 37 | } 38 | 39 | apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle' -------------------------------------------------------------------------------- /iosdialog/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:\Users\Vitalu\AppData\Local\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 | -------------------------------------------------------------------------------- /iosdialog/src/androidTest/java/com/gmail/samehadar/iosdialog/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.gmail.samehadar.iosdialog.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /iosdialog/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /iosdialog/src/main/java/com/gmail/samehadar/iosdialog/CamomileSpinner.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.content.res.TypedArray; 6 | import android.graphics.drawable.AnimationDrawable; 7 | import android.os.Build; 8 | import android.support.annotation.ColorInt; 9 | import android.support.v4.content.ContextCompat; 10 | import android.util.AttributeSet; 11 | 12 | import com.gmail.samehadar.iosdialog.utils.DialogUtils; 13 | 14 | //TODO:: try to extends from view 15 | public class CamomileSpinner extends android.support.v7.widget.AppCompatImageView { 16 | 17 | public static final int DEFAULT_DURATION = 60; 18 | @ColorInt public static final int DEFAULT_COLOR; 19 | static { 20 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 21 | DEFAULT_COLOR = Resources.getSystem().getColor(android.R.color.white, null); 22 | } else { 23 | DEFAULT_COLOR = Resources.getSystem().getColor(android.R.color.white); 24 | } 25 | } 26 | public static final boolean DEFAULT_CLOCKWISE = true; 27 | 28 | private int spinnerColor; 29 | private int duration; 30 | private boolean clockwise = DEFAULT_CLOCKWISE; 31 | 32 | public CamomileSpinner(Context context) { 33 | super(context); 34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 35 | this.setBackground(ContextCompat.getDrawable(context, R.drawable.spinner)); 36 | } else { 37 | this.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.spinner)); 38 | } 39 | } 40 | 41 | public CamomileSpinner(Context context, AttributeSet attrs) { 42 | super(context, attrs); 43 | initCustomAttr(context, attrs); 44 | } 45 | 46 | public CamomileSpinner(Context context, AttributeSet attrs, int defStyleAttr) { 47 | super(context, attrs, defStyleAttr); 48 | initCustomAttr(context, attrs); 49 | } 50 | 51 | // @RequiresApi(Build.VERSION_CODES.LOLLIPOP) 52 | // public CamomileSpinner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 53 | // super(context, attrs, defStyleAttr, defStyleRes); 54 | // initCustomAttr(context, attrs); 55 | // } 56 | 57 | public CamomileSpinner(Context context, @ColorInt int spinnerColor) { 58 | this(context, spinnerColor, DEFAULT_DURATION); 59 | } 60 | 61 | public CamomileSpinner(Context context, @ColorInt int spinnerColor, int duration) { 62 | this(context, spinnerColor, duration, DEFAULT_CLOCKWISE); 63 | } 64 | 65 | public CamomileSpinner(Context context, @ColorInt int spinnerColor, int duration, boolean clockwise) { 66 | super(context); 67 | this.spinnerColor = spinnerColor; 68 | this.duration = duration; 69 | this.clockwise = clockwise; 70 | AnimationDrawable spinnerAnimation = createSpinner(context, spinnerColor, duration, clockwise); 71 | updateSpinner(spinnerAnimation); 72 | } 73 | 74 | private void initCustomAttr(Context context, AttributeSet attrs) { 75 | TypedArray typedArray = context.getTheme().obtainStyledAttributes( 76 | attrs, 77 | R.styleable.CamomileSpinner, 78 | 0, 0); 79 | try { 80 | duration = typedArray.getInteger(R.styleable.CamomileSpinner_duration, DEFAULT_DURATION); 81 | spinnerColor = typedArray.getColor(R.styleable.CamomileSpinner_spinnerColor, DEFAULT_COLOR); 82 | clockwise = typedArray.getBoolean(R.styleable.CamomileSpinner_clockwise, DEFAULT_CLOCKWISE); 83 | AnimationDrawable spinnerAnimation = createSpinner(context, spinnerColor, duration, clockwise); 84 | updateSpinner(spinnerAnimation); 85 | } finally { 86 | typedArray.recycle(); 87 | } 88 | } 89 | 90 | private AnimationDrawable createSpinner(Context context, @ColorInt int spinnerColor, int duration, boolean clockwise) { 91 | if (spinnerColor == DEFAULT_COLOR && duration == DEFAULT_DURATION && clockwise == DEFAULT_CLOCKWISE) { 92 | //create from xml if default params 93 | return DialogUtils.createAnimation(context); 94 | } else { 95 | //create programmatically if params is not default 96 | return DialogUtils.createAnimation(context, spinnerColor, duration, clockwise); 97 | } 98 | } 99 | 100 | private void updateSpinner(AnimationDrawable spinnerAnimation) { 101 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 102 | this.setBackground(spinnerAnimation); 103 | } else { 104 | this.setBackgroundDrawable(spinnerAnimation); 105 | } 106 | } 107 | 108 | public void start() { 109 | ((AnimationDrawable) this.getBackground()).start(); 110 | } 111 | 112 | public void stop() { 113 | ((AnimationDrawable)this.getBackground()).stop(); 114 | } 115 | 116 | public void recreateWithParams(Context context, @ColorInt int spinnerColor, int duration, boolean clockwise) { 117 | boolean wasRunning = false; 118 | boolean oneShot = isOneShot(); 119 | 120 | if (((AnimationDrawable)this.getBackground()).isRunning()) { 121 | wasRunning = true; 122 | stop(); 123 | } 124 | 125 | AnimationDrawable newSpinner = createSpinner(context, spinnerColor, duration, clockwise); 126 | if (newSpinner != null) { 127 | if (oneShot) newSpinner.setOneShot(true); 128 | this.spinnerColor = spinnerColor; 129 | this.duration = duration; 130 | this.clockwise = clockwise; 131 | updateSpinner(newSpinner); 132 | } 133 | 134 | if (wasRunning) start(); 135 | } 136 | 137 | public void setOneShot(boolean oneShot) { 138 | ((AnimationDrawable) this.getBackground()).setOneShot(oneShot); 139 | } 140 | 141 | public boolean isOneShot() { 142 | return ((AnimationDrawable) this.getBackground()).isOneShot(); 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /iosdialog/src/main/java/com/gmail/samehadar/iosdialog/DialogInit.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog; 2 | 3 | import android.graphics.drawable.GradientDrawable; 4 | import android.os.Build; 5 | import android.support.annotation.LayoutRes; 6 | import android.support.annotation.UiThread; 7 | import android.text.method.LinkMovementMethod; 8 | import android.view.View; 9 | import android.widget.ImageView; 10 | import android.widget.LinearLayout; 11 | import android.widget.TextView; 12 | 13 | import com.gmail.samehadar.iosdialog.utils.DialogUtils; 14 | 15 | public class DialogInit { 16 | 17 | 18 | @LayoutRes 19 | static int getInflateLayout(IOSDialog.Builder builder) { 20 | if (builder.customView != null) { 21 | return -1; 22 | //TODO:: realize custom view 23 | // return R.layout.md_dialog_custom; 24 | } else { 25 | return R.layout.ios_progress_dialog; 26 | } 27 | } 28 | 29 | 30 | @UiThread 31 | public static void init(final IOSDialog dialog) { 32 | final IOSDialog.Builder builder = dialog.builder; 33 | 34 | // Retrieve references to views 35 | dialog.titleFrame = (LinearLayout) dialog.rootView.findViewById(R.id.title_frame); 36 | dialog.titleIcon = (ImageView) dialog.rootView.findViewById(R.id.title_icon); 37 | dialog.title = (TextView) dialog.rootView.findViewById(R.id.title_text); 38 | dialog.spinner = (CamomileSpinner) dialog.rootView.findViewById(R.id.spinner); 39 | dialog.message = (TextView) dialog.rootView.findViewById(R.id.message); 40 | 41 | // Set cancelable flag 42 | dialog.setCancelable(builder.cancelable); 43 | // Set dialog background color //TODO:: back not worked 44 | if (builder.isBackgroundColorSet) { 45 | GradientDrawable drawable = new GradientDrawable(); 46 | drawable.setCornerRadius( 47 | builder.context.getResources().getDimension(R.dimen.ios_bg_corner_radius) 48 | ); 49 | drawable.setColor(builder.backgroundColor); 50 | dialog.getWindow().setBackgroundDrawable(drawable); 51 | } else { 52 | builder.backgroundColor = DialogUtils 53 | .getColor(builder.context, R.color.dark_gray_background); 54 | } 55 | 56 | // Retrieve default title colors 57 | if (!builder.isTitleColorSet) { 58 | builder.titleColor = DialogUtils 59 | .getColor(builder.context, R.color.standard_white); 60 | } 61 | if (!builder.isMessageColorSet) { 62 | builder.messageColor = DialogUtils 63 | .getColor(builder.context, R.color.standard_white); 64 | } 65 | 66 | setupTitle(dialog, builder); 67 | setupSpinner(dialog, builder); 68 | setupMessageContent(dialog, builder); 69 | setupListeners(dialog, builder); 70 | 71 | 72 | dialog.setContentView(dialog.rootView); 73 | } 74 | 75 | private static void setupTitle(IOSDialog dialog, IOSDialog.Builder builder) { 76 | if (dialog.title != null) { 77 | //TODO;; uncomment when add supporting 78 | // dialog.setTypeface(dialog.title, builder.mediumFont); 79 | dialog.title.setTextColor(builder.titleColor); 80 | dialog.title.setGravity(builder.titleGravity); 81 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 82 | //noinspection ResourceType 83 | dialog.title.setTextAlignment(builder.titleGravity); 84 | } 85 | 86 | if (builder.title == null) { 87 | dialog.titleFrame.setVisibility(View.GONE); 88 | } else { 89 | dialog.title.setText(builder.title); 90 | dialog.titleFrame.setVisibility(View.VISIBLE); 91 | } 92 | } 93 | } 94 | 95 | private static void setupSpinner(IOSDialog dialog, IOSDialog.Builder builder) { 96 | if (builder.spinnerColor == 0) builder.spinnerColor = CamomileSpinner.DEFAULT_COLOR; 97 | if (builder.spinnerDuration == 0) builder.spinnerDuration = CamomileSpinner.DEFAULT_DURATION; 98 | if (builder.oneShot) dialog.spinner.setOneShot(true); 99 | dialog.spinner.recreateWithParams( 100 | builder.context, 101 | builder.spinnerColor, 102 | builder.spinnerDuration, 103 | builder.spinnerClockwise 104 | ); 105 | } 106 | 107 | private static void setupListeners(IOSDialog dialog, IOSDialog.Builder builder) { 108 | // Setup user listeners 109 | if (builder.showListener != null) { 110 | dialog.setOnShowListener(builder.showListener); 111 | } 112 | if (builder.cancelListener != null) { 113 | dialog.setOnCancelListener(builder.cancelListener); 114 | } 115 | if (builder.dismissListener != null) { 116 | dialog.setOnDismissListener(builder.dismissListener); 117 | } 118 | if (builder.keyListener != null) { 119 | dialog.setOnKeyListener(builder.keyListener); 120 | } 121 | } 122 | 123 | private static void setupMessageContent(IOSDialog dialog, IOSDialog.Builder builder) { 124 | // Setup content 125 | if (dialog.message != null) { 126 | dialog.message.setMovementMethod(new LinkMovementMethod()); 127 | // dialog.setTypeface(dialog.message, builder.regularFont); 128 | // dialog.message.setLineSpacing(0f, builder.contentLineSpacingMultiplier); 129 | // if (builder.linkColor == null) { 130 | // dialog.message.setLinkTextColor( 131 | // DialogUtils.resolveColor(dialog.getContext(), android.R.attr.textColorPrimary)); 132 | // } else { 133 | // dialog.message.setLinkTextColor(builder.linkColor); 134 | // } 135 | dialog.message.setTextColor(builder.messageColor); 136 | dialog.message.setGravity(builder.messageGravity); 137 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 138 | //noinspection ResourceType 139 | dialog.message.setTextAlignment(builder.messageGravity); 140 | } 141 | 142 | if (builder.message != null) { 143 | dialog.message.setText(builder.message); 144 | dialog.message.setVisibility(View.VISIBLE); 145 | } else { 146 | dialog.message.setVisibility(View.GONE); 147 | } 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /iosdialog/src/main/java/com/gmail/samehadar/iosdialog/IOSDialog.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.Color; 7 | import android.graphics.Typeface; 8 | import android.graphics.drawable.AnimationDrawable; 9 | import android.graphics.drawable.BitmapDrawable; 10 | import android.graphics.drawable.Drawable; 11 | import android.os.Build; 12 | import android.support.annotation.AttrRes; 13 | import android.support.annotation.ColorInt; 14 | import android.support.annotation.ColorRes; 15 | import android.support.annotation.NonNull; 16 | import android.support.annotation.StringRes; 17 | import android.support.annotation.StyleRes; 18 | import android.support.annotation.UiThread; 19 | import android.text.Html; 20 | import android.view.Gravity; 21 | import android.view.LayoutInflater; 22 | import android.view.View; 23 | import android.view.ViewGroup; 24 | import android.widget.ImageView; 25 | import android.widget.LinearLayout; 26 | import android.widget.TextView; 27 | 28 | import com.gmail.samehadar.iosdialog.utils.DialogUtils; 29 | 30 | /** 31 | * Created by Vitalu on 4/17/2017. "Head Up Display" HUD 32 | */ 33 | 34 | public class IOSDialog extends Dialog { 35 | 36 | protected IOSDialog.Builder builder; 37 | //TODO:: change to custom view, when realize custom view 38 | protected ViewGroup rootView; 39 | protected LinearLayout titleFrame; 40 | protected ImageView titleIcon; 41 | protected TextView title; 42 | protected CamomileSpinner spinner; 43 | protected TextView message; 44 | 45 | private IOSDialog(IOSDialog.Builder builder) { 46 | super(builder.context, builder.theme); 47 | final LayoutInflater inflater = LayoutInflater.from(builder.context); 48 | rootView = (ViewGroup) inflater.inflate(DialogInit.getInflateLayout(builder), null); 49 | this.builder = builder; 50 | DialogInit.init(this); 51 | } 52 | 53 | private IOSDialog(Context context, int theme) { 54 | super(context, theme); 55 | } 56 | 57 | //TODO:: add indeterminate support: 58 | //The second property tells the dialog whether to display a spinner. If false, the ProgressDialog will contain a real progress bar, and you will need to periodically update the UI with the current completion percent of your background task. 59 | 60 | @Override 61 | public void onWindowFocusChanged(boolean hasFocus){ 62 | AnimationDrawable spinnerAnimation = (AnimationDrawable) spinner.getBackground(); 63 | spinnerAnimation.start(); 64 | } 65 | 66 | // dialog.getWindow().getAttributes().gravity = Gravity.CENTER; 67 | // //затемнение 68 | // WindowManager.LayoutParams lp = dialog.getWindow().getAttributes(); 69 | // lp.dimAmount=0.2f; 70 | // dialog.getWindow().setAttributes(lp); 71 | //// dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); 72 | 73 | 74 | 75 | public static class Builder { 76 | 77 | protected Context context; 78 | protected View customView; 79 | protected CharSequence title; 80 | protected CharSequence message; 81 | protected boolean cancelable; 82 | protected boolean indeterminate; 83 | protected float dimAmount; 84 | protected int spinnerDuration; 85 | 86 | protected int titleGravity; 87 | protected int messageGravity; 88 | 89 | protected OnShowListener showListener; 90 | protected OnCancelListener cancelListener; 91 | protected OnDismissListener dismissListener; 92 | protected OnKeyListener keyListener; 93 | 94 | protected Typeface regularFont; 95 | protected Typeface mediumFont; 96 | 97 | protected int theme; 98 | 99 | protected int titleColor; 100 | protected int messageColor; 101 | protected int spinnerColor; 102 | protected int backgroundColor; 103 | 104 | protected boolean spinnerClockwise = true; 105 | 106 | protected boolean oneShot = false; 107 | 108 | protected boolean isTitleColorSet = false; 109 | protected boolean isMessageColorSet = false; 110 | protected boolean isSpinnerColorSet = false; 111 | protected boolean isBackgroundColorSet = false; 112 | 113 | public Builder(Context context) { 114 | this.context = context; 115 | this.theme = R.style.CamomileDialog; 116 | this.cancelable = true; 117 | this.titleGravity = Gravity.CENTER; 118 | this.messageGravity = Gravity.CENTER; 119 | this.dimAmount = 0.2f; 120 | 121 | if (this.mediumFont == null) { 122 | try { 123 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 124 | this.mediumFont = Typeface.create("sans-serif-medium", Typeface.NORMAL); 125 | } else { 126 | this.mediumFont = Typeface.create("sans-serif", Typeface.BOLD); 127 | } 128 | } catch (Exception ignored) { 129 | this.mediumFont = Typeface.DEFAULT_BOLD; 130 | } 131 | } 132 | if (this.regularFont == null) { 133 | try { 134 | this.regularFont = Typeface.create("sans-serif", Typeface.NORMAL); 135 | } catch (Exception ignored) { 136 | this.regularFont = Typeface.SANS_SERIF; 137 | if (this.regularFont == null) { 138 | this.regularFont = Typeface.DEFAULT; 139 | } 140 | } 141 | } 142 | } 143 | 144 | public Builder setTitle(@StringRes int titleRes) { 145 | setTitle(this.context.getText(titleRes)); 146 | return this; 147 | } 148 | 149 | public Builder setTitle(@NonNull CharSequence title) { 150 | this.title = title; 151 | return this; 152 | } 153 | 154 | public Builder setTitleGravity(int gravity) { 155 | this.titleGravity = gravity; 156 | return this; 157 | } 158 | 159 | public Builder setMessageContent(@StringRes int messageContent) { 160 | return setMessageContent(messageContent, false); 161 | } 162 | 163 | public Builder setMessageContent(@StringRes int messageContentRes, boolean html) { 164 | CharSequence text = this.context.getText(messageContentRes); 165 | if (html) { 166 | text = Html.fromHtml(text.toString().replace("\n", "
")); 167 | } 168 | return setMessageContent(text); 169 | } 170 | 171 | public Builder setMessageContent(@StringRes int messageContentRes, Object... formatArgs) { 172 | String str = String.format(this.context.getString(messageContentRes), formatArgs) 173 | .replace("\n", "
"); 174 | //noinspection deprecation 175 | return setMessageContent(Html.fromHtml(str)); 176 | } 177 | 178 | public Builder setMessageContent(@NonNull CharSequence messageContent) { 179 | if (this.customView != null) { 180 | throw new IllegalStateException("You cannot setMessageContent() " + 181 | "when you're using a custom view."); 182 | } 183 | this.message = messageContent; 184 | return this; 185 | } 186 | 187 | public Builder setMessageContentGravity(int gravity) { 188 | this.messageGravity = gravity; 189 | return this; 190 | } 191 | 192 | public Builder setMessageColor(@ColorInt int color) { 193 | this.messageColor = color; 194 | this.isMessageColorSet = true; 195 | return this; 196 | } 197 | 198 | public Builder setMessageColorRes(@ColorRes int colorRes) { 199 | return setMessageColor(DialogUtils.getColor(this.context, colorRes)); 200 | } 201 | 202 | public Builder setMessageColorAttr(@AttrRes int colorAttr) { 203 | return setMessageColor(DialogUtils.resolveColor(this.context, colorAttr)); 204 | } 205 | 206 | public Builder setCancelable(boolean cancelable) { 207 | this.cancelable = cancelable; 208 | return this; 209 | } 210 | 211 | public Builder setOnCancelListener(@NonNull OnCancelListener cancelListener) { 212 | this.cancelListener = cancelListener; 213 | return this; 214 | } 215 | 216 | public Builder setOnShowListener(@NonNull OnShowListener showListener) { 217 | this.showListener = showListener; 218 | return this; 219 | } 220 | 221 | public Builder setOnDismissListener(@NonNull OnDismissListener dismissListener) { 222 | this.dismissListener = dismissListener; 223 | return this; 224 | } 225 | 226 | public Builder setOnKeyListener(@NonNull OnKeyListener keyListener) { 227 | this.keyListener = keyListener; 228 | return this; 229 | } 230 | 231 | /** 232 | * @param indeterminate indeterminate 233 | * @return {@link Builder} IOSDialog.Builder 234 | * @deprecated Do not use this method, it's not working now! 235 | */ 236 | @Deprecated 237 | public Builder setIndeterminate(boolean indeterminate) { 238 | this.indeterminate = indeterminate; 239 | return this; 240 | } 241 | 242 | /** 243 | * @param dimAmount dimAmount 244 | * @return {@link Builder} IOSDialog.Builder 245 | * @deprecated Do not use this method, it's not working now! 246 | */ 247 | @Deprecated 248 | public Builder setDimAmount(float dimAmount) { 249 | this.dimAmount = dimAmount; 250 | return this; 251 | } 252 | 253 | public Builder setSpinnerColor(@ColorInt int color) { 254 | this.spinnerColor = color; 255 | this.isSpinnerColorSet = true; 256 | return this; 257 | } 258 | 259 | public Builder setSpinnerColorRes(@ColorRes int colorRes) { 260 | return setSpinnerColor(DialogUtils.getColor(this.context, colorRes)); 261 | } 262 | 263 | public Builder setSpinnerColorAttr(@AttrRes int colorAttr) { 264 | return setSpinnerColor(DialogUtils.resolveColor(this.context, colorAttr)); 265 | } 266 | 267 | public Builder setSpinnerDuration(int spinnerDuration) { 268 | this.spinnerDuration = spinnerDuration; 269 | return this; 270 | } 271 | 272 | public Builder setSpinnerClockwise(boolean spinnerClockwise) { 273 | this.spinnerClockwise = spinnerClockwise; 274 | return this; 275 | } 276 | 277 | public Builder setOneShot(boolean oneShot) { 278 | this.oneShot = oneShot; 279 | return this; 280 | } 281 | 282 | public Builder setTitleColor(@ColorInt int color) { 283 | this.titleColor = color; 284 | this.isTitleColorSet = true; 285 | return this; 286 | } 287 | 288 | public Builder setTitleColorRes(@ColorRes int colorRes) { 289 | return setTitleColor(DialogUtils.getColor(this.context, colorRes)); 290 | } 291 | 292 | public Builder setTitleColorAttr(@AttrRes int colorAttr) { 293 | return setTitleColor(DialogUtils.resolveColor(this.context, colorAttr)); 294 | } 295 | 296 | /** 297 | * @param color IOSDialog background ColorInt 298 | * @return {@link Builder} IOSDialog.Builder 299 | * @deprecated Do not use this method, it's not working now! 300 | */ 301 | @Deprecated 302 | public Builder setBackgroundColor(@ColorInt int color) { 303 | this.backgroundColor = color; 304 | this.isBackgroundColorSet = true; 305 | return this; 306 | } 307 | 308 | /** 309 | * @param colorRes IOSDialog background colorRes 310 | * @return {@link Builder} IOSDialog.Builder 311 | * @deprecated Do not use this method, it's not working now! 312 | */ 313 | @Deprecated 314 | public Builder setBackgroundColorRes(@ColorRes int colorRes) { 315 | return setBackgroundColor(DialogUtils.getColor(this.context, colorRes)); 316 | } 317 | 318 | /** 319 | * @param colorAttr IOSDialog background colorAttr 320 | * @return {@link Builder} IOSDialog.Builder 321 | * @deprecated Do not use this method, it's not working now! 322 | */ 323 | @Deprecated 324 | public Builder setBackgroundColorAttr(@AttrRes int colorAttr) { 325 | return setBackgroundColor(DialogUtils.resolveColor(this.context, colorAttr)); 326 | } 327 | 328 | public Builder setTheme(@StyleRes int theme) { 329 | this.theme = theme; 330 | return this; 331 | } 332 | 333 | //TODO:: add setCustomView 334 | //TODO:: add set title icon 335 | 336 | @UiThread 337 | public IOSDialog build() { 338 | return new IOSDialog(this); 339 | } 340 | 341 | @UiThread 342 | public IOSDialog show() { 343 | IOSDialog dialog = build(); 344 | dialog.show(); 345 | return dialog; 346 | } 347 | 348 | } 349 | 350 | //methods for future features 351 | private Drawable adjust(Drawable d) { 352 | int to = Color.RED; 353 | 354 | //Need to copy to ensure that the bitmap is mutable. 355 | Bitmap src = ((BitmapDrawable) d).getBitmap(); 356 | Bitmap bitmap = src.copy(Bitmap.Config.ARGB_8888, true); 357 | for(int x = 0;x < bitmap.getWidth();x++) 358 | for(int y = 0;y < bitmap.getHeight();y++) 359 | if(match(bitmap.getPixel(x, y))) 360 | bitmap.setPixel(x, y, to); 361 | 362 | return new BitmapDrawable(bitmap); 363 | } 364 | 365 | private Bitmap adjust(Bitmap src) { 366 | int to = Color.RED; 367 | 368 | Bitmap bitmap = src.copy(Bitmap.Config.ARGB_8888, true); 369 | for(int x = 0;x < bitmap.getWidth();x++) 370 | for(int y = 0;y < bitmap.getHeight();y++) 371 | if(match(bitmap.getPixel(x, y))) 372 | bitmap.setPixel(x, y, to); 373 | 374 | return bitmap; 375 | } 376 | 377 | private static final int[] FROM_COLOR = new int[]{49, 179, 110}; 378 | private static final int THRESHOLD = 3; 379 | private boolean match(int pixel) { 380 | //There may be a better way to match, but I wanted to do a comparison ignoring 381 | //transparency, so I couldn't just do a direct integer compare. 382 | return Math.abs(Color.red(pixel) - FROM_COLOR[0]) < THRESHOLD && 383 | Math.abs(Color.green(pixel) - FROM_COLOR[1]) < THRESHOLD && 384 | Math.abs(Color.blue(pixel) - FROM_COLOR[2]) < THRESHOLD; 385 | } 386 | 387 | } 388 | -------------------------------------------------------------------------------- /iosdialog/src/main/java/com/gmail/samehadar/iosdialog/utils/DialogUtils.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog.utils; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.PorterDuff; 6 | import android.graphics.drawable.AnimationDrawable; 7 | import android.graphics.drawable.Drawable; 8 | import android.support.annotation.AttrRes; 9 | import android.support.annotation.ColorInt; 10 | import android.support.annotation.ColorRes; 11 | import android.support.v4.content.ContextCompat; 12 | 13 | import com.gmail.samehadar.iosdialog.R; 14 | 15 | import java.util.ArrayList; 16 | import java.util.Collections; 17 | import java.util.List; 18 | 19 | public class DialogUtils { 20 | 21 | private static List petals; 22 | private static final int PETALS_COUNT = 12; 23 | 24 | private static final int DEFAULT_DURATION = 60; 25 | 26 | /** 27 | * Returns a color associated with a particular resource ID 28 | *

29 | * Starting in {@link android.os.Build.VERSION_CODES#M}, the returned 30 | * color will be styled for the specified Context's theme. 31 | * 32 | * @param context Current application context 33 | * @param colorId The desired resource identifier, as generated by the aapt tool. This integer 34 | * encodes the package, type, and resource entry. The value 0 is an invalid identifier. 35 | * @return A single color value in the form 0xAARRGGBB. 36 | */ 37 | @ColorInt 38 | public static int getColor(Context context, @ColorRes int colorId) { 39 | return ContextCompat.getColor(context, colorId); 40 | } 41 | 42 | @ColorInt 43 | public static int resolveColor(Context context, @AttrRes int attr) { 44 | return resolveColor(context, attr, 0); 45 | } 46 | 47 | @ColorInt 48 | public static int resolveColor(Context context, @AttrRes int attr, int fallback) { 49 | TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr}); 50 | try { 51 | return a.getColor(0, fallback); 52 | } finally { 53 | a.recycle(); 54 | } 55 | } 56 | 57 | public static AnimationDrawable createAnimation(Context context) { 58 | return (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.spinner); 59 | } 60 | 61 | public static AnimationDrawable createAnimation(Context context, @ColorInt int color) { 62 | return createAnimation(context, color, DEFAULT_DURATION); 63 | } 64 | 65 | public static AnimationDrawable createAnimation(Context context, @ColorInt int color, int duration) { 66 | return createAnimation(context, color, duration, true); 67 | 68 | } 69 | 70 | public static AnimationDrawable createAnimation(Context context, @ColorInt int color, int duration, boolean clockwise) { 71 | if (petals == null) { 72 | petals = new ArrayList<>(PETALS_COUNT); 73 | Drawable dr0 = ContextCompat.getDrawable(context, R.drawable.spinner_0); 74 | Drawable dr1 = ContextCompat.getDrawable(context, R.drawable.spinner_1); 75 | Drawable dr2 = ContextCompat.getDrawable(context, R.drawable.spinner_2); 76 | Drawable dr3 = ContextCompat.getDrawable(context, R.drawable.spinner_3); 77 | Drawable dr4 = ContextCompat.getDrawable(context, R.drawable.spinner_4); 78 | Drawable dr5 = ContextCompat.getDrawable(context, R.drawable.spinner_5); 79 | Drawable dr6 = ContextCompat.getDrawable(context, R.drawable.spinner_6); 80 | Drawable dr7 = ContextCompat.getDrawable(context, R.drawable.spinner_7); 81 | Drawable dr8 = ContextCompat.getDrawable(context, R.drawable.spinner_8); 82 | Drawable dr9 = ContextCompat.getDrawable(context, R.drawable.spinner_9); 83 | Drawable dr10 = ContextCompat.getDrawable(context, R.drawable.spinner_10); 84 | Drawable dr11 = ContextCompat.getDrawable(context, R.drawable.spinner_11); 85 | Collections.addAll(petals 86 | , dr0 87 | , dr1 88 | , dr2 89 | , dr3 90 | , dr4 91 | , dr5 92 | , dr6 93 | , dr7 94 | , dr8 95 | , dr9 96 | , dr10 97 | , dr11 98 | ); 99 | } 100 | AnimationDrawable animation = new AnimationDrawable(); 101 | List drawables = new ArrayList<>(PETALS_COUNT); 102 | for (Drawable drawable : petals) { 103 | Drawable drwNewCopy = drawable.getConstantState().newDrawable().mutate(); 104 | drwNewCopy.setColorFilter(color, PorterDuff.Mode.MULTIPLY); 105 | drawables.add(drwNewCopy); 106 | } 107 | if (!clockwise) { 108 | Collections.reverse(drawables); 109 | } 110 | for (Drawable drawable: drawables) { 111 | animation.addFrame(drawable, duration); 112 | } 113 | return animation; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/progress_hud_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 10 | 13 | 16 | 19 | 22 | 25 | 28 | 31 | 34 | 37 | 40 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_0.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_1.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_10.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_11.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_2.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_3.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_4.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_5.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_6.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_7.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_8.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/drawable/spinner_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Samehadar/IOSDialog/d22a0353f32c83c6d1a7986af6b7b6fbc183eb6f/iosdialog/src/main/res/drawable/spinner_9.png -------------------------------------------------------------------------------- /iosdialog/src/main/res/layout/ios_progress_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 24 | 25 | 26 | 35 | 42 | 43 | 44 | 50 | 51 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #7B1FA2 6 | #6A1B9A 7 | #DD2C00 8 | #EF5350 9 | 10 | 11 | #ff404040 12 | #E91E63 13 | #FFFFFF 14 | 15 | 16 | #8E8E93 17 | #BDBEC2 18 | #C7C7CC 19 | 20 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8dp 4 | 5 | 24dp 6 | 7 | 12dp 8 | 16dp 9 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | IOSDialog 3 | Title 4 | Message 5 | 6 | -------------------------------------------------------------------------------- /iosdialog/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /iosdialog/src/test/java/com/gmail/samehadar/iosdialog/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.samehadar.iosdialog; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':iosdialog' 2 | --------------------------------------------------------------------------------