List of usage examples for android.support.v4.app DialogFragment show
public int show(FragmentTransaction transaction, String tag)
From source file:com.owncloud.android.ui.helpers.FileOperationsHelper.java
/** * Share link with other apps/* ww w . j a v a2 s. c o m*/ * * @param link link to share */ private void shareLink(String link) { Intent intentToShareLink = new Intent(Intent.ACTION_SEND); intentToShareLink.putExtra(Intent.EXTRA_TEXT, link); intentToShareLink.setType("text/plain"); String username = com.owncloud.android.lib.common.accounts.AccountUtils .getUsernameForAccount(mFileActivity.getAccount()); if (username != null) { intentToShareLink.putExtra(Intent.EXTRA_SUBJECT, mFileActivity.getString( R.string.subject_user_shared_with_you, username, mFileActivity.getFile().getFileName())); } else { intentToShareLink.putExtra(Intent.EXTRA_SUBJECT, mFileActivity .getString(R.string.subject_shared_with_you, mFileActivity.getFile().getFileName())); } String[] packagesToExclude = new String[] { mFileActivity.getPackageName() }; DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude); chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG); }
From source file:io.v.android.apps.syncslides.NavigateFragment.java
/** * When the user presses the icon, add the user's identity to the presenter's question queue. * If presenter presses the button, get a list of users who are asking questions. *//*from ww w.j a v a 2 s . c o m*/ private void questionButton() { DB db = DB.Singleton.get(getActivity().getApplicationContext()); switch (mRole) { case AUDIENCE: db.askQuestion(mDeckId, mPresentationId, SignInActivity.getUserName(getActivity())); toast("You have been added to the Q&A queue."); break; case PRESENTER: if (mQuestionList == null || mQuestionList.size() == 0) { break; } DialogFragment dialog = QuestionDialogFragment.newInstance(mQuestionList); dialog.setTargetFragment(this, DIALOG_REQUEST_CODE); dialog.show(getFragmentManager(), "QuestionerDialogFragment"); break; case BROWSER: // Do nothing. break; } }
From source file:edu.cmu.cylab.starslinger.view.SlingerFragment.java
protected void showHelp(String title, String msg) { Bundle args = new Bundle(); args.putString(extra.RESID_TITLE, title); args.putString(extra.RESID_MSG, msg); DialogFragment newFragment = SlingerAlertDialogFragment.newInstance(BaseActivity.DIALOG_HELP, args); newFragment.show(getFragmentManager(), "dialog"); }
From source file:com.intervigil.micdroid.MainActivity.java
@Override public void onRename(Recording r) { DialogFragment nameEntryFragment = new NameEntryDialogFragment(); Bundle args = new Bundle(); args.putBoolean(NameEntryDialogFragment.NAME_ENTRY_RENAME_FILE_KEY, true); args.putString(NameEntryDialogFragment.NAME_ENTRY_RENAME_FILE_NAME, r.getName()); nameEntryFragment.setArguments(args); nameEntryFragment.show(getSupportFragmentManager(), "renameEntry"); }
From source file:com.quarterfull.newsAndroid.NewsDetailFragment.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v instanceof WebView) { WebView.HitTestResult result = ((WebView) v).getHitTestResult(); if (result != null) { int type = result.getType(); Document htmldoc = Jsoup.parse(html); FragmentTransaction ft = getFragmentManager().beginTransaction(); if (type == WebView.HitTestResult.IMAGE_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) { String imageUrl = result.getExtra(); if (imageUrl.startsWith("http") || imageUrl.startsWith("file")) { URL mImageUrl; String imgtitle; String imgaltval; String imgsrcval; imgsrcval = imageUrl.substring(imageUrl.lastIndexOf('/') + 1, imageUrl.length()); Elements imgtag = htmldoc.getElementsByAttributeValueContaining("src", imageUrl); try { imgtitle = imgtag.first().attr("title"); } catch (NullPointerException e) { imgtitle = ""; }//from w ww .j a va 2 s.co m try { imgaltval = imgtag.first().attr("alt"); } catch (NullPointerException e) { imgaltval = ""; } try { mImageUrl = new URL(imageUrl); } catch (MalformedURLException e) { return; } String title = imgsrcval; int titleIcon = android.R.drawable.ic_menu_gallery; String text = (imgtitle.isEmpty()) ? imgaltval : imgtitle; // Create and show the dialog. DialogFragment newFragment = NewsDetailImageDialogFragment.newInstanceImage(title, titleIcon, text, mImageUrl); newFragment.show(ft, "menu_fragment_dialog"); } } else if (type == WebView.HitTestResult.SRC_ANCHOR_TYPE) { String url = result.getExtra(); URL mUrl; String text; try { Elements urltag = htmldoc.getElementsByAttributeValueContaining("href", url); text = urltag.text(); mUrl = new URL(url); } catch (MalformedURLException e) { return; } // Create and show the dialog. DialogFragment newFragment = NewsDetailImageDialogFragment.newInstanceUrl(text, mUrl.toString()); newFragment.show(ft, "menu_fragment_dialog"); } //else if (type == WebView.HitTestResult.EMAIL_TYPE) { } //else if (type == WebView.HitTestResult.GEO_TYPE) { } //else if (type == WebView.HitTestResult.PHONE_TYPE) { } //else if (type == WebView.HitTestResult.EDIT_TEXT_TYPE) { } } } }
From source file:com.iskrembilen.quasseldroid.gui.fragments.BufferFragment.java
private void showJoinChannelDialog() { List<Network> networkList = bufferListAdapter.networks.getNetworkList(); String[] networkArray = new String[networkList.size()]; for (int i = 0; i < networkList.size(); i++) { networkArray[i] = networkList.get(i).getName(); }/*from w w w . j av a 2 s.c om*/ FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = JoinChannelDialog.newInstance(networkArray); newFragment.show(ft, "dialog"); }
From source file:com.notepadlite.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Remove margins from layout on Lollipop devices LinearLayout layout = (LinearLayout) findViewById(R.id.noteViewEdit); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) layout.getLayoutParams(); params.setMargins(0, 0, 0, 0);// w w w .ja va2 s . co m layout.setLayoutParams(params); // Set action bar elevation getSupportActionBar().setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation)); } // Show dialog if this is the user's first time running Notepad SharedPreferences prefMain = getPreferences(Context.MODE_PRIVATE); if (prefMain.getInt("first-run", 0) == 0) { // Show welcome dialog if (getSupportFragmentManager().findFragmentByTag("firstrunfragment") == null) { DialogFragment firstRun = new FirstRunDialogFragment(); firstRun.show(getSupportFragmentManager(), "firstrunfragment"); } } else { // Check to see if Android Wear app is installed, and offer to install the Notepad Plugin checkForAndroidWear(); // The following code is only present to support existing users of Notepad on Google Play // and can be removed if using this source code for a different app // Convert old preferences to new ones SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); if (prefMain.getInt("sort-by", -1) == 0) { SharedPreferences.Editor editor = pref.edit(); SharedPreferences.Editor editorMain = prefMain.edit(); editor.putString("sort_by", "date"); editorMain.putInt("sort-by", -1); editor.apply(); editorMain.apply(); } else if (prefMain.getInt("sort-by", -1) == 1) { SharedPreferences.Editor editor = pref.edit(); SharedPreferences.Editor editorMain = prefMain.edit(); editor.putString("sort_by", "name"); editorMain.putInt("sort-by", -1); editor.apply(); editorMain.apply(); } if (pref.getString("font_size", "null").equals("null")) { SharedPreferences.Editor editor = pref.edit(); editor.putString("font_size", "large"); editor.apply(); } // Rename any saved drafts from 1.3.x File oldDraft = new File(getFilesDir() + File.separator + "draft"); File newDraft = new File(getFilesDir() + File.separator + String.valueOf(System.currentTimeMillis())); if (oldDraft.exists()) oldDraft.renameTo(newDraft); } // Begin a new FragmentTransaction FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // This fragment shows NoteListFragment as a sidebar (only seen in tablet mode landscape) if (!(getSupportFragmentManager().findFragmentById(R.id.noteList) instanceof NoteListFragment)) transaction.replace(R.id.noteList, new NoteListFragment(), "NoteListFragment"); // This fragment shows NoteListFragment in the main screen area (only seen on phones and tablet mode portrait), // but only if it doesn't already contain NoteViewFragment or NoteEditFragment. // If NoteListFragment is already showing in the sidebar, use WelcomeFragment instead if (!((getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment) || (getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteViewFragment))) { if ((getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) == null && findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) || ((getSupportFragmentManager() .findFragmentById(R.id.noteViewEdit) instanceof NoteListFragment) && findViewById(R.id.layoutMain).getTag().equals("main-layout-large"))) transaction.replace(R.id.noteViewEdit, new WelcomeFragment(), "NoteListFragment"); else if (findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) transaction.replace(R.id.noteViewEdit, new NoteListFragment(), "NoteListFragment"); } // Commit fragment transaction transaction.commit(); }
From source file:de.eidottermihi.rpicheck.activity.CustomCommandActivity.java
private void runCommand(long commandId) { ConnectivityManager connMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { if (currentDevice.getAuthMethod().equals(NewRaspiAuthActivity.SPINNER_AUTH_METHODS[2]) && Strings.isNullOrEmpty(currentDevice.getKeyfilePass())) { // must ask for key passphrase first LOGGER.debug("Asking for key passphrase."); // dirty hack, saving commandId as "dialog type" final String dialogType = commandId + ""; final DialogFragment passphraseDialog = new PassphraseDialog(); final Bundle args = new Bundle(); args.putString(PassphraseDialog.KEY_TYPE, dialogType); passphraseDialog.setArguments(args); passphraseDialog.setCancelable(false); passphraseDialog.show(getSupportFragmentManager(), "passphrase"); } else {/* w ww .jav a2 s . co m*/ LOGGER.debug("Opening command dialog."); openCommandDialog(commandId, currentDevice.getKeyfilePass()); } } else { Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT).show(); } }
From source file:de.stkl.gbgvertretungsplan.fragments.MainFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); getActivity();/*from ww w. j a va 2s . c o m*/ switch (id) { // request a sync case R.id.action_refresh: actionRefresh(); break; // show help dialogue for colours case R.id.action_legend: DialogFragment newFragment = new LegendDialogFragment(); newFragment.show(getActivity().getSupportFragmentManager(), "legend"); break; } return super.onOptionsItemSelected(item); }
From source file:com.fullmeadalchemist.mustwatch.ui.log.form.LogFormFragment.java
private void initClickListeners() { TextView dateField = getActivity().findViewById(R.id.createDateDate); if (dateField != null) { dateField.setOnClickListener(v -> { Log.i(TAG, "Date was clicked!"); DialogFragment newFragment = new DatePickerFragment(); Bundle args = new Bundle(); args.putInt(YEAR, viewModel.logEntry.entryDate.get(Calendar.YEAR)); args.putInt(MONTH, viewModel.logEntry.entryDate.get(Calendar.MONTH)); args.putInt(DAY_OF_MONTH, viewModel.logEntry.entryDate.get(Calendar.DAY_OF_MONTH)); newFragment.setArguments(args); newFragment.setTargetFragment(this, DATE_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "datePicker"); });//from ww w . j a v a 2 s .c o m } TextView timeField = getActivity().findViewById(R.id.createDateTime); if (timeField != null) { timeField.setOnClickListener(v -> { Log.i(TAG, "Time was clicked!"); DialogFragment newFragment = new TimePickerFragment(); Bundle args = new Bundle(); args.putInt(HOUR, viewModel.logEntry.entryDate.get(Calendar.HOUR)); args.putInt(MINUTE, viewModel.logEntry.entryDate.get(Calendar.MINUTE)); newFragment.setArguments(args); newFragment.setTargetFragment(this, TIME_REQUEST_CODE); newFragment.show(getActivity().getSupportFragmentManager(), "timePicker"); }); } Button submitButton = getActivity().findViewById(R.id.button_submit); if (submitButton != null) { submitButton.setOnClickListener(v -> { Log.i(TAG, "Submit button clicked!"); TextView phTv = getActivity().findViewById(R.id.ph); if (phTv != null) { viewModel.logEntry.acidity = toFloat(phTv.getText().toString().trim()); } TextView sgTv = getActivity().findViewById(R.id.sg); if (sgTv != null) { viewModel.logEntry.sg = toFloat(sgTv.getText().toString().trim()); } TextView noteTv = getActivity().findViewById(R.id.notes); if (noteTv != null) { viewModel.logEntry.note = noteTv.getText().toString().trim(); } viewModel.saveNewLogEntry(); navigationController.navigateToBatchDetail(this.batchId); }); } }