Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoLSN committed Jun 14, 2016
2 parents 5104bb3 + 2e99cb9 commit c4f6879
Show file tree
Hide file tree
Showing 27 changed files with 1,346 additions and 115 deletions.
61 changes: 51 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
DialogAlchemy
========

[![Release](https://jitpack.io/v/NeoLSN/DialogAlchemy.svg?style=flat)](https://jitpack.io/#NeoLSN/DialogAlchemy)

<img src="https://github.com/NeoLSN/DialogAlchemy/raw/master/arts/device_portrait.png" height="300" alt="Portrait image" />
<img src="https://github.com/NeoLSN/DialogAlchemy/raw/master/arts/device_landscape.png" width="300" alt="Landscape image" />

This is a dialog utility library. It provides a easy way to let developers deal with screen rotation issue.

Installation
Expand All @@ -12,28 +17,34 @@ repositories {
}
dependencies {
...
compile 'com.github.NeoLSN:DialogAlchemy:1.0.0'
compile 'com.github.NeoLSN:DialogAlchemy:1.1.0'
}
```
API
--------
- Alchemist - Dialog fragment
- Material - Basic dialog model
- PhilosopherStone - A interface for custom view
- Material - Basic dialog model for most of Android Dialog library
- PhilosopherStone - There are two purpose for Philosopher Stone
1. A interface for custom view (main purpose)
2. Expand the Dialog library ability
- Be a model, not be a controller
- TransmutationCircle - A interface for dialog creation factory
1. Should satisfy Material model requirement
2. At least process PhilosopherStone as a custom view
3. Increase
- DialogAlchemy - A utility class to show a dialog

Usage
--------
##### Basic Usage
#### Basic Usage
```Java
Material material = new Material.Builder(getActivity())
.setTitle("Dialog Title")
.setMessage("Dialog message")
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
... do something ...
... Do something ...
}
})
.setNegativeButton(android.R.string.cancel, null)
Expand All @@ -42,7 +53,7 @@ Usage
Alchemist alchemist = DialogAlchemy.show(getFragmentManager(), material);
```

##### Advanced Usage
#### Advanced Usage
```Java
//Create a custom view
PhilosopherStone stone = new EditTextStone.Builder()
Expand All @@ -56,7 +67,7 @@ Usage
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
... do something ...
... Do something ...
}
})
.setNegativeButton(android.R.string.cancel, null)
Expand All @@ -83,7 +94,7 @@ When ```DialogAlchemy.show()``` called, it will set a tag to ```Alchemist``` aut
Material material = alchemist.getMaterial();
Material.Builder builder = material.rebuild(this);

// reset listner or callback in here
// reset listener or callback in here

Material newMaterial = builder.build();
alchemist.setMaterial(newMaterial);
Expand All @@ -109,7 +120,7 @@ When ```DialogAlchemy.show()``` called, it will set a tag to ```Alchemist``` aut
Material material = alchemist.getMaterial();
Material.Builder builder = material.rebuild(this);

// reset listner or callback in here
// reset listener or callback in here

Material newMaterial = builder.build();
alchemist.setMaterial(newMaterial);
Expand All @@ -122,4 +133,34 @@ When ```DialogAlchemy.show()``` called, it will set a tag to ```Alchemist``` aut

super.onSaveInstanceState(outState);
}
```
```
#### Set default TransmutationCircle
```Java
public class DemoApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
...
DialogAlchemy.setDefaultCircle(new MetalTransmutationCircle());
}
}
```

License
--------

Copyright (C) 2016 Jason Yang
Copyright (C) 2007 The Android Open Source Project

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.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ dependencies {
compile project(path: ':library')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.github.fengdai:alertdialogpro-theme-holo:0.2.6'
compile 'com.afollestad.material-dialogs:core:0.8.5.9'

testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ui.android.dialogalchemy;
package ui.android.dialogalchemy.example;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
Expand All @@ -23,6 +23,6 @@ public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("ui.android.dialogalchemy", appContext.getPackageName());
assertEquals("ui.android.dialogalchemy.example", appContext.getPackageName());
}
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="ui.android.dialogalchemy.example">

<application
android:name=".DemoApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ui.android.dialogalchemy.example;

import android.app.Application;

import ui.android.dialogalchemy.DialogAlchemy;
import ui.android.dialogalchemy.circle.MetalTransmutationCircle;

/**
* Created by JasonYang on 2016/6/14.
*/
public class DemoApplication extends Application {

@Override
public void onCreate() {
super.onCreate();

DialogAlchemy.setDefaultCircle(new MetalTransmutationCircle());
}
}
Loading

0 comments on commit c4f6879

Please sign in to comment.