Skip to content

Commit

Permalink
Fix #28 Use AppCompat AlertDialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed May 12, 2016
1 parent 8a8ed8a commit d1eb761
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
5 changes: 2 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile('com.github.afollestad.material-dialogs:core:0.8.5.8@aar') { transitive = true }
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.media.RingtoneManager;
import android.support.design.widget.Snackbar;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AlertDialog;
import android.view.View;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.github.javiersantos.appupdater.enums.UpdateFrom;

import java.net.URL;
Expand All @@ -20,31 +20,35 @@ class UtilsDisplay {
static void showUpdateAvailableDialog(final Context context, String title, String content, String btnNegative, String btnPositive, String btnNeutral, final UpdateFrom updateFrom, final URL apk) {
final LibraryPreferences libraryPreferences = new LibraryPreferences(context);

new MaterialDialog.Builder(context)
.title(title)
.content(content)
.positiveText(btnPositive)
.negativeText(btnNegative)
.neutralText(btnNeutral)
.onPositive(new MaterialDialog.SingleButtonCallback() {
new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(content)
.setPositiveButton(btnPositive, new DialogInterface.OnClickListener() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
public void onClick(DialogInterface dialogInterface, int i) {
UtilsLibrary.goToUpdate(context, updateFrom, apk);
}
})
.onNeutral(new MaterialDialog.SingleButtonCallback() {
.setNegativeButton(btnNegative, new DialogInterface.OnClickListener() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
public void onClick(DialogInterface dialogInterface, int i) {}
})
.setNeutralButton(btnNeutral, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
libraryPreferences.setAppUpdaterShow(false);
}
}).show();
}

static void showUpdateNotAvailableDialog(final Context context, String title, String content) {
new MaterialDialog.Builder(context)
.title(title)
.content(content)
.positiveText(context.getResources().getString(android.R.string.ok))
new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(content)
.setPositiveButton(context.getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {}
})
.show();
}

Expand Down

0 comments on commit d1eb761

Please sign in to comment.