use of android.support.v7.app.AlertDialog in project LeafPic by HoraApps.
the class AlertDialogsHelper method showChangelogDialog.
public static AlertDialog showChangelogDialog(final ThemedActivity activity) {
final AlertDialog.Builder changelogDialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_changelog, null);
TextView dialogTitle = dialogLayout.findViewById(R.id.dialog_changelog_title);
TextView dialogMessage = dialogLayout.findViewById(R.id.dialog_changelog_text);
CardView cvBackground = dialogLayout.findViewById(R.id.dialog_changelog_card);
ScrollView scrChangelog = dialogLayout.findViewById(R.id.changelog_scrollview);
cvBackground.setCardBackgroundColor(activity.getCardBackgroundColor());
dialogTitle.setBackgroundColor(activity.getPrimaryColor());
activity.getThemeHelper().setScrollViewColor(scrChangelog);
dialogTitle.setText(activity.getString(R.string.changelog));
Bypass bypass = new Bypass(activity);
String markdownString;
try {
markdownString = getChangeLogFromAssets(activity);
} catch (IOException e) {
ChromeCustomTabs.launchUrl(activity, LEAFPIC_CHANGELOG);
return null;
}
CharSequence string = bypass.markdownToSpannable(markdownString);
dialogMessage.setText(string);
dialogMessage.setMovementMethod(LinkMovementMethod.getInstance());
dialogMessage.setTextColor(activity.getTextColor());
changelogDialogBuilder.setView(dialogLayout);
changelogDialogBuilder.setPositiveButton(activity.getString(R.string.ok_action).toUpperCase(), null);
changelogDialogBuilder.setNeutralButton(activity.getString(R.string.show_full).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ChromeCustomTabs.launchUrl(activity, LEAFPIC_CHANGELOG);
}
});
return changelogDialogBuilder.show();
}
use of android.support.v7.app.AlertDialog in project LeafPic by HoraApps.
the class SelectAlbumBuilder method setupDialog.
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
View contentView = View.inflate(getContext(), R.layout.select_folder_bottom_sheet, null);
final RecyclerView mRecyclerView = contentView.findViewById(R.id.folders);
final Spinner spinner = contentView.findViewById(R.id.storage_spinner);
currentFolderPath = contentView.findViewById(R.id.bottom_sheet_sub_title);
exploreModePanel = contentView.findViewById(R.id.ll_explore_mode_panel);
imgExploreMode = contentView.findViewById(R.id.toggle_hidden_icon);
theme = ThemeHelper.getInstanceLoaded(getContext());
sdCardPath = StorageHelper.getSdcardPath(getContext());
mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, Measure.pxToDp(3, getContext()), true));
adapter = new BottomSheetAlbumsAdapter();
mRecyclerView.setAdapter(adapter);
spinner.setAdapter(new VolumeSpinnerAdapter(contentView.getContext()));
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) {
switch(pos) {
case INTERNAL_STORAGE:
displayContentFolder(Environment.getExternalStorageDirectory());
break;
default:
// }
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
/**
*SET UP THEME*
*/
contentView.findViewById(R.id.rl_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
exploreModePanel.setBackgroundColor(theme.getPrimaryColor());
contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
mRecyclerView.setBackgroundColor(theme.getBackgroundColor());
fabDone = contentView.findViewById(R.id.fab_bottomsheet_done);
fabDone.setBackgroundTintList(ColorStateList.valueOf(theme.getAccentColor()));
fabDone.setImageDrawable(new IconicsDrawable(getContext()).icon(GoogleMaterial.Icon.gmd_done).color(Color.WHITE));
fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
fabDone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
onFolderSelected.folderSelected(currentFolderPath.getText().toString());
}
});
((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
((ThemedIcon) contentView.findViewById(R.id.create_new_folder_icon)).setColor(theme.getIconColor());
contentView.findViewById(R.id.rl_create_new_folder).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final EditText editText = new EditText(getContext());
AlertDialog insertTextDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editText, R.string.new_folder);
insertTextDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
if (folderPath.mkdir())
displayContentFolder(folderPath);
}
});
insertTextDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
insertTextDialog.show();
}
});
contentView.findViewById(R.id.rl_bottom_sheet_title).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!forzed) {
toggleExplorerMode(!exploreMode);
fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
}
}
});
dialog.setContentView(contentView);
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
adapter.notifyDataSetChanged();
toggleExplorerMode(exploreMode);
}
use of android.support.v7.app.AlertDialog in project LeafPic by HoraApps.
the class SharedMediaActivity method requestSdCardPermissions.
public void requestSdCardPermissions() {
AlertDialog textDialog = AlertDialogsHelper.getTextDialog(this, R.string.sd_card_write_permission_title, R.string.sd_card_permissions_message);
textDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), REQUEST_CODE_SD_CARD_PERMISSIONS);
}
});
textDialog.show();
}
use of android.support.v7.app.AlertDialog in project instructure-android by instructure.
the class AuthenticationDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.authenticationRequired);
View root = LayoutInflater.from(getContext()).inflate(R.layout.dialog_auth, null);
mUsername = (EditText) root.findViewById(R.id.username);
mPassword = (EditText) root.findViewById(R.id.password);
builder.setView(root);
builder.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mCallback != null) {
mCallback.onRetrieveCredentials(mUsername.getText().toString(), mPassword.getText().toString());
}
dialog.dismiss();
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
return dialog;
}
use of android.support.v7.app.AlertDialog in project instructure-android by instructure.
the class AskInstructorDialogStyled method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(getActivity().getString(R.string.instructor_question)).setPositiveButton(getActivity().getString(R.string.send), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (canClickSend) {
if (message == null || message.getText().toString().trim().equals("")) {
Toast.makeText(getActivity(), getString(R.string.emptyMessage), Toast.LENGTH_SHORT).show();
} else {
progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getString(R.string.sending));
loadTeacherData();
}
}
}
});
// Suppress lint warning about null parent when inflating layout
@SuppressLint("InflateParams") final View view = LayoutInflater.from(getActivity()).inflate(R.layout.ask_instructor, null);
courseSpinner = view.findViewById(R.id.courseSpinner);
ArrayList<Course> loadingIndicator = new ArrayList<Course>();
Course loading = new Course();
loading.setName(getActivity().getString(R.string.loading));
loadingIndicator.add(loading);
courseAdapter = new CourseSpinnerAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, loadingIndicator);
// we haven't set an onItemSelectedListener, so selecting the item shouldn't do anything
courseSpinner.setAdapter(courseAdapter);
message = view.findViewById(R.id.message);
builder.setView(view);
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface worthless) {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ThemePrefs.getBrandColor());
ViewStyler.themeEditText(getContext(), (AppCompatEditText) message, ThemePrefs.getBrandColor());
}
});
dialog.setCanceledOnTouchOutside(true);
return dialog;
}
Aggregations