use of android.support.v7.app.AlertDialog.Builder in project Notes by lguipeng.
the class SettingFragment method showThemeChooseDialog.
@Override
public void showThemeChooseDialog() {
AlertDialog.Builder builder = DialogUtils.makeDialogBuilder(activity);
builder.setTitle(R.string.change_theme);
Integer[] res = new Integer[] { R.drawable.red_round, R.drawable.brown_round, R.drawable.blue_round, R.drawable.blue_grey_round, R.drawable.yellow_round, R.drawable.deep_purple_round, R.drawable.pink_round, R.drawable.green_round };
List<Integer> list = Arrays.asList(res);
ColorsListAdapter adapter = new ColorsListAdapter(getActivity(), list);
adapter.setCheckItem(ThemeUtils.getCurrentTheme(activity).getIntValue());
GridView gridView = (GridView) LayoutInflater.from(activity).inflate(R.layout.colors_panel_layout, null);
gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gridView.setCacheColorHint(0);
gridView.setAdapter(adapter);
builder.setView(gridView);
final AlertDialog dialog = builder.show();
gridView.setOnItemClickListener((parent, view, position, id) -> {
dialog.dismiss();
settingPresenter.onThemeChoose(position);
});
}
use of android.support.v7.app.AlertDialog.Builder in project Notes by lguipeng.
the class AboutActivity method showShareDialog.
private void showShareDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.ShareDialog);
builder.setTitle(getString(R.string.share));
final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(this);
String[] array = getResources().getStringArray(R.array.share_dialog_text);
adapter.add(new ShareListItem.Builder(this).content(array[0]).icon(R.drawable.ic_wx_logo).build());
adapter.add(new ShareListItem.Builder(this).content(array[1]).icon(R.drawable.ic_wx_moments).build());
adapter.add(new ShareListItem.Builder(this).content(array[2]).icon(R.drawable.ic_wx_collect).build());
adapter.add(new ShareListItem.Builder(this).content(array[3]).icon(R.drawable.ic_sina_logo).build());
adapter.add(new ShareListItem.Builder(this).content(array[4]).icon(R.drawable.ic_share_more).build());
builder.setAdapter(adapter, (dialog, which) -> {
switch(which) {
case 0:
shareToWeChatSession();
break;
case 1:
shareToWeChatTimeline();
break;
case 2:
shareToWeChatFavorite();
break;
case 3:
shareToWeibo();
break;
default:
share("", null);
}
});
AlertDialog dialog = builder.create();
Window window = dialog.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams lp = window.getAttributes();
Display display = getWindowManager().getDefaultDisplay();
Point out = new Point();
display.getSize(out);
lp.width = out.x;
window.setAttributes(lp);
View decorView = window.getDecorView();
decorView.setBackgroundColor(getResources().getColor(R.color.window_background));
dialog.setOnShowListener((dialog1 -> {
Animator animator = ObjectAnimator.ofFloat(decorView, "translationY", decorView.getMeasuredHeight() / 1.5F, 0);
animator.setDuration(200);
animator.start();
}));
dialog.show();
}
use of android.support.v7.app.AlertDialog.Builder in project material-components-android by material-components.
the class BottomSheetDialogTest method showDialog.
private void showDialog() {
Context context = activityTestRule.getActivity();
mDialog = new BottomSheetDialog(context);
AppCompatTextView text = new AppCompatTextView(context);
StringBuilder builder = new StringBuilder();
builder.append("It is fine today. ");
text.setText(builder);
mDialog.setContentView(text);
mDialog.show();
}
use of android.support.v7.app.AlertDialog.Builder in project android by owncloud.
the class ReceiveExternalFilesActivity method onCreateDialog.
@Override
protected Dialog onCreateDialog(final int id) {
final AlertDialog.Builder builder = new Builder(this);
switch(id) {
case DIALOG_NO_ACCOUNT:
builder.setIcon(R.drawable.ic_warning);
builder.setTitle(R.string.uploader_wrn_no_account_title);
builder.setMessage(String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name)));
builder.setCancelable(false);
builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) {
// using string value since in API7 this
// constatn is not defined
// in API7 < this constatant is defined in
// Settings.ADD_ACCOUNT_SETTINGS
// and Settings.EXTRA_AUTHORITIES
Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() });
startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
} else {
// since in API7 there is no direct call for
// account setup, so we need to
// show our own AccountSetupAcricity, get
// desired results and setup
// everything for ourself
Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class);
startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
}
}
});
builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
return builder.create();
case DIALOG_MULTIPLE_ACCOUNT:
Account[] accounts = mAccountManager.getAccountsByType(MainApp.getAccountType());
CharSequence[] dialogItems = new CharSequence[accounts.length];
OwnCloudAccount oca;
for (int i = 0; i < dialogItems.length; ++i) {
try {
oca = new OwnCloudAccount(accounts[i], this);
dialogItems[i] = oca.getDisplayName() + " @ " + DisplayUtils.convertIdn(accounts[i].name.substring(accounts[i].name.lastIndexOf("@") + 1), false);
} catch (Exception e) {
Log_OC.w(TAG, "Couldn't read display name of account; using account name instead");
dialogItems[i] = DisplayUtils.convertIdn(accounts[i].name, false);
}
}
builder.setTitle(R.string.common_choose_account);
builder.setItems(dialogItems, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]);
onAccountSet(mAccountWasRestored);
dialog.dismiss();
mAccountSelected = true;
mAccountSelectionShowing = false;
}
});
builder.setCancelable(true);
builder.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mAccountSelectionShowing = false;
dialog.cancel();
finish();
}
});
return builder.create();
default:
throw new IllegalArgumentException("Unknown dialog id: " + id);
}
}
use of android.support.v7.app.AlertDialog.Builder in project android by owncloud.
the class ChangelogDialog method onCreateDialog.
/**
* {@inheritDoc}
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
/// load the custom view to insert in the dialog, between title and
WebView webview = new WebView(getActivity());
webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
/// build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
Dialog dialog = builder.setView(webview).setIcon(DisplayUtils.getSeasonalIconId()).setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create();
dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
return dialog;
}
Aggregations