import login check

This commit is contained in:
rimthekid 2022-03-29 11:46:34 -07:00
parent 3f05ce9acb
commit 6076598dbd
3 changed files with 14 additions and 11 deletions

View File

@ -116,7 +116,8 @@ class Settings : PreferenceFragmentCompat() {
val importFromYt = findPreference<Preference>("import_from_yt")
importFromYt?.setOnPreferenceClickListener {
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
val token = sharedPref?.getString("token","")!!
//check StorageAccess
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Log.d("myz", "" + Build.VERSION.SDK_INT)
@ -127,8 +128,10 @@ class Settings : PreferenceFragmentCompat() {
Manifest.permission.MANAGE_EXTERNAL_STORAGE
), 1
) //permission request code is just an int
}else{
}else if (token != ""){
getContent.launch("*/*")
}else{
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
}
} else {
if (ActivityCompat.checkSelfPermission(
@ -147,8 +150,10 @@ class Settings : PreferenceFragmentCompat() {
),
1
)
}else{
}else if (token != ""){
getContent.launch("*/*")
}else{
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
}
}
true

View File

@ -59,7 +59,9 @@ class Subscriptions : Fragment() {
fetchChannels(channelRecView)
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)
refreshLayout?.setOnRefreshListener {
@ -137,16 +139,11 @@ class Subscriptions : Fragment() {
}
run()
}
override fun onStop() {
Log.e(TAG,"Stopped")
subscriptionAdapter = null
view?.findViewById<RecyclerView>(R.id.sub_feed)?.adapter=null
super.onStop()
}
override fun onDestroy() {
Log.e(TAG,"Destroyed")
super.onDestroy()
subscriptionAdapter = null
view?.findViewById<RecyclerView>(R.id.sub_feed)?.adapter=null
}
}

View File

@ -17,6 +17,7 @@
<string name="loggedout">Logged out successfully!</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="login_first">Please login and try again!</string>
<string name="instances">Choose an instance</string>
<string name="customInstance">Add a custom instance</string>
<string name="region">Choose a region</string>