FileDocCategorySizeDatePackage
SaveFragment.javaAPI DocAndroid 5.1 API5211Thu Mar 12 22:22:40 GMT 2015com.android.documentsui

SaveFragment

public class SaveFragment extends android.app.Fragment
Display document title editor and save button.

Fields Summary
public static final String
TAG
private com.android.documentsui.model.DocumentInfo
mReplaceTarget
private android.widget.EditText
mDisplayName
private android.widget.Button
mSave
private android.widget.ProgressBar
mProgress
private boolean
mIgnoreNextEdit
private static final String
EXTRA_MIME_TYPE
private static final String
EXTRA_DISPLAY_NAME
private android.text.TextWatcher
mDisplayNameWatcher
private View.OnClickListener
mSaveListener
Constructors Summary
Methods Summary
public static com.android.documentsui.SaveFragmentget(android.app.FragmentManager fm)

        return (SaveFragment) fm.findFragmentByTag(TAG);
    
public android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)

        final Context context = inflater.getContext();

        final View view = inflater.inflate(R.layout.fragment_save, container, false);

        final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
        icon.setImageDrawable(
                IconUtils.loadMimeIcon(context, getArguments().getString(EXTRA_MIME_TYPE)));

        mDisplayName = (EditText) view.findViewById(android.R.id.title);
        mDisplayName.addTextChangedListener(mDisplayNameWatcher);
        mDisplayName.setText(getArguments().getString(EXTRA_DISPLAY_NAME));

        mSave = (Button) view.findViewById(android.R.id.button1);
        mSave.setOnClickListener(mSaveListener);
        mSave.setEnabled(false);

        mProgress = (ProgressBar) view.findViewById(android.R.id.progress);

        return view;
    
public voidsetPending(boolean pending)

        mSave.setVisibility(pending ? View.INVISIBLE : View.VISIBLE);
        mProgress.setVisibility(pending ? View.VISIBLE : View.GONE);
    
public voidsetReplaceTarget(com.android.documentsui.model.DocumentInfo replaceTarget)
Set given document as target for in-place writing if user hits save without changing the filename. Can be set to {@code null} if user navigates outside the target directory.


                                      
        
        mReplaceTarget = replaceTarget;

        if (mReplaceTarget != null) {
            getArguments().putString(EXTRA_DISPLAY_NAME, replaceTarget.displayName);
            mIgnoreNextEdit = true;
            mDisplayName.setText(replaceTarget.displayName);
        }
    
public voidsetSaveEnabled(boolean enabled)

        mSave.setEnabled(enabled);
    
public static voidshow(android.app.FragmentManager fm, java.lang.String mimeType, java.lang.String displayName)


             
        final Bundle args = new Bundle();
        args.putString(EXTRA_MIME_TYPE, mimeType);
        args.putString(EXTRA_DISPLAY_NAME, displayName);

        final SaveFragment fragment = new SaveFragment();
        fragment.setArguments(args);

        final FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.container_save, fragment, TAG);
        ft.commitAllowingStateLoss();