From 8a88975d6ab4990be00bf1e4c5d061ba781d12fa Mon Sep 17 00:00:00 2001 From: tom79 Date: Wed, 8 May 2019 09:37:17 +0200 Subject: [PATCH] Fix for all --- .../mastodon/client/Entities/Status.java | 12 +++ .../mastodon/drawers/StatusListAdapter.java | 75 ++++++++++--------- .../res/drawable/rounded_label_sensitive.xml | 16 ++++ app/src/main/res/layout/drawer_status.xml | 7 +- .../main/res/layout/drawer_status_compact.xml | 5 +- .../main/res/layout/drawer_status_console.xml | 5 +- .../main/res/layout/drawer_status_focused.xml | 5 +- 7 files changed, 79 insertions(+), 46 deletions(-) create mode 100644 app/src/main/res/drawable/rounded_label_sensitive.xml diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java index 0ba3a6a4b..667183a57 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java @@ -134,6 +134,8 @@ public class Status implements Parcelable{ private boolean isNotice = false; private Poll poll = null; + private int media_height; + @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(this.id); @@ -190,6 +192,7 @@ public class Status implements Parcelable{ dest.writeByte(this.showSpoiler ? (byte) 1 : (byte) 0); dest.writeByte(this.isNotice ? (byte) 1 : (byte) 0); dest.writeParcelable(this.poll, flags); + dest.writeInt(this.media_height); } protected Status(Parcel in) { @@ -249,6 +252,7 @@ public class Status implements Parcelable{ this.showSpoiler = in.readByte() != 0; this.isNotice = in.readByte() != 0; this.poll = in.readParcelable(Poll.class.getClassLoader()); + this.media_height = in.readInt(); } public static final Creator CREATOR = new Creator() { @@ -1340,4 +1344,12 @@ public class Status implements Parcelable{ public void setPoll(Poll poll) { this.poll = poll; } + + public int getMedia_height() { + return media_height; + } + + public void setMedia_height(int media_height) { + this.media_height = media_height; + } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index a1bc07ee1..87288a991 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -538,7 +538,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct boolean display_card = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CARD, false); boolean display_video_preview = sharedpreferences.getBoolean(Helper.SET_DISPLAY_VIDEO_PREVIEWS, true); int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0); - final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5); + boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true); boolean confirmFav = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION_FAV, false); boolean confirmBoost = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, true); @@ -2075,32 +2075,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct } }); - holder.status_show_more.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - status.setAttachmentShown(true); - notifyStatusChanged(status); - /* - Added a Countdown Timer, so that Sensitive (NSFW) - images only get displayed for user set time, - giving the user time to click on them to expand them, - if they want. Images are then hidden again. - -> Default value is set to 5 seconds - */ - - if (timeout > 0) { - new CountDownTimer((timeout * 1000), 1000) { - public void onTick(long millisUntilFinished) { - } - - public void onFinish() { - status.setAttachmentShown(false); - notifyStatusChanged(status); - } - }.start(); - } - } - }); if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) holder.status_more.setVisibility(View.GONE); @@ -2723,8 +2697,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct }else{ holder.status_toot_app.setVisibility(View.GONE); } - } + } @@ -2808,6 +2782,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct int position = 1; for(final Attachment attachment: attachments){ ImageView imageView; + RelativeLayout container = holder.status_horizontal_document_container; if( i == 0) { imageView = fullAttachement?holder.status_prev1_h:holder.status_prev1; if( attachment.getType().toLowerCase().equals("image") || attachment.getType().toLowerCase().equals("unknown")) @@ -2927,6 +2902,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct resource = Bitmap.createScaledBitmap(resource, width, height, false); } imageView.setImageBitmap(resource); + status.setMedia_height(container.getHeight()); } }); }else{ @@ -2978,15 +2954,40 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if( attachment.getType().equals("web")){ - Helper.openBrowser(context, attachment.getUrl()); - }else { - Intent intent = new Intent(context, MediaActivity.class); - Bundle b = new Bundle(); - intent.putParcelableArrayListExtra("mediaArray", status.getMedia_attachments()); - b.putInt("position", finalPosition); - intent.putExtras(b); - context.startActivity(intent); + if( status.isAttachmentShown()) { + + if (attachment.getType().equals("web")) { + Helper.openBrowser(context, attachment.getUrl()); + } else { + Intent intent = new Intent(context, MediaActivity.class); + Bundle b = new Bundle(); + intent.putParcelableArrayListExtra("mediaArray", status.getMedia_attachments()); + b.putInt("position", finalPosition); + intent.putExtras(b); + context.startActivity(intent); + } + }else{ + status.setAttachmentShown(true); + notifyStatusChanged(status); + /* + Added a Countdown Timer, so that Sensitive (NSFW) + images only get displayed for user set time, + giving the user time to click on them to expand them, + if they want. Images are then hidden again. + -> Default value is set to 5 seconds + */ + final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5); + if (timeout > 0) { + new CountDownTimer((timeout * 1000), 1000) { + public void onTick(long millisUntilFinished) { + } + + public void onFinish() { + status.setAttachmentShown(false); + notifyStatusChanged(status); + } + }.start(); + } } } }); diff --git a/app/src/main/res/drawable/rounded_label_sensitive.xml b/app/src/main/res/drawable/rounded_label_sensitive.xml new file mode 100644 index 000000000..94100870a --- /dev/null +++ b/app/src/main/res/drawable/rounded_label_sensitive.xml @@ -0,0 +1,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index 9c69e4ad7..efe3fb26e 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -672,8 +672,9 @@ android:visibility="gone" android:id="@+id/status_show_more" android:layout_width="match_parent" - android:layout_height="200dp" - > + android:layout_height="match_parent" + android:layout_centerInParent="true" + > diff --git a/app/src/main/res/layout/drawer_status_compact.xml b/app/src/main/res/layout/drawer_status_compact.xml index b06df6022..c37d302b1 100644 --- a/app/src/main/res/layout/drawer_status_compact.xml +++ b/app/src/main/res/layout/drawer_status_compact.xml @@ -633,7 +633,8 @@ android:visibility="gone" android:id="@+id/status_show_more" android:layout_width="match_parent" - android:layout_height="200dp" + android:layout_height="match_parent" + android:layout_centerInParent="true" > diff --git a/app/src/main/res/layout/drawer_status_console.xml b/app/src/main/res/layout/drawer_status_console.xml index bdfe79f2a..466447bd2 100644 --- a/app/src/main/res/layout/drawer_status_console.xml +++ b/app/src/main/res/layout/drawer_status_console.xml @@ -633,7 +633,8 @@ android:visibility="gone" android:id="@+id/status_show_more" android:layout_width="match_parent" - android:layout_height="200dp" + android:layout_height="match_parent" + android:layout_centerInParent="true" > diff --git a/app/src/main/res/layout/drawer_status_focused.xml b/app/src/main/res/layout/drawer_status_focused.xml index 73f0947b1..6dd9660fd 100644 --- a/app/src/main/res/layout/drawer_status_focused.xml +++ b/app/src/main/res/layout/drawer_status_focused.xml @@ -557,7 +557,8 @@ android:visibility="gone" android:id="@+id/status_show_more" android:layout_width="match_parent" - android:layout_height="200dp" + android:layout_height="match_parent" + android:layout_centerInParent="true" >