use of com.afollestad.materialdialogs.MaterialDialog in project AntennaPod by AntennaPod.
the class VariableSpeedDialog method showGetPluginDialog.
private static void showGetPluginDialog(final Context context, boolean showSpeedSelector) {
MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
builder.title(R.string.no_playback_plugin_title);
builder.content(R.string.no_playback_plugin_or_sonic_msg);
builder.positiveText(R.string.enable_sonic);
builder.negativeText(R.string.download_plugin_label);
builder.neutralText(R.string.close_label);
builder.onPositive((dialog, which) -> {
if (Build.VERSION.SDK_INT >= 16) {
// just to be safe
UserPreferences.enableSonic(true);
if (showSpeedSelector) {
showSpeedSelectorDialog(context);
}
}
});
builder.onNegative((dialog, which) -> {
try {
context.startActivity(playStoreIntent);
} catch (ActivityNotFoundException e) {
// this is usually thrown on an emulator if the Android market is not installed
Log.e(TAG, Log.getStackTraceString(e));
}
});
builder.forceStacking(true);
MaterialDialog dialog = builder.show();
if (Build.VERSION.SDK_INT < 16) {
View pos = dialog.getActionButton(DialogAction.POSITIVE);
pos.setEnabled(false);
}
if (!IntentUtils.isCallable(context.getApplicationContext(), playStoreIntent)) {
View pos = dialog.getActionButton(DialogAction.NEGATIVE);
pos.setEnabled(false);
}
}
use of com.afollestad.materialdialogs.MaterialDialog in project AntennaPod by AntennaPod.
the class PreferenceController method showChooseDataFolderDialog.
private void showChooseDataFolderDialog() {
Context context = ui.getActivity();
File dataFolder = UserPreferences.getDataFolder(null);
if (dataFolder == null) {
new MaterialDialog.Builder(ui.getActivity()).title(R.string.error_label).content(R.string.external_storage_error_msg).neutralText(android.R.string.ok).show();
return;
}
String dataFolderPath = dataFolder.getAbsolutePath();
int selectedIndex = -1;
File[] mediaDirs = ContextCompat.getExternalFilesDirs(context, null);
List<String> folders = new ArrayList<>(mediaDirs.length);
List<CharSequence> choices = new ArrayList<>(mediaDirs.length);
for (int i = 0; i < mediaDirs.length; i++) {
File dir = mediaDirs[i];
if (dir == null || !dir.exists() || !dir.canRead() || !dir.canWrite()) {
continue;
}
String path = mediaDirs[i].getAbsolutePath();
folders.add(path);
if (dataFolderPath.equals(path)) {
selectedIndex = i;
}
int index = path.indexOf("Android");
String choice;
if (index >= 0) {
choice = path.substring(0, index);
} else {
choice = path;
}
long bytes = StorageUtils.getFreeSpaceAvailable(path);
String freeSpace = String.format(context.getString(R.string.free_space_label), Converter.byteToString(bytes));
choices.add(Html.fromHtml("<html><small>" + choice + " [" + freeSpace + "]" + "</small></html>"));
}
if (choices.size() == 0) {
new MaterialDialog.Builder(ui.getActivity()).title(R.string.error_label).content(R.string.external_storage_error_msg).neutralText(android.R.string.ok).show();
return;
}
MaterialDialog dialog = new MaterialDialog.Builder(ui.getActivity()).title(R.string.choose_data_directory).content(R.string.choose_data_directory_message).items(choices.toArray(new CharSequence[choices.size()])).itemsCallbackSingleChoice(selectedIndex, (dialog1, itemView, which, text) -> {
String folder = folders.get(which);
Log.d(TAG, "data folder: " + folder);
UserPreferences.setDataFolder(folder);
setDataFolderText();
return true;
}).negativeText(R.string.cancel_label).cancelable(true).build();
dialog.show();
}
use of com.afollestad.materialdialogs.MaterialDialog in project Weather by Sparker0i.
the class GPSTracker method showSettingsAlert.
/**
* Function to show settings alert dialog
* On pressing Settings button will launch Settings Options
* */
public void showSettingsAlert() {
new MaterialDialog.Builder(mContext).title("Enable GPS").content("You need to enable GPS for this function to work").positiveText("ENABLE").onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
}
}).negativeText("CANCEL").onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).show();
}
use of com.afollestad.materialdialogs.MaterialDialog in project Tapad by berict.
the class UserBenefitsActivity method showDialogPreset.
private void showDialogPreset(int delay) {
Handler dialogDelay = new Handler();
dialogDelay.postDelayed(new Runnable() {
@Override
public void run() {
int color;
switch(prefs.getInt("scheme", 0)) {
case 1:
color = R.color.hello;
break;
case 2:
color = R.color.roses;
break;
case 3:
color = R.color.faded;
break;
default:
color = R.color.hello;
break;
}
PresetDialog = new MaterialDialog.Builder(activity).title(R.string.dialog_preset_title).content(R.string.user_benefits_dialog_hint).items(R.array.presets).cancelable(false).autoDismiss(false).itemsCallbackSingleChoice(0, new MaterialDialog.ListCallbackSingleChoice() {
@Override
public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
setPreset(which);
switch(which) {
case 0:
PresetDialog.getBuilder().widgetColorRes(R.color.hello).positiveColorRes(R.color.hello);
break;
case 1:
PresetDialog.getBuilder().widgetColorRes(R.color.roses).positiveColorRes(R.color.roses);
break;
case 2:
PresetDialog.getBuilder().widgetColorRes(R.color.faded).positiveColorRes(R.color.faded);
break;
default:
break;
}
return true;
}
}).alwaysCallSingleChoiceCallback().widgetColorRes(color).positiveText(R.string.user_benefits_dialog_positive).positiveColorRes(R.color.colorAccent).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
PresetDialog.dismiss();
intent.intentFlag(activity, "activity.MainActivity", 0);
prefs.edit().putInt("quickstart", 0).apply();
}
}).show();
}
}, delay);
}
use of com.afollestad.materialdialogs.MaterialDialog in project Tapad by berict.
the class MainActivity method setQuickstart.
public void setQuickstart(final Activity activity) {
final SharedPreferences pref = activity.getSharedPreferences(APPLICATION_ID, MODE_PRIVATE);
try {
currentVersionCode = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionCode;
Log.i("versionCode", "versionCode retrieved = " + String.valueOf(currentVersionCode));
} catch (android.content.pm.PackageManager.NameNotFoundException e) {
// handle exception
currentVersionCode = -1;
Log.e("NameNotFound", "NNFE, currentVersionCode = -1");
}
try {
Log.d("VersionCode", "sharedPrefs versionCode = " + String.valueOf(pref.getInt("versionCode", -1)) + " , currentVersionCode = " + String.valueOf(currentVersionCode));
Log.d("VersionCode", "Updated, show changelog");
if (currentVersionCode > pref.getInt("versionCode", -1)) {
// new app and updates
new MaterialDialog.Builder(activity).title(w.getStringId("info_tapad_info_changelog")).content(w.getStringId("info_tapad_info_changelog_text")).contentColorRes(R.color.dark_primary).positiveText(R.string.dialog_close).positiveColorRes(R.color.colorAccent).dismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
// Dialog
if (pref.getInt(qs, 0) == 0) {
closeToolbar(activity);
new MaterialDialog.Builder(activity).title(R.string.dialog_quickstart_welcome_title).content(R.string.dialog_quickstart_welcome_text).positiveText(R.string.dialog_quickstart_welcome_positive).positiveColorRes(R.color.colorAccent).negativeText(R.string.dialog_quickstart_welcome_negative).negativeColorRes(R.color.dark_secondary).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
pref.edit().putInt(qs, 0).apply();
Log.i("sharedPrefs", "quickstart edited to 0");
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
pref.edit().putInt(qs, -1).apply();
Log.i("sharedPrefs", "quickstart edited to -1");
}
}).dismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
if (pref.getInt(qs, 0) == 0) {
Log.i("setQuickstart", "Quickstart started");
if (promptFab != null) {
return;
}
promptToggle = new MaterialTapTargetPrompt.Builder(activity).setTarget(activity.findViewById(R.id.tgl1)).setPrimaryText(R.string.dialog_tap_target_toggle_primary).setSecondaryText(R.string.dialog_tap_target_toggle_secondary).setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false).setAutoFinish(false).setFocalColourFromRes(R.color.white).setCaptureTouchEventOutsidePrompt(true).setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
if (tappedTarget) {
promptToggle.finish();
promptToggle = null;
pref.edit().putInt(qs, 1).apply();
Log.i("sharedPrefs", "quickstart edited to 1");
}
}
@Override
public void onHidePromptComplete() {
promptButton = new MaterialTapTargetPrompt.Builder(activity).setTarget(activity.findViewById(R.id.btn31)).setPrimaryText(R.string.dialog_tap_target_button_primary).setSecondaryText(R.string.dialog_tap_target_button_secondary).setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false).setAutoFinish(false).setFocalColourFromRes(R.color.white).setFocalRadius((float) w.convertDPtoPX(80, activity)).setCaptureTouchEventOutsidePrompt(true).setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
if (tappedTarget) {
promptButton.finish();
promptButton = null;
pref.edit().putInt(qs, 3).apply();
Log.i("sharedPrefs", "quickstart edited to 3");
}
}
@Override
public void onHidePromptComplete() {
promptSwipe = new MaterialTapTargetPrompt.Builder(activity).setTarget(activity.findViewById(R.id.btn23)).setPrimaryText(R.string.dialog_tap_target_swipe_primary).setSecondaryText(R.string.dialog_tap_target_swipe_secondary).setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false).setAutoFinish(false).setFocalColourFromRes(R.color.white).setFocalRadius((float) w.convertDPtoPX(80, activity)).setCaptureTouchEventOutsidePrompt(true).setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
if (tappedTarget) {
promptSwipe.finish();
promptSwipe = null;
pref.edit().putInt(qs, 4).apply();
Log.i("sharedPrefs", "quickstart edited to 4");
}
}
@Override
public void onHidePromptComplete() {
promptLoop = new MaterialTapTargetPrompt.Builder(activity).setTarget(activity.findViewById(R.id.btn42)).setPrimaryText(R.string.dialog_tap_target_loop_primary).setSecondaryText(R.string.dialog_tap_target_loop_secondary).setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false).setAutoFinish(false).setFocalColourFromRes(R.color.white).setFocalRadius((float) w.convertDPtoPX(80, activity)).setCaptureTouchEventOutsidePrompt(true).setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
if (tappedTarget) {
promptLoop.finish();
promptLoop = null;
pref.edit().putInt(qs, 5).apply();
Log.i("sharedPrefs", "quickstart edited to 5");
}
}
@Override
public void onHidePromptComplete() {
promptPattern = new MaterialTapTargetPrompt.Builder(activity).setTarget(activity.findViewById(R.id.tgl7)).setPrimaryText(R.string.dialog_tap_target_pattern_primary).setSecondaryText(R.string.dialog_tap_target_pattern_secondary).setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false).setAutoFinish(false).setFocalColourFromRes(R.color.white).setCaptureTouchEventOutsidePrompt(true).setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
if (tappedTarget) {
promptPattern.finish();
promptPattern = null;
pref.edit().putInt(qs, 5).apply();
Log.i("sharedPrefs", "quickstart edited to 5");
}
}
@Override
public void onHidePromptComplete() {
promptFab = new MaterialTapTargetPrompt.Builder(activity).setTarget(activity.findViewById(R.id.fab)).setPrimaryText(R.string.dialog_tap_target_fab_primary).setSecondaryText(R.string.dialog_tap_target_fab_secondary).setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false).setAutoFinish(false).setFocalColourFromRes(R.color.white).setCaptureTouchEventOutsidePrompt(true).setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
if (tappedTarget) {
promptFab.finish();
promptFab = null;
pref.edit().putInt(qs, 6).apply();
Log.i("sharedPrefs", "quickstart edited to 6");
}
}
@Override
public void onHidePromptComplete() {
promptPreset = new MaterialTapTargetPrompt.Builder(activity).setTarget(activity.findViewById(R.id.toolbar_preset)).setPrimaryText(R.string.dialog_tap_target_preset_primary).setSecondaryText(R.string.dialog_tap_target_preset_secondary).setAnimationInterpolator(new FastOutSlowInInterpolator()).setAutoDismiss(false).setAutoFinish(false).setFocalColourFromRes(R.color.blue_500).setCaptureTouchEventOutsidePrompt(true).setOnHidePromptListener(new MaterialTapTargetPrompt.OnHidePromptListener() {
@Override
public void onHidePrompt(MotionEvent event, boolean tappedTarget) {
if (tappedTarget) {
promptPreset.finish();
promptPreset = null;
pref.edit().putInt(qs, 7).apply();
Log.i("sharedPrefs", "quickstart edited to 7");
}
}
@Override
public void onHidePromptComplete() {
}
}).show();
}
}).show();
}
}).show();
}
}).show();
}
}).show();
}
}).show();
}
}).show();
} else {
Log.i("setQuickstart", "Quickstart canceled");
pref.edit().putInt(qs, -1).apply();
}
}
}).show();
}
// Change this
pref.edit().putInt("versionCode", currentVersionCode).apply();
Log.d("VersionCode", "putInt " + String.valueOf(pref.getInt("versionCode", -1)));
}
}).show();
}
} catch (Exception e) {
Log.e("QuickstartException", e.getMessage());
}
}
Aggregations