mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
import login check
This commit is contained in:
parent
3f05ce9acb
commit
6076598dbd
@ -116,7 +116,8 @@ class Settings : PreferenceFragmentCompat() {
|
|||||||
|
|
||||||
val importFromYt = findPreference<Preference>("import_from_yt")
|
val importFromYt = findPreference<Preference>("import_from_yt")
|
||||||
importFromYt?.setOnPreferenceClickListener {
|
importFromYt?.setOnPreferenceClickListener {
|
||||||
|
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
|
val token = sharedPref?.getString("token","")!!
|
||||||
//check StorageAccess
|
//check StorageAccess
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
Log.d("myz", "" + Build.VERSION.SDK_INT)
|
Log.d("myz", "" + Build.VERSION.SDK_INT)
|
||||||
@ -127,8 +128,10 @@ class Settings : PreferenceFragmentCompat() {
|
|||||||
Manifest.permission.MANAGE_EXTERNAL_STORAGE
|
Manifest.permission.MANAGE_EXTERNAL_STORAGE
|
||||||
), 1
|
), 1
|
||||||
) //permission request code is just an int
|
) //permission request code is just an int
|
||||||
}else{
|
}else if (token != ""){
|
||||||
getContent.launch("*/*")
|
getContent.launch("*/*")
|
||||||
|
}else{
|
||||||
|
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ActivityCompat.checkSelfPermission(
|
if (ActivityCompat.checkSelfPermission(
|
||||||
@ -147,8 +150,10 @@ class Settings : PreferenceFragmentCompat() {
|
|||||||
),
|
),
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
}else{
|
}else if (token != ""){
|
||||||
getContent.launch("*/*")
|
getContent.launch("*/*")
|
||||||
|
}else{
|
||||||
|
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
@ -59,7 +59,9 @@ class Subscriptions : Fragment() {
|
|||||||
fetchChannels(channelRecView)
|
fetchChannels(channelRecView)
|
||||||
|
|
||||||
var feedRecView = view.findViewById<RecyclerView>(R.id.sub_feed)
|
var feedRecView = view.findViewById<RecyclerView>(R.id.sub_feed)
|
||||||
feedRecView.layoutManager = GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
|
val grid = sharedPreferences.getString("grid", resources.getInteger(R.integer.grid_items).toString())!!
|
||||||
|
feedRecView.layoutManager = GridLayoutManager(view.context, grid.toInt())
|
||||||
fetchFeed(feedRecView, progressBar)
|
fetchFeed(feedRecView, progressBar)
|
||||||
|
|
||||||
refreshLayout?.setOnRefreshListener {
|
refreshLayout?.setOnRefreshListener {
|
||||||
@ -137,16 +139,11 @@ class Subscriptions : Fragment() {
|
|||||||
}
|
}
|
||||||
run()
|
run()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
|
||||||
Log.e(TAG,"Stopped")
|
|
||||||
subscriptionAdapter = null
|
|
||||||
view?.findViewById<RecyclerView>(R.id.sub_feed)?.adapter=null
|
|
||||||
super.onStop()
|
|
||||||
}
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
Log.e(TAG,"Destroyed")
|
Log.e(TAG,"Destroyed")
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
subscriptionAdapter = null
|
||||||
|
view?.findViewById<RecyclerView>(R.id.sub_feed)?.adapter=null
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<string name="loggedout">Logged out successfully!</string>
|
<string name="loggedout">Logged out successfully!</string>
|
||||||
<string name="registered">Registered successfully! You may now subscribe to channels you want.</string>
|
<string name="registered">Registered successfully! You may now subscribe to channels you want.</string>
|
||||||
<string name="already_logged_in">You are already logged in, you may logout of your account.</string>
|
<string name="already_logged_in">You are already logged in, you may logout of your account.</string>
|
||||||
|
<string name="login_first">Please login and try again!</string>
|
||||||
<string name="instances">Choose an instance</string>
|
<string name="instances">Choose an instance</string>
|
||||||
<string name="customInstance">Add a custom instance</string>
|
<string name="customInstance">Add a custom instance</string>
|
||||||
<string name="region">Choose a region</string>
|
<string name="region">Choose a region</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user