Fix issue #353 - Add a message that allows to open context when media are in fullscreen.

This commit is contained in:
Thomas 2022-10-16 11:29:24 +02:00
parent 3dad1b23f3
commit 4d1aff63a8
5 changed files with 38 additions and 2 deletions

View file

@ -58,6 +58,7 @@ import java.util.ArrayList;
import app.fedilab.android.R;
import app.fedilab.android.client.entities.api.Attachment;
import app.fedilab.android.client.entities.api.Status;
import app.fedilab.android.databinding.ActivityMediaPagerBinding;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MediaHelper;
@ -106,6 +107,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
private float startY;
private ActivityMediaPagerBinding binding;
private FragmentMedia mCurrentFragment;
private Status status;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -123,6 +125,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
if (b != null) {
mediaPosition = b.getInt(Helper.ARG_MEDIA_POSITION, 1);
attachments = (ArrayList<Attachment>) b.getSerializable(Helper.ARG_MEDIA_ARRAY);
status = (Status) b.getSerializable(Helper.ARG_STATUS);
}
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -143,6 +146,14 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
registerReceiver(onDownloadComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
String description = attachments.get(mediaPosition - 1).description;
handler = new Handler();
if (status != null) {
binding.originalMessage.setOnClickListener(v -> {
Intent intentContext = new Intent(MediaActivity.this, ContextActivity.class);
intentContext.putExtra(Helper.ARG_STATUS, status);
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentContext);
});
}
if (description != null && description.trim().length() > 0 && description.trim().compareTo("null") != 0) {
binding.mediaDescription.setText(description);
binding.translate.setOnClickListener(v -> {
@ -377,10 +388,12 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
}
} else {
binding.translate.setVisibility(View.GONE);
binding.originalMessage.setVisibility(View.GONE);
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
binding.mediaDescription.setVisibility(View.GONE);
}
} else {
binding.originalMessage.setVisibility(View.GONE);
binding.translate.setVisibility(View.GONE);
binding.mediaDescriptionTranslated.setVisibility(View.GONE);
binding.mediaDescription.setVisibility(View.GONE);
@ -437,9 +450,13 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
showSystemUI();
binding.mediaDescription.setVisibility(View.VISIBLE);
binding.translate.setVisibility(View.VISIBLE);
if (status != null) {
binding.originalMessage.setVisibility(View.VISIBLE);
}
} else {
binding.mediaDescription.setVisibility(View.GONE);
binding.translate.setVisibility(View.GONE);
binding.originalMessage.setVisibility(View.GONE);
hideSystemUI();
}
}

View file

@ -458,6 +458,7 @@ public class PinnedTimelineHelper {
activityMainBinding.tabLayout.clearOnTabSelectedListeners();
FedilabPageAdapter fedilabPageAdapter = new FedilabPageAdapter(activity, activity.getSupportFragmentManager(), pinned, bottomMenu);
activityMainBinding.viewPager.setAdapter(fedilabPageAdapter);
activityMainBinding.viewPager.setOffscreenPageLimit(tabStrip.getChildCount());
activityMainBinding.viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(activityMainBinding.tabLayout));
if (!singleBar) {
activityMainBinding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

View file

@ -83,6 +83,7 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
for (Status status1 : statuses) {
attachmentsTmp.add(status1.art_attachment);
}
b.putSerializable(Helper.ARG_STATUS, status);
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(attachmentsTmp));
mediaIntent.putExtras(b);
ActivityOptionsCompat options = ActivityOptionsCompat

View file

@ -43,14 +43,13 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="70dp"
android:background="#AA000000"
android:gravity="center"
android:padding="12dp"
android:textColor="#ffffffff"
android:textIsSelectable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/original_message"
app:layout_constraintEnd_toStartOf="@+id/translate"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
@ -85,6 +84,23 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/media_description"
tools:visibility="visible" />
<TextView
android:id="@+id/original_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="70dp"
android:padding="5dp"
android:text="@string/view_the_original_message"
android:textColor="@color/cyanea_accent_dark_reference"
android:textSize="18sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/translate"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</app.futured.hauler.HaulerView>

View file

@ -1478,4 +1478,5 @@
<string name="fetch_notifications">Fetch notifications</string>
<string name="set_display_counters">Display counters</string>
<string name="set_display_counters_description">Will display a bubble counter in tab timelines for new messages</string>
<string name="view_the_original_message">Open the original message</string>
</resources>