mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
commit
f33b9b7afb
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
@ -7,7 +8,9 @@
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<application
|
||||
@ -20,13 +23,25 @@
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Purple">
|
||||
android:theme="@style/Theme.Purple"
|
||||
tools:targetApi="n">
|
||||
|
||||
<activity
|
||||
android:name=".activities.NoInternetActivity"
|
||||
android:label="@string/noInternet" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:label="@string/settings" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.AboutActivity"
|
||||
android:label="@string/settings" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.CommunityActivity"
|
||||
android:label="@string/settings" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
|
@ -1,48 +1,35 @@
|
||||
package com.github.libretube.preferences
|
||||
package com.github.libretube.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
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.WEBLATE_URL
|
||||
import com.github.libretube.WEBSITE_URL
|
||||
import com.github.libretube.activities.SettingsActivity
|
||||
import com.github.libretube.databinding.FragmentAboutBinding
|
||||
import com.github.libretube.databinding.ActivityAboutBinding
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
class AboutFragment : Fragment() {
|
||||
private lateinit var binding: FragmentAboutBinding
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityAboutBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentAboutBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.about))
|
||||
binding = ActivityAboutBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
binding.website.setOnClickListener {
|
||||
openLinkFromHref(WEBSITE_URL)
|
||||
}
|
||||
binding.website.setOnLongClickListener {
|
||||
val text = context?.getString(R.string.website_summary)!!
|
||||
val text = getString(R.string.website_summary)
|
||||
showSnackBar(text)
|
||||
true
|
||||
}
|
||||
@ -51,7 +38,7 @@ class AboutFragment : Fragment() {
|
||||
openLinkFromHref(PIPED_GITHUB_URL)
|
||||
}
|
||||
binding.piped.setOnLongClickListener {
|
||||
val text = context?.getString(R.string.piped_summary)!!
|
||||
val text = getString(R.string.piped_summary)
|
||||
showSnackBar(text)
|
||||
true
|
||||
}
|
||||
@ -60,7 +47,7 @@ class AboutFragment : Fragment() {
|
||||
openLinkFromHref(WEBLATE_URL)
|
||||
}
|
||||
binding.translate.setOnLongClickListener {
|
||||
val text = context?.getString(R.string.translate_summary)!!
|
||||
val text = getString(R.string.translate_summary)
|
||||
showSnackBar(text)
|
||||
true
|
||||
}
|
||||
@ -69,7 +56,7 @@ class AboutFragment : Fragment() {
|
||||
openLinkFromHref(DONATE_URL)
|
||||
}
|
||||
binding.donate.setOnLongClickListener {
|
||||
val text = context?.getString(R.string.donate_summary)!!
|
||||
val text = getString(R.string.donate_summary)
|
||||
showSnackBar(text)
|
||||
true
|
||||
}
|
||||
@ -78,7 +65,7 @@ class AboutFragment : Fragment() {
|
||||
openLinkFromHref(GITHUB_URL)
|
||||
}
|
||||
binding.github.setOnLongClickListener {
|
||||
val text = context?.getString(R.string.contributing_summary)!!
|
||||
val text = getString(R.string.contributing_summary)
|
||||
showSnackBar(text)
|
||||
true
|
||||
}
|
||||
@ -87,17 +74,10 @@ class AboutFragment : Fragment() {
|
||||
showLicense()
|
||||
}
|
||||
binding.license.setOnLongClickListener {
|
||||
val text = context?.getString(R.string.license_summary)!!
|
||||
val text = getString(R.string.license_summary)
|
||||
showSnackBar(text)
|
||||
true
|
||||
}
|
||||
|
||||
binding.community.setOnClickListener {
|
||||
val communityFragment = CommunityFragment()
|
||||
parentFragmentManager.beginTransaction()
|
||||
.replace(R.id.settings, communityFragment)
|
||||
.commitNow()
|
||||
}
|
||||
}
|
||||
|
||||
private fun openLinkFromHref(link: String) {
|
||||
@ -117,7 +97,6 @@ class AboutFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun showLicense() {
|
||||
val assets = view?.context?.assets
|
||||
val licenseString = assets
|
||||
?.open("gpl3.html")
|
||||
?.bufferedReader()
|
||||
@ -131,7 +110,7 @@ class AboutFragment : Fragment() {
|
||||
Html.fromHtml(licenseString.toString())
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setPositiveButton(getString(R.string.okay)) { _, _ -> }
|
||||
.setMessage(licenseHtml)
|
||||
.create()
|
@ -1,38 +1,24 @@
|
||||
package com.github.libretube.preferences
|
||||
package com.github.libretube.activities
|
||||
|
||||
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 androidx.appcompat.app.AppCompatActivity
|
||||
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.TWITTER_URL
|
||||
import com.github.libretube.activities.SettingsActivity
|
||||
import com.github.libretube.databinding.FragmentCommunityBinding
|
||||
import com.github.libretube.databinding.ActivityCommunityBinding
|
||||
|
||||
class CommunityFragment : Fragment() {
|
||||
private lateinit var binding: FragmentCommunityBinding
|
||||
class CommunityActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityCommunityBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentCommunityBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.community))
|
||||
binding = ActivityCommunityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
binding.telegram.setOnClickListener {
|
||||
openLinkFromHref(TELEGRAM_URL)
|
@ -9,6 +9,8 @@ import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowInsetsController
|
||||
@ -82,6 +84,9 @@ class MainActivity : AppCompatActivity() {
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
// set the action bar for the activity
|
||||
setSupportActionBar(binding.toolbar)
|
||||
|
||||
navController = findNavController(R.id.fragment)
|
||||
binding.bottomNav.setupWithNavController(navController)
|
||||
|
||||
@ -143,21 +148,40 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
binding.toolbar.title = ThemeHelper.getStyledAppName(this)
|
||||
}
|
||||
}
|
||||
|
||||
binding.toolbar.setNavigationOnClickListener {
|
||||
// settings activity stuff
|
||||
val intent = Intent(this, SettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
menuInflater.inflate(R.menu.action_bar, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
binding.toolbar.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_search -> {
|
||||
navController.navigate(R.id.searchFragment)
|
||||
}
|
||||
}
|
||||
false
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
return when (item.itemId) {
|
||||
R.id.action_search -> {
|
||||
navController.navigate(R.id.searchFragment)
|
||||
true
|
||||
}
|
||||
R.id.action_settings -> {
|
||||
val settingsIntent = Intent(this, SettingsActivity::class.java)
|
||||
startActivity(settingsIntent)
|
||||
true
|
||||
}
|
||||
R.id.action_about -> {
|
||||
val aboutIntent = Intent(this, AboutActivity::class.java)
|
||||
startActivity(aboutIntent)
|
||||
true
|
||||
}
|
||||
R.id.action_community -> {
|
||||
val communityIntent = Intent(this, CommunityActivity::class.java)
|
||||
startActivity(communityIntent)
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,6 @@ import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.databinding.ActivitySettingsBinding
|
||||
import com.github.libretube.preferences.AboutFragment
|
||||
import com.github.libretube.preferences.CommunityFragment
|
||||
import com.github.libretube.preferences.MainSettings
|
||||
import com.github.libretube.util.ThemeHelper
|
||||
|
||||
@ -51,12 +49,6 @@ class SettingsActivity : AppCompatActivity() {
|
||||
super.onBackPressed()
|
||||
finishAndRemoveTask()
|
||||
}
|
||||
is CommunityFragment -> {
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.settings, AboutFragment())
|
||||
.commit()
|
||||
}
|
||||
else -> {
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
|
@ -116,13 +116,6 @@ class MainSettings : PreferenceFragmentCompat() {
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
val about = findPreference<Preference>("about")
|
||||
about?.setOnPreferenceClickListener {
|
||||
val newFragment = AboutFragment()
|
||||
navigateToSettingsFragment(newFragment)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateToSettingsFragment(newFragment: Fragment) {
|
||||
|
@ -135,24 +135,6 @@
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/community"
|
||||
style="@style/AboutCard">
|
||||
|
||||
<LinearLayout style="@style/AboutItem">
|
||||
|
||||
<ImageView
|
||||
style="@style/AboutImageView"
|
||||
android:src="@drawable/ic_community" />
|
||||
|
||||
<TextView
|
||||
style="@style/AboutTextView"
|
||||
android:text="@string/community" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -8,17 +8,22 @@
|
||||
app:layoutDescription="@xml/activity_main_scene"
|
||||
tools:context=".activities.MainActivity">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:menu="@menu/action_bar"
|
||||
app:navigationIcon="@drawable/ic_settings"
|
||||
app:subtitleCentered="true"
|
||||
app:title="@string/app_name"
|
||||
app:titleCentered="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
/>
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:menu="@menu/action_bar"
|
||||
app:title="@string/app_name" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottomNav"
|
||||
@ -37,7 +42,7 @@
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottomNav"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
app:layout_constraintTop_toBottomOf="@id/appBarLayout"
|
||||
app:navGraph="@navigation/nav" />
|
||||
|
||||
<FrameLayout
|
||||
|
@ -6,6 +6,21 @@
|
||||
android:id="@+id/action_search"
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/search_hint"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_about"
|
||||
android:title="@string/about"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_community"
|
||||
android:title="@string/community"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
@ -2,8 +2,6 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:summary="@string/general_summary"
|
||||
@ -52,8 +50,6 @@
|
||||
app:summary="@string/advanced_summary"
|
||||
app:title="@string/advanced" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
@ -62,10 +58,6 @@
|
||||
app:summary="@string/update_summary"
|
||||
app:title="App version" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_info"
|
||||
app:key="about"
|
||||
app:title="@string/about" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user