Automatically expand hidden media

This commit is contained in:
stom79 2018-09-15 09:33:53 +02:00
parent b72726a407
commit 4db989442b
7 changed files with 30 additions and 1 deletions

View File

@ -16,6 +16,7 @@ package fr.gouv.etalab.mastodon.client;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;

View File

@ -550,6 +550,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_privacy.setVisibility(View.VISIBLE);
boolean expand_cw = sharedpreferences.getBoolean(Helper.SET_EXPAND_CW, false);
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK){
changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon);
changeDrawableColor(context, holder.status_more, R.color.dark_icon);
@ -792,7 +793,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_show_more.setVisibility(View.GONE);
} else {
//If medias are loaded without any conditions or if device is on wifi
if (!status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
if (expand_media || !status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
loadAttachments(status, holder);
holder.status_show_more.setVisibility(View.GONE);
status.setAttachmentShown(true);

View File

@ -200,6 +200,18 @@ public class SettingsFragment extends Fragment {
}
});
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
final CheckBox set_expand_media = rootView.findViewById(R.id.set_expand_image);
set_expand_media.setChecked(expand_media);
set_expand_media.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_EXPAND_MEDIA, set_expand_media.isChecked());
editor.apply();
}
});
boolean display_bookmark = sharedpreferences.getBoolean(Helper.SET_SHOW_BOOKMARK, true);
final CheckBox set_display_bookmark = rootView.findViewById(R.id.set_display_bookmarks);

View File

@ -298,6 +298,7 @@ public class Helper {
public static final String SET_NOTIF_HOMETIMELINE = "set_notif_hometimeline";
public static final String SET_NOTIF_SILENT = "set_notif_silent";
public static final String SET_EXPAND_CW = "set_expand_cw";
public static final String SET_EXPAND_MEDIA = "set_expand_media";
public static final String SET_EMBEDDED_BROWSER = "set_embedded_browser";
public static final String SET_CUSTOM_TABS = "set_custom_tabs";
public static final String SET_JAVASCRIPT = "set_javascript";

View File

@ -102,6 +102,12 @@
android:text="@string/expand_cw"
android:layout_height="wrap_content" />
<!-- EXPAND Images -->
<CheckBox
android:id="@+id/set_expand_image"
android:layout_width="wrap_content"
android:text="@string/expand_image"
android:layout_height="wrap_content" />
<!-- DISPLAY BOOKMARK BUTTON -->
<CheckBox

View File

@ -101,6 +101,13 @@
android:text="@string/expand_cw"
android:layout_height="wrap_content" />
<!-- EXPAND Images -->
<CheckBox
android:id="@+id/set_expand_image"
android:layout_width="wrap_content"
android:text="@string/expand_image"
android:layout_height="wrap_content" />
<!-- DISPLAY BOOKMARK BUTTON -->
<CheckBox
android:id="@+id/set_display_bookmarks"

View File

@ -601,6 +601,7 @@
<string name="about_trunk_action">Trunk API</string>
<string name="toast_impossible_to_follow">Account(s) can\'t be followed</string>
<string name="retrieve_remote_account">Fetching remote account</string>
<string name="expand_image">Automatically expand hidden media</string>
<string-array translatable="false" name="proxy_type_choice">