- make image & text clickable

- show snackbar correctly if resharing is not allowed, then also grey out image&text if not folder
This commit is contained in:
tobiasKaminsky 2017-11-23 09:59:48 +01:00 committed by AndyScherzinger
parent dc2d7edc56
commit 2168e5a344
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 64 additions and 23 deletions

View file

@ -13,6 +13,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.owncloud.android.R; import com.owncloud.android.R;
@ -90,21 +91,50 @@ public class SendShareDialog extends BottomSheetDialogFragment {
view = inflater.inflate(R.layout.send_share_fragment, container, false); view = inflater.inflate(R.layout.send_share_fragment, container, false);
// Share with people // Share with people
TextView sharePeopleButton = (TextView) view.findViewById(R.id.share_people_button); TextView sharePeopleText = (TextView) view.findViewById(R.id.share_people_button);
sharePeopleText.setOnClickListener(v -> shareFile(file));
sharePeopleButton.setOnClickListener(v -> fileOperationsHelper.showShareFile(file));
ImageView sharePeopleImageView = (ImageView) view.findViewById(R.id.share_people_icon);
sharePeopleImageView.setOnClickListener(v -> shareFile(file));
// Share via link button // Share via link button
TextView shareLinkButton = (TextView) view.findViewById(R.id.share_link_button); TextView shareLinkText = (TextView) view.findViewById(R.id.share_link_button);
shareLinkText.setOnClickListener(v -> fileOperationsHelper.showShareFile(file));
ImageView shareLinkImageView = (ImageView) view.findViewById(R.id.share_link_icon);
shareLinkImageView.setOnClickListener(v -> shareFile(file));
if (file.isSharedWithMe() && !file.canReshare()) { if (file.isSharedWithMe() && !file.canReshare()) {
Snackbar.make(view, R.string.resharing_is_not_allowed, Snackbar.LENGTH_LONG).show(); Snackbar snackbar = Snackbar.make(view, R.string.resharing_is_not_allowed, Snackbar.LENGTH_LONG);
shareLinkButton.setVisibility(View.GONE); snackbar.addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar transientBottomBar, int event) {
super.onDismissed(transientBottomBar, event);
if (file.isFolder()) {
dismiss();
} }
}
});
shareLinkButton.setOnClickListener(v -> fileOperationsHelper.showShareFile(file)); snackbar.show();
if (file.isFolder()) {
shareLinkText.setVisibility(View.GONE);
shareLinkImageView.setVisibility(View.GONE);
sharePeopleText.setVisibility(View.GONE);
sharePeopleImageView.setVisibility(View.GONE);
} else {
shareLinkText.setEnabled(false);
shareLinkText.setAlpha(0.3f);
shareLinkImageView.setEnabled(false);
shareLinkImageView.setAlpha(0.3f);
sharePeopleText.setEnabled(false);
sharePeopleText.setAlpha(0.3f);
sharePeopleImageView.setEnabled(false);
sharePeopleImageView.setAlpha(0.3f);
}
}
// populate send apps // populate send apps
Intent sendIntent = new Intent(Intent.ACTION_SEND); Intent sendIntent = new Intent(Intent.ACTION_SEND);
@ -124,7 +154,7 @@ public class SendShareDialog extends BottomSheetDialogFragment {
} }
if (getContext().getString(R.string.send_files_to_other_apps).equalsIgnoreCase("off")) { if (getContext().getString(R.string.send_files_to_other_apps).equalsIgnoreCase("off")) {
sharePeopleButton.setVisibility(View.GONE); sharePeopleText.setVisibility(View.GONE);
} }
SendButtonAdapter.ClickListener clickListener = sendButtonDataData -> { SendButtonAdapter.ClickListener clickListener = sendButtonDataData -> {
@ -159,6 +189,11 @@ public class SendShareDialog extends BottomSheetDialogFragment {
return view; return view;
} }
private void shareFile(OCFile file) {
fileOperationsHelper.showShareFile(file);
dismiss();
}
public void setFileOperationsHelper(FileOperationsHelper fileOperationsHelper) { public void setFileOperationsHelper(FileOperationsHelper fileOperationsHelper) {
this.fileOperationsHelper = fileOperationsHelper; this.fileOperationsHelper = fileOperationsHelper;
} }

View file

@ -20,7 +20,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -33,6 +37,7 @@
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:orientation="horizontal" android:orientation="horizontal"
android:baselineAligned="false"
android:padding="20dp"> android:padding="20dp">
<LinearLayout <LinearLayout
@ -99,4 +104,5 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/divider"/> android:layout_below="@id/divider"/>
</RelativeLayout> </RelativeLayout>
</android.support.design.widget.CoordinatorLayout>