diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/ImageDescriptionSheet.java b/mastodon/src/main/java/org/joinmastodon/android/ui/ImageDescriptionSheet.java deleted file mode 100644 index 5abd991d6..000000000 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/ImageDescriptionSheet.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.joinmastodon.android.ui; - -import android.app.Activity; -import android.graphics.Typeface; -import android.graphics.drawable.ColorDrawable; -import android.os.Build; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowInsets; -import android.widget.FrameLayout; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.LinearLayoutManager; - -import org.joinmastodon.android.R; -import org.joinmastodon.android.model.Attachment; -import org.joinmastodon.android.ui.utils.UiUtils; - -import me.grishka.appkit.utils.SingleViewRecyclerAdapter; -import me.grishka.appkit.utils.V; -import me.grishka.appkit.views.BottomSheet; -import me.grishka.appkit.views.UsableRecyclerView; - -public class ImageDescriptionSheet extends BottomSheet{ - private UsableRecyclerView list; - - public ImageDescriptionSheet(@NonNull Activity activity, Attachment attachment){ - super(activity); - - View handleView=new View(activity); - handleView.setBackgroundResource(R.drawable.bg_bottom_sheet_handle); - ViewGroup handle=new FrameLayout(activity); - handle.addView(handleView); - handle.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, V.dp(24))); - - TextView textView = new TextView(activity); - if (attachment.description == null || attachment.description.isEmpty()) { - textView.setText(R.string.media_no_description); - textView.setTypeface(null, Typeface.ITALIC); - } else { - textView.setText(attachment.description); - textView.setTextIsSelectable(true); - } - - TextView heading=new TextView(activity); - heading.setText(R.string.sk_image_description); - heading.setAllCaps(true); - heading.setTypeface(null, Typeface.BOLD); - heading.setPadding(0, V.dp(24), 0, V.dp(8)); - - LinearLayout linearLayout = new LinearLayout(activity); - linearLayout.setOrientation(LinearLayout.VERTICAL); - linearLayout.setPadding(V.dp(24), 0, V.dp(24), 0); - linearLayout.addView(heading); - linearLayout.addView(textView); - - FrameLayout layout=new FrameLayout(activity); - layout.addView(handle); - layout.addView(linearLayout); - - list=new UsableRecyclerView(activity); - list.setLayoutManager(new LinearLayoutManager(activity)); - list.setBackgroundResource(R.drawable.bg_bottom_sheet); - list.setAdapter(new SingleViewRecyclerAdapter(layout)); - list.setClipToPadding(false); - - setContentView(list); - setNavigationBarBackground(new ColorDrawable(UiUtils.getThemeColor(activity, R.attr.colorM3Surface)), !UiUtils.isDarkTheme()); - } - - @Override - protected void onWindowInsetsUpdated(WindowInsets insets){ - if(Build.VERSION.SDK_INT>=29){ - int tappableBottom=insets.getTappableElementInsets().bottom; - int insetBottom=insets.getSystemWindowInsetBottom(); - if(tappableBottom==0 && insetBottom>0){ - list.setPadding(0, 0, 0, V.dp(48)-insetBottom); - }else{ - list.setPadding(0, 0, 0, V.dp(24)); - } - }else{ - list.setPadding(0, 0, 0, V.dp(24)); - } - } -} diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/PhotoViewer.java b/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/PhotoViewer.java index f87856b4f..5278a7152 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/PhotoViewer.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/photoviewer/PhotoViewer.java @@ -56,13 +56,10 @@ import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; import org.joinmastodon.android.api.MastodonAPIController; import org.joinmastodon.android.api.session.AccountSessionManager; -import org.joinmastodon.android.events.StatusCountersUpdatedEvent; import org.joinmastodon.android.model.Attachment; -import org.joinmastodon.android.ui.ImageDescriptionSheet; import org.joinmastodon.android.model.Status; import org.joinmastodon.android.ui.M3AlertDialogBuilder; import org.joinmastodon.android.utils.FileProvider; -import org.joinmastodon.android.ui.utils.UiUtils; import java.io.File; import java.io.FileOutputStream; @@ -117,7 +114,6 @@ public class PhotoViewer implements ZoomPanView.Listener{ private TextView videoTimeView; private ImageButton videoPlayPauseButton; private View videoControls; - private MenuItem imageDescriptionButton; private boolean uiVisible=true; private AudioManager.OnAudioFocusChangeListener audioFocusListener=this::onAudioFocusChanged; private Runnable uiAutoHider=()->{ @@ -210,32 +206,6 @@ public class PhotoViewer implements ZoomPanView.Listener{ toolbarWrap=uiOverlay.findViewById(R.id.toolbar_wrap); toolbar=uiOverlay.findViewById(R.id.toolbar); toolbar.setNavigationOnClickListener(v->onStartSwipeToDismissTransition(0)); - imageDescriptionButton = toolbar.getMenu() - .add(R.string.sk_image_description) - .setIcon(R.drawable.ic_fluent_image_alt_text_24_regular) - .setVisible(attachments.get(pager.getCurrentItem()).description != null - && !attachments.get(pager.getCurrentItem()).description.isEmpty()) - .setOnMenuItemClickListener(item -> { - new ImageDescriptionSheet(activity,attachments.get(pager.getCurrentItem())).show(); - return true; - }); - imageDescriptionButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - toolbar.getMenu() - .add(R.string.download) - .setIcon(R.drawable.ic_fluent_arrow_download_24_regular) - .setOnMenuItemClickListener(item -> { - saveCurrentFile(); - return true; - }) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - toolbar.getMenu() - .add(R.string.button_share) - .setIcon(R.drawable.ic_fluent_share_24_regular) - .setOnMenuItemClickListener(item -> { - shareCurrentFile(); - return true; - }) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); if(status!=null) toolbar.getMenu().add(R.string.info).setIcon(R.drawable.ic_fluent_info_24_regular).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); else @@ -446,7 +416,6 @@ public class PhotoViewer implements ZoomPanView.Listener{ private void onPageChanged(int index){ currentIndex=index; Attachment att=attachments.get(index); - imageDescriptionButton.setVisible(att.description != null && !att.description.isEmpty()); V.setVisibilityAnimated(videoControls, att.type==Attachment.Type.VIDEO ? View.VISIBLE : View.GONE); if(att.type==Attachment.Type.VIDEO){ videoSeekBar.setSecondaryProgress(0); @@ -805,7 +774,7 @@ public class PhotoViewer implements ZoomPanView.Listener{ } }else if(id==R.id.btn_share){ if(status!=null){ - UiUtils.openSystemShareSheet(activity, status.url); + shareCurrentFile(); } }else if(id==R.id.btn_bookmark){ if(status!=null){ diff --git a/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml b/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml index 9ce319fb6..e61b8ca21 100644 --- a/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml +++ b/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml @@ -47,7 +47,7 @@