Skip to content

Commit 712f1f0

Browse files
author
David Vavra
committed
Merge branch 'material'
2 parents 72dbc10 + 6032403 commit 712f1f0

File tree

87 files changed

+1389
-1973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1389
-1973
lines changed

README.md

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,45 @@
11
# StyledDialogs for Android
22

3-
This library makes styling and using dialogs _a piece of cake_.
4-
53
![Screenshot of the dialogs](graphics/screenshot-small.png)
64

75
Features:
86

9-
- Compatible with Holo style and **Android Design Guidelines**
10-
- Change style for all dialogs only by changing a **few color resources**
7+
- Compatible with **Material Design Guidelines**
118
- Same look for **Android 2.2+**
12-
- **Same API** as native Android DialogFragments
13-
- `SimpleDialogFragment` class, which makes displaying simple dialogs a **one line of code**
14-
- `ListDialogFragment`, `DatePickerDialogFragment` and `TimePickerDialogFragment`
9+
- Built on top of standard **DialogFragment**
10+
- Supports stacked buttons, neutral button, callbacks even after rotation
11+
- Contains even more specialized dialogs: List, Progress, Time&Date Picker, Custom, ...
1512

1613
## How to include it in your project:
1714

18-
With Gradle:
1915
```groovy
20-
compile 'eu.inmite.android.lib:android-styled-dialogs:1.2.0'
16+
dependencies {
17+
compile 'com.avast:android-styled-dialogs:2.0.0'
18+
}
2119
```
22-
23-
With Maven:
24-
```xml
25-
<dependency>
26-
<groupId>eu.inmite.android.lib</groupId>
27-
<artifactId>android-styled-dialogs</artifactId>
28-
<version>1.2.0</version>
29-
<type>aar</type>
30-
</dependency>
31-
```
32-
33-
Manually:
34-
35-
- clone the project
36-
- add it as library project in your IDE
37-
- include latest support library
20+
(from [jcenter](https://bintray.com/avast/android/styled-dialogs/))
3821

3922
## How to style all dialogs:
4023

41-
Add following into your application theme:
42-
```xml
43-
<item name="sdlDialogStyle">@style/DialogStyleLight.Custom</item>
44-
```
45-
or
46-
```xml
47-
<item name="sdlDialogStyle">@style/DialogStyleDark.Custom</item>
48-
```
49-
Define your dialog style, example for light theme:
24+
It uses standard Material colors, for example like this:
25+
5026
```xml
51-
<style name="DialogStyleLight.Custom">
52-
<!-- anything can be left out: -->
53-
<item name="titleTextColor">@color/dialog_title_text</item>
54-
<item name="titleSeparatorColor">@color/dialog_title_separator</item>
55-
<item name="messageTextColor">@color/dialog_message_text</item>
56-
<item name="buttonTextColor">@color/dialog_button_text</item>
57-
<item name="buttonSeparatorColor">@color/dialog_button_separator</item>
58-
<item name="buttonBackgroundColorNormal">@color/dialog_button_normal</item>
59-
<item name="buttonBackgroundColorPressed">@color/dialog_button_pressed</item>
60-
<item name="buttonBackgroundColorFocused">@color/dialog_button_focused</item>
61-
<item name="dialogBackground">@drawable/dialog_background</item>
27+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
28+
<item name="colorPrimary">@color/indigo</item>
29+
<item name="colorPrimaryDark">@color/indigo_dark</item>
30+
<item name="colorAccent">@color/pink</item>
6231
</style>
6332
```
6433

6534
## How to create simple dialogs:
6635

6736
Easy:
6837

69-
### Dialog with a simple message and Close button:
38+
### Dialog with a simple message only:
7039
```java
7140
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setMessage(R.string.message).show();
7241
```
73-
### Dialog with a title, message and Close button:
74-
```java
75-
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).show();
76-
```
42+
7743
### Dialog with a title, message and two buttons:
7844
```java
7945
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).setPositiveButtonText(R.string.positive_button).setNegativeButtonText(R.string.negative_button).show();

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
repositories {
3-
mavenCentral()
3+
jcenter()
44
}
55

66
dependencies {
@@ -9,12 +9,14 @@ buildscript {
99
}
1010

1111
allprojects {
12-
version = VERSION_NAME
13-
group = GROUP
14-
1512
repositories {
16-
mavenCentral()
13+
jcenter()
1714
}
1815
}
1916

17+
ext {
18+
VERSION_NAME = "2.0.1"
19+
VERSION_CODE = 6
20+
}
21+
2022
apply plugin: 'android-reporting'

demo/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ android {
55
buildToolsVersion "20"
66

77
defaultConfig {
8-
minSdkVersion 7
8+
minSdkVersion 8
99
targetSdkVersion 21
1010
versionName project.VERSION_NAME
11-
versionCode Integer.parseInt(project.VERSION_CODE)
11+
versionCode project.VERSION_CODE
1212
}
1313
}
1414

1515
dependencies {
16-
compile project(':library')
16+
compile project(":library")
1717
}

demo/src/main/AndroidManifest.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="eu.inmite.demo.dialogs"
4-
android:versionCode="1"
5-
android:versionName="1.0">
3+
package="com.avast.dialogs">
64

7-
<uses-sdk
8-
android:minSdkVersion="8"
9-
android:targetSdkVersion="17" />
105
<application
116
android:label="@string/app_name"
127
android:icon="@drawable/ic_launcher"
13-
android:theme="@style/CustomDarkTheme">
8+
android:theme="@style/AppTheme"
9+
android:allowBackup="true">
1410
<activity
15-
android:name=".MyActivity"
16-
android:label="@string/app_name">
11+
android:name=".DemoActivity">
1712
<intent-filter>
1813
<action android:name="android.intent.action.MAIN" />
1914
<category android:name="android.intent.category.LAUNCHER" />
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
/*
2+
* Copyright 2013 Inmite s.r.o. (www.inmite.eu).
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.avast.dialogs;
18+
19+
import java.text.DateFormat;
20+
import java.util.Date;
21+
22+
import android.os.Bundle;
23+
import android.support.v7.app.ActionBarActivity;
24+
import android.view.View;
25+
import android.widget.Toast;
26+
27+
import com.avast.android.dialogs.fragment.*;
28+
import com.avast.android.dialogs.iface.IDateDialogListener;
29+
import com.avast.android.dialogs.iface.IListDialogListener;
30+
import com.avast.android.dialogs.iface.ISimpleDialogCancelListener;
31+
import com.avast.android.dialogs.iface.ISimpleDialogListener;
32+
33+
public class DemoActivity extends ActionBarActivity implements
34+
ISimpleDialogListener,
35+
IDateDialogListener,
36+
ISimpleDialogCancelListener,
37+
IListDialogListener {
38+
39+
private static final int REQUEST_PROGRESS = 1;
40+
41+
DemoActivity c = this;
42+
43+
@Override
44+
public void onCreate(Bundle savedInstanceState) {
45+
super.onCreate(savedInstanceState);
46+
setContentView(R.layout.main);
47+
findViewById(R.id.message_dialog).setOnClickListener(new View.OnClickListener() {
48+
@Override
49+
public void onClick(View v) {
50+
SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
51+
.setMessage("Love. Can know all the math in the \'verse but take a boat in the air that you don\'t " +
52+
"love? She\'ll shake you off just as sure as a turn in the worlds. Love keeps her in the air when " +
53+
"she oughtta fall down...tell you she\'s hurtin\' \'fore she keens...makes her a home.").show();
54+
}
55+
});
56+
findViewById(R.id.message_title_dialog).setOnClickListener(new View.OnClickListener() {
57+
@Override
58+
public void onClick(View v) {
59+
SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
60+
.setTitle("More Firefly quotes:").setMessage
61+
("Wash: \"Psychic, though? That sounds like something out of science fiction.\"\n\nZoe: \"We live" +
62+
" " +
63+
"in a space ship, dear.\"\nWash: \"Here lies my beloved Zoe, " +
64+
("my autumn flower ... somewhat less attractive now that she's all corpsified and gross" +
65+
".\"\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" +
66+
"Mal: \"I can't know that.\" \n" +
67+
"Jayne: \"I can stand to hear a little more.\"\n\nWash: \"I've been under fire before. " +
68+
"Well ... I've been in a fire. Actually, I was fired. I can handle myself.\""))
69+
.setNegativeButtonText("Close")
70+
.show();
71+
}
72+
});
73+
findViewById(R.id.message_title_buttons_dialog)
74+
.setOnClickListener(new View.OnClickListener() {
75+
@Override
76+
public void onClick(View v) {
77+
SimpleDialogFragment.createBuilder(c, getSupportFragmentManager())
78+
.setTitle("Do you like this quote?")
79+
.setMessage("Jayne: \"Shiny. Let's be bad guys.\"")
80+
.setPositiveButtonText("Love")
81+
.setNegativeButtonText("Hate").setNeutralButtonText("WTF?").setRequestCode(42)
82+
.show();
83+
}
84+
});
85+
findViewById(R.id.long_buttons).setOnClickListener(new View.OnClickListener() {
86+
@Override
87+
public void onClick(View v) {
88+
SimpleDialogFragment.createBuilder(c, getSupportFragmentManager()).setMessage("How will you decide?")
89+
.setPositiveButtonText("Time for some thrillin' heroics!").setNegativeButtonText("Misbehave")
90+
.setNeutralButtonText("Keep flying").show();
91+
}
92+
});
93+
findViewById(R.id.progress_dialog).setOnClickListener(new View.OnClickListener() {
94+
@Override
95+
public void onClick(View v) {
96+
ProgressDialogFragment.createBuilder(c, getSupportFragmentManager())
97+
.setMessage("Mal: I\'m just waiting to see if I pass out. Long story.")
98+
.setRequestCode(REQUEST_PROGRESS)
99+
.show();
100+
}
101+
});
102+
findViewById(R.id.list_dialog).setOnClickListener(new View.OnClickListener() {
103+
@Override
104+
public void onClick(View v) {
105+
ListDialogFragment
106+
.createBuilder(c, getSupportFragmentManager())
107+
.setTitle("Your favorite character:")
108+
.setItems(new String[]{"Jayne", "Malcolm", "Kaylee",
109+
"Wash", "Zoe", "River"})
110+
.show();
111+
112+
}
113+
});
114+
findViewById(R.id.custom_dialog).setOnClickListener(new View.OnClickListener() {
115+
@Override
116+
public void onClick(View v) {
117+
JayneHatDialogFragment.show(c);
118+
}
119+
});
120+
findViewById(R.id.time_picker).setOnClickListener(new View.OnClickListener() {
121+
@Override
122+
public void onClick(View v) {
123+
TimePickerDialogFragment
124+
.createBuilder(DemoActivity.this, getSupportFragmentManager())
125+
.setDate(new Date())
126+
.set24hour(true)
127+
.setPositiveButtonText(android.R.string.ok)
128+
.setNegativeButtonText(android.R.string.cancel)
129+
.setRequestCode(13)
130+
.show();
131+
}
132+
});
133+
findViewById(R.id.date_picker).setOnClickListener(new View.OnClickListener() {
134+
@Override
135+
public void onClick(View v) {
136+
DatePickerDialogFragment
137+
.createBuilder(DemoActivity.this, getSupportFragmentManager())
138+
.setDate(new Date())
139+
.set24hour(true)
140+
.setPositiveButtonText(android.R.string.ok)
141+
.setNegativeButtonText(android.R.string.cancel)
142+
.setRequestCode(12)
143+
.show();
144+
}
145+
});
146+
}
147+
148+
// IListDialogListener
149+
150+
@Override
151+
public void onListItemSelected(String value, int number) {
152+
Toast.makeText(c, "Selected: " + value, Toast.LENGTH_SHORT).show();
153+
}
154+
155+
@Override
156+
public void onCancelled() {
157+
Toast.makeText(c, "Nothing selected", Toast.LENGTH_SHORT).show();
158+
}
159+
160+
// ISimpleDialogCancelListener
161+
162+
@Override
163+
public void onCancelled(int requestCode) {
164+
if (requestCode == 42) {
165+
Toast.makeText(c, "Dialog cancelled", Toast.LENGTH_SHORT).show();
166+
} else if (requestCode == REQUEST_PROGRESS) {
167+
Toast.makeText(c, "Progress dialog cancelled", Toast.LENGTH_SHORT).show();
168+
}
169+
}
170+
171+
// ISimpleDialogListener
172+
173+
@Override
174+
public void onPositiveButtonClicked(int requestCode) {
175+
if (requestCode == 42) {
176+
Toast.makeText(c, "Positive button clicked", Toast.LENGTH_SHORT).show();
177+
}
178+
}
179+
180+
@Override
181+
public void onNegativeButtonClicked(int requestCode) {
182+
if (requestCode == 42) {
183+
Toast.makeText(c, "Negative button clicked", Toast.LENGTH_SHORT).show();
184+
}
185+
}
186+
187+
@Override
188+
public void onNeutralButtonClicked(int requestCode) {
189+
if (requestCode == 42) {
190+
Toast.makeText(c, "Neutral button clicked", Toast.LENGTH_SHORT).show();
191+
}
192+
}
193+
194+
// IDateDialogListener
195+
196+
@Override
197+
public void onNegativeButtonClicked(int resultCode, Date date) {
198+
String text = "";
199+
if (resultCode == 12) {
200+
text = "Date ";
201+
} else if (resultCode == 13) {
202+
text = "Time ";
203+
}
204+
205+
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT);
206+
Toast.makeText(this, text + "Cancelled " + dateFormat.format(date), Toast.LENGTH_SHORT).show();
207+
}
208+
209+
@Override
210+
public void onPositiveButtonClicked(int resultCode, Date date) {
211+
String text = "";
212+
if (resultCode == 12) {
213+
text = "Date ";
214+
} else if (resultCode == 13) {
215+
text = "Time ";
216+
}
217+
218+
DateFormat dateFormat = DateFormat.getDateTimeInstance();
219+
Toast.makeText(this, text + "Success! " + dateFormat.format(date), Toast.LENGTH_SHORT).show();
220+
}
221+
}

0 commit comments

Comments
 (0)