From 05c4742facdf7bafff3087b165e18aab8811dc53 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 5 Jul 2022 11:14:51 +0200 Subject: [PATCH 1/3] add community section --- .../github/libretube/{util => }/Constants.kt | 17 ++- .../libretube/preferences/AboutFragment.kt | 8 +- .../preferences/CommunityFragment.kt | 58 ++++++++++ .../libretube/preferences/MainSettings.kt | 21 ++-- .../github/libretube/util/UpdateChecker.kt | 1 + app/src/main/res/drawable/ic_community.xml | 15 +++ app/src/main/res/drawable/ic_discord.xml | 10 ++ app/src/main/res/drawable/ic_matrix.xml | 10 ++ app/src/main/res/drawable/ic_reddit.xml | 10 ++ app/src/main/res/drawable/ic_telegram.xml | 10 ++ .../main/res/layout/fragment_community.xml | 104 ++++++++++++++++++ app/src/main/res/values/strings.xml | 5 + app/src/main/res/xml/settings.xml | 6 +- 13 files changed, 262 insertions(+), 13 deletions(-) rename app/src/main/java/com/github/libretube/{util => }/Constants.kt (56%) create mode 100644 app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt create mode 100644 app/src/main/res/drawable/ic_community.xml create mode 100644 app/src/main/res/drawable/ic_discord.xml create mode 100644 app/src/main/res/drawable/ic_matrix.xml create mode 100644 app/src/main/res/drawable/ic_reddit.xml create mode 100644 app/src/main/res/drawable/ic_telegram.xml create mode 100644 app/src/main/res/layout/fragment_community.xml diff --git a/app/src/main/java/com/github/libretube/util/Constants.kt b/app/src/main/java/com/github/libretube/Constants.kt similarity index 56% rename from app/src/main/java/com/github/libretube/util/Constants.kt rename to app/src/main/java/com/github/libretube/Constants.kt index 8b120a006..ca6ffa026 100644 --- a/app/src/main/java/com/github/libretube/util/Constants.kt +++ b/app/src/main/java/com/github/libretube/Constants.kt @@ -1,7 +1,22 @@ -package com.github.libretube.util +package com.github.libretube +/** + * API link for the update checker + */ const val GITHUB_API_URL = "https://api.github.com/repos/libre-tube/LibreTube/releases/latest" + +/** + * Links for the about fragment + */ const val WEBSITE_URL = "https://libre-tube.github.io/" const val DONATE_URL = "https://github.com/libre-tube/LibreTube#donate" const val GITHUB_URL = "https://github.com/libre-tube/LibreTube" const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped" + +/** + * Social media links for the community fragment + */ +const val TELEGRAM_URL = "" +const val MATRIX_URL = "" +const val DISCORD_URL = "" +const val REDDIT_URL = "" \ No newline at end of file diff --git a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt index 24db4013c..0605e6707 100644 --- a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt +++ b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt @@ -9,14 +9,14 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import com.github.libretube.DONATE_URL +import com.github.libretube.GITHUB_URL +import com.github.libretube.PIPED_GITHUB_URL import com.github.libretube.R +import com.github.libretube.WEBSITE_URL import com.github.libretube.activities.SettingsActivity import com.github.libretube.databinding.FragmentAboutBinding -import com.github.libretube.util.DONATE_URL -import com.github.libretube.util.GITHUB_URL -import com.github.libretube.util.PIPED_GITHUB_URL import com.github.libretube.util.ThemeHelper.getThemeColor -import com.github.libretube.util.WEBSITE_URL import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar diff --git a/app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt b/app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt new file mode 100644 index 000000000..1e7b8f8be --- /dev/null +++ b/app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt @@ -0,0 +1,58 @@ +package com.github.libretube.preferences + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.github.libretube.DISCORD_URL +import com.github.libretube.MATRIX_URL +import com.github.libretube.R +import com.github.libretube.REDDIT_URL +import com.github.libretube.TELEGRAM_URL +import com.github.libretube.activities.SettingsActivity +import com.github.libretube.databinding.FragmentCommunityBinding + +class CommunityFragment : Fragment() { + private lateinit var binding: FragmentCommunityBinding + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = FragmentCommunityBinding.inflate(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val settingsActivity = activity as SettingsActivity + settingsActivity.changeTopBarText(getString(R.string.community)) + + binding.telegram.setOnClickListener { + openLinkFromHref(TELEGRAM_URL) + } + + binding.matrix.setOnClickListener { + openLinkFromHref(MATRIX_URL) + } + + binding.discord.setOnClickListener { + openLinkFromHref(DISCORD_URL) + } + + binding.reddit.setOnClickListener { + openLinkFromHref(REDDIT_URL) + } + } + + private fun openLinkFromHref(link: String) { + val uri = Uri.parse(link) + val intent = Intent(Intent.ACTION_VIEW).setData(uri) + startActivity(intent) + } +} diff --git a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt index 075b35643..52ee90b8f 100644 --- a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt @@ -38,35 +38,35 @@ class MainSettings : PreferenceFragmentCompat() { val instance = findPreference("instance") instance?.setOnPreferenceClickListener { val newFragment = InstanceSettings() - navigateSettings(newFragment) + navigateToSettingsFragment(newFragment) true } val appearance = findPreference("appearance") appearance?.setOnPreferenceClickListener { val newFragment = AppearanceSettings() - navigateSettings(newFragment) + navigateToSettingsFragment(newFragment) true } val sponsorBlock = findPreference("sponsorblock") sponsorBlock?.setOnPreferenceClickListener { val newFragment = SponsorBlockSettings() - navigateSettings(newFragment) + navigateToSettingsFragment(newFragment) true } val player = findPreference("player") player?.setOnPreferenceClickListener { val newFragment = PlayerSettings() - navigateSettings(newFragment) + navigateToSettingsFragment(newFragment) true } val advanced = findPreference("advanced") advanced?.setOnPreferenceClickListener { val newFragment = AdvancedSettings() - navigateSettings(newFragment) + navigateToSettingsFragment(newFragment) true } @@ -80,12 +80,19 @@ class MainSettings : PreferenceFragmentCompat() { val about = findPreference("about") about?.setOnPreferenceClickListener { val newFragment = AboutFragment() - navigateSettings(newFragment) + navigateToSettingsFragment(newFragment) + true + } + + val community = findPreference("community") + community?.setOnPreferenceClickListener { + val newFragment = CommunityFragment() + navigateToSettingsFragment(newFragment) true } } - private fun navigateSettings(newFragment: Fragment) { + private fun navigateToSettingsFragment(newFragment: Fragment) { isCurrentViewMainSettings = false parentFragmentManager.beginTransaction() .replace(R.id.settings, newFragment) diff --git a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt index 4fa20c45e..3513a636d 100644 --- a/app/src/main/java/com/github/libretube/util/UpdateChecker.kt +++ b/app/src/main/java/com/github/libretube/util/UpdateChecker.kt @@ -3,6 +3,7 @@ package com.github.libretube.util import android.util.Log import androidx.fragment.app.FragmentManager import com.github.libretube.BuildConfig +import com.github.libretube.GITHUB_API_URL import com.github.libretube.dialogs.NoUpdateAvailableDialog import com.github.libretube.dialogs.UpdateAvailableDialog import com.github.libretube.obj.UpdateInfo diff --git a/app/src/main/res/drawable/ic_community.xml b/app/src/main/res/drawable/ic_community.xml new file mode 100644 index 000000000..53b474fd6 --- /dev/null +++ b/app/src/main/res/drawable/ic_community.xml @@ -0,0 +1,15 @@ + + + + diff --git a/app/src/main/res/drawable/ic_discord.xml b/app/src/main/res/drawable/ic_discord.xml new file mode 100644 index 000000000..1f9e2f420 --- /dev/null +++ b/app/src/main/res/drawable/ic_discord.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_matrix.xml b/app/src/main/res/drawable/ic_matrix.xml new file mode 100644 index 000000000..e06da1bef --- /dev/null +++ b/app/src/main/res/drawable/ic_matrix.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_reddit.xml b/app/src/main/res/drawable/ic_reddit.xml new file mode 100644 index 000000000..d7480cdb2 --- /dev/null +++ b/app/src/main/res/drawable/ic_reddit.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_telegram.xml b/app/src/main/res/drawable/ic_telegram.xml new file mode 100644 index 000000000..154dda875 --- /dev/null +++ b/app/src/main/res/drawable/ic_telegram.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_community.xml b/app/src/main/res/layout/fragment_community.xml new file mode 100644 index 000000000..2ac874fde --- /dev/null +++ b/app/src/main/res/layout/fragment_community.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0cc5687a2..c08963f15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -221,4 +221,9 @@ Auto rotation Landscape Portrait + Community + Discord + Matrix + Telegram + Reddit \ No newline at end of file diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index c474c2472..44067df2c 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -69,9 +69,13 @@ + + From 647b2fdac21b7d7567c5da9217a866ef14344606 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 5 Jul 2022 11:22:55 +0200 Subject: [PATCH 2/3] add twitter and add links --- .../java/com/github/libretube/Constants.kt | 9 +++++---- .../libretube/preferences/CommunityFragment.kt | 5 +++++ app/src/main/res/drawable/ic_twitter.xml | 10 ++++++++++ app/src/main/res/layout/fragment_community.xml | 18 ++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/ic_twitter.xml diff --git a/app/src/main/java/com/github/libretube/Constants.kt b/app/src/main/java/com/github/libretube/Constants.kt index ca6ffa026..2434efbb7 100644 --- a/app/src/main/java/com/github/libretube/Constants.kt +++ b/app/src/main/java/com/github/libretube/Constants.kt @@ -16,7 +16,8 @@ const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped" /** * Social media links for the community fragment */ -const val TELEGRAM_URL = "" -const val MATRIX_URL = "" -const val DISCORD_URL = "" -const val REDDIT_URL = "" \ No newline at end of file +const val TELEGRAM_URL = "https://libre-tube.github.io/assets/tg-widget.svg)](https://t.me/libretube" +const val MATRIX_URL = "https://libre-tube.github.io/assets/mat-widget.svg)](https://matrix.to/#/#LibreTube:matrix.org" +const val DISCORD_URL = "https://discord.com/invite/Qc34xCj2GV" +const val REDDIT_URL = "https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/" +const val TWITTER_URL = "https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube" \ No newline at end of file diff --git a/app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt b/app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt index 1e7b8f8be..90b2d9a5b 100644 --- a/app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt +++ b/app/src/main/java/com/github/libretube/preferences/CommunityFragment.kt @@ -12,6 +12,7 @@ import com.github.libretube.MATRIX_URL import com.github.libretube.R import com.github.libretube.REDDIT_URL import com.github.libretube.TELEGRAM_URL +import com.github.libretube.TWITTER_URL import com.github.libretube.activities.SettingsActivity import com.github.libretube.databinding.FragmentCommunityBinding @@ -48,6 +49,10 @@ class CommunityFragment : Fragment() { binding.reddit.setOnClickListener { openLinkFromHref(REDDIT_URL) } + + binding.twitter.setOnClickListener { + openLinkFromHref(TWITTER_URL) + } } private fun openLinkFromHref(link: String) { diff --git a/app/src/main/res/drawable/ic_twitter.xml b/app/src/main/res/drawable/ic_twitter.xml new file mode 100644 index 000000000..3f0d9f1a0 --- /dev/null +++ b/app/src/main/res/drawable/ic_twitter.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_community.xml b/app/src/main/res/layout/fragment_community.xml index 2ac874fde..6651fbd90 100644 --- a/app/src/main/res/layout/fragment_community.xml +++ b/app/src/main/res/layout/fragment_community.xml @@ -99,6 +99,24 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c08963f15..1851db862 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -226,4 +226,5 @@ Matrix Telegram Reddit + Twitter \ No newline at end of file From a1763e9b40d4f22343c773edf0fe23c06c5684c6 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 5 Jul 2022 11:27:21 +0200 Subject: [PATCH 3/3] fix links --- app/src/main/java/com/github/libretube/Constants.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/libretube/Constants.kt b/app/src/main/java/com/github/libretube/Constants.kt index 2434efbb7..26d940916 100644 --- a/app/src/main/java/com/github/libretube/Constants.kt +++ b/app/src/main/java/com/github/libretube/Constants.kt @@ -16,8 +16,8 @@ const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped" /** * Social media links for the community fragment */ -const val TELEGRAM_URL = "https://libre-tube.github.io/assets/tg-widget.svg)](https://t.me/libretube" -const val MATRIX_URL = "https://libre-tube.github.io/assets/mat-widget.svg)](https://matrix.to/#/#LibreTube:matrix.org" +const val TELEGRAM_URL = "https://t.me/libretube" +const val MATRIX_URL = "https://matrix.to/#/#LibreTube:matrix.org" const val DISCORD_URL = "https://discord.com/invite/Qc34xCj2GV" -const val REDDIT_URL = "https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/" -const val TWITTER_URL = "https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube" \ No newline at end of file +const val REDDIT_URL = "https://www.reddit.com/r/Libretube/" +const val TWITTER_URL = "https://twitter.com/libretube"