Merge pull request #5234 from nextcloud/moveAddFolderInfo

move create rich workspace into bottom sheet
This commit is contained in:
Andy Scherzinger 2020-01-20 10:09:16 +01:00 committed by GitHub
commit b2fb207a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 45 deletions

View file

@ -66,4 +66,9 @@ public interface OCFileListBottomSheetActions {
* open template selection for creator @link Creator
*/
void showTemplate(Creator creator);
/**
* open editor for rich workspace
*/
void createRichWorkspace();
}

View file

@ -23,6 +23,7 @@ package com.owncloud.android.ui.fragment;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -37,6 +38,7 @@ import com.nextcloud.client.account.User;
import com.nextcloud.client.device.DeviceInfo;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.Creator;
import com.owncloud.android.lib.common.DirectEditing;
import com.owncloud.android.lib.resources.status.OCCapability;
@ -75,21 +77,27 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
@BindView(R.id.menu_direct_camera_upload)
public View cameraView;
@BindView(R.id.menu_create_rich_workspace)
public View createRichWorkspace;
private Unbinder unbinder;
private OCFileListBottomSheetActions actions;
private FileActivity fileActivity;
private DeviceInfo deviceInfo;
private User user;
private OCFile file;
public OCFileListBottomSheetDialog(FileActivity fileActivity,
OCFileListBottomSheetActions actions,
DeviceInfo deviceInfo,
User user) {
User user,
OCFile file) {
super(fileActivity);
this.actions = actions;
this.fileActivity = fileActivity;
this.deviceInfo = deviceInfo;
this.user = user;
this.file = file;
}
@Override
@ -155,6 +163,22 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
cameraView.setVisibility(View.GONE);
}
// create rich workspace
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && file != null) {
if (TextUtils.isEmpty(file.getRichWorkspace())) {
createRichWorkspace.setVisibility(View.VISIBLE);
} else {
createRichWorkspace.setVisibility(View.GONE);
}
} else {
createRichWorkspace.setVisibility(View.GONE);
}
createRichWorkspace.setOnClickListener(v -> {
actions.createRichWorkspace();
dismiss();
});
setOnShowListener(d ->
BottomSheetBehavior.from((View) view.getParent()).setPeekHeight(view.getMeasuredHeight())
);

View file

@ -402,7 +402,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
getFabMain().setOnClickListener(v -> new OCFileListBottomSheetDialog(activity,
this,
deviceInfo,
accountManager.getUser())
accountManager.getUser(),
getCurrentFile())
.show());
}
@ -447,6 +448,23 @@ public class OCFileListFragment extends ExtendedListFragment implements
);
}
@Override
public void createRichWorkspace() {
new Thread(() -> {
RemoteOperationResult result = new RichWorkspaceDirectEditingRemoteOperation(mFile.getRemotePath())
.execute(accountManager.getUser().toPlatformAccount(), requireContext());
if (result.isSuccess()) {
String url = (String) result.getSingleData();
mContainerActivity.getFileOperationsHelper().openRichWorkspaceWithTextEditor(mFile,
url,
requireContext());
} else {
DisplayUtils.showSnackMessage(getView(), R.string.failed_to_start_editor);
}
}).start();
}
@Override
public void onShareIconClick(OCFile file) {
if (file.isFolder()) {
@ -790,36 +808,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
menu.removeItem(R.id.action_switch_view);
menu.removeItem(R.id.action_search);
}
// create rich workspace
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& menu.findItem(R.id.action_create_rich_workspace) != null
&& mFile != null) {
menu.findItem(R.id.action_create_rich_workspace).setVisible(
TextUtils.isEmpty(mFile.getRichWorkspace()));
}
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (R.id.action_create_rich_workspace == item.getItemId()) {
new Thread(() -> {
RemoteOperationResult result = new RichWorkspaceDirectEditingRemoteOperation(mFile.getRemotePath())
.execute(accountManager.getUser().toPlatformAccount(), requireContext());
if (result.isSuccess()) {
String url = (String) result.getSingleData();
mContainerActivity.getFileOperationsHelper().openRichWorkspaceWithTextEditor(mFile,
url,
requireContext());
} else {
DisplayUtils.showSnackMessage(getView(), R.string.failed_to_start_editor);
}
}).start();
return true;
}
return super.onOptionsItemSelected(item);
}
/**

View file

@ -299,4 +299,36 @@
</LinearLayout>
<LinearLayout
android:id="@+id/menu_create_rich_workspace"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/standard_padding"
android:paddingTop="@dimen/standard_half_padding"
android:paddingRight="@dimen/standard_padding"
android:paddingBottom="@dimen/standard_half_padding"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/menu_icon_add_folder_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="@drawable/ic_post_add"
android:tint="@color/primary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_margin"
android:layout_marginLeft="@dimen/standard_margin"
android:text="@string/create_rich_workspace"
android:textColor="@color/text_color"
android:textSize="@dimen/bottom_sheet_text_size"
android:contentDescription="@string/creates_rich_workspace" />
</LinearLayout>
</LinearLayout>

View file

@ -62,17 +62,4 @@
android:title="@string/select_all"
android:contentDescription="@string/select_all"/>
<item
android:id="@+id/action_create_rich_workspace"
android:icon="@drawable/ic_post_add"
android:orderInCategory="2"
app:showAsAction="never"
android:visible="false"
android:title="@string/create_rich_workspace"
android:contentDescription="@string/creates_rich_workspace" />
<!-- <item android:id="@+id/search"
android:title="@string/actionbar_search"
android:icon="@drawable/ic_action_search"></item> -->
</menu>