Java Code Examples for android.support.v7.app.AlertDialog#Builder

The following examples show how to use android.support.v7.app.AlertDialog#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrivacySettingsFragment.java    From Xndroid with GNU General Public License v3.0 6 votes vote down vote up
private void clearHistoryDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setTitle(getResources().getString(R.string.title_clear_history));
    Dialog dialog = builder.setMessage(getResources().getString(R.string.dialog_history))
        .setPositiveButton(getResources().getString(R.string.action_yes),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    clearHistory()
                        .subscribeOn(Schedulers.io())
                        .observeOn(Schedulers.main())
                        .subscribe(new CompletableOnSubscribe() {
                            @Override
                            public void onComplete() {
                                Utils.showSnackbar(getActivity(), R.string.message_clear_history);
                            }
                        });
                }
            })
        .setNegativeButton(getResources().getString(R.string.action_no), null).show();
    BrowserDialog.setDialogSize(mActivity, dialog);
}
 
Example 2
Source File: EditLabelDialog.java    From OpenHub with GNU General Public License v3.0 6 votes vote down vote up
public EditLabelDialog(@NonNull Activity activity, @NonNull EditLabelListener editLabelListener,
                       @Nullable Label label) {
    this.activity = activity;
    this.label = label;
    this.listener = editLabelListener;
    isEditMode = label != null;
    colorArray = activity.getResources().getIntArray(R.array.labels_color_array);

    contentView = activity.getLayoutInflater().inflate(R.layout.layout_edit_label, null);
    unbinder = ButterKnife.bind(this, contentView);
    initContentView();

    AlertDialog.Builder builder = new AlertDialog.Builder(activity)
            .setTitle(isEditMode ? R.string.edit_label : R.string.create_label)
            .setView(contentView)
            .setOnDismissListener(this)
            .setPositiveButton(R.string.save, null)
            .setNegativeButton(R.string.cancel, null);
    if (label != null) {
        builder.setNeutralButton(R.string.delete, (dialog, which) -> {
            showDeleteLabelWarning();
        });
    }
    dialog = builder.create();
}
 
Example 3
Source File: ClipboardActivity.java    From XposedNavigationBar with GNU General Public License v3.0 6 votes vote down vote up
private void initAction() {
    View dialogView = LayoutInflater.from(this).inflate(R.layout.d_clip, null);
    rcvDialogApps = (RecyclerView) dialogView.findViewById(R.id.rcv_dialog_clip);
    rcvDialogApps.setLayoutManager(new LinearLayoutManager(this));
    rcvDialogApps.setHasFixedSize(true);
    DialogClipAdapter adapter = new DialogClipAdapter(clipData);
    rcvDialogApps.setAdapter(adapter);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getResources().getString(R.string.clipboard))
            .setView(dialogView)
            .setNegativeButton(R.string.no,null)
            .setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    Log.i(TAG, "onDismiss: ");
                    finish();
                }
            }).create().show();
}
 
Example 4
Source File: ColorPickerDialogBuilder.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private ColorPickerDialogBuilder(Context context, int theme) {
	defaultMargin = getDimensionAsPx(context, R.dimen.default_slider_margin);
	final int dialogMarginBetweenTitle = getDimensionAsPx(context, R.dimen.default_slider_margin_btw_title);

	builder = new AlertDialog.Builder(context, theme);
	pickerContainer = new LinearLayout(context);
	pickerContainer.setOrientation(LinearLayout.VERTICAL);
	pickerContainer.setGravity(Gravity.CENTER_HORIZONTAL);
	pickerContainer.setPadding(defaultMargin, dialogMarginBetweenTitle, defaultMargin, defaultMargin);

	LinearLayout.LayoutParams layoutParamsForColorPickerView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
	layoutParamsForColorPickerView.weight = 1;
	colorPickerView = new ColorPickerView(context);

	pickerContainer.addView(colorPickerView, layoutParamsForColorPickerView);

	builder.setView(pickerContainer);
}
 
Example 5
Source File: ws_Main3Activity.java    From styT with Apache License 2.0 5 votes vote down vote up
private void showThemeChooseDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(ws_Main3Activity.this);
    builder.setTitle("设置主题");
    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(ws_Main3Activity.this, list);
    adapter.setCheckItem(MyThemeUtils.getCurrentTheme(ws_Main3Activity.this).getIntValue());
    GridView gridView = (GridView) LayoutInflater.from(ws_Main3Activity.this).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(
            new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    dialog.dismiss();
                    int value = MyThemeUtils.getCurrentTheme(ws_Main3Activity.this).getIntValue();
                    if (value != position) {
                        PreferenceUtils.getInstance(ws_Main3Activity.this).saveParam("change_theme_key", position);
                        MyThemeUtils.Theme.mapValueToTheme(position);

                    }
                }
            }

    );
}
 
Example 6
Source File: VideoInviteActivity.java    From video-quickstart-android with MIT License 5 votes vote down vote up
public static AlertDialog createConnectDialog(String title,
                                              EditText roomEditText,
                                              DialogInterface.OnClickListener callParticipantsClickListener,
                                              DialogInterface.OnClickListener cancelClickListener,
                                              Context context) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    alertDialogBuilder.setIcon(R.drawable.ic_video_call_black_24dp);
    alertDialogBuilder.setTitle(title);
    alertDialogBuilder.setPositiveButton("Connect", callParticipantsClickListener);
    alertDialogBuilder.setNegativeButton("Cancel", cancelClickListener);
    alertDialogBuilder.setCancelable(false);
    alertDialogBuilder.setView(roomEditText);
    return alertDialogBuilder.create();
}
 
Example 7
Source File: MainActivity.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
/**
 * 弹出对话框更新app版本
 */
protected void showUpdateDialog() {

    // 检查是否是新版本
    String currentVersion = App.app.getVersionName();
    if (currentVersion.equals(serverVersion)) {
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("发现新版本:" + serverVersion);
    builder.setIcon(R.mipmap.ic_launcher);
    builder.setMessage(description);
    builder.setCancelable(false);
    builder.setPositiveButton("立即更新", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // 判断是否有写入SD权限
            if (ContextCompat.checkSelfPermission(mContext,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                // 申请权限
                ActivityCompat.requestPermissions(mContext,
                        new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                        PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
            } else {
                // 有写入权限直接下载apk
                downloadAPK();
            }
        }
    });
    builder.setNegativeButton("取消", null);
    builder.show();
}
 
Example 8
Source File: ActivityUtils.java    From memetastic with GNU General Public License v3.0 5 votes vote down vote up
public void showDialogWithRawFileInWebView(String fileInRaw, @StringRes int resTitleId) {
    WebView wv = new WebView(_context);
    wv.loadUrl("file:///android_res/raw/" + fileInRaw);
    AlertDialog.Builder dialog = new AlertDialog.Builder(_context)
            .setPositiveButton(android.R.string.ok, null)
            .setTitle(resTitleId)
            .setView(wv);
    dialogFullWidth(dialog.show(), true, false);
}
 
Example 9
Source File: EditMashProfileActivity.java    From biermacht with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a Builder for an AlertDialog which informs the User that the active Mash Profile has
 * been saved for use in other recipes.
 *
 * @return AlertDialog.Builder
 */
private AlertDialog.Builder onMashProfileSavedAlert() {
  return new AlertDialog.Builder(this)
          .setTitle("Profile Saved")
          .setMessage("Your mash profile has been saved! Make changes in the Mash Profile Editor.")
          .setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
          });
}
 
Example 10
Source File: HelpActivity.java    From Birdays with Apache License 2.0 5 votes vote down vote up
private void showAlertDialog(String title, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
}
 
Example 11
Source File: BarcodeCaptureActivity.java    From google-authenticator-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode,
    String[] permissions,
    int[] grantResults) {
  if (requestCode != RC_HANDLE_CAMERA_PERM) {
    Log.e(TAG, "Got unexpected permission result: " + requestCode);
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    return;
  }

  if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
    Log.d(TAG, "Camera permission granted - initialize the camera source");
    // We have permission, so create the camera source.
    createCameraSource();
    return;
  }

  Log.e(TAG, "Permission not granted: results len = " + grantResults.length
      + " Result code = " + (grantResults.length > 0 ? grantResults[0] : "(empty)"));

  // Permission is not granted.
  DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int id) {
      // If this activity is started from {@link AddAccountActivity}, open it again.
      if (mStartFromAddAccountActivity) {
        startActivity(new Intent(BarcodeCaptureActivity.this, AddAccountActivity.class));
      }
      finish();
    }
  };

  AlertDialog.Builder builder = new AlertDialog.Builder(this);
  builder.setMessage(R.string.no_camera_permission)
      .setPositiveButton(R.string.ok, listener)
      .show();
}
 
Example 12
Source File: WhitelistAppsActivity.java    From ForceDoze with GNU General Public License v3.0 5 votes vote down vote up
public void displayDialog(String title, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(getString(R.string.close_button_text), null);
    builder.show();
}
 
Example 13
Source File: ManageActivity.java    From ActivityDiary with GNU General Public License v3.0 5 votes vote down vote up
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
    Cursor c = (Cursor)parent.getItemAtPosition(position);
    if(c.getInt(c.getColumnIndex(ActivityDiaryContract.DiaryActivity._DELETED)) == 0) {
        Intent i = new Intent(ManageActivity.this, EditActivity.class);
        i.putExtra("activityID", c.getInt(c.getColumnIndex(ActivityDiaryContract.DiaryActivity._ID)));
        startActivity(i);
    }else{
        // selected item is deleted. Ask for undeleting it.
        AlertDialog.Builder builder = new AlertDialog.Builder(ManageActivity.this)
                .setTitle(R.string.dlg_undelete_activity_title)
                .setMessage(getResources().getString(R.string.dlg_undelete_activity_text,
                        c.getString(c.getColumnIndex(ActivityDiaryContract.DiaryActivity.NAME))))
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        ContentValues values = new ContentValues();
                        values.put(ActivityDiaryContract.DiaryActivity._DELETED, 0);

                        mQHandler.startUpdate(0,
                                null,
                                ContentUris.withAppendedId(ActivityDiaryContract.DiaryActivity.CONTENT_URI,
                                        c.getLong(c.getColumnIndex(ActivityDiaryContract.DiaryActivity._ID))),
                                values,
                                ActivityDiaryContract.DiaryActivity._ID + "=?",
                                new String[]{c.getString(c.getColumnIndex(ActivityDiaryContract.DiaryActivity._ID))}
                        );

                    }})
                .setNegativeButton(android.R.string.no, null);

        builder.create().show();

    }
}
 
Example 14
Source File: AbsLovelyDialog.java    From LovelyDialog with Apache License 2.0 5 votes vote down vote up
private void init(AlertDialog.Builder dialogBuilder, @LayoutRes int res) {
    dialogView = LayoutInflater.from(dialogBuilder.getContext()).inflate(res, null);
    dialog = dialogBuilder.setView(dialogView).create();

    iconView = findView(R.id.ld_icon);
    titleView = findView(R.id.ld_title);
    messageView = findView(R.id.ld_message);
    topTitleView = findView(R.id.ld_top_title);
}
 
Example 15
Source File: searchAdapter.java    From music_player with Open Software License 3.0 4 votes vote down vote up
private void showMusicInfo(final Activity context, final int position) {
        LayoutInflater inflater = context.getLayoutInflater();
        final View musicinfo_dialog = inflater.inflate(R.layout.musicinfo_dialog, (ViewGroup) context.findViewById(R.id.musicInfo_dialog));
        final EditText title = (EditText) musicinfo_dialog.findViewById(R.id.dialog_title);
        final EditText artist = (EditText) musicinfo_dialog.findViewById(R.id.dialog_artist);
        final EditText album = (EditText) musicinfo_dialog.findViewById(R.id.dialog_album);
        TextView duration = (TextView) musicinfo_dialog.findViewById(R.id.dialog_duration);
        TextView playtimes = (TextView) musicinfo_dialog.findViewById(R.id.dialog_playtimes);
        TextView path = (TextView) musicinfo_dialog.findViewById(R.id.dialog_path);
        final musicInfo nowMusic = musicInfoArrayList.get(position);
        title.setText(nowMusic.getMusicTitle());
        artist.setText(nowMusic.getMusicArtist());
        album.setText(nowMusic.getMusicAlbum());
        int totalSecond = nowMusic.getMusicDuration() / 1000;
        int minute = totalSecond / 60;
        int second = totalSecond - minute * 60;
        duration.setText(String.valueOf(minute) + "分" + String.valueOf(second) + "秒");
        playtimes.setText(String.valueOf(nowMusic.getTimes()));
        path.setText(nowMusic.getMusicData());
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("歌曲信息");
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                nowMusic.setmTitle(title.getText().toString());
                nowMusic.setmArtist(artist.getText().toString());
                nowMusic.setmAlbum(album.getText().toString());
                MyApplication.getBoxStore().boxFor(musicInfo.class).put(nowMusic);
                MyApplication.initialMusicInfo(context);
//                Intent intent = new Intent("permission_granted");
//                context.sendBroadcast(intent);
//                Intent intent2 = new Intent("list_permission_granted");
//                context.sendBroadcast(intent2);
//                EventBus.getDefault().post(new showListEvent(3));
//                Intent intent3 = new Intent("list_changed");
//                context.sendBroadcast(intent3);
                EventBus.getDefault().post(new showListEvent(2,3,6));
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
        builder.setView(musicinfo_dialog);
        builder.show();
    }
 
Example 16
Source File: IjkVideoView.java    From ZZShow with Apache License 2.0 4 votes vote down vote up
public void showMediaInfo() {
    if (mMediaPlayer == null)
        return;

    int selectedVideoTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_VIDEO);
    int selectedAudioTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_AUDIO);

    TableLayoutBinder builder = new TableLayoutBinder(getContext());
    builder.appendSection(R.string.mi_player);
    builder.appendRow2(R.string.mi_player, MediaPlayerCompat.getName(mMediaPlayer));
    builder.appendSection(R.string.mi_media);
    builder.appendRow2(R.string.mi_resolution, buildResolution(mVideoWidth, mVideoHeight, mVideoSarNum, mVideoSarDen));
    builder.appendRow2(R.string.mi_length, buildTimeMilli(mMediaPlayer.getDuration()));

    ITrackInfo trackInfos[] = mMediaPlayer.getTrackInfo();
    if (trackInfos != null) {
        int index = -1;
        for (ITrackInfo trackInfo : trackInfos) {
            index++;

            int trackType = trackInfo.getTrackType();
            if (index == selectedVideoTrack) {
                builder.appendSection(getContext().getString(R.string.mi_stream_fmt1, index) + " " + getContext().getString(R.string.mi__selected_video_track));
            } else if (index == selectedAudioTrack) {
                builder.appendSection(getContext().getString(R.string.mi_stream_fmt1, index) + " " + getContext().getString(R.string.mi__selected_audio_track));
            } else {
                builder.appendSection(getContext().getString(R.string.mi_stream_fmt1, index));
            }
            builder.appendRow2(R.string.mi_type, buildTrackType(trackType));
            builder.appendRow2(R.string.mi_language, buildLanguage(trackInfo.getLanguage()));

            IMediaFormat mediaFormat = trackInfo.getFormat();
            if (mediaFormat == null) {
            } else if (mediaFormat instanceof IjkMediaFormat) {
                switch (trackType) {
                    case ITrackInfo.MEDIA_TRACK_TYPE_VIDEO:
                        builder.appendRow2(R.string.mi_codec, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_LONG_NAME_UI));
                        builder.appendRow2(R.string.mi_profile_level, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PROFILE_LEVEL_UI));
                        builder.appendRow2(R.string.mi_pixel_format, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PIXEL_FORMAT_UI));
                        builder.appendRow2(R.string.mi_resolution, mediaFormat.getString(IjkMediaFormat.KEY_IJK_RESOLUTION_UI));
                        builder.appendRow2(R.string.mi_frame_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_FRAME_RATE_UI));
                        builder.appendRow2(R.string.mi_bit_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_BIT_RATE_UI));
                        break;
                    case ITrackInfo.MEDIA_TRACK_TYPE_AUDIO:
                        builder.appendRow2(R.string.mi_codec, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_LONG_NAME_UI));
                        builder.appendRow2(R.string.mi_profile_level, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PROFILE_LEVEL_UI));
                        builder.appendRow2(R.string.mi_sample_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_SAMPLE_RATE_UI));
                        builder.appendRow2(R.string.mi_channels, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CHANNEL_UI));
                        builder.appendRow2(R.string.mi_bit_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_BIT_RATE_UI));
                        break;
                    default:
                        break;
                }
            }
        }
    }

    AlertDialog.Builder adBuilder = builder.buildAlertDialogBuilder();
    adBuilder.setTitle(R.string.media_information);
    adBuilder.setNegativeButton(R.string.close, null);
    adBuilder.show();
}
 
Example 17
Source File: BaseActivity.java    From social-app-android with Apache License 2.0 4 votes vote down vote up
public void showWarningDialog(int messageId) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(messageId);
    builder.setPositiveButton(R.string.button_ok, null);
    builder.show();
}
 
Example 18
Source File: EditActivity.java    From homeassist with Apache License 2.0 4 votes vote down vote up
private void showAddDialog() {
    if (mEntities == null) mEntities = DatabaseManager.getInstance(this).getEntities();

    Collections.sort(mEntities, new Comparator<Entity>() {
        @Override
        public int compare(Entity lhs, Entity rhs) {
            return lhs.getFriendlyName().compareTo(rhs.getFriendlyName()); //descending order
        }
    });

    final ArrayAdapter<Entity> adapter = new ArrayAdapter<Entity>(this, android.R.layout.simple_list_item_1, mEntities) {
        @NonNull
        @Override
        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(getContext(), R.layout.item_widget_select, null);
            }

            Entity entity = mEntities.get(position);

            ViewGroup mItemView = convertView.findViewById(R.id.item);
            TextView mIconView = convertView.findViewById(R.id.text_mdi);
            TextView mMainText = convertView.findViewById(R.id.main_text);
            TextView mLabelText = convertView.findViewById(R.id.sub_text);

            ProgressBar mProgressBar = convertView.findViewById(R.id.progressbar);

            mItemView.setClickable(false);
            mItemView.setFocusable(false);
            mIconView.setText(entity.getMdiIcon());
            mMainText.setText(entity.attributes.friendlyName);
            mLabelText.setText(entity.getDomain());
            mProgressBar.setVisibility(View.GONE);
            return convertView;
        }
    };


    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.title_additem);
    builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            mEdited = true;
            Entity selectedEntity = mEntities.get(which);
            mItems.add(selectedEntity);
            mAdapter.notifyItemInserted(mItems.size() - 1);

        }
    });
    builder.show();
}
 
Example 19
Source File: HomeActivity.java    From Hillffair17 with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();
        switch(id) {
            case R.id.profile:
//                startActivity(new Intent(HomeActivity.this, ProfileActivity.class));
                break;
//            case R.id.settings:
//                startActivity(new Intent(HomeActivity.this, SettingsActivity.class));
//                finish();
//                break;
            case R.id.aboutus:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(String.format("%1$s", getString(R.string.app_name)));
                builder.setMessage(getResources().getText(R.string.aboutus_text));
                builder.setPositiveButton("OK", null);
                builder.setIcon(R.drawable.ic_action_about);
                AlertDialog welcomeAlert = builder.create();
                welcomeAlert.show();
                break;

            case R.id.report:  Intent intent = new Intent(Intent.ACTION_SENDTO);
                String uriText = "mailto:" + Uri.encode("[email protected]") + "?subject=" +
                        Uri.encode("Reporting A Bug/Feedback") + "&body=" + Uri.encode("Hello, Appteam \nI want to report a bug/give feedback corresponding to the app Hillfair 2k16.\n.....\n\n-Your name");

                Uri uri = Uri.parse(uriText);
                intent.setData(uri);
                startActivity(Intent.createChooser(intent, "Send Email"));
                break;
            case R.id.license:
                AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
                builder2.setTitle(String.format("%1$s", getString(R.string.open_source_licenses)));
                CharSequence str=getResources().getText(R.string.licenses_text);
                builder2.setMessage(str );
                builder2.setPositiveButton("OK", null);
                AlertDialog welcomeAlert2 = builder2.create();
                welcomeAlert2.show();
                ((TextView) welcomeAlert2.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
                break;
            case R.id.notification:
               startActivity(new Intent(HomeActivity.this, NotificationActivity.class));
                break;
            case R.id.logout:
//                pref.setUserId(null);
//                pref.setRollNo(null);
//                pref.setUserName(null);
//                startActivity(new Intent(HomeActivity.this,LoginActivity.class));
//                finish();
                break;

        }
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
 
Example 20
Source File: SettingsAdapter.java    From citra_android with GNU General Public License v3.0 3 votes vote down vote up
public void onSingleChoiceClick(SingleChoiceSetting item)
{
	mClickedItem = item;

	int value = getSelectionForSingleChoiceValue(item);

	AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

	builder.setTitle(item.getNameId());
	builder.setSingleChoiceItems(item.getChoicesId(), value, this);

	mDialog = builder.show();
}