Search in sources :

Example 1 with ClientFactory

use of com.nextcloud.client.network.ClientFactory in project android by nextcloud.

the class ChooseRichDocumentsTemplateDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle arguments = getArguments();
    if (arguments == null) {
        throw new IllegalArgumentException("Arguments may not be null");
    }
    Activity activity = getActivity();
    if (activity == null) {
        throw new IllegalArgumentException("Activity may not be null");
    }
    try {
        client = clientFactory.create(currentAccount.getUser());
    } catch (ClientFactory.CreationException e) {
        // we'll NPE without the client
        throw new RuntimeException(e);
    }
    parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER);
    // Inflate the layout for the dialog
    LayoutInflater inflater = requireActivity().getLayoutInflater();
    binding = ChooseTemplateBinding.inflate(inflater, null, false);
    View view = binding.getRoot();
    binding.filename.requestFocus();
    ThemeTextInputUtils.colorTextInput(binding.filenameContainer, binding.filename, ThemeColorUtils.primaryColor(getContext()));
    Type type = Type.valueOf(arguments.getString(ARG_TYPE));
    new FetchTemplateTask(this, client).execute(type);
    binding.list.setHasFixedSize(true);
    binding.list.setLayoutManager(new GridLayoutManager(activity, 2));
    adapter = new RichDocumentsTemplateAdapter(type, this, getContext(), currentAccount, clientFactory);
    binding.list.setAdapter(adapter);
    // Build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setView(view).setPositiveButton(R.string.create, null).setNeutralButton(R.string.common_cancel, null).setTitle(getTitle(type));
    Dialog dialog = builder.create();
    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Window(android.view.Window) Bundle(android.os.Bundle) ClientFactory(com.nextcloud.client.network.ClientFactory) Activity(android.app.Activity) View(android.view.View) ExternalSiteWebView(com.owncloud.android.ui.activity.ExternalSiteWebView) RichDocumentsEditorWebView(com.owncloud.android.ui.activity.RichDocumentsEditorWebView) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) LayoutInflater(android.view.LayoutInflater) RichDocumentsTemplateAdapter(com.owncloud.android.ui.adapter.RichDocumentsTemplateAdapter) NonNull(androidx.annotation.NonNull)

Aggregations

Activity (android.app.Activity)1 Dialog (android.app.Dialog)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 Window (android.view.Window)1 NonNull (androidx.annotation.NonNull)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 ClientFactory (com.nextcloud.client.network.ClientFactory)1 ExternalSiteWebView (com.owncloud.android.ui.activity.ExternalSiteWebView)1 RichDocumentsEditorWebView (com.owncloud.android.ui.activity.RichDocumentsEditorWebView)1 RichDocumentsTemplateAdapter (com.owncloud.android.ui.adapter.RichDocumentsTemplateAdapter)1