Search in sources :

Example 1 with ShareFileFragment

use of com.owncloud.android.ui.fragment.ShareFileFragment in project android by owncloud.

the class ShareActivity method onCreateShareViaLinkOperationFinish.

private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation, RemoteOperationResult result) {
    if (result.isSuccess()) {
        updateFileFromDB();
        // Create dialog to allow the user choose an app to send the link
        Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
        String link = ((OCShare) (result.getData().get(0))).getShareLink();
        intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
        intentToShareLink.setType("text/plain");
        String username = AccountUtils.getUsernameForAccount(getAccount());
        if (username != null) {
            intentToShareLink.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.subject_user_shared_with_you, username, getFile().getFileName()));
        } else {
            intentToShareLink.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.subject_shared_with_you, getFile().getFileName()));
        }
        String[] packagesToExclude = new String[] { getPackageName() };
        DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
        chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
    } else {
        // Detect Failure (403) --> maybe needs password
        String password = operation.getPassword();
        if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_FORBIDDEN && (password == null || password.length() == 0) && getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
            // Was tried without password, but not sure that it's optional.
            // Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
            ShareFileFragment shareFileFragment = getShareFileFragment();
            if (shareFileFragment != null && shareFileFragment.isAdded()) {
                // only if added to the view hierarchy!!
                shareFileFragment.requestPasswordForShareViaLink(true);
            }
        } else {
            Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Snackbar.LENGTH_LONG);
            snackbar.show();
        }
    }
}
Also used : OCShare(com.owncloud.android.lib.resources.shares.OCShare) DialogFragment(android.support.v4.app.DialogFragment) Intent(android.content.Intent) ShareFileFragment(com.owncloud.android.ui.fragment.ShareFileFragment) Snackbar(android.support.design.widget.Snackbar)

Example 2 with ShareFileFragment

use of com.owncloud.android.ui.fragment.ShareFileFragment in project android by owncloud.

the class ShareActivity method refreshSharesFromStorageManager.

/**
     * Updates the view, reading data from {@link com.owncloud.android.datamodel.FileDataStorageManager}
     */
private void refreshSharesFromStorageManager() {
    ShareFileFragment shareFileFragment = getShareFileFragment();
    if (shareFileFragment != null && shareFileFragment.isAdded()) {
        // only if added to the view hierarchy!!
        shareFileFragment.refreshCapabilitiesFromDB();
        shareFileFragment.refreshUsersOrGroupsListFromDB();
        shareFileFragment.refreshPublicShareFromDB();
    }
    SearchShareesFragment searchShareesFragment = getSearchFragment();
    if (searchShareesFragment != null && searchShareesFragment.isAdded()) {
        // only if added to the view hierarchy!!
        searchShareesFragment.refreshUsersOrGroupsListFromDB();
    }
    EditShareFragment editShareFragment = getEditShareFragment();
    if (editShareFragment != null && editShareFragment.isAdded()) {
        editShareFragment.refreshUiFromDB();
    }
}
Also used : SearchShareesFragment(com.owncloud.android.ui.fragment.SearchShareesFragment) EditShareFragment(com.owncloud.android.ui.fragment.EditShareFragment) ShareFileFragment(com.owncloud.android.ui.fragment.ShareFileFragment)

Aggregations

ShareFileFragment (com.owncloud.android.ui.fragment.ShareFileFragment)2 Intent (android.content.Intent)1 Snackbar (android.support.design.widget.Snackbar)1 DialogFragment (android.support.v4.app.DialogFragment)1 OCShare (com.owncloud.android.lib.resources.shares.OCShare)1 EditShareFragment (com.owncloud.android.ui.fragment.EditShareFragment)1 SearchShareesFragment (com.owncloud.android.ui.fragment.SearchShareesFragment)1