Search in sources :

Example 1 with DialogFragment

use of androidx.fragment.app.DialogFragment in project k-9 by k9mail.

the class AccountSetupCheckSettings method showDialogFragment.

private void showDialogFragment(int dialogId, String customMessage) {
    if (mDestroyed) {
        return;
    }
    mProgressBar.setIndeterminate(false);
    DialogFragment fragment;
    if (dialogId == R.id.dialog_account_setup_error) {
        fragment = ConfirmationDialogFragment.newInstance(dialogId, getString(R.string.account_setup_failed_dlg_title), customMessage, getString(R.string.account_setup_failed_dlg_edit_details_action), getString(R.string.account_setup_failed_dlg_continue_action));
    } else {
        throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
    }
    FragmentTransaction ta = getSupportFragmentManager().beginTransaction();
    ta.add(fragment, getDialogTag(dialogId));
    ta.commitAllowingStateLoss();
// TODO: commitAllowingStateLoss() is used to prevent https://code.google.com/p/android/issues/detail?id=23761
// but is a bad...
// fragment.show(ta, getDialogTag(dialogId));
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) ConfirmationDialogFragment(com.fsck.k9.fragment.ConfirmationDialogFragment) DialogFragment(androidx.fragment.app.DialogFragment)

Example 2 with DialogFragment

use of androidx.fragment.app.DialogFragment in project android by owncloud.

the class FileOperationsHelper method sendDownloadedFile.

public void sendDownloadedFile(OCFile ocFile) {
    if (ocFile != null) {
        Intent sendIntent = makeActionSendIntent(ocFile);
        // Show dialog, without the own app
        String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Intent shareSheetIntent = new ShareSheetHelper().getShareSheetIntent(sendIntent, mFileActivity.getApplicationContext(), R.string.activity_chooser_send_file_title, packagesToExclude);
            mFileActivity.startActivity(shareSheetIntent);
        } else {
            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude);
            chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
        }
    } else {
        Timber.e("Trying to send a NULL OCFile");
    }
}
Also used : DialogFragment(androidx.fragment.app.DialogFragment) Intent(android.content.Intent)

Example 3 with DialogFragment

use of androidx.fragment.app.DialogFragment in project android by owncloud.

the class FileOperationsHelper method shareLink.

/**
 * Share link with other apps
 *
 * @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() };
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        Intent shareSheetIntent = new ShareSheetHelper().getShareSheetIntent(intentToShareLink, mFileActivity.getApplicationContext(), R.string.activity_chooser_title, packagesToExclude);
        mFileActivity.startActivity(shareSheetIntent);
    } else {
        DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
        chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
    }
}
Also used : DialogFragment(androidx.fragment.app.DialogFragment) Intent(android.content.Intent)

Example 4 with DialogFragment

use of androidx.fragment.app.DialogFragment in project kdeconnect-android by KDE.

the class DeviceFragment method refreshUI.

private void refreshUI() {
    if (device == null || binding == null) {
        return;
    }
    // Once in-app, there is no point in keep displaying the notification if any
    device.hidePairingNotification();
    mActivity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            if (device.isPairRequestedByPeer()) {
                binding.pairMessage.setText(R.string.pair_requested);
                binding.pairVerification.setVisibility(View.VISIBLE);
                binding.pairVerification.setText(SslHelper.getVerificationKey(SslHelper.certificate, device.certificate));
                binding.pairingButtons.setVisibility(View.VISIBLE);
                binding.pairProgress.setVisibility(View.GONE);
                binding.pairButton.setVisibility(View.GONE);
                binding.pairRequestButtons.setVisibility(View.VISIBLE);
            } else {
                boolean paired = device.isPaired();
                boolean reachable = device.isReachable();
                binding.pairingButtons.setVisibility(paired ? View.GONE : View.VISIBLE);
                errorBinding.errorMessageContainer.setVisibility((paired && !reachable) ? View.VISIBLE : View.GONE);
                errorBinding.notReachableMessage.setVisibility((paired && !reachable) ? View.VISIBLE : View.GONE);
                deviceBinding.viewStatusContainer.setVisibility((paired && reachable) ? View.VISIBLE : View.GONE);
                try {
                    pluginListItems = new ArrayList<>();
                    if (paired && reachable) {
                        // Plugins button list
                        final Collection<Plugin> plugins = device.getLoadedPlugins().values();
                        for (final Plugin p : plugins) {
                            if (!p.hasMainActivity())
                                continue;
                            if (p.displayInContextMenu())
                                continue;
                            pluginListItems.add(new PluginItem(p, v -> p.startMainActivity(mActivity)));
                        }
                        DeviceFragment.this.createPluginsList(device.getPluginsWithoutPermissions(), R.string.plugins_need_permission, (plugin) -> {
                            DialogFragment dialog = plugin.getPermissionExplanationDialog();
                            if (dialog != null) {
                                dialog.show(getChildFragmentManager(), null);
                            }
                        });
                        DeviceFragment.this.createPluginsList(device.getPluginsWithoutOptionalPermissions(), R.string.plugins_need_optional_permission, (plugin) -> {
                            DialogFragment dialog = plugin.getOptionalPermissionExplanationDialog();
                            if (dialog != null) {
                                dialog.show(getChildFragmentManager(), null);
                            }
                        });
                        DeviceFragment.this.displayBatteryInfoIfPossible();
                    }
                    ListAdapter adapter = new ListAdapter(mActivity, pluginListItems);
                    deviceBinding.buttonsList.setAdapter(adapter);
                    mActivity.invalidateOptionsMenu();
                } catch (IllegalStateException e) {
                // Ignore: The activity was closed while we were trying to update it
                } catch (ConcurrentModificationException e) {
                    Log.e(TAG, "ConcurrentModificationException");
                    // Try again
                    this.run();
                }
            }
        }
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) ViewPairRequestBinding(org.kde.kdeconnect_tp.databinding.ViewPairRequestBinding) PluginListHeaderItem(org.kde.kdeconnect.UserInterface.List.PluginListHeaderItem) Intent(android.content.Intent) ViewPairErrorBinding(org.kde.kdeconnect_tp.databinding.ViewPairErrorBinding) Device(org.kde.kdeconnect.Device) FailedPluginListItem(org.kde.kdeconnect.UserInterface.List.FailedPluginListItem) R(org.kde.kdeconnect_tp.R) ArrayList(java.util.ArrayList) PluginItem(org.kde.kdeconnect.UserInterface.List.PluginItem) ActivityDeviceBinding(org.kde.kdeconnect_tp.databinding.ActivityDeviceBinding) Menu(android.view.Menu) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Plugin(org.kde.kdeconnect.Plugins.Plugin) Log(android.util.Log) BatteryPlugin(org.kde.kdeconnect.Plugins.BatteryPlugin.BatteryPlugin) DeviceBatteryInfo(org.kde.kdeconnect.Plugins.BatteryPlugin.DeviceBatteryInfo) LayoutInflater(android.view.LayoutInflater) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SslHelper(org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper) ViewGroup(android.view.ViewGroup) BackgroundService(org.kde.kdeconnect.BackgroundService) StringRes(androidx.annotation.StringRes) Nullable(androidx.annotation.Nullable) ListAdapter(org.kde.kdeconnect.UserInterface.List.ListAdapter) ConcurrentModificationException(java.util.ConcurrentModificationException) DialogFragment(androidx.fragment.app.DialogFragment) ConcurrentModificationException(java.util.ConcurrentModificationException) ArrayList(java.util.ArrayList) DialogFragment(androidx.fragment.app.DialogFragment) Collection(java.util.Collection) PluginItem(org.kde.kdeconnect.UserInterface.List.PluginItem) ListAdapter(org.kde.kdeconnect.UserInterface.List.ListAdapter) Plugin(org.kde.kdeconnect.Plugins.Plugin) BatteryPlugin(org.kde.kdeconnect.Plugins.BatteryPlugin.BatteryPlugin)

Example 5 with DialogFragment

use of androidx.fragment.app.DialogFragment in project materialistic by hidroh.

the class ItemFragment method showPreferences.

private void showPreferences() {
    Bundle args = new Bundle();
    args.putInt(PopupSettingsFragment.EXTRA_TITLE, R.string.font_options);
    args.putInt(PopupSettingsFragment.EXTRA_SUMMARY, R.string.pull_up_hint);
    args.putIntArray(PopupSettingsFragment.EXTRA_XML_PREFERENCES, new int[] { R.xml.preferences_font, R.xml.preferences_comments });
    ((DialogFragment) Fragment.instantiate(getActivity(), PopupSettingsFragment.class.getName(), args)).show(getFragmentManager(), PopupSettingsFragment.class.getName());
}
Also used : Bundle(android.os.Bundle) DialogFragment(androidx.fragment.app.DialogFragment)

Aggregations

DialogFragment (androidx.fragment.app.DialogFragment)46 Bundle (android.os.Bundle)15 Intent (android.content.Intent)7 InstrumentedDialogFragment (com.android.settings.core.instrumentation.InstrumentedDialogFragment)4 BottomSheetDialogFragment (com.google.android.material.bottomsheet.BottomSheetDialogFragment)4 Test (org.junit.Test)4 Fragment (androidx.fragment.app.Fragment)3 FragmentTransaction (androidx.fragment.app.FragmentTransaction)3 ConfirmationDialogFragment (com.fsck.k9.fragment.ConfirmationDialogFragment)3 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)3 OCFile (com.owncloud.android.datamodel.OCFile)3 OCUpload (com.owncloud.android.db.OCUpload)3 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)3 NonNull (androidx.annotation.NonNull)2 FragmentManager (androidx.fragment.app.FragmentManager)2 AttachmentDownloadDialogFragment (com.fsck.k9.fragment.AttachmentDownloadDialogFragment)2 ArrayList (java.util.ArrayList)2 AuthenticatorException (android.accounts.AuthenticatorException)1 DatePickerDialog (android.app.DatePickerDialog)1 Context (android.content.Context)1