diff --git a/README.md b/README.md
index a29fc36..4451d43 100644
--- a/README.md
+++ b/README.md
@@ -1,64 +1,33 @@
# StyledDialogs for Android
-This library makes styling and using dialogs _a piece of cake_.
-
![Screenshot of the dialogs](graphics/screenshot-small.png)
Features:
- - Compatible with Holo style and **Android Design Guidelines**
- - Change style for all dialogs only by changing a **few color resources**
+ - Compatible with **Material Design Guidelines**
- Same look for **Android 2.2+**
- - **Same API** as native Android DialogFragments
- - `SimpleDialogFragment` class, which makes displaying simple dialogs a **one line of code**
- - `ListDialogFragment`, `DatePickerDialogFragment` and `TimePickerDialogFragment`
+ - Built on top of standard **DialogFragment**
+ - Supports stacked buttons, neutral button, callbacks even after rotation
+ - Contains even more specialized dialogs: List, Progress, Time&Date Picker, Custom, ...
## How to include it in your project:
-With Gradle:
```groovy
-compile 'eu.inmite.android.lib:android-styled-dialogs:1.2.0'
+dependencies {
+ compile 'com.avast:android-styled-dialogs:2.0.0'
+}
```
-
-With Maven:
-```xml
-
- eu.inmite.android.lib
- android-styled-dialogs
- 1.2.0
- aar
-
-```
-
-Manually:
-
- - clone the project
- - add it as library project in your IDE
- - include latest support library
+(from [jcenter](https://bintray.com/avast/android/styled-dialogs/))
## How to style all dialogs:
-Add following into your application theme:
-```xml
-@style/DialogStyleLight.Custom
-```
-or
-```xml
-@style/DialogStyleDark.Custom
-```
-Define your dialog style, example for light theme:
+It uses standard Material colors, for example like this:
+
```xml
-
```
@@ -66,14 +35,11 @@ Define your dialog style, example for light theme:
Easy:
-### Dialog with a simple message and Close button:
+### Dialog with a simple message only:
```java
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setMessage(R.string.message).show();
```
-### Dialog with a title, message and Close button:
-```java
-SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).show();
-```
+
### Dialog with a title, message and two buttons:
```java
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).setPositiveButtonText(R.string.positive_button).setNegativeButtonText(R.string.negative_button).show();
diff --git a/build.gradle b/build.gradle
index 15a299f..ea87842 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
buildscript {
repositories {
- mavenCentral()
+ jcenter()
}
dependencies {
@@ -9,12 +9,14 @@ buildscript {
}
allprojects {
- version = VERSION_NAME
- group = GROUP
-
repositories {
- mavenCentral()
+ jcenter()
}
}
+ext {
+ VERSION_NAME = "2.0.1"
+ VERSION_CODE = 6
+}
+
apply plugin: 'android-reporting'
\ No newline at end of file
diff --git a/demo/build.gradle b/demo/build.gradle
index dc643c6..73c130b 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -5,13 +5,13 @@ android {
buildToolsVersion "20"
defaultConfig {
- minSdkVersion 7
+ minSdkVersion 8
targetSdkVersion 21
versionName project.VERSION_NAME
- versionCode Integer.parseInt(project.VERSION_CODE)
+ versionCode project.VERSION_CODE
}
}
dependencies {
- compile project(':library')
+ compile project(":library")
}
\ No newline at end of file
diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml
index f8b6c4d..c2282bd 100644
--- a/demo/src/main/AndroidManifest.xml
+++ b/demo/src/main/AndroidManifest.xml
@@ -1,19 +1,14 @@
+ package="com.avast.dialogs">
-
+ android:theme="@style/AppTheme"
+ android:allowBackup="true">
+ android:name=".DemoActivity">
diff --git a/demo/src/main/java/com/avast/dialogs/DemoActivity.java b/demo/src/main/java/com/avast/dialogs/DemoActivity.java
new file mode 100644
index 0000000..4f1ff1c
--- /dev/null
+++ b/demo/src/main/java/com/avast/dialogs/DemoActivity.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2013 Inmite s.r.o. (www.inmite.eu).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.avast.dialogs;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+import android.view.View;
+import android.widget.Toast;
+
+import com.avast.android.dialogs.fragment.*;
+import com.avast.android.dialogs.iface.IDateDialogListener;
+import com.avast.android.dialogs.iface.IListDialogListener;
+import com.avast.android.dialogs.iface.ISimpleDialogCancelListener;
+import com.avast.android.dialogs.iface.ISimpleDialogListener;
+
+public class DemoActivity extends ActionBarActivity implements
+ ISimpleDialogListener,
+ IDateDialogListener,
+ ISimpleDialogCancelListener,
+ IListDialogListener {
+
+ private static final int REQUEST_PROGRESS = 1;
+
+ DemoActivity c = this;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ findViewById(R.id.message_dialog).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
+ .setMessage("Love. Can know all the math in the \'verse but take a boat in the air that you don\'t " +
+ "love? She\'ll shake you off just as sure as a turn in the worlds. Love keeps her in the air when " +
+ "she oughtta fall down...tell you she\'s hurtin\' \'fore she keens...makes her a home.").show();
+ }
+ });
+ findViewById(R.id.message_title_dialog).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
+ .setTitle("More Firefly quotes:").setMessage
+ ("Wash: \"Psychic, though? That sounds like something out of science fiction.\"\n\nZoe: \"We live" +
+ " " +
+ "in a space ship, dear.\"\nWash: \"Here lies my beloved Zoe, " +
+ ("my autumn flower ... somewhat less attractive now that she's all corpsified and gross" +
+ ".\"\n\nRiver Tam: \"Also? I can kill you with my brain.\"\n\nKayle: \"Going on a year now, nothins twixed my neathers not run on batteries.\" \n" +
+ "Mal: \"I can't know that.\" \n" +
+ "Jayne: \"I can stand to hear a little more.\"\n\nWash: \"I've been under fire before. " +
+ "Well ... I've been in a fire. Actually, I was fired. I can handle myself.\""))
+ .setNegativeButtonText("Close")
+ .show();
+ }
+ });
+ findViewById(R.id.message_title_buttons_dialog)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
+ .setTitle("Do you like this quote?")
+ .setMessage("Jayne: \"Shiny. Let's be bad guys.\"")
+ .setPositiveButtonText("Love")
+ .setNegativeButtonText("Hate").setNeutralButtonText("WTF?").setRequestCode(42)
+ .show();
+ }
+ });
+ findViewById(R.id.long_buttons).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ SimpleDialogFragment.createBuilder(c, getSupportFragmentManager()).setMessage("How will you decide?")
+ .setPositiveButtonText("Time for some thrillin' heroics!").setNegativeButtonText("Misbehave")
+ .setNeutralButtonText("Keep flying").show();
+ }
+ });
+ findViewById(R.id.progress_dialog).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ProgressDialogFragment.createBuilder(c, getSupportFragmentManager())
+ .setMessage("Mal: I\'m just waiting to see if I pass out. Long story.")
+ .setRequestCode(REQUEST_PROGRESS)
+ .show();
+ }
+ });
+ findViewById(R.id.list_dialog).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ListDialogFragment
+ .createBuilder(c, getSupportFragmentManager())
+ .setTitle("Your favorite character:")
+ .setItems(new String[]{"Jayne", "Malcolm", "Kaylee",
+ "Wash", "Zoe", "River"})
+ .show();
+
+ }
+ });
+ findViewById(R.id.custom_dialog).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ JayneHatDialogFragment.show(c);
+ }
+ });
+ findViewById(R.id.time_picker).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ TimePickerDialogFragment
+ .createBuilder(DemoActivity.this, getSupportFragmentManager())
+ .setDate(new Date())
+ .set24hour(true)
+ .setPositiveButtonText(android.R.string.ok)
+ .setNegativeButtonText(android.R.string.cancel)
+ .setRequestCode(13)
+ .show();
+ }
+ });
+ findViewById(R.id.date_picker).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ DatePickerDialogFragment
+ .createBuilder(DemoActivity.this, getSupportFragmentManager())
+ .setDate(new Date())
+ .set24hour(true)
+ .setPositiveButtonText(android.R.string.ok)
+ .setNegativeButtonText(android.R.string.cancel)
+ .setRequestCode(12)
+ .show();
+ }
+ });
+ }
+
+ // IListDialogListener
+
+ @Override
+ public void onListItemSelected(String value, int number) {
+ Toast.makeText(c, "Selected: " + value, Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onCancelled() {
+ Toast.makeText(c, "Nothing selected", Toast.LENGTH_SHORT).show();
+ }
+
+ // ISimpleDialogCancelListener
+
+ @Override
+ public void onCancelled(int requestCode) {
+ if (requestCode == 42) {
+ Toast.makeText(c, "Dialog cancelled", Toast.LENGTH_SHORT).show();
+ } else if (requestCode == REQUEST_PROGRESS) {
+ Toast.makeText(c, "Progress dialog cancelled", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ // ISimpleDialogListener
+
+ @Override
+ public void onPositiveButtonClicked(int requestCode) {
+ if (requestCode == 42) {
+ Toast.makeText(c, "Positive button clicked", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Override
+ public void onNegativeButtonClicked(int requestCode) {
+ if (requestCode == 42) {
+ Toast.makeText(c, "Negative button clicked", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Override
+ public void onNeutralButtonClicked(int requestCode) {
+ if (requestCode == 42) {
+ Toast.makeText(c, "Neutral button clicked", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ // IDateDialogListener
+
+ @Override
+ public void onNegativeButtonClicked(int resultCode, Date date) {
+ String text = "";
+ if (resultCode == 12) {
+ text = "Date ";
+ } else if (resultCode == 13) {
+ text = "Time ";
+ }
+
+ DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT);
+ Toast.makeText(this, text + "Cancelled " + dateFormat.format(date), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onPositiveButtonClicked(int resultCode, Date date) {
+ String text = "";
+ if (resultCode == 12) {
+ text = "Date ";
+ } else if (resultCode == 13) {
+ text = "Time ";
+ }
+
+ DateFormat dateFormat = DateFormat.getDateTimeInstance();
+ Toast.makeText(this, text + "Success! " + dateFormat.format(date), Toast.LENGTH_SHORT).show();
+ }
+}
diff --git a/demo/src/main/java/eu/inmite/demo/dialogs/JayneHatDialogFragment.java b/demo/src/main/java/com/avast/dialogs/JayneHatDialogFragment.java
similarity index 80%
rename from demo/src/main/java/eu/inmite/demo/dialogs/JayneHatDialogFragment.java
rename to demo/src/main/java/com/avast/dialogs/JayneHatDialogFragment.java
index f6140a5..ffdf4b9 100644
--- a/demo/src/main/java/eu/inmite/demo/dialogs/JayneHatDialogFragment.java
+++ b/demo/src/main/java/com/avast/dialogs/JayneHatDialogFragment.java
@@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package eu.inmite.demo.dialogs;
+package com.avast.dialogs;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
-import eu.inmite.android.lib.dialogs.BaseDialogFragment;
-import eu.inmite.android.lib.dialogs.ISimpleDialogListener;
-import eu.inmite.android.lib.dialogs.SimpleDialogFragment;
+import com.avast.android.dialogs.core.BaseDialogFragment;
+import com.avast.android.dialogs.fragment.SimpleDialogFragment;
+import com.avast.android.dialogs.iface.ISimpleDialogListener;
/**
- * Sample implementation of eu.inmite.android.lib.dialogs.BaseDialogFragment - custom view by extending {@link SimpleDialogFragment}.
+ * Sample implementation of custom dialog by extending {@link SimpleDialogFragment}.
*
* @author David Vávra (david@inmite.eu)
*/
@@ -39,7 +39,7 @@ public static void show(FragmentActivity activity) {
@Override
public BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
builder.setTitle("Jayne's hat");
- builder.setView(LayoutInflater.from(getActivity()).inflate(R.layout.item_jayne_hat, null));
+ builder.setView(LayoutInflater.from(getActivity()).inflate(R.layout.view_jayne_hat, null));
builder.setPositiveButton("I want one", new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/demo/src/main/java/eu/inmite/demo/dialogs/MyActivity.java b/demo/src/main/java/eu/inmite/demo/dialogs/MyActivity.java
deleted file mode 100644
index a9531e6..0000000
--- a/demo/src/main/java/eu/inmite/demo/dialogs/MyActivity.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2013 Inmite s.r.o. (www.inmite.eu).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package eu.inmite.demo.dialogs;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-import android.view.View;
-import android.widget.Toast;
-
-import java.text.DateFormat;
-import java.util.Date;
-
-import eu.inmite.android.lib.dialogs.DatePickerDialogFragment;
-import eu.inmite.android.lib.dialogs.IDateDialogListener;
-import eu.inmite.android.lib.dialogs.IListDialogListener;
-import eu.inmite.android.lib.dialogs.ISimpleDialogCancelListener;
-import eu.inmite.android.lib.dialogs.ISimpleDialogListener;
-import eu.inmite.android.lib.dialogs.ListDialogFragment;
-import eu.inmite.android.lib.dialogs.ProgressDialogFragment;
-import eu.inmite.android.lib.dialogs.SimpleDialogFragment;
-import eu.inmite.android.lib.dialogs.TimePickerDialogFragment;
-
-public class MyActivity extends FragmentActivity implements
- ISimpleDialogListener,
- IDateDialogListener,
- ISimpleDialogCancelListener,
- IListDialogListener {
-
- public static final int THEME_DEFAULT_DARK = 0;
-
- public static final int THEME_DEFAULT_LIGHT = 1;
-
- public static final int THEME_CUSTOM_DARK = 2;
-
- public static final int THEME_CUSTOM_LIGHT = 3;
-
- public static final String EXTRA_THEME = "theme";
-
- private static final int REQUEST_PROGRESS = 1;
-
- MyActivity c = this;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- setThemeOnCreate();
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- findViewById(R.id.message_dialog).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
- .setMessage(R.string.message_1).show();
- }
- });
- findViewById(R.id.message_title_dialog).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
- .setTitle(R.string.title).setMessage(R.string.message_2).show();
- }
- });
- findViewById(R.id.message_title_buttons_dialog)
- .setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
- .setTitle(R.string.title)
- .setMessage(R.string.message_3)
- .setPositiveButtonText(R.string.positive_button)
- .setNegativeButtonText(R.string.negative_button).setRequestCode(42)
- .setTag("custom-tag")
- .show();
- }
- });
- findViewById(R.id.progress_dialog).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ProgressDialogFragment.createBuilder(c, getSupportFragmentManager())
- .setMessage(R.string.message_4)
- .setRequestCode(REQUEST_PROGRESS)
- .setTitle(R.string.app_name)
- .show();
- }
- });
- findViewById(R.id.list_dialog).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ListDialogFragment
- .createBuilder(c, getSupportFragmentManager())
- .setTitle("Your favorite character:")
- .setItems(new String[]{"Jayne", "Malcolm", "Kaylee",
- "Wash", "Zoe", "River"})
- .show();
-
- }
- });
- findViewById(R.id.custom_dialog).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- JayneHatDialogFragment.show(c);
- }
- });
- findViewById(R.id.default_dark_theme).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setCurrentTheme(THEME_DEFAULT_DARK);
- }
- });
- findViewById(R.id.default_light_theme).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setCurrentTheme(THEME_DEFAULT_LIGHT);
- }
- });
- findViewById(R.id.custom_dark_theme).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setCurrentTheme(THEME_CUSTOM_DARK);
- }
- });
- findViewById(R.id.custom_light_theme).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setCurrentTheme(THEME_CUSTOM_LIGHT);
- }
- });
- findViewById(R.id.time_picker).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- TimePickerDialogFragment
- .createBuilder(MyActivity.this, getSupportFragmentManager())
- .setDate(new Date())
- .set24hour(true)
- .setPositiveButtonText(android.R.string.ok)
- .setNegativeButtonText(android.R.string.cancel)
- .setRequestCode(13)
- .show();
- }
- });
- findViewById(R.id.date_picker).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- DatePickerDialogFragment
- .createBuilder(MyActivity.this, getSupportFragmentManager())
- .setDate(new Date())
- .set24hour(true)
- .setPositiveButtonText(android.R.string.ok)
- .setNegativeButtonText(android.R.string.cancel)
- .setRequestCode(12)
- .show();
- }
- });
- }
-
- // IListDialogListener
-
- @Override
- public void onListItemSelected(String value, int number) {
- Toast.makeText(c, "Selected: " + value, Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void onCancelled() {
- Toast.makeText(c, "Nothing selected", Toast.LENGTH_SHORT).show();
- }
-
- // ISimpleDialogCancelListener
-
- @Override
- public void onCancelled(int requestCode) {
- if (requestCode == 42) {
- Toast.makeText(c, "Dialog cancelled", Toast.LENGTH_SHORT).show();
- } else if (requestCode == REQUEST_PROGRESS) {
- Toast.makeText(c, "Progress dialog cancelled", Toast.LENGTH_SHORT).show();
- }
- }
-
- // ISimpleDialogListener
-
- @Override
- public void onPositiveButtonClicked(int requestCode) {
- if (requestCode == 42) {
- Toast.makeText(c, "Positive button clicked", Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onNegativeButtonClicked(int requestCode) {
- if (requestCode == 42) {
- Toast.makeText(c, "Negative button clicked", Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onNeutralButtonClicked(int requestCode) {
- if (requestCode == 42) {
- Toast.makeText(c, "Neutral button clicked", Toast.LENGTH_SHORT).show();
- }
- }
-
- // IDateDialogListener
-
- @Override
- public void onNegativeButtonClicked(int resultCode, Date date) {
- String text="";
- if (resultCode==12) {
- text="Date ";
- } else if (resultCode==13) {
- text="Time ";
- }
-
- DateFormat dateFormat= DateFormat.getDateInstance(DateFormat.DEFAULT);
- Toast.makeText(this,text+"Cancelled "+ dateFormat.format(date),Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void onPositiveButtonClicked(int resultCode, Date date) {
- String text="";
- if (resultCode==12) {
- text="Date ";
- } else if (resultCode==13) {
- text="Time ";
- }
-
- DateFormat dateFormat= DateFormat.getDateTimeInstance();
- Toast.makeText(this,text+ "Success! "+ dateFormat.format(date),Toast.LENGTH_SHORT).show();
- }
-
- private void setCurrentTheme(int theme) {
- Intent i = new Intent(c, MyActivity.class);
- i.putExtra(EXTRA_THEME, theme);
- startActivity(i);
- finish();
- overridePendingTransition(0, 0);
- }
-
- private void setThemeOnCreate() {
- int theme = getIntent().getIntExtra(EXTRA_THEME, THEME_CUSTOM_DARK);
- switch (theme) {
- case THEME_DEFAULT_DARK:
- setTheme(R.style.DefaultDarkTheme);
- break;
- case THEME_DEFAULT_LIGHT:
- setTheme(R.style.DefaultLightTheme);
- break;
- case THEME_CUSTOM_DARK:
- setTheme(R.style.CustomDarkTheme);
- break;
- case THEME_CUSTOM_LIGHT:
- setTheme(R.style.CustomLightTheme);
- break;
- }
- }
-}
diff --git a/demo/src/main/res/drawable-hdpi/ic_launcher.png b/demo/src/main/res/drawable-hdpi/ic_launcher.png
old mode 100644
new mode 100755
index 96a442e..091c6af
Binary files a/demo/src/main/res/drawable-hdpi/ic_launcher.png and b/demo/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/demo/src/main/res/drawable-ldpi/ic_launcher.png b/demo/src/main/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index 9923872..0000000
Binary files a/demo/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/demo/src/main/res/drawable-mdpi/ic_launcher.png b/demo/src/main/res/drawable-mdpi/ic_launcher.png
old mode 100644
new mode 100755
index 359047d..9491280
Binary files a/demo/src/main/res/drawable-mdpi/ic_launcher.png and b/demo/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/demo/src/main/res/drawable-xhdpi/ic_launcher.png b/demo/src/main/res/drawable-xhdpi/ic_launcher.png
old mode 100644
new mode 100755
index 71c6d76..8b6882c
Binary files a/demo/src/main/res/drawable-xhdpi/ic_launcher.png and b/demo/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/demo/src/main/res/drawable-xhdpi/jayne_icon.png b/demo/src/main/res/drawable-xhdpi/jayne_icon.png
deleted file mode 100644
index dd5bf1e..0000000
Binary files a/demo/src/main/res/drawable-xhdpi/jayne_icon.png and /dev/null differ
diff --git a/demo/src/main/res/drawable-xxhdpi/ic_launcher.png b/demo/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755
index 0000000..e141f4d
Binary files /dev/null and b/demo/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/demo/src/main/res/drawable-xxxhdpi/ic_launcher.png b/demo/src/main/res/drawable-xxxhdpi/ic_launcher.png
new file mode 100755
index 0000000..c466224
Binary files /dev/null and b/demo/src/main/res/drawable-xxxhdpi/ic_launcher.png differ
diff --git a/demo/src/main/res/layout/item_list.xml b/demo/src/main/res/layout/item_list.xml
deleted file mode 100644
index 83ded4a..0000000
--- a/demo/src/main/res/layout/item_list.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/layout/main.xml b/demo/src/main/res/layout/main.xml
index e81d0d5..dbda732 100644
--- a/demo/src/main/res/layout/main.xml
+++ b/demo/src/main/res/layout/main.xml
@@ -9,59 +9,31 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+ android:text="List dialog"
+ android:id="@+id/list_dialog" />
+ android:text="Time picker dialog" />
+ android:text="Date picker dialog"/>
+
+
diff --git a/demo/src/main/res/layout/item_jayne_hat.xml b/demo/src/main/res/layout/view_jayne_hat.xml
similarity index 80%
rename from demo/src/main/res/layout/item_jayne_hat.xml
rename to demo/src/main/res/layout/view_jayne_hat.xml
index e707e29..9afcc20 100644
--- a/demo/src/main/res/layout/item_jayne_hat.xml
+++ b/demo/src/main/res/layout/view_jayne_hat.xml
@@ -3,4 +3,5 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/jayne_hat"
+ android:contentDescription="Jayne has the best hat ever"
android:padding="@dimen/grid_2"/>
\ No newline at end of file
diff --git a/demo/src/main/res/values-v11/theme.xml b/demo/src/main/res/values-v11/theme.xml
deleted file mode 100644
index ed04a03..0000000
--- a/demo/src/main/res/values-v11/theme.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/values/colors.xml b/demo/src/main/res/values/colors.xml
index 424f0e1..5d0d3b2 100644
--- a/demo/src/main/res/values/colors.xml
+++ b/demo/src/main/res/values/colors.xml
@@ -1,23 +1,7 @@
- #333333
- #f3a71e
- #f3a71e
- #333333
- @android:color/transparent
- #99f3a71e
- #4Cf3a71e
- #25000000
- #FFA500
-
- #FFFFFF
- #F8A500
- #F8A500
- #FFFFFF
- @android:color/transparent
- #99F8A500
- #4CF8A500
- #12FFFFFF
- #C35817
+ #3F51B5
+ #303F9F
+ #FF4081
\ No newline at end of file
diff --git a/demo/src/main/res/values/strings.xml b/demo/src/main/res/values/strings.xml
index 9baada2..021a177 100644
--- a/demo/src/main/res/values/strings.xml
+++ b/demo/src/main/res/values/strings.xml
@@ -1,19 +1,4 @@
StyledDialogs Demo
- Favourite Firefly quote
- Love. Can know all the math in the \'verse but take a boat in the air that you
- don\'t
- love? She\'ll shake you off just as sure as a turn in the worlds. Love keeps her in the air when she oughtta
- fall
- down...tell you she\'s hurtin\' \'fore she keens...makes her a home.
-
- Wash: "Psychic, though? That sounds like something out of science fiction."\nZoe: "We live in a space ship, dear."
-
- Jayne: "Shiny. Let's be bad guys."
-
- Mal: I\'m just waiting to see if I pass out. Long story."
-
- Love
- Hate
diff --git a/demo/src/main/res/values/styles.xml b/demo/src/main/res/values/styles.xml
index e572623..6aababa 100644
--- a/demo/src/main/res/values/styles.xml
+++ b/demo/src/main/res/values/styles.xml
@@ -1,30 +1,12 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/values/theme.xml b/demo/src/main/res/values/theme.xml
index 5e76ecb..9ddbb44 100644
--- a/demo/src/main/res/values/theme.xml
+++ b/demo/src/main/res/values/theme.xml
@@ -1,54 +1,10 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index a3a2be7..0000000
--- a/gradle.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-VERSION_NAME=1.2.0
-VERSION_CODE=4
-GROUP=eu.inmite.android.lib
-
-POM_DESCRIPTION=Android library for creating styleable dialogs easily
-POM_URL=https://github.com/inmite/android-styled-dialogs
-POM_SCM_URL=https://github.com/inmite/android-styled-dialogs
-POM_SCM_CONNECTION=scm:git@github.com:inmite/android-styled-dialogs.git
-POM_SCM_DEV_CONNECTION=scm:git@github.com:inmite/android-styled-dialogs.git
-POM_LICENCE_NAME=The Apache Software License, Version 2.0
-POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
-POM_LICENCE_DIST=repo
-POM_DEVELOPER_ID=david@inmite.eu
-POM_DEVELOPER_NAME=David Vavra
\ No newline at end of file
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/graphics/screenshot-original.png b/graphics/screenshot-original.png
index f071257..1e9075e 100644
Binary files a/graphics/screenshot-original.png and b/graphics/screenshot-original.png differ
diff --git a/graphics/screenshot-small.png b/graphics/screenshot-small.png
index 90f4e83..ebf5bd4 100644
Binary files a/graphics/screenshot-small.png and b/graphics/screenshot-small.png differ
diff --git a/library/android-release-aar.gradle b/library/android-release-aar.gradle
new file mode 100644
index 0000000..64ae4f3
--- /dev/null
+++ b/library/android-release-aar.gradle
@@ -0,0 +1,61 @@
+// ./gradlew clean build generateRelease
+apply plugin: 'maven'
+
+def groupId = project.PUBLISH_GROUP_ID
+def artifactId = project.PUBLISH_ARTIFACT_ID
+def version = project.PUBLISH_VERSION
+
+def localReleaseDest = "${buildDir}/release/${version}"
+
+task androidJavadocs(type: Javadoc) {
+ source = android.sourceSets.main.java.srcDirs
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+}
+
+task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
+ classifier = 'javadoc'
+ from androidJavadocs.destinationDir
+}
+
+task androidSourcesJar(type: Jar) {
+ classifier = 'sources'
+ from android.sourceSets.main.java.srcDirs
+}
+
+uploadArchives {
+ repositories.mavenDeployer {
+ pom.groupId = groupId
+ pom.artifactId = artifactId
+ pom.version = version
+ // Add other pom properties here if you want (developer details / licenses)
+ repository(url: "file://${localReleaseDest}")
+ // workaround for: https://code.google.com/p/android/issues/detail?id=72807
+ pom.whenConfigured { pom ->
+ pom.dependencies.findAll { dependency ->
+ if (dependency.artifactId == 'appcompat-v7') {
+ dependency.type = 'aar'
+ }
+ }
+ }
+ }
+}
+
+task zipRelease(type: Zip) {
+ from localReleaseDest
+ destinationDir buildDir
+ archiveName "release-${version}.zip"
+}
+
+task generateRelease << {
+ println "Release ${version} can be found at ${localReleaseDest}/"
+ println "Release ${version} zipped can be found ${buildDir}/release-${version}.zip"
+}
+
+generateRelease.dependsOn(uploadArchives)
+generateRelease.dependsOn(zipRelease)
+
+
+artifacts {
+ archives androidSourcesJar
+ //archives androidJavadocs doesn't work for some reason
+}
diff --git a/library/build.gradle b/library/build.gradle
index 621c18f..bf6ea07 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,7 +1,9 @@
apply plugin: 'com.android.library'
-repositories {
- mavenCentral()
+ext {
+ PUBLISH_GROUP_ID = 'com.avast'
+ PUBLISH_ARTIFACT_ID = 'android-styled-dialogs'
+ PUBLISH_VERSION = project.VERSION_NAME
}
android {
@@ -9,16 +11,15 @@ android {
buildToolsVersion "20"
defaultConfig {
- minSdkVersion 7
+ minSdkVersion 8
targetSdkVersion 21
versionName project.VERSION_NAME
- versionCode Integer.parseInt(project.VERSION_CODE)
+ versionCode project.VERSION_CODE
}
}
dependencies {
- compile 'com.android.support:support-v4:21.0.3'
+ compile 'com.android.support:appcompat-v7:21.0.3'
}
-// Used to push in maven
-apply from: '../maven_push.gradle'
\ No newline at end of file
+apply from: 'android-release-aar.gradle'
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
index 7cf43ae..cc9ee9d 100644
--- a/library/src/main/AndroidManifest.xml
+++ b/library/src/main/AndroidManifest.xml
@@ -1,6 +1,2 @@
-
-
+
diff --git a/library/src/main/assets/fonts/Roboto-Medium.ttf b/library/src/main/assets/fonts/Roboto-Medium.ttf
new file mode 100644
index 0000000..a3c1a1f
Binary files /dev/null and b/library/src/main/assets/fonts/Roboto-Medium.ttf differ
diff --git a/library/src/main/assets/fonts/Roboto-Regular.ttf b/library/src/main/assets/fonts/Roboto-Regular.ttf
new file mode 100644
index 0000000..0e58508
Binary files /dev/null and b/library/src/main/assets/fonts/Roboto-Regular.ttf differ
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/BaseDialogBuilder.java b/library/src/main/java/com/avast/android/dialogs/core/BaseDialogBuilder.java
similarity index 96%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/BaseDialogBuilder.java
rename to library/src/main/java/com/avast/android/dialogs/core/BaseDialogBuilder.java
index 38f0c9c..28c69c5 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/BaseDialogBuilder.java
+++ b/library/src/main/java/com/avast/android/dialogs/core/BaseDialogBuilder.java
@@ -1,4 +1,4 @@
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.core;
import android.content.Context;
import android.os.Bundle;
@@ -11,7 +11,7 @@
*
* @author Tomas Vondracek
*/
-abstract class BaseDialogBuilder> {
+public abstract class BaseDialogBuilder> {
public final static String ARG_REQUEST_CODE = "request_code";
public final static String ARG_CANCELABLE_ON_TOUCH_OUTSIDE = "cancelable_oto";
diff --git a/library/src/main/java/com/avast/android/dialogs/core/BaseDialogFragment.java b/library/src/main/java/com/avast/android/dialogs/core/BaseDialogFragment.java
new file mode 100644
index 0000000..9601a9e
--- /dev/null
+++ b/library/src/main/java/com/avast/android/dialogs/core/BaseDialogFragment.java
@@ -0,0 +1,341 @@
+/*
+ * Copyright 2013 Inmite s.r.o. (www.inmite.eu).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.avast.android.dialogs.core;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.*;
+
+import com.avast.android.dialogs.R;
+import com.avast.android.dialogs.util.TypefaceHelper;
+
+/**
+ * Base dialog fragment for all your dialogs, stylable and same design on Android 2.2+.
+ *
+ * @author David Vávra (david@inmite.eu)
+ */
+public abstract class BaseDialogFragment extends DialogFragment implements DialogInterface.OnShowListener {
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ Dialog dialog = new Dialog(getActivity(), R.style.SDL_Dialog);
+ Bundle args = getArguments();
+ if (args != null) {
+ dialog.setCanceledOnTouchOutside(
+ args.getBoolean(BaseDialogBuilder.ARG_CANCELABLE_ON_TOUCH_OUTSIDE));
+ }
+ dialog.setOnShowListener(this);
+ return dialog;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ Builder builder = new Builder(getActivity(), inflater, container);
+ return build(builder).create();
+ }
+
+ protected abstract Builder build(Builder initialBuilder);
+
+ @Override
+ public void onDestroyView() {
+ // bug in the compatibility library
+ if (getDialog() != null && getRetainInstance()) {
+ getDialog().setDismissMessage(null);
+ }
+ super.onDestroyView();
+ }
+
+ public void showAllowingStateLoss(FragmentManager manager, String tag) {
+ FragmentTransaction ft = manager.beginTransaction();
+ ft.add(this, tag);
+ ft.commitAllowingStateLoss();
+ }
+
+ @Override
+ public void onShow(DialogInterface dialog) {
+ if (getView() != null) {
+ ScrollView vScrollView = (ScrollView)getView().findViewById(R.id.sdl_scrollview);
+ boolean scrollable = isScrollable(vScrollView);
+ modifyButtonsBasedOnScrollableContent(scrollable);
+ }
+ }
+
+ /**
+ * Button divider should be shown only if the content is scrollable.
+ */
+ private void modifyButtonsBasedOnScrollableContent(boolean scrollable) {
+ if (getView() == null) {
+ return;
+ }
+ View vButtonDivider = getView().findViewById(R.id.sdl_button_divider);
+ View vButtonsBottomSpace = getView().findViewById(R.id.sdl_buttons_bottom_space);
+ View vDefaultButtons = getView().findViewById(R.id.sdl_buttons_default);
+ View vStackedButtons = getView().findViewById(R.id.sdl_buttons_stacked);
+ if (vDefaultButtons.getVisibility() == View.GONE && vStackedButtons.getVisibility() == View.GONE) {
+ // no buttons
+ vButtonDivider.setVisibility(View.GONE);
+ vButtonsBottomSpace.setVisibility(View.GONE);
+ } else if (scrollable) {
+ vButtonDivider.setVisibility(View.VISIBLE);
+ vButtonsBottomSpace.setVisibility(View.GONE);
+ } else {
+ vButtonDivider.setVisibility(View.GONE);
+ vButtonsBottomSpace.setVisibility(View.VISIBLE);
+ }
+ }
+
+ boolean isScrollable(ScrollView scrollView) {
+ if (scrollView.getChildCount() == 0) {
+ return false;
+ }
+ final int childHeight = scrollView.getChildAt(0).getMeasuredHeight();
+ return scrollView.getMeasuredHeight() < childHeight;
+ }
+
+ /**
+ * Custom dialog builder
+ */
+ protected static class Builder {
+
+ private final Context mContext;
+
+ private final ViewGroup mContainer;
+
+ private final LayoutInflater mInflater;
+
+ private CharSequence mTitle = null;
+
+ private CharSequence mPositiveButtonText;
+
+ private View.OnClickListener mPositiveButtonListener;
+
+ private CharSequence mNegativeButtonText;
+
+ private View.OnClickListener mNegativeButtonListener;
+
+ private CharSequence mNeutralButtonText;
+
+ private View.OnClickListener mNeutralButtonListener;
+
+ private CharSequence mMessage;
+
+ private View mCustomView;
+
+ private ListAdapter mListAdapter;
+
+ private int mListCheckedItemIdx;
+
+ private AdapterView.OnItemClickListener mOnItemClickListener;
+
+
+
+ public Builder(Context context, LayoutInflater inflater, ViewGroup container) {
+ this.mContext = context;
+ this.mContainer = container;
+ this.mInflater = inflater;
+ }
+
+ public LayoutInflater getLayoutInflater() {
+ return mInflater;
+ }
+
+ public Builder setTitle(int titleId) {
+ this.mTitle = mContext.getText(titleId);
+ return this;
+ }
+
+ public Builder setTitle(CharSequence title) {
+ this.mTitle = title;
+ return this;
+ }
+
+ public Builder setPositiveButton(int textId, final View.OnClickListener listener) {
+ mPositiveButtonText = mContext.getText(textId);
+ mPositiveButtonListener = listener;
+ return this;
+ }
+
+ public Builder setPositiveButton(CharSequence text, final View.OnClickListener listener) {
+ mPositiveButtonText = text;
+ mPositiveButtonListener = listener;
+ return this;
+ }
+
+ public Builder setNegativeButton(int textId, final View.OnClickListener listener) {
+ mNegativeButtonText = mContext.getText(textId);
+ mNegativeButtonListener = listener;
+ return this;
+ }
+
+ public Builder setNegativeButton(CharSequence text, final View.OnClickListener listener) {
+ mNegativeButtonText = text;
+ mNegativeButtonListener = listener;
+ return this;
+ }
+
+ public Builder setNeutralButton(int textId, final View.OnClickListener listener) {
+ mNeutralButtonText = mContext.getText(textId);
+ mNeutralButtonListener = listener;
+ return this;
+ }
+
+ public Builder setNeutralButton(CharSequence text, final View.OnClickListener listener) {
+ mNeutralButtonText = text;
+ mNeutralButtonListener = listener;
+ return this;
+ }
+
+ public Builder setMessage(int messageId) {
+ mMessage = mContext.getText(messageId);
+ return this;
+ }
+
+ public Builder setMessage(CharSequence message) {
+ mMessage = message;
+ return this;
+ }
+
+ /**
+ * Set list
+ *
+ * @param checkedItemIdx Item check by default, -1 if no item should be checked
+ */
+ public Builder setItems(ListAdapter listAdapter, int checkedItemIdx,
+ final AdapterView.OnItemClickListener listener) {
+ mListAdapter = listAdapter;
+ mOnItemClickListener = listener;
+ mListCheckedItemIdx = checkedItemIdx;
+ return this;
+ }
+
+ public Builder setView(View view) {
+ mCustomView = view;
+ return this;
+ }
+
+ public View create() {
+
+ LinearLayout content = (LinearLayout)mInflater.inflate(R.layout.sdl_dialog, mContainer, false);
+
+ TextView vTitle = (TextView)content.findViewById(R.id.sdl_title);
+ TextView vMessage = (TextView)content.findViewById(R.id.sdl_message);
+ FrameLayout vCustomView = (FrameLayout)content.findViewById(R.id.sdl_custom);
+ Button vPositiveButton = (Button)content.findViewById(R.id.sdl_button_positive);
+ Button vNegativeButton = (Button)content.findViewById(R.id.sdl_button_negative);
+ Button vNeutralButton = (Button)content.findViewById(R.id.sdl_button_neutral);
+ Button vPositiveButtonStacked = (Button)content.findViewById(R.id.sdl_button_positive_stacked);
+ Button vNegativeButtonStacked = (Button)content.findViewById(R.id.sdl_button_negative_stacked);
+ Button vNeutralButtonStacked = (Button)content.findViewById(R.id.sdl_button_neutral_stacked);
+ View vButtonsDefault = content.findViewById(R.id.sdl_buttons_default);
+ View vButtonsStacked = content.findViewById(R.id.sdl_buttons_stacked);
+ ListView vList = (ListView)content.findViewById(R.id.sdl_list);
+
+ Typeface regularFont = TypefaceHelper.get(mContext, "Roboto-Regular");
+ Typeface mediumFont = TypefaceHelper.get(mContext, "Roboto-Medium");
+
+ set(vTitle, mTitle, mediumFont);
+ set(vMessage, mMessage, regularFont);
+ setPaddingOfTitleAndMessage(vTitle, vMessage);
+
+ if (mCustomView != null) {
+ vCustomView.addView(mCustomView);
+ }
+ if (mListAdapter != null) {
+ vList.setAdapter(mListAdapter);
+ vList.setOnItemClickListener(mOnItemClickListener);
+ if (mListCheckedItemIdx != -1) {
+ vList.setSelection(mListCheckedItemIdx);
+ }
+ }
+
+ if (shouldStackButtons()) {
+ set(vPositiveButtonStacked, mPositiveButtonText, mediumFont, mPositiveButtonListener);
+ set(vNegativeButtonStacked, mNegativeButtonText, mediumFont, mNegativeButtonListener);
+ set(vNeutralButtonStacked, mNeutralButtonText, mediumFont, mNeutralButtonListener);
+ vButtonsDefault.setVisibility(View.GONE);
+ vButtonsStacked.setVisibility(View.VISIBLE);
+ } else {
+ set(vPositiveButton, mPositiveButtonText, mediumFont, mPositiveButtonListener);
+ set(vNegativeButton, mNegativeButtonText, mediumFont, mNegativeButtonListener);
+ set(vNeutralButton, mNeutralButtonText, mediumFont, mNeutralButtonListener);
+ vButtonsDefault.setVisibility(View.VISIBLE);
+ vButtonsStacked.setVisibility(View.GONE);
+ }
+ if (TextUtils.isEmpty(mPositiveButtonText) && TextUtils.isEmpty(mNegativeButtonText) && TextUtils.isEmpty
+ (mNeutralButtonText)) {
+ vButtonsDefault.setVisibility(View.GONE);
+ }
+
+ return content;
+ }
+
+ /**
+ * Padding is different if there is only title, only message or both.
+ */
+ private void setPaddingOfTitleAndMessage(TextView vTitle, TextView vMessage) {
+ int grid6 = mContext.getResources().getDimensionPixelSize(R.dimen.grid_6);
+ int grid4 = mContext.getResources().getDimensionPixelSize(R.dimen.grid_4);
+ if (!TextUtils.isEmpty(mTitle) && !TextUtils.isEmpty(mMessage)) {
+ vTitle.setPadding(grid6, grid6, grid6, grid4);
+ vMessage.setPadding(grid6, 0, grid6, grid4);
+ } else if (TextUtils.isEmpty(mTitle)) {
+ vMessage.setPadding(grid6, grid4, grid6, grid4);
+ } else if (TextUtils.isEmpty(mMessage)) {
+ vTitle.setPadding(grid6, grid6, grid6, grid4);
+ }
+ }
+
+ private boolean shouldStackButtons() {
+ return shouldStackButton(mPositiveButtonText) || shouldStackButton(mNegativeButtonText)
+ || shouldStackButton(mNeutralButtonText);
+ }
+
+ private boolean shouldStackButton(CharSequence text) {
+ final int MAX_BUTTON_CHARS = 12; // based on observation, could be done better with measuring widths
+ return text != null && text.length() > MAX_BUTTON_CHARS;
+ }
+
+ private void set(Button button, CharSequence text, Typeface font, View.OnClickListener listener) {
+ set(button, text, font);
+ if (listener != null) {
+ button.setOnClickListener(listener);
+ }
+ }
+
+ private void set(TextView textView, CharSequence text, Typeface font) {
+ if (text != null) {
+ textView.setText(text);
+ textView.setTypeface(font);
+ } else {
+ textView.setVisibility(View.GONE);
+ }
+ }
+ }
+}
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/DatePickerDialogFragment.java b/library/src/main/java/com/avast/android/dialogs/fragment/DatePickerDialogFragment.java
similarity index 88%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/DatePickerDialogFragment.java
rename to library/src/main/java/com/avast/android/dialogs/fragment/DatePickerDialogFragment.java
index 762afe8..72a4913 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/DatePickerDialogFragment.java
+++ b/library/src/main/java/com/avast/android/dialogs/fragment/DatePickerDialogFragment.java
@@ -1,244 +1,236 @@
-package eu.inmite.android.lib.dialogs;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.DatePicker;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Dialog with a date picker. Implement {@link eu.inmite.android.lib.dialogs.IDateDialogListener} or {@link eu.inmite.android.lib.dialogs.IDateDialogCancelListener} to handle events.
- */
-public class DatePickerDialogFragment extends BaseDialogFragment {
-
- protected static final String ARG_ZONE = "zone";
- protected static final String ARG_TITLE = "title";
- protected static final String ARG_POSITIVE_BUTTON = "positive_button";
- protected static final String ARG_NEGATIVE_BUTTON = "negative_button";
- protected static final String ARG_DATE = "date";
- protected static final String ARG_24H = "24h";
-
- DatePicker mDatePicker;
- Calendar mCalendar;
-
- private int mRequestCode;
-
-
- public static SimpleDialogBuilder createBuilder(Context context, FragmentManager fragmentManager) {
- return new SimpleDialogBuilder(context, fragmentManager, DatePickerDialogFragment.class);
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- final Fragment targetFragment = getTargetFragment();
- if (targetFragment != null) {
- mRequestCode = getTargetRequestCode();
- } else {
- Bundle args = getArguments();
- if (args != null) {
- mRequestCode = args.getInt(BaseDialogBuilder.ARG_REQUEST_CODE, 0);
- }
- }
- }
-
- protected IDateDialogListener getDialogListener() {
- final Fragment targetFragment = getTargetFragment();
- if (targetFragment != null) {
- if (targetFragment instanceof IDateDialogListener) {
- return (IDateDialogListener) targetFragment;
- }
- } else {
- if (getActivity() instanceof IDateDialogListener) {
- return (IDateDialogListener) getActivity();
- }
- }
- return null;
- }
-
- protected IDateDialogCancelListener getCancelListener() {
- final Fragment targetFragment = getTargetFragment();
- if (targetFragment != null) {
- if (targetFragment instanceof IDateDialogCancelListener) {
- return (IDateDialogCancelListener) targetFragment;
- }
- } else {
- if (getActivity() instanceof IDateDialogCancelListener) {
- return (IDateDialogCancelListener) getActivity();
- }
- }
- return null;
- }
-
- @Override
- protected BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
- final String title = getTitle();
- if (!TextUtils.isEmpty(title)) {
- builder.setTitle(title);
- }
-
- final String positiveButtonText = getPositiveButtonText();
- if (!TextUtils.isEmpty(positiveButtonText)) {
- builder.setPositiveButton(positiveButtonText, new View.OnClickListener() {
-
- @Override
- public void onClick(View view) {
- IDateDialogListener listener = getDialogListener();
- if (listener != null) {
- listener.onPositiveButtonClicked(mRequestCode, getDate());
- }
- dismiss();
- }
- });
- }
-
- final String negativeButtonText = getNegativeButtonText();
- if (!TextUtils.isEmpty(negativeButtonText)) {
- builder.setNegativeButton(negativeButtonText, new View.OnClickListener() {
-
- @Override
- public void onClick(View view) {
- IDateDialogListener listener = getDialogListener();
- if (listener != null) {
- listener.onNegativeButtonClicked(mRequestCode, getDate());
- }
- dismiss();
- }
- });
- }
- mDatePicker = (DatePicker) LayoutInflater.from(getActivity()).inflate(R.layout.dialog_part_datepicker, null);
- builder.setView(mDatePicker);
-
- TimeZone zone = TimeZone.getTimeZone(getArguments().getString(ARG_ZONE));
- mCalendar = Calendar.getInstance(zone);
- mCalendar.setTimeInMillis(getArguments().getLong(ARG_DATE, System.currentTimeMillis()));
- mDatePicker.updateDate(mCalendar.get(Calendar.YEAR)
- , mCalendar.get(Calendar.MONTH)
- , mCalendar.get(Calendar.DAY_OF_MONTH));
- return builder;
- }
-
- protected String getTitle() {
- return getArguments().getString(ARG_TITLE);
- }
-
- protected String getPositiveButtonText() {
- return getArguments().getString(ARG_POSITIVE_BUTTON);
- }
-
- protected String getNegativeButtonText() {
- return getArguments().getString(ARG_NEGATIVE_BUTTON);
- }
-
- public Date getDate() {
- mCalendar.set(Calendar.YEAR, mDatePicker.getYear());
- mCalendar.set(Calendar.MONTH, mDatePicker.getMonth());
- mCalendar.set(Calendar.DAY_OF_MONTH, mDatePicker.getDayOfMonth());
- return mCalendar.getTime();
- }
-
- public static class SimpleDialogBuilder extends BaseDialogBuilder {
- Date mDate = new Date();
- String mTimeZone = null;
-
- private String mTitle;
- private String mPositiveButtonText;
- private String mNegativeButtonText;
-
- private boolean mShowDefaultButton = true;
- private boolean m24h;
-
- protected SimpleDialogBuilder(Context context, FragmentManager fragmentManager, Class extends DatePickerDialogFragment> clazz) {
- super(context, fragmentManager, clazz);
- }
-
- public SimpleDialogBuilder setTitle(int titleResourceId) {
- mTitle = mContext.getString(titleResourceId);
- return this;
- }
-
-
- public SimpleDialogBuilder setTitle(String title) {
- mTitle = title;
- return this;
- }
-
- public SimpleDialogBuilder setPositiveButtonText(int textResourceId) {
- mPositiveButtonText = mContext.getString(textResourceId);
- return this;
- }
-
- public SimpleDialogBuilder setPositiveButtonText(String text) {
- mPositiveButtonText = text;
- return this;
- }
-
- public SimpleDialogBuilder setNegativeButtonText(int textResourceId) {
- mNegativeButtonText = mContext.getString(textResourceId);
- return this;
- }
-
- public SimpleDialogBuilder setNegativeButtonText(String text) {
- mNegativeButtonText = text;
- return this;
- }
-
- public SimpleDialogBuilder setDate(Date date) {
- mDate = date;
- return this;
- }
-
- public SimpleDialogBuilder setTimeZone(String zone) {
- mTimeZone = zone;
- return this;
- }
-
- public SimpleDialogBuilder set24hour(boolean state) {
- m24h = state;
- return this;
- }
-
- /**
- * When there is neither positive nor negative button, default "close" button is created if it was enabled.
- * Default is true.
- */
- public SimpleDialogBuilder hideDefaultButton(boolean hide) {
- mShowDefaultButton = !hide;
- return this;
- }
-
-
- @Override
- protected Bundle prepareArguments() {
- if (mShowDefaultButton && mPositiveButtonText == null && mNegativeButtonText == null) {
- mPositiveButtonText = mContext.getString(R.string.dialog_close);
- }
-
- Bundle args = new Bundle();
- args.putString(SimpleDialogFragment.ARG_TITLE, mTitle);
- args.putString(SimpleDialogFragment.ARG_POSITIVE_BUTTON, mPositiveButtonText);
- args.putString(SimpleDialogFragment.ARG_NEGATIVE_BUTTON, mNegativeButtonText);
-
- args.putLong(ARG_DATE, mDate.getTime());
- args.putBoolean(ARG_24H, m24h);
- if (mTimeZone != null) {
- args.putString(ARG_ZONE, mTimeZone);
- } else {
- args.putString(ARG_ZONE, "GMT");
- }
- return args;
- }
-
- @Override
- protected SimpleDialogBuilder self() {
- return this;
- }
- }
-}
+package com.avast.android.dialogs.fragment;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.DatePicker;
+
+import com.avast.android.dialogs.R;
+import com.avast.android.dialogs.core.BaseDialogBuilder;
+import com.avast.android.dialogs.core.BaseDialogFragment;
+import com.avast.android.dialogs.iface.IDateDialogCancelListener;
+import com.avast.android.dialogs.iface.IDateDialogListener;
+
+/**
+ * Dialog with a date picker. Implement {@link com.avast.android.dialogs.iface.IDateDialogListener} or {@link com.avast.android.dialogs.iface.IDateDialogCancelListener} to handle events.
+ */
+public class DatePickerDialogFragment extends BaseDialogFragment {
+
+ protected static final String ARG_ZONE = "zone";
+ protected static final String ARG_TITLE = "title";
+ protected static final String ARG_POSITIVE_BUTTON = "positive_button";
+ protected static final String ARG_NEGATIVE_BUTTON = "negative_button";
+ protected static final String ARG_DATE = "date";
+ protected static final String ARG_24H = "24h";
+
+ DatePicker mDatePicker;
+ Calendar mCalendar;
+
+ private int mRequestCode;
+
+
+ public static SimpleDialogBuilder createBuilder(Context context, FragmentManager fragmentManager) {
+ return new SimpleDialogBuilder(context, fragmentManager, DatePickerDialogFragment.class);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ final Fragment targetFragment = getTargetFragment();
+ if (targetFragment != null) {
+ mRequestCode = getTargetRequestCode();
+ } else {
+ Bundle args = getArguments();
+ if (args != null) {
+ mRequestCode = args.getInt(BaseDialogBuilder.ARG_REQUEST_CODE, 0);
+ }
+ }
+ }
+
+ protected IDateDialogListener getDialogListener() {
+ final Fragment targetFragment = getTargetFragment();
+ if (targetFragment != null) {
+ if (targetFragment instanceof IDateDialogListener) {
+ return (IDateDialogListener) targetFragment;
+ }
+ } else {
+ if (getActivity() instanceof IDateDialogListener) {
+ return (IDateDialogListener) getActivity();
+ }
+ }
+ return null;
+ }
+
+ protected IDateDialogCancelListener getCancelListener() {
+ final Fragment targetFragment = getTargetFragment();
+ if (targetFragment != null) {
+ if (targetFragment instanceof IDateDialogCancelListener) {
+ return (IDateDialogCancelListener) targetFragment;
+ }
+ } else {
+ if (getActivity() instanceof IDateDialogCancelListener) {
+ return (IDateDialogCancelListener) getActivity();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
+ final String title = getTitle();
+ if (!TextUtils.isEmpty(title)) {
+ builder.setTitle(title);
+ }
+
+ final String positiveButtonText = getPositiveButtonText();
+ if (!TextUtils.isEmpty(positiveButtonText)) {
+ builder.setPositiveButton(positiveButtonText, new View.OnClickListener() {
+
+ @Override
+ public void onClick(View view) {
+ IDateDialogListener listener = getDialogListener();
+ if (listener != null) {
+ listener.onPositiveButtonClicked(mRequestCode, getDate());
+ }
+ dismiss();
+ }
+ });
+ }
+
+ final String negativeButtonText = getNegativeButtonText();
+ if (!TextUtils.isEmpty(negativeButtonText)) {
+ builder.setNegativeButton(negativeButtonText, new View.OnClickListener() {
+
+ @Override
+ public void onClick(View view) {
+ IDateDialogListener listener = getDialogListener();
+ if (listener != null) {
+ listener.onNegativeButtonClicked(mRequestCode, getDate());
+ }
+ dismiss();
+ }
+ });
+ }
+ mDatePicker = (DatePicker) LayoutInflater.from(getActivity()).inflate(R.layout.sdl_datepicker, null);
+ builder.setView(mDatePicker);
+
+ TimeZone zone = TimeZone.getTimeZone(getArguments().getString(ARG_ZONE));
+ mCalendar = Calendar.getInstance(zone);
+ mCalendar.setTimeInMillis(getArguments().getLong(ARG_DATE, System.currentTimeMillis()));
+ mDatePicker.updateDate(mCalendar.get(Calendar.YEAR)
+ , mCalendar.get(Calendar.MONTH)
+ , mCalendar.get(Calendar.DAY_OF_MONTH));
+ return builder;
+ }
+
+ protected String getTitle() {
+ return getArguments().getString(ARG_TITLE);
+ }
+
+ protected String getPositiveButtonText() {
+ return getArguments().getString(ARG_POSITIVE_BUTTON);
+ }
+
+ protected String getNegativeButtonText() {
+ return getArguments().getString(ARG_NEGATIVE_BUTTON);
+ }
+
+ public Date getDate() {
+ mCalendar.set(Calendar.YEAR, mDatePicker.getYear());
+ mCalendar.set(Calendar.MONTH, mDatePicker.getMonth());
+ mCalendar.set(Calendar.DAY_OF_MONTH, mDatePicker.getDayOfMonth());
+ return mCalendar.getTime();
+ }
+
+ public static class SimpleDialogBuilder extends BaseDialogBuilder {
+ Date mDate = new Date();
+ String mTimeZone = null;
+
+ private String mTitle;
+ private String mPositiveButtonText;
+ private String mNegativeButtonText;
+
+ private boolean mShowDefaultButton = true;
+ private boolean m24h;
+
+ protected SimpleDialogBuilder(Context context, FragmentManager fragmentManager, Class extends DatePickerDialogFragment> clazz) {
+ super(context, fragmentManager, clazz);
+ }
+
+ public SimpleDialogBuilder setTitle(int titleResourceId) {
+ mTitle = mContext.getString(titleResourceId);
+ return this;
+ }
+
+
+ public SimpleDialogBuilder setTitle(String title) {
+ mTitle = title;
+ return this;
+ }
+
+ public SimpleDialogBuilder setPositiveButtonText(int textResourceId) {
+ mPositiveButtonText = mContext.getString(textResourceId);
+ return this;
+ }
+
+ public SimpleDialogBuilder setPositiveButtonText(String text) {
+ mPositiveButtonText = text;
+ return this;
+ }
+
+ public SimpleDialogBuilder setNegativeButtonText(int textResourceId) {
+ mNegativeButtonText = mContext.getString(textResourceId);
+ return this;
+ }
+
+ public SimpleDialogBuilder setNegativeButtonText(String text) {
+ mNegativeButtonText = text;
+ return this;
+ }
+
+ public SimpleDialogBuilder setDate(Date date) {
+ mDate = date;
+ return this;
+ }
+
+ public SimpleDialogBuilder setTimeZone(String zone) {
+ mTimeZone = zone;
+ return this;
+ }
+
+ public SimpleDialogBuilder set24hour(boolean state) {
+ m24h = state;
+ return this;
+ }
+
+ @Override
+ protected Bundle prepareArguments() {
+ Bundle args = new Bundle();
+ args.putString(SimpleDialogFragment.ARG_TITLE, mTitle);
+ args.putString(SimpleDialogFragment.ARG_POSITIVE_BUTTON, mPositiveButtonText);
+ args.putString(SimpleDialogFragment.ARG_NEGATIVE_BUTTON, mNegativeButtonText);
+
+ args.putLong(ARG_DATE, mDate.getTime());
+ args.putBoolean(ARG_24H, m24h);
+ if (mTimeZone != null) {
+ args.putString(ARG_ZONE, mTimeZone);
+ } else {
+ args.putString(ARG_ZONE, "GMT");
+ }
+ return args;
+ }
+
+ @Override
+ protected SimpleDialogBuilder self() {
+ return this;
+ }
+ }
+}
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/ListDialogFragment.java b/library/src/main/java/com/avast/android/dialogs/fragment/ListDialogFragment.java
similarity index 86%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/ListDialogFragment.java
rename to library/src/main/java/com/avast/android/dialogs/fragment/ListDialogFragment.java
index 36ba208..fc0462d 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/ListDialogFragment.java
+++ b/library/src/main/java/com/avast/android/dialogs/fragment/ListDialogFragment.java
@@ -1,4 +1,4 @@
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.fragment;
import android.content.Context;
import android.content.DialogInterface;
@@ -12,8 +12,13 @@
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
+import com.avast.android.dialogs.R;
+import com.avast.android.dialogs.core.BaseDialogBuilder;
+import com.avast.android.dialogs.core.BaseDialogFragment;
+import com.avast.android.dialogs.iface.IListDialogListener;
+
/**
- * Dialog with a list of options. Implement {@link eu.inmite.android.lib.dialogs.IListDialogListener} to handle selection.
+ * Dialog with a list of options. Implement {@link com.avast.android.dialogs.iface.IListDialogListener} to handle selection.
*/
public class ListDialogFragment extends BaseDialogFragment {
@@ -41,8 +46,6 @@ public static class SimpleListDialogBuilder extends BaseDialogBuilder
- * Default is true.
- */
- public SimpleListDialogBuilder hideDefaultButton(boolean hide) {
- mShowDefaultButton = !hide;
- return this;
- }
-
@Override
protected Bundle prepareArguments() {
- if (mShowDefaultButton && cancelButtonText == null) {
- cancelButtonText = mContext.getString(R.string.dialog_close);
- }
-
Bundle args = new Bundle();
args.putString(SimpleDialogFragment.ARG_TITLE, title);
args.putString(SimpleDialogFragment.ARG_POSITIVE_BUTTON, cancelButtonText);
@@ -147,9 +136,9 @@ public void onClick(View view) {
final String[] items = getItems();
if (items != null && items.length > 0) {
- ListAdapter adapter = new ArrayAdapter(getActivity(),
- R.layout.dialog_list_item,
- R.id.list_item_text,
+ ListAdapter adapter = new ArrayAdapter<>(getActivity(),
+ R.layout.sdl_list_item,
+ R.id.sdl_text,
items);
builder.setItems(adapter, 0, new AdapterView.OnItemClickListener() {
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/ProgressDialogFragment.java b/library/src/main/java/com/avast/android/dialogs/fragment/ProgressDialogFragment.java
similarity index 84%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/ProgressDialogFragment.java
rename to library/src/main/java/com/avast/android/dialogs/fragment/ProgressDialogFragment.java
index f509043..38889e3 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/ProgressDialogFragment.java
+++ b/library/src/main/java/com/avast/android/dialogs/fragment/ProgressDialogFragment.java
@@ -1,8 +1,7 @@
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.fragment;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
@@ -10,13 +9,18 @@
import android.view.View;
import android.widget.TextView;
+import com.avast.android.dialogs.R;
+import com.avast.android.dialogs.core.BaseDialogBuilder;
+import com.avast.android.dialogs.core.BaseDialogFragment;
+import com.avast.android.dialogs.iface.ISimpleDialogCancelListener;
+
/**
* Simple progress dialog that shows indeterminate progress bar together with message and dialog title (optional).
*
* To show the dialog, start with {@link #createBuilder(android.content.Context, android.support.v4.app.FragmentManager)}.
*
*
- * Dialog can be cancelable - to listen to cancellation, activity or target fragment must implement {@link ISimpleDialogCancelListener}
+ * Dialog can be cancelable - to listen to cancellation, activity or target fragment must implement {@link com.avast.android.dialogs.iface.ISimpleDialogCancelListener}
*
*
* @author Tomas Vondracek
@@ -34,16 +38,10 @@ public static ProgressDialogBuilder createBuilder(Context context, FragmentManag
@Override
protected Builder build(Builder builder) {
- final int defaultMessageTextColor = getResources().getColor(R.color.sdl_message_text_dark);
- final TypedArray a = getActivity().getTheme().obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle, 0);
- final int messageTextColor = a.getColor(R.styleable.DialogStyle_messageTextColor, defaultMessageTextColor);
- a.recycle();
-
final LayoutInflater inflater = builder.getLayoutInflater();
- final View view = inflater.inflate(R.layout.dialog_part_progress, null, false);
- final TextView tvMessage = (TextView) view.findViewById(R.id.sdl__message);
+ final View view = inflater.inflate(R.layout.sdl_progress, null, false);
+ final TextView tvMessage = (TextView) view.findViewById(R.id.sdl_message);
tvMessage.setText(getArguments().getString(ARG_MESSAGE));
- tvMessage.setTextColor(messageTextColor);
builder.setView(view);
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/SimpleDialogFragment.java b/library/src/main/java/com/avast/android/dialogs/fragment/SimpleDialogFragment.java
similarity index 92%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/SimpleDialogFragment.java
rename to library/src/main/java/com/avast/android/dialogs/fragment/SimpleDialogFragment.java
index 1536dda..ded52df 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/SimpleDialogFragment.java
+++ b/library/src/main/java/com/avast/android/dialogs/fragment/SimpleDialogFragment.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.fragment;
import android.content.Context;
import android.content.DialogInterface;
@@ -26,9 +26,14 @@
import android.text.TextUtils;
import android.view.View;
+import com.avast.android.dialogs.core.BaseDialogBuilder;
+import com.avast.android.dialogs.core.BaseDialogFragment;
+import com.avast.android.dialogs.iface.ISimpleDialogCancelListener;
+import com.avast.android.dialogs.iface.ISimpleDialogListener;
+
/**
* Dialog for displaying simple message, message with title or message with title and two buttons. Implement {@link
- * ISimpleDialogListener} in your Fragment or Activity to rect on positive and negative button clicks. This class can
+ * com.avast.android.dialogs.iface.ISimpleDialogListener} in your Fragment or Activity to rect on positive and negative button clicks. This class can
* be extended and more parameters can be added in overridden build() method.
*
* @author David Vávra (david@inmite.eu)
@@ -186,8 +191,6 @@ public static class SimpleDialogBuilder extends BaseDialogBuilder clazz) {
super(context, fragmentManager, clazz);
}
@@ -257,21 +260,8 @@ public SimpleDialogBuilder setNeutralButtonText(String text) {
return this;
}
- /**
- * When there is neither positive nor negative button, default "close" button is created if it was enabled.
- * Default is true.
- */
- public SimpleDialogBuilder hideDefaultButton(boolean hide) {
- mShowDefaultButton = !hide;
- return this;
- }
-
@Override
protected Bundle prepareArguments() {
- if (mShowDefaultButton && mPositiveButtonText == null && mNegativeButtonText == null) {
- mPositiveButtonText = mContext.getString(R.string.dialog_close);
- }
-
Bundle args = new Bundle();
args.putCharSequence(SimpleDialogFragment.ARG_MESSAGE, mMessage);
args.putString(SimpleDialogFragment.ARG_TITLE, mTitle);
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/TimePickerDialogFragment.java b/library/src/main/java/com/avast/android/dialogs/fragment/TimePickerDialogFragment.java
similarity index 80%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/TimePickerDialogFragment.java
rename to library/src/main/java/com/avast/android/dialogs/fragment/TimePickerDialogFragment.java
index 0eeecfe..28efe90 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/TimePickerDialogFragment.java
+++ b/library/src/main/java/com/avast/android/dialogs/fragment/TimePickerDialogFragment.java
@@ -1,46 +1,49 @@
-package eu.inmite.android.lib.dialogs;
-
-import android.content.Context;
-import android.support.v4.app.FragmentManager;
-import android.view.LayoutInflater;
-import android.widget.TimePicker;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Dialog with a time picker. Implement {@link eu.inmite.android.lib.dialogs.IDateDialogListener} or {@link eu.inmite.android.lib.dialogs.IDateDialogCancelListener} to handle events.
- */
-public class TimePickerDialogFragment extends DatePickerDialogFragment {
-
- TimePicker mTimePicker;
- Calendar mCalendar;
-
-
- public static SimpleDialogBuilder createBuilder(Context context, FragmentManager fragmentManager) {
- return new SimpleDialogBuilder(context, fragmentManager, TimePickerDialogFragment.class);
- }
-
- @Override
- protected BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
- builder = super.build(builder);
- mTimePicker = (TimePicker) LayoutInflater.from(getActivity()).inflate(R.layout.dialog_part_timepicker, null);
- mTimePicker.setIs24HourView(getArguments().getBoolean(ARG_24H));
- builder.setView(mTimePicker);
-
- TimeZone zone = TimeZone.getTimeZone(getArguments().getString(ARG_ZONE));
- mCalendar = Calendar.getInstance(zone);
- mCalendar.setTimeInMillis(getArguments().getLong(ARG_DATE, System.currentTimeMillis()));
-
- mTimePicker.setCurrentHour(mCalendar.get(Calendar.HOUR_OF_DAY));
- mTimePicker.setCurrentMinute(mCalendar.get(Calendar.MINUTE));
- return builder;
- }
-
- public Date getDate() {
- mCalendar.set(Calendar.HOUR_OF_DAY, mTimePicker.getCurrentHour());
- mCalendar.set(Calendar.MINUTE, mTimePicker.getCurrentMinute());
- return mCalendar.getTime();
- }
-}
+package com.avast.android.dialogs.fragment;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import android.content.Context;
+import android.support.v4.app.FragmentManager;
+import android.view.LayoutInflater;
+import android.widget.TimePicker;
+
+import com.avast.android.dialogs.R;
+import com.avast.android.dialogs.core.BaseDialogFragment;
+
+/**
+ * Dialog with a time picker. Implement {@link com.avast.android.dialogs.iface.IDateDialogListener} or {@link com.avast.android.dialogs.iface.IDateDialogCancelListener} to handle events.
+ */
+public class TimePickerDialogFragment extends DatePickerDialogFragment {
+
+ TimePicker mTimePicker;
+ Calendar mCalendar;
+
+
+ public static SimpleDialogBuilder createBuilder(Context context, FragmentManager fragmentManager) {
+ return new SimpleDialogBuilder(context, fragmentManager, TimePickerDialogFragment.class);
+ }
+
+ @Override
+ protected BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
+ builder = super.build(builder);
+ mTimePicker = (TimePicker) LayoutInflater.from(getActivity()).inflate(R.layout.sdl_timepicker, null);
+ mTimePicker.setIs24HourView(getArguments().getBoolean(ARG_24H));
+ builder.setView(mTimePicker);
+
+ TimeZone zone = TimeZone.getTimeZone(getArguments().getString(ARG_ZONE));
+ mCalendar = Calendar.getInstance(zone);
+ mCalendar.setTimeInMillis(getArguments().getLong(ARG_DATE, System.currentTimeMillis()));
+
+ mTimePicker.setCurrentHour(mCalendar.get(Calendar.HOUR_OF_DAY));
+ mTimePicker.setCurrentMinute(mCalendar.get(Calendar.MINUTE));
+ return builder;
+ }
+
+ public Date getDate() {
+ mCalendar.set(Calendar.HOUR_OF_DAY, mTimePicker.getCurrentHour());
+ mCalendar.set(Calendar.MINUTE, mTimePicker.getCurrentMinute());
+ return mCalendar.getTime();
+ }
+}
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/IDateDialogCancelListener.java b/library/src/main/java/com/avast/android/dialogs/iface/IDateDialogCancelListener.java
similarity index 92%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/IDateDialogCancelListener.java
rename to library/src/main/java/com/avast/android/dialogs/iface/IDateDialogCancelListener.java
index 4828f82..a4035a4 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/IDateDialogCancelListener.java
+++ b/library/src/main/java/com/avast/android/dialogs/iface/IDateDialogCancelListener.java
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.iface;
import java.util.Date;
/**
* @author Tomáš Kypta
- * @since 13/05/2013
*/
public interface IDateDialogCancelListener {
public void onCancelled(int requestCode, Date date);
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/IDateDialogListener.java b/library/src/main/java/com/avast/android/dialogs/iface/IDateDialogListener.java
similarity index 95%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/IDateDialogListener.java
rename to library/src/main/java/com/avast/android/dialogs/iface/IDateDialogListener.java
index f4cee37..c04b632 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/IDateDialogListener.java
+++ b/library/src/main/java/com/avast/android/dialogs/iface/IDateDialogListener.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.iface;
import java.util.Date;
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/IListDialogListener.java b/library/src/main/java/com/avast/android/dialogs/iface/IListDialogListener.java
similarity index 65%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/IListDialogListener.java
rename to library/src/main/java/com/avast/android/dialogs/iface/IListDialogListener.java
index 10c8c85..e58d75b 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/IListDialogListener.java
+++ b/library/src/main/java/com/avast/android/dialogs/iface/IListDialogListener.java
@@ -1,7 +1,7 @@
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.iface;
/**
- *
+ * Interface for ListDialogFragment
*/
public interface IListDialogListener {
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/ISimpleDialogCancelListener.java b/library/src/main/java/com/avast/android/dialogs/iface/ISimpleDialogCancelListener.java
similarity index 92%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/ISimpleDialogCancelListener.java
rename to library/src/main/java/com/avast/android/dialogs/iface/ISimpleDialogCancelListener.java
index 896040e..639ca9b 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/ISimpleDialogCancelListener.java
+++ b/library/src/main/java/com/avast/android/dialogs/iface/ISimpleDialogCancelListener.java
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.iface;
/**
* @author Tomáš Kypta
- * @since 13/05/2013
*/
public interface ISimpleDialogCancelListener {
public void onCancelled(int requestCode);
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/ISimpleDialogListener.java b/library/src/main/java/com/avast/android/dialogs/iface/ISimpleDialogListener.java
similarity index 95%
rename from library/src/main/java/eu/inmite/android/lib/dialogs/ISimpleDialogListener.java
rename to library/src/main/java/com/avast/android/dialogs/iface/ISimpleDialogListener.java
index 8ef36a4..ae2c4a6 100644
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/ISimpleDialogListener.java
+++ b/library/src/main/java/com/avast/android/dialogs/iface/ISimpleDialogListener.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package eu.inmite.android.lib.dialogs;
+package com.avast.android.dialogs.iface;
/**
* Implement this interface in Activity or Fragment to react to positive and negative buttons.
diff --git a/library/src/main/java/com/avast/android/dialogs/util/TypefaceHelper.java b/library/src/main/java/com/avast/android/dialogs/util/TypefaceHelper.java
new file mode 100644
index 0000000..41af331
--- /dev/null
+++ b/library/src/main/java/com/avast/android/dialogs/util/TypefaceHelper.java
@@ -0,0 +1,41 @@
+package com.avast.android.dialogs.util;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.support.v4.util.SimpleArrayMap;
+
+/*
+ Taken from:
+ https://github.com/afollestad/material-dialogs/blob/master/library/src/main/java/com/afollestad/materialdialogs/util/TypefaceHelper.java
+
+ Each call to Typeface.createFromAsset will load a new instance of the typeface into memory,
+ and this memory is not consistently get garbage collected
+ http://code.google.com/p/android/issues/detail?id=9904
+ (It states released but even on Lollipop you can see the typefaces accumulate even after
+ multiple GC passes)
+ You can detect this by running:
+ adb shell dumpsys meminfo com.your.packagenage
+ You will see output like:
+ Asset Allocations
+ zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
+ zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
+ zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
+ zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Regular.ttf: 123K
+ zip:/data/app/com.your.packagenage-1.apk:/assets/Roboto-Medium.ttf: 125K
+*/
+public class TypefaceHelper {
+
+ private static final SimpleArrayMap cache = new SimpleArrayMap<>();
+
+ public static Typeface get(Context c, String name) {
+ synchronized (cache) {
+ if (!cache.containsKey(name)) {
+ Typeface t = Typeface.createFromAsset(
+ c.getAssets(), String.format("fonts/%s.ttf", name));
+ cache.put(name, t);
+ return t;
+ }
+ return cache.get(name);
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/eu/inmite/android/lib/dialogs/BaseDialogFragment.java b/library/src/main/java/eu/inmite/android/lib/dialogs/BaseDialogFragment.java
deleted file mode 100644
index 06012dc..0000000
--- a/library/src/main/java/eu/inmite/android/lib/dialogs/BaseDialogFragment.java
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
- * Copyright 2013 Inmite s.r.o. (www.inmite.eu).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package eu.inmite.android.lib.dialogs;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.StateListDrawable;
-import android.os.Build;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-/**
- * Base dialog fragment for all your dialogs, stylable and same design on Android 2.2+.
- *
- * @author David Vávra (david@inmite.eu)
- */
-public abstract class BaseDialogFragment extends DialogFragment {
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- Dialog dialog = new Dialog(getActivity(), R.style.SDL_Dialog);
- // custom dialog background
- final TypedArray a = getActivity().getTheme()
- .obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle, 0);
- Drawable dialogBackground = a.getDrawable(R.styleable.DialogStyle_dialogBackground);
- a.recycle();
- dialog.getWindow().setBackgroundDrawable(dialogBackground);
- Bundle args = getArguments();
- if (args != null) {
- dialog.setCanceledOnTouchOutside(
- args.getBoolean(BaseDialogBuilder.ARG_CANCELABLE_ON_TOUCH_OUTSIDE));
- }
- return dialog;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- Builder builder = new Builder(this, getActivity(), inflater, container);
- return build(builder).create();
- }
-
- protected abstract Builder build(Builder initialBuilder);
-
- @Override
- public void onDestroyView() {
- // bug in the compatibility library
- if (getDialog() != null && getRetainInstance()) {
- getDialog().setDismissMessage(null);
- }
- super.onDestroyView();
- }
-
- public void showAllowingStateLoss(FragmentManager manager, String tag) {
- FragmentTransaction ft = manager.beginTransaction();
- ft.add(this, tag);
- ft.commitAllowingStateLoss();
- }
-
- /**
- * @return the positive button if specified and the view is created, null otherwise
- */
- protected Button getPositiveButton() {
- if (getView() != null) {
- return (Button) getView().findViewById(R.id.sdl__positive_button);
- } else {
- return null;
- }
- }
-
- /**
- * @return the negative button if specified and the view is created, null otherwise
- */
- protected Button getNegativeButton() {
- if (getView() != null) {
- return (Button) getView().findViewById(R.id.sdl__negative_button);
- } else {
- return null;
- }
- }
-
- /**
- * @return the neutral button if specified and the view is created, null otherwise
- */
- protected Button getNeutralButton() {
- if (getView() != null) {
- return (Button) getView().findViewById(R.id.sdl__neutral_button);
- } else {
- return null;
- }
- }
-
- /**
- * Custom dialog builder
- */
- protected static class Builder {
-
- private final DialogFragment mDialogFragment;
-
- private final Context mContext;
-
- private final ViewGroup mContainer;
-
- private final LayoutInflater mInflater;
-
- private CharSequence mTitle = null;
-
- private CharSequence mPositiveButtonText;
-
- private View.OnClickListener mPositiveButtonListener;
-
- private CharSequence mNegativeButtonText;
-
- private View.OnClickListener mNegativeButtonListener;
-
- private CharSequence mNeutralButtonText;
-
- private View.OnClickListener mNeutralButtonListener;
-
- private CharSequence mMessage;
-
- private View mView;
-
- private boolean mViewSpacingSpecified;
-
- private int mViewSpacingLeft;
-
- private int mViewSpacingTop;
-
- private int mViewSpacingRight;
-
- private int mViewSpacingBottom;
-
- private ListAdapter mListAdapter;
-
- private int mListCheckedItemIdx;
-
- private AdapterView.OnItemClickListener mOnItemClickListener;
-
- private Drawable mIcon;
-
- /**
- * Styling: *
- */
- private int mTitleTextColor;
-
- private int mTitleSeparatorColor;
-
- private int mMessageTextColor;
-
- private ColorStateList mButtonTextColor;
-
- private int mButtonSeparatorColor;
-
- private int mButtonBackgroundColorNormal;
-
- private int mButtonBackgroundColorPressed;
-
- private int mButtonBackgroundColorFocused;
-
- private int mListItemSeparatorColor;
-
- private int mListItemBackgroundColorNormal;
-
- private int mListItemBackgroundColorPressed;
-
- private int mListItemBackgroundColorFocused;
-
- private final static int[] pressedState = {android.R.attr.state_pressed};
-
- private final static int[] focusedState = {android.R.attr.state_focused};
-
- private final static int[] defaultState = {android.R.attr.state_enabled};
-
- public Builder(DialogFragment dialogFragment, Context context, LayoutInflater inflater,
- ViewGroup container) {
- this.mDialogFragment = dialogFragment;
- this.mContext = context;
- this.mContainer = container;
- this.mInflater = inflater;
- }
-
- public LayoutInflater getLayoutInflater() {
- return mInflater;
- }
-
- public Builder setTitle(int titleId) {
- this.mTitle = mContext.getText(titleId);
- return this;
- }
-
- public Builder setTitle(CharSequence title) {
- this.mTitle = title;
- return this;
- }
-
- public Builder setPositiveButton(int textId, final View.OnClickListener listener) {
- mPositiveButtonText = mContext.getText(textId);
- mPositiveButtonListener = listener;
- return this;
- }
-
- public Builder setPositiveButton(CharSequence text, final View.OnClickListener listener) {
- mPositiveButtonText = text;
- mPositiveButtonListener = listener;
- return this;
- }
-
- public Builder setNegativeButton(int textId, final View.OnClickListener listener) {
- mNegativeButtonText = mContext.getText(textId);
- mNegativeButtonListener = listener;
- return this;
- }
-
- public Builder setNegativeButton(CharSequence text, final View.OnClickListener listener) {
- mNegativeButtonText = text;
- mNegativeButtonListener = listener;
- return this;
- }
-
- public Builder setNeutralButton(int textId, final View.OnClickListener listener) {
- mNeutralButtonText = mContext.getText(textId);
- mNeutralButtonListener = listener;
- return this;
- }
-
- public Builder setNeutralButton(CharSequence text, final View.OnClickListener listener) {
- mNeutralButtonText = text;
- mNeutralButtonListener = listener;
- return this;
- }
-
- public Builder setMessage(int messageId) {
- mMessage = mContext.getText(messageId);
- return this;
- }
-
- public Builder setMessage(CharSequence message) {
- mMessage = message;
- return this;
- }
-
- /**
- * Set list
- *
- * @param checkedItemIdx Item check by default, -1 if no item should be checked
- */
- public Builder setItems(ListAdapter listAdapter, int checkedItemIdx,
- final AdapterView.OnItemClickListener listener) {
- mListAdapter = listAdapter;
- mOnItemClickListener = listener;
- mListCheckedItemIdx = checkedItemIdx;
- return this;
- }
-
- public Builder setView(View view) {
- mView = view;
- mViewSpacingSpecified = false;
- return this;
- }
-
- public Builder setView(View view, int viewSpacingLeft, int viewSpacingTop,
- int viewSpacingRight, int viewSpacingBottom) {
- mView = view;
- mViewSpacingSpecified = true;
- mViewSpacingLeft = viewSpacingLeft;
- mViewSpacingTop = viewSpacingTop;
- mViewSpacingRight = viewSpacingRight;
- mViewSpacingBottom = viewSpacingBottom;
- return this;
- }
-
- public Builder setIcon(int resourceId) {
- mIcon = mContext.getResources().getDrawable(resourceId);
- return this;
- }
-
- public Builder setIcon(Drawable drawable) {
- mIcon = drawable;
- return this;
- }
-
- public View create() {
- final Resources res = mContext.getResources();
- final int defaultTitleTextColor = res.getColor(R.color.sdl_title_text_dark);
- final int defaultTitleSeparatorColor = res.getColor(R.color.sdl_title_separator_dark);
- final int defaultMessageTextColor = res.getColor(R.color.sdl_message_text_dark);
- final ColorStateList defaultButtonTextColor = res
- .getColorStateList(R.color.sdl_button_text_dark);
- final int defaultButtonSeparatorColor = res.getColor(R.color.sdl_button_separator_dark);
- final int defaultButtonBackgroundColorNormal = res
- .getColor(R.color.sdl_button_normal_dark);
- final int defaultButtonBackgroundColorPressed = res
- .getColor(R.color.sdl_button_pressed_dark);
- final int defaultButtonBackgroundColorFocused = res
- .getColor(R.color.sdl_button_focused_dark);
-
- final TypedArray a = mContext.getTheme()
- .obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle,
- 0);
- mTitleTextColor = a
- .getColor(R.styleable.DialogStyle_titleTextColor, defaultTitleTextColor);
- mTitleSeparatorColor = a.getColor(R.styleable.DialogStyle_titleSeparatorColor,
- defaultTitleSeparatorColor);
- mMessageTextColor = a
- .getColor(R.styleable.DialogStyle_messageTextColor, defaultMessageTextColor);
- mButtonTextColor = a.getColorStateList(R.styleable.DialogStyle_buttonTextColor);
- if (mButtonTextColor == null) {
- mButtonTextColor = defaultButtonTextColor;
- }
- mButtonSeparatorColor = a.getColor(R.styleable.DialogStyle_buttonSeparatorColor,
- defaultButtonSeparatorColor);
- mButtonBackgroundColorNormal = a
- .getColor(R.styleable.DialogStyle_buttonBackgroundColorNormal,
- defaultButtonBackgroundColorNormal);
- mButtonBackgroundColorPressed = a
- .getColor(R.styleable.DialogStyle_buttonBackgroundColorPressed,
- defaultButtonBackgroundColorPressed);
- mButtonBackgroundColorFocused = a
- .getColor(R.styleable.DialogStyle_buttonBackgroundColorFocused,
- defaultButtonBackgroundColorFocused);
- if (mListAdapter != null) {
- final int defaultListItemSeparatorColor = res
- .getColor(R.color.sdl_list_item_separator_dark);
- final int defaultListItemBackgroundColorNormal = res
- .getColor(R.color.sdl_button_normal_dark);
- final int defaultListItemBackgroundColorFocused = res
- .getColor(R.color.sdl_button_focused_dark);
- final int defaultListItemBackgroundColorPressed = res
- .getColor(R.color.sdl_button_pressed_dark);
- mListItemSeparatorColor = a.getColor(R.styleable.DialogStyle_listItemSeparatorColor,
- defaultListItemSeparatorColor);
- mListItemBackgroundColorNormal = a
- .getColor(R.styleable.DialogStyle_listItemColorNormal,
- defaultListItemBackgroundColorNormal);
- mListItemBackgroundColorFocused = a
- .getColor(R.styleable.DialogStyle_listItemColorFocused,
- defaultListItemBackgroundColorFocused);
- mListItemBackgroundColorPressed = a
- .getColor(R.styleable.DialogStyle_listItemColorPressed,
- defaultListItemBackgroundColorPressed);
- }
- a.recycle();
-
- View v = getDialogLayoutAndInitTitle();
-
- LinearLayout content = (LinearLayout) v.findViewById(R.id.sdl__content);
-
- if (mMessage != null) {
- View viewMessage = mInflater.inflate(R.layout.dialog_part_message, content, false);
- TextView tvMessage = (TextView) viewMessage.findViewById(R.id.sdl__message);
- tvMessage.setTextColor(mMessageTextColor);
- tvMessage.setText(mMessage);
- content.addView(viewMessage);
- }
-
- if (mView != null) {
- FrameLayout customPanel = (FrameLayout) mInflater
- .inflate(R.layout.dialog_part_custom, content, false);
- FrameLayout custom = (FrameLayout) customPanel.findViewById(R.id.sdl__custom);
- custom.addView(mView,
- new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT)
- );
- if (mViewSpacingSpecified) {
- custom.setPadding(mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight,
- mViewSpacingBottom);
- }
- content.addView(customPanel);
- }
-
- if (mListAdapter != null) {
- ListView listView = (ListView) mInflater
- .inflate(R.layout.dialog_part_list, content, false);
- listView.setAdapter(mListAdapter);
- listView.setDivider(getColoredListItemsDivider());
- listView.setDividerHeight(1);
- listView.setSelector(getListItemSelector());
- listView.setOnItemClickListener(mOnItemClickListener);
- if (mListCheckedItemIdx != -1) {
- listView.setSelection(mListCheckedItemIdx);
- }
- content.addView(listView);
- }
-
- addButtons(content);
-
- return v;
- }
-
- private View getDialogLayoutAndInitTitle() {
- View v = mInflater.inflate(R.layout.dialog_part_title, mContainer, false);
- TextView tvTitle = (TextView) v.findViewById(R.id.sdl__title);
- View viewTitleDivider = v.findViewById(R.id.sdl__titleDivider);
- if (mTitle != null) {
- tvTitle.setText(mTitle);
- tvTitle.setTextColor(mTitleTextColor);
- if (mIcon != null) {
- tvTitle.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
- tvTitle.setCompoundDrawablePadding(
- mContext.getResources().getDimensionPixelSize(R.dimen.grid_2));
- }
- viewTitleDivider.setBackgroundDrawable(new ColorDrawable(mTitleSeparatorColor));
- } else {
- tvTitle.setVisibility(View.GONE);
- viewTitleDivider.setVisibility(View.GONE);
- }
- return v;
- }
-
- private void addButtons(LinearLayout llListDialog) {
- if (mNegativeButtonText != null || mNeutralButtonText != null
- || mPositiveButtonText != null) {
- View viewButtonPanel = mInflater
- .inflate(R.layout.dialog_part_button_panel, llListDialog, false);
- LinearLayout llButtonPanel = (LinearLayout) viewButtonPanel
- .findViewById(R.id.dialog_button_panel);
- viewButtonPanel.findViewById(R.id.dialog_horizontal_separator)
- .setBackgroundDrawable(new ColorDrawable(mButtonSeparatorColor));
-
- boolean addDivider = false;
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- addDivider = addPositiveButton(llButtonPanel, addDivider);
- } else {
- addDivider = addNegativeButton(llButtonPanel, addDivider);
- }
- addDivider = addNeutralButton(llButtonPanel, addDivider);
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- addNegativeButton(llButtonPanel, addDivider);
- } else {
- addPositiveButton(llButtonPanel, addDivider);
- }
-
- llListDialog.addView(viewButtonPanel);
- }
- }
-
- private boolean addNegativeButton(ViewGroup parent, boolean addDivider) {
- if (mNegativeButtonText != null) {
- if (addDivider) {
- addDivider(parent);
- }
- Button btn = (Button) mInflater.inflate(R.layout.dialog_part_button, parent, false);
- btn.setId(R.id.sdl__negative_button);
- btn.setText(mNegativeButtonText);
- btn.setTextColor(mButtonTextColor);
- btn.setBackgroundDrawable(getButtonBackground());
- btn.setOnClickListener(mNegativeButtonListener);
- parent.addView(btn);
- return true;
- }
- return addDivider;
- }
-
- private boolean addPositiveButton(ViewGroup parent, boolean addDivider) {
- if (mPositiveButtonText != null) {
- if (addDivider) {
- addDivider(parent);
- }
- Button btn = (Button) mInflater.inflate(R.layout.dialog_part_button, parent, false);
- btn.setId(R.id.sdl__positive_button);
- btn.setText(mPositiveButtonText);
- btn.setTextColor(mButtonTextColor);
- btn.setBackgroundDrawable(getButtonBackground());
- btn.setOnClickListener(mPositiveButtonListener);
- parent.addView(btn);
- return true;
- }
- return addDivider;
- }
-
- private boolean addNeutralButton(ViewGroup parent, boolean addDivider) {
- if (mNeutralButtonText != null) {
- if (addDivider) {
- addDivider(parent);
- }
- Button btn = (Button) mInflater.inflate(R.layout.dialog_part_button, parent, false);
- btn.setId(R.id.sdl__neutral_button);
- btn.setText(mNeutralButtonText);
- btn.setTextColor(mButtonTextColor);
- btn.setBackgroundDrawable(getButtonBackground());
- btn.setOnClickListener(mNeutralButtonListener);
- parent.addView(btn);
- return true;
- }
- return addDivider;
- }
-
- private void addDivider(ViewGroup parent) {
- View view = mInflater.inflate(R.layout.dialog_part_button_separator, parent, false);
- view.findViewById(R.id.dialog_button_separator)
- .setBackgroundDrawable(new ColorDrawable(mButtonSeparatorColor));
- parent.addView(view);
- }
-
- private StateListDrawable getButtonBackground() {
- ColorDrawable colorDefault = new ColorDrawable(mButtonBackgroundColorNormal);
- ColorDrawable colorPressed = new ColorDrawable(mButtonBackgroundColorPressed);
- ColorDrawable colorFocused = new ColorDrawable(mButtonBackgroundColorFocused);
- StateListDrawable background = new StateListDrawable();
- background.addState(pressedState, colorPressed);
- background.addState(focusedState, colorFocused);
- background.addState(defaultState, colorDefault);
- return background;
- }
-
- private StateListDrawable getListItemSelector() {
- ColorDrawable colorDefault = new ColorDrawable(mListItemBackgroundColorNormal);
- ColorDrawable colorPressed = new ColorDrawable(mListItemBackgroundColorPressed);
- ColorDrawable colorFocused = new ColorDrawable(mListItemBackgroundColorFocused);
- StateListDrawable background = new StateListDrawable();
- background.addState(pressedState, colorPressed);
- background.addState(focusedState, colorFocused);
- background.addState(defaultState, colorDefault);
- return background;
- }
-
- private ColorDrawable getColoredListItemsDivider() {
- ColorDrawable colorDividerDrawable = new ColorDrawable(mListItemSeparatorColor);
- return colorDividerDrawable;
- }
- }
-}
diff --git a/library/src/main/res/color/sdl_primary_text_holo_dark.xml b/library/src/main/res/color/sdl_primary_text_holo_dark.xml
deleted file mode 100644
index ee118df..0000000
--- a/library/src/main/res/color/sdl_primary_text_holo_dark.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/library/src/main/res/color/sdl_primary_text_holo_light.xml b/library/src/main/res/color/sdl_primary_text_holo_light.xml
deleted file mode 100644
index b9b4b8d..0000000
--- a/library/src/main/res/color/sdl_primary_text_holo_light.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/drawable-hdpi/sdl_background_light.9.png b/library/src/main/res/drawable-hdpi/sdl_background.9.png
similarity index 100%
rename from library/src/main/res/drawable-hdpi/sdl_background_light.9.png
rename to library/src/main/res/drawable-hdpi/sdl_background.9.png
diff --git a/library/src/main/res/drawable-hdpi/sdl_background_dark.9.png b/library/src/main/res/drawable-hdpi/sdl_background_dark.9.png
deleted file mode 100644
index a582a77..0000000
Binary files a/library/src/main/res/drawable-hdpi/sdl_background_dark.9.png and /dev/null differ
diff --git a/library/src/main/res/drawable-mdpi/sdl_background_light.9.png b/library/src/main/res/drawable-mdpi/sdl_background.9.png
similarity index 100%
rename from library/src/main/res/drawable-mdpi/sdl_background_light.9.png
rename to library/src/main/res/drawable-mdpi/sdl_background.9.png
diff --git a/library/src/main/res/drawable-mdpi/sdl_background_dark.9.png b/library/src/main/res/drawable-mdpi/sdl_background_dark.9.png
deleted file mode 100644
index cff4c10..0000000
Binary files a/library/src/main/res/drawable-mdpi/sdl_background_dark.9.png and /dev/null differ
diff --git a/library/src/main/res/drawable-v21/sdl_button.xml b/library/src/main/res/drawable-v21/sdl_button.xml
new file mode 100644
index 0000000..b71813b
--- /dev/null
+++ b/library/src/main/res/drawable-v21/sdl_button.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable-v21/sdl_button_selector.xml b/library/src/main/res/drawable-v21/sdl_button_selector.xml
new file mode 100644
index 0000000..677097e
--- /dev/null
+++ b/library/src/main/res/drawable-v21/sdl_button_selector.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable-v21/sdl_list.xml b/library/src/main/res/drawable-v21/sdl_list.xml
new file mode 100644
index 0000000..3264346
--- /dev/null
+++ b/library/src/main/res/drawable-v21/sdl_list.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable-v21/sdl_list_selector.xml b/library/src/main/res/drawable-v21/sdl_list_selector.xml
new file mode 100644
index 0000000..ccdffc8
--- /dev/null
+++ b/library/src/main/res/drawable-v21/sdl_list_selector.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable-xhdpi/sdl_background_light.9.png b/library/src/main/res/drawable-xhdpi/sdl_background.9.png
similarity index 100%
rename from library/src/main/res/drawable-xhdpi/sdl_background_light.9.png
rename to library/src/main/res/drawable-xhdpi/sdl_background.9.png
diff --git a/library/src/main/res/drawable-xhdpi/sdl_background_dark.9.png b/library/src/main/res/drawable-xhdpi/sdl_background_dark.9.png
deleted file mode 100644
index e611771..0000000
Binary files a/library/src/main/res/drawable-xhdpi/sdl_background_dark.9.png and /dev/null differ
diff --git a/library/src/main/res/drawable/sdl_button.xml b/library/src/main/res/drawable/sdl_button.xml
new file mode 100644
index 0000000..7a6c6d4
--- /dev/null
+++ b/library/src/main/res/drawable/sdl_button.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/sdl_button_normal.xml b/library/src/main/res/drawable/sdl_button_normal.xml
new file mode 100644
index 0000000..399a46b
--- /dev/null
+++ b/library/src/main/res/drawable/sdl_button_normal.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/sdl_button_pressed.xml b/library/src/main/res/drawable/sdl_button_pressed.xml
new file mode 100644
index 0000000..596e94e
--- /dev/null
+++ b/library/src/main/res/drawable/sdl_button_pressed.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/sdl_list.xml b/library/src/main/res/drawable/sdl_list.xml
new file mode 100644
index 0000000..41284d0
--- /dev/null
+++ b/library/src/main/res/drawable/sdl_list.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/sdl_list_normal.xml b/library/src/main/res/drawable/sdl_list_normal.xml
new file mode 100644
index 0000000..399a46b
--- /dev/null
+++ b/library/src/main/res/drawable/sdl_list_normal.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/drawable/sdl_list_pressed.xml b/library/src/main/res/drawable/sdl_list_pressed.xml
new file mode 100644
index 0000000..5ce2954
--- /dev/null
+++ b/library/src/main/res/drawable/sdl_list_pressed.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_list_item.xml b/library/src/main/res/layout/dialog_list_item.xml
deleted file mode 100644
index d17708f..0000000
--- a/library/src/main/res/layout/dialog_list_item.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
diff --git a/library/src/main/res/layout/dialog_part_button.xml b/library/src/main/res/layout/dialog_part_button.xml
deleted file mode 100644
index b3d1019..0000000
--- a/library/src/main/res/layout/dialog_part_button.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
diff --git a/library/src/main/res/layout/dialog_part_button_panel.xml b/library/src/main/res/layout/dialog_part_button_panel.xml
deleted file mode 100644
index 0c9fc28..0000000
--- a/library/src/main/res/layout/dialog_part_button_panel.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_part_button_separator.xml b/library/src/main/res/layout/dialog_part_button_separator.xml
deleted file mode 100644
index 748a65a..0000000
--- a/library/src/main/res/layout/dialog_part_button_separator.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
diff --git a/library/src/main/res/layout/dialog_part_custom.xml b/library/src/main/res/layout/dialog_part_custom.xml
deleted file mode 100644
index a3eeab2..0000000
--- a/library/src/main/res/layout/dialog_part_custom.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_part_list.xml b/library/src/main/res/layout/dialog_part_list.xml
deleted file mode 100644
index d197970..0000000
--- a/library/src/main/res/layout/dialog_part_list.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_part_message.xml b/library/src/main/res/layout/dialog_part_message.xml
deleted file mode 100644
index c07f512..0000000
--- a/library/src/main/res/layout/dialog_part_message.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_part_progress.xml b/library/src/main/res/layout/dialog_part_progress.xml
deleted file mode 100644
index f849f95..0000000
--- a/library/src/main/res/layout/dialog_part_progress.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_part_title.xml b/library/src/main/res/layout/dialog_part_title.xml
deleted file mode 100644
index 0b68822..0000000
--- a/library/src/main/res/layout/dialog_part_title.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/library/src/main/res/layout/dialog_part_datepicker.xml b/library/src/main/res/layout/sdl_datepicker.xml
similarity index 80%
rename from library/src/main/res/layout/dialog_part_datepicker.xml
rename to library/src/main/res/layout/sdl_datepicker.xml
index 8db41be..8471897 100644
--- a/library/src/main/res/layout/dialog_part_datepicker.xml
+++ b/library/src/main/res/layout/sdl_datepicker.xml
@@ -1,5 +1,5 @@
\ No newline at end of file
diff --git a/library/src/main/res/layout/sdl_dialog.xml b/library/src/main/res/layout/sdl_dialog.xml
new file mode 100644
index 0000000..f027b19
--- /dev/null
+++ b/library/src/main/res/layout/sdl_dialog.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/layout/sdl_list_item.xml b/library/src/main/res/layout/sdl_list_item.xml
new file mode 100644
index 0000000..e81f9ea
--- /dev/null
+++ b/library/src/main/res/layout/sdl_list_item.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/library/src/main/res/layout/sdl_progress.xml b/library/src/main/res/layout/sdl_progress.xml
new file mode 100644
index 0000000..adb7f31
--- /dev/null
+++ b/library/src/main/res/layout/sdl_progress.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_part_timepicker.xml b/library/src/main/res/layout/sdl_timepicker.xml
similarity index 78%
rename from library/src/main/res/layout/dialog_part_timepicker.xml
rename to library/src/main/res/layout/sdl_timepicker.xml
index 9343790..0c79560 100644
--- a/library/src/main/res/layout/dialog_part_timepicker.xml
+++ b/library/src/main/res/layout/sdl_timepicker.xml
@@ -1,5 +1,5 @@
-
-
-
+
+
\ No newline at end of file
diff --git a/library/src/main/res/values-v11/sdl__theme.xml b/library/src/main/res/values-v11/sdl__theme.xml
deleted file mode 100644
index 72a4dc7..0000000
--- a/library/src/main/res/values-v11/sdl__theme.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/sdl__attrs.xml b/library/src/main/res/values/sdl__attrs.xml
deleted file mode 100644
index 8d6b2ae..0000000
--- a/library/src/main/res/values/sdl__attrs.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/sdl__colors.xml b/library/src/main/res/values/sdl__colors.xml
deleted file mode 100755
index 3db8b38..0000000
--- a/library/src/main/res/values/sdl__colors.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- #FFFFFF
- #ff0099cc
- #ff0099cc
- @color/sdl_primary_text_holo_dark
- @android:color/transparent
- #990099cc
- #4C0099cc
- #12ffffff
- #eeffffff
-
- #333333
- #33B5E5
- #33B5E5
- @color/sdl_primary_text_holo_light
- @android:color/transparent
- #9933B5E5
- #4C33B5E5
- #25000000
- #ee000000
-
-
- #fff3f3f3
- #ff000000
- #ff4c4c4c
- #ffb2b2b2
-
-
diff --git a/library/src/main/res/values/sdl__ids.xml b/library/src/main/res/values/sdl__ids.xml
deleted file mode 100644
index 047bc0f..0000000
--- a/library/src/main/res/values/sdl__ids.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/sdl__strings.xml b/library/src/main/res/values/sdl__strings.xml
deleted file mode 100644
index 18a8935..0000000
--- a/library/src/main/res/values/sdl__strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- Close
-
diff --git a/library/src/main/res/values/sdl__theme.xml b/library/src/main/res/values/sdl__theme.xml
deleted file mode 100644
index bb5400c..0000000
--- a/library/src/main/res/values/sdl__theme.xml
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/library/src/main/res/values/sdl_colors.xml b/library/src/main/res/values/sdl_colors.xml
new file mode 100755
index 0000000..cfdd982
--- /dev/null
+++ b/library/src/main/res/values/sdl_colors.xml
@@ -0,0 +1,8 @@
+
+
+
+ #DE000000
+ #8A000000
+ #1F000000
+ #D5D5D5
+
diff --git a/library/src/main/res/values/sdl__dimens.xml b/library/src/main/res/values/sdl_dimens.xml
similarity index 100%
rename from library/src/main/res/values/sdl__dimens.xml
rename to library/src/main/res/values/sdl_dimens.xml
diff --git a/library/src/main/res/values/sdl_styles.xml b/library/src/main/res/values/sdl_styles.xml
new file mode 100644
index 0000000..da43442
--- /dev/null
+++ b/library/src/main/res/values/sdl_styles.xml
@@ -0,0 +1,162 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/maven_push.gradle b/maven_push.gradle
deleted file mode 100644
index 096d73f..0000000
--- a/maven_push.gradle
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2013 Chris Banes
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-apply plugin: 'maven'
-apply plugin: 'signing'
-
-def isReleaseBuild() {
- return VERSION_NAME.contains("SNAPSHOT") == false
-}
-
-def getReleaseRepositoryUrl() {
- return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
- : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
-}
-
-def getSnapshotRepositoryUrl() {
- return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
- : "https://oss.sonatype.org/content/repositories/snapshots/"
-}
-
-def getRepositoryUsername() {
- return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
-}
-
-def getRepositoryPassword() {
- return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
-}
-
-afterEvaluate { project ->
- uploadArchives {
- repositories {
- mavenDeployer {
- beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-
- pom.groupId = GROUP
- pom.artifactId = POM_ARTIFACT_ID
- pom.version = VERSION_NAME
-
- repository(url: getReleaseRepositoryUrl()) {
- authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
- }
- snapshotRepository(url: getSnapshotRepositoryUrl()) {
- authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
- }
-
- pom.project {
- name POM_NAME
- packaging POM_PACKAGING
- description POM_DESCRIPTION
- url POM_URL
-
- scm {
- url POM_SCM_URL
- connection POM_SCM_CONNECTION
- developerConnection POM_SCM_DEV_CONNECTION
- }
-
- licenses {
- license {
- name POM_LICENCE_NAME
- url POM_LICENCE_URL
- distribution POM_LICENCE_DIST
- }
- }
-
- developers {
- developer {
- id POM_DEVELOPER_ID
- name POM_DEVELOPER_NAME
- }
- }
- }
- }
- }
- }
-
- signing {
- required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
- sign configurations.archives
- }
-
- task androidJavadocs(type: Javadoc) {
- source = android.sourceSets.main.java
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
- }
-
- task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
- classifier = 'javadoc'
- from androidJavadocs.destinationDir
- }
-
- task androidSourcesJar(type: Jar) {
- classifier = 'sources'
- from android.sourceSets.main.java
- }
-
- artifacts {
- archives androidSourcesJar
- archives androidJavadocsJar
- }
-}
\ No newline at end of file