use of com.owncloud.android.ui.activity.FileActivity in project android by owncloud.
the class EditShareFragment method refreshUiFromDB.
/**
* Get {@link OCShare} instance from DB and updates the UI.
*
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
* instance ready to use. If not ready, does nothing.
*
* @param editShareView Root view in the fragment.
*/
private void refreshUiFromDB(View editShareView) {
FileDataStorageManager storageManager = ((FileActivity) getActivity()).getStorageManager();
if (storageManager != null) {
// Get edited share
mShare = storageManager.getShareById(mShare.getId());
// Updates UI with new state
refreshUiFromState(editShareView);
}
}
use of com.owncloud.android.ui.activity.FileActivity in project android by owncloud.
the class ShareFileFragment method updatePublicShareSection.
/**
* Updates in the UI the section about public share with the information in the current
* public share bound to mFile, if any
*/
private void updatePublicShareSection() {
if (mPublicShare != null && ShareType.PUBLIC_LINK.equals(mPublicShare.getShareType())) {
/// public share bound -> expand section
SwitchCompat shareViaLinkSwitch = getShareViaLinkSwitch();
if (!shareViaLinkSwitch.isChecked()) {
// set null listener before setChecked() to prevent infinite loop of calls
shareViaLinkSwitch.setOnCheckedChangeListener(null);
shareViaLinkSwitch.setChecked(true);
shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener);
}
getExpirationDateSection().setVisibility(View.VISIBLE);
getPasswordSection().setVisibility(View.VISIBLE);
if (mFile.isFolder() && !mCapabilities.getFilesSharingPublicUpload().isFalse()) {
getEditPermissionSection().setVisibility(View.VISIBLE);
} else {
getEditPermissionSection().setVisibility(View.GONE);
}
// GetLink button
AppCompatButton getLinkButton = getGetLinkButton();
getLinkButton.setVisibility(View.VISIBLE);
getLinkButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//GetLink from the server and show ShareLinkToDialog
((FileActivity) getActivity()).getFileOperationsHelper().getFileWithLink(mFile);
}
});
/// update state of expiration date switch and message depending on expiration date
SwitchCompat expirationDateSwitch = getExpirationDateSwitch();
// set null listener before setChecked() to prevent infinite loop of calls
expirationDateSwitch.setOnCheckedChangeListener(null);
long expirationDate = mPublicShare.getExpirationDate();
if (expirationDate > 0) {
if (!expirationDateSwitch.isChecked()) {
expirationDateSwitch.toggle();
}
String formattedDate = SimpleDateFormat.getDateInstance().format(new Date(expirationDate));
getExpirationDateValue().setText(formattedDate);
} else {
if (expirationDateSwitch.isChecked()) {
expirationDateSwitch.toggle();
}
getExpirationDateValue().setText(R.string.empty);
}
// recover listener
expirationDateSwitch.setOnCheckedChangeListener(mOnExpirationDateInteractionListener);
/// update state of password switch and message depending on password protection
SwitchCompat passwordSwitch = getPasswordSwitch();
// set null listener before setChecked() to prevent infinite loop of calls
passwordSwitch.setOnCheckedChangeListener(null);
if (mPublicShare.isPasswordProtected()) {
if (!passwordSwitch.isChecked()) {
passwordSwitch.toggle();
}
getPasswordValue().setVisibility(View.VISIBLE);
} else {
if (passwordSwitch.isChecked()) {
passwordSwitch.toggle();
}
getPasswordValue().setVisibility(View.INVISIBLE);
}
// recover listener
passwordSwitch.setOnCheckedChangeListener(mOnPasswordInteractionListener);
/// update state of the edit permission switch
SwitchCompat editPermissionSwitch = getEditPermissionSwitch();
// set null listener before setChecked() to prevent infinite loop of calls
editPermissionSwitch.setOnCheckedChangeListener(null);
if (mPublicShare.getPermissions() > OCShare.READ_PERMISSION_FLAG) {
if (!editPermissionSwitch.isChecked()) {
editPermissionSwitch.toggle();
}
} else {
if (editPermissionSwitch.isChecked()) {
editPermissionSwitch.toggle();
}
}
// recover listener
editPermissionSwitch.setOnCheckedChangeListener(mOnEditPermissionInteractionListener);
} else {
/// no public share -> collapse section
SwitchCompat shareViaLinkSwitch = getShareViaLinkSwitch();
if (shareViaLinkSwitch.isChecked()) {
shareViaLinkSwitch.setOnCheckedChangeListener(null);
getShareViaLinkSwitch().setChecked(false);
shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener);
}
getExpirationDateSection().setVisibility(View.GONE);
getPasswordSection().setVisibility(View.GONE);
getEditPermissionSection().setVisibility(View.GONE);
getGetLinkButton().setVisibility(View.GONE);
}
}
use of com.owncloud.android.ui.activity.FileActivity in project android by owncloud.
the class UploadSourceDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) };
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.actionbar_upload);
builder.setItems(allTheItems, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if (item == 0) {
Intent action = new Intent(getActivity(), UploadFilesActivity.class);
action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, ((FileActivity) getActivity()).getAccount());
//startActivityForResult(action, REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM);
// this flow seems broken;
// Actionbarsherlock, maybe?
getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM);
} else if (item == 1) {
Intent action = new Intent(Intent.ACTION_GET_CONTENT);
action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
//Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}
getActivity().startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS);
}
}
});
return builder.create();
}
use of com.owncloud.android.ui.activity.FileActivity in project android by owncloud.
the class UploadListFragment method onStart.
@Override
public void onStart() {
Log_OC.d(TAG, "onStart() start");
super.onStart();
mAdapter = new ExpandableUploadListAdapter((FileActivity) getActivity());
setListAdapter(mAdapter);
}
Aggregations