From 349cd9be310c710bb6c19fff077a282cac1808d0 Mon Sep 17 00:00:00 2001 From: Len Chan Date: Tue, 19 Mar 2019 09:04:09 +0800 Subject: [PATCH] add hide notification delete button --- .../mastodon/drawers/PeertubeAdapter.java | 7 +++++-- .../mastodon/fragments/SettingsFragment.java | 18 ++++++++++++++++++ .../fr/gouv/etalab/mastodon/helper/Helper.java | 1 + app/src/main/res/layout/fragment_settings.xml | 8 ++++++++ app/src/main/res/values/strings.xml | 1 + 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PeertubeAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PeertubeAdapter.java index 9d224aa32..01496ebb2 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PeertubeAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/PeertubeAdapter.java @@ -96,6 +96,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio peertube.setInstance(Helper.getLiveInstance(context)); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); + boolean hide_notification_delete = sharedpreferences.getBoolean(Helper.SET_HIDE_DELETE_BUTTON_ON_TAB, false); if( theme == Helper.THEME_LIGHT){ holder.main_container.setBackgroundResource(R.color.mastodonC3__); }else if (theme == Helper.THEME_DARK){ @@ -103,7 +104,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio }else if (theme == Helper.THEME_BLACK){ holder.main_container.setBackgroundResource(R.color.black); } - + if(hide_notification_delete) + holder.notification_delete.setVisibility(View.GONE); Account account = peertube.getAccount(); holder.peertube_account_name.setText(account.getAcct()); @@ -207,7 +209,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio class ViewHolder extends RecyclerView.ViewHolder{ LinearLayout main_container; - ImageView peertube_profile, peertube_video_image; + ImageView peertube_profile, peertube_video_image, notification_delete; TextView peertube_account_name, peertube_views, peertube_duration; TextView peertube_title, peertube_date, header_title; @@ -222,6 +224,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio peertube_duration = itemView.findViewById(R.id.peertube_duration); main_container = itemView.findViewById(R.id.main_container); header_title = itemView.findViewById(R.id.header_title); + notification_delete = itemView.findViewById(R.id.notification_delete); } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java index 5a782868b..e4e8c3fbb 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java @@ -607,6 +607,24 @@ public class SettingsFragment extends Fragment { } }); + boolean hide_delete_notification_on_tab = sharedpreferences.getBoolean(Helper.SET_HIDE_DELETE_BUTTON_ON_TAB, false); + final CheckBox set_hide_delete_notification_on_tab = rootView.findViewById(R.id.set_hide_delete_notification_on_tab); + set_old_direct_timeline.setChecked(hide_delete_notification_on_tab); + + set_old_direct_timeline.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putBoolean(Helper.SET_HIDE_DELETE_BUTTON_ON_TAB, set_hide_delete_notification_on_tab.isChecked()); + editor.apply(); + if( getActivity() != null) + getActivity().recreate(); + Intent intent = new Intent(context, MainActivity.class); + if(getActivity() != null) + getActivity().finish(); + startActivity(intent); + } + }); int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0); SeekBar set_truncate_size = rootView.findViewById(R.id.set_truncate_size); set_truncate_size.setMax(20); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 8d496f5b1..6b7bbc644 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -307,6 +307,7 @@ public class Helper { public static final String SET_DISPLAY_CONTENT_AFTER_FM = "set_display_content_after_fm"; public static final String SET_FEATURED_TAGS ="set_featured_tags"; public static final String SET_FEATURED_TAG_ACTION ="set_featured_tag_action"; + public static final String SET_HIDE_DELETE_BUTTON_ON_TAB = "set_hide_delete_notification_on_tab"; public static final int S_NO = 0; static final int S_512KO = 1; public static final int S_1MO = 2; diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index b448e6fce..18269a6e1 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -139,6 +139,14 @@ android:text="@string/set_old_direct_timeline" android:layout_height="wrap_content" /> + + Featured hashtags Filter timeline with tags No tags + Hide delete notifcation button on notification tab