mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-16 15:20:31 +05:30
Merge branch 'libre-tube:master' into master
This commit is contained in:
commit
cd39b9d76d
@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.obj.PlaylistId
|
import com.github.libretube.obj.PlaylistId
|
||||||
@ -44,8 +45,16 @@ class PlaylistOptionsDialog(
|
|||||||
0 -> {
|
0 -> {
|
||||||
val sharedPref =
|
val sharedPref =
|
||||||
context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
val token = sharedPref?.getString("token", "")!!
|
val token = sharedPref?.getString("token", "")
|
||||||
importPlaylist(token, playlistId)
|
if (token != "") {
|
||||||
|
importPlaylist(token!!, playlistId)
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
R.string.login_first,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// share the playlist
|
// share the playlist
|
||||||
1 -> {
|
1 -> {
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package com.github.libretube.preferences
|
package com.github.libretube.preferences
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
|
import com.github.libretube.requireMainActivityRestart
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import org.chromium.base.CommandLine.reset
|
||||||
|
|
||||||
class AdvancedSettings : PreferenceFragmentCompat() {
|
class AdvancedSettings : PreferenceFragmentCompat() {
|
||||||
val TAG = "AdvancedSettings"
|
val TAG = "AdvancedSettings"
|
||||||
@ -23,5 +27,33 @@ class AdvancedSettings : PreferenceFragmentCompat() {
|
|||||||
sharedPreferences.edit().remove("search_history").commit()
|
sharedPreferences.edit().remove("search_history").commit()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val resetSettings = findPreference<Preference>("reset_settings")
|
||||||
|
resetSettings?.setOnPreferenceClickListener {
|
||||||
|
showResetDialog()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showResetDialog() {
|
||||||
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setPositiveButton(R.string.reset) { _, _ ->
|
||||||
|
// clear default preferences
|
||||||
|
val sharedPreferences =
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
|
sharedPreferences.edit().clear().commit()
|
||||||
|
|
||||||
|
// clear login token
|
||||||
|
val sharedPrefToken =
|
||||||
|
context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
|
sharedPrefToken?.edit()?.clear()?.commit()
|
||||||
|
|
||||||
|
requireMainActivityRestart = true
|
||||||
|
activity?.recreate()
|
||||||
|
}
|
||||||
|
.setNegativeButton(getString(R.string.cancel)) { _, _ -> }
|
||||||
|
.setTitle(R.string.reset)
|
||||||
|
.setMessage(R.string.reset_message)
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
app/src/main/res/drawable/ic_reset.xml
Normal file
10
app/src/main/res/drawable/ic_reset.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?android:attr/colorControlNormal"
|
||||||
|
android:viewportWidth="459"
|
||||||
|
android:viewportHeight="459">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M229.5,0C102.75,0 0,102.75 0,229.5S102.75,459 229.5,459S459,356.25 459,229.5S356.25,0 229.5,0zM307.11,271.63c9.8,9.8 9.8,25.68 0,35.48c-4.9,4.9 -11.32,7.35 -17.74,7.35c-6.42,0 -12.84,-2.45 -17.74,-7.35L229.5,264.98l-42.13,42.13c-4.9,4.9 -11.32,7.35 -17.74,7.35c-6.42,0 -12.84,-2.45 -17.74,-7.35c-9.8,-9.8 -9.8,-25.68 0,-35.48l42.13,-42.13l-42.13,-42.13c-9.8,-9.8 -9.8,-25.68 0,-35.48s25.68,-9.8 35.48,0l42.13,42.13l42.13,-42.13c9.8,-9.8 25.68,-9.8 35.48,0c9.8,9.8 9.8,25.68 0,35.48l-42.13,42.13L307.11,271.63z" />
|
||||||
|
</vector>
|
@ -201,4 +201,6 @@
|
|||||||
<string name="pauseOnScreenOff_summary">Pause the player when the screen is turned off.</string>
|
<string name="pauseOnScreenOff_summary">Pause the player when the screen is turned off.</string>
|
||||||
<string name="autoplay_summary">Automatically play the next video when the current is finished.</string>
|
<string name="autoplay_summary">Automatically play the next video when the current is finished.</string>
|
||||||
<string name="clonePlaylist">Clone playlist</string>
|
<string name="clonePlaylist">Clone playlist</string>
|
||||||
|
<string name="reset">Restore defaults</string>
|
||||||
|
<string name="reset_message">Are you sure you want to reset all the apps settings to its default?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -46,4 +46,13 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:icon="@drawable/ic_reset"
|
||||||
|
app:key="reset_settings"
|
||||||
|
app:title="@string/reset" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user