From 932fa5111a92970e63b74ef5ce3f3f221a42e149 Mon Sep 17 00:00:00 2001 From: Boyd Date: Sun, 17 Nov 2019 11:29:39 +0100 Subject: [PATCH] Revert "Remove string" This reverts commit a9978f8f --- .../activities/SlideMediaActivity.java | 10 +++-- .../fragments/ContentSettingsFragment.java | 32 +++++++++++++++ .../app/fedilab/android/helper/Helper.java | 1 + .../res/layout/fragment_settings_reveal.xml | 39 +++++++++++++++++-- app/src/main/res/values/strings.xml | 1 + 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java b/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java index 67ee9c339..26d95ede7 100644 --- a/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java @@ -127,6 +127,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf fullscreen = false; media_description = findViewById(R.id.media_description); + final int med_desc_timeout = sharedpreferences.getInt(Helper.SET_MED_DESC_TIMEOUT, 3) * 1000; flags = getWindow().getDecorView().getSystemUiVisibility(); swipeEnabled = true; @@ -214,7 +215,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf public void run() { media_description.setVisibility(View.GONE); } - }, 3000); + }, med_desc_timeout); } else { media_description.setVisibility(View.GONE); @@ -241,7 +242,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf public void run() { media_description.setVisibility(View.GONE); } - }, 3000); + }, med_desc_timeout); } else { media_description.setVisibility(View.GONE); @@ -275,6 +276,9 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf @Override public boolean dispatchTouchEvent(MotionEvent event) { + SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + final int med_desc_timeout = sharedpreferences.getInt(Helper.SET_MED_DESC_TIMEOUT, 3) * 1000; + switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startX = event.getX(); @@ -300,7 +304,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf public void run() { media_description.setVisibility(View.GONE); } - }, 3000); + }, med_desc_timeout); } else { media_description.setVisibility(View.GONE); diff --git a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java index a2ff09e6e..cb255b682 100644 --- a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java +++ b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java @@ -1605,6 +1605,38 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot }); + // Media Description Timeout + SeekBar medDescTimeoutSeekBar = rootView.findViewById(R.id.set_med_desc_timeout); + final TextView set_med_desc_timeout_value = rootView.findViewById(R.id.set_med_desc_timeout_value); + + medDescTimeoutSeekBar.setMax(30); + + int medDescTimeout = sharedpreferences.getInt(Helper.SET_MED_DESC_TIMEOUT, 3); + + medDescTimeoutSeekBar.setProgress(medDescTimeout); + set_med_desc_timeout_value.setText(String.valueOf(medDescTimeout)); + + medDescTimeoutSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + + set_med_desc_timeout_value.setText(String.valueOf(progress)); + + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putInt(Helper.SET_MED_DESC_TIMEOUT, progress); + editor.apply(); + } + }); + + LinearLayout toot_visibility_container = rootView.findViewById(R.id.toot_visibility_container); SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index fdf120cff..71e767fbe 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -338,6 +338,7 @@ public class Helper { public static final String SET_AUTO_STORE = "set_auto_store"; public static final String SET_POPUP_PUSH = "set_popup_push_new"; public static final String SET_NSFW_TIMEOUT = "set_nsfw_timeout"; + public static final String SET_MED_DESC_TIMEOUT = "set_med_desc_timeout"; public static final String SET_MEDIA_URLS = "set_media_urls"; public static final String SET_TEXT_SIZE = "set_text_size"; public static final String SET_ICON_SIZE = "set_icon_size"; diff --git a/app/src/main/res/layout/fragment_settings_reveal.xml b/app/src/main/res/layout/fragment_settings_reveal.xml index af45f762d..4525f0b51 100644 --- a/app/src/main/res/layout/fragment_settings_reveal.xml +++ b/app/src/main/res/layout/fragment_settings_reveal.xml @@ -1,5 +1,6 @@ - @@ -9,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - @@ -2111,6 +2112,38 @@ android:layout_gravity="center_vertical" /> + + + + + + + + + + Notify? Silent Notifications NSFW view timeout (seconds, 0 means off) + Media Description timeout (seconds, 0 means off) Edit profile Custom sharing Your custom sharing URL…