From edf084e42c442a26125f6b501ec239b7b82da556 Mon Sep 17 00:00:00 2001 From: crockwave Date: Wed, 13 Feb 2019 14:31:08 -0600 Subject: [PATCH] - Added Custom Sharing feature support to SettingsFragment and supporting XML --- .../mastodon/fragments/SettingsFragment.java | 22 +++++++++++++++++++ .../gouv/etalab/mastodon/helper/Helper.java | 1 + .../res/layout-sw600dp/fragment_settings.xml | 15 +++++++++++++ app/src/main/res/layout/fragment_settings.xml | 15 +++++++++++++ 4 files changed, 53 insertions(+) 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 d2221a029..6e1aa3a4e 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 @@ -468,6 +468,28 @@ public class SettingsFragment extends Fragment { } }); + // Custom Sharing + boolean custom_sharing = sharedpreferences.getBoolean(Helper.SET_CUSTOM_SHARING, true); + final CheckBox set_custom_sharing = rootView.findViewById(R.id.set_custom_sharing); + set_custom_sharing.setChecked(custom_sharing); + + set_custom_sharing.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putBoolean(Helper.SET_CUSTOM_SHARING, set_custom_sharing.isChecked()); + editor.apply(); + } + }); + + String custom_sharing_url = sharedpreferences.getString(Helper.SET_CUSTOM_SHARING_URL, + "http://my.site/add?user=fedilab&url=${url}&title=${title}&source=${source}&id=${id}&descripition=${description}&keywords=${keywords}"); + final EditText edit_custom_sharing_url = rootView.findViewById(R.id.custom_sharing_url); + if (custom_sharing_url.equals("")) { + custom_sharing_url = "http://my.site/add?user=fedilab&url=${url}&title=${title}&source=${source}&id=${id}&descripition=${description}&keywords=${keywords}"; + } + edit_custom_sharing_url.setText(custom_sharing_url); + boolean display_direct = sharedpreferences.getBoolean(Helper.SET_DISPLAY_DIRECT, true); final CheckBox set_display_direct = rootView.findViewById(R.id.set_display_direct); set_display_direct.setChecked(display_direct); 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 38f7c9ee6..8c6c7f508 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 @@ -288,6 +288,7 @@ public class Helper { public static final String SET_COMPACT_MODE = "set_compact_mode"; public static final String SET_SHARE_DETAILS = "set_share_details"; public static final String SET_CUSTOM_SHARING = "set_custom_sharing"; + public static final String SET_CUSTOM_SHARING_URL = "set_custom_sharing_url"; public static final String SET_NOTIF_SOUND = "set_notif_sound"; public static final String SET_ENABLE_TIME_SLOT = "set_enable_time_slot"; public static final String SET_KEEP_BACKGROUND_PROCESS = "set_keep_background_process"; diff --git a/app/src/main/res/layout-sw600dp/fragment_settings.xml b/app/src/main/res/layout-sw600dp/fragment_settings.xml index 6b25806c9..df70e231e 100644 --- a/app/src/main/res/layout-sw600dp/fragment_settings.xml +++ b/app/src/main/res/layout-sw600dp/fragment_settings.xml @@ -347,6 +347,21 @@ android:text="@string/set_share_details" android:layout_height="wrap_content" /> + + + + + + + + + +