mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
account name and pfp on settings page
This commit is contained in:
parent
1ff0b5dccd
commit
d6c5c69b97
3 changed files with 53 additions and 15 deletions
|
@ -19,11 +19,16 @@ import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.databinding.MainSettingsBinding
|
import com.lagradost.cloudstream3.databinding.MainSettingsBinding
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.accountManagers
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.accountManagers
|
||||||
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi
|
||||||
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi
|
||||||
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.simklApi
|
||||||
|
import com.lagradost.cloudstream3.syncproviders.AuthAPI
|
||||||
import com.lagradost.cloudstream3.ui.home.HomeFragment
|
import com.lagradost.cloudstream3.ui.home.HomeFragment
|
||||||
import com.lagradost.cloudstream3.ui.result.txt
|
import com.lagradost.cloudstream3.ui.result.txt
|
||||||
import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR
|
import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR
|
||||||
import com.lagradost.cloudstream3.ui.settings.Globals.TV
|
import com.lagradost.cloudstream3.ui.settings.Globals.TV
|
||||||
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
|
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
|
||||||
|
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper
|
import com.lagradost.cloudstream3.utils.UIHelper
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.clipboardHelper
|
import com.lagradost.cloudstream3.utils.UIHelper.clipboardHelper
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
|
@ -136,21 +141,38 @@ class SettingsFragment : Fragment() {
|
||||||
activity?.navigate(id, Bundle())
|
activity?.navigate(id, Bundle())
|
||||||
}
|
}
|
||||||
|
|
||||||
// used to debug leaks showToast(activity,"${VideoDownloadManager.downloadStatusEvent.size} : ${VideoDownloadManager.downloadProgressEvent.size}")
|
/** used to debug leaks
|
||||||
|
showToast(activity,"${VideoDownloadManager.downloadStatusEvent.size} :
|
||||||
|
${VideoDownloadManager.downloadProgressEvent.size}") **/
|
||||||
|
// Check login status for each OAuth2 API
|
||||||
|
val isSyncing = simklApi.loginInfo() != null || malApi.loginInfo() != null || aniListApi.loginInfo() != null
|
||||||
|
|
||||||
for (syncApi in accountManagers) {
|
// show local account image and pfp when not syncing with any api.
|
||||||
val login = syncApi.loginInfo()
|
if (!isSyncing) {
|
||||||
val pic = login?.profilePicture ?: continue
|
val currentAccount = DataStoreHelper.accounts.firstOrNull {
|
||||||
if (binding?.settingsProfilePic?.setImage(
|
it.keyIndex == DataStoreHelper.selectedKeyIndex
|
||||||
pic,
|
} ?: DataStoreHelper.getDefaultAccount(activity ?: requireActivity())
|
||||||
errorImageDrawable = HomeFragment.errorProfilePic
|
val name = currentAccount.name
|
||||||
) == true
|
val image = currentAccount.image
|
||||||
) {
|
|
||||||
binding?.settingsProfileText?.text = login.name
|
binding?.settingsProfilePic?.setImage(image)
|
||||||
binding?.settingsProfile?.isVisible = true
|
binding?.settingsProfileText?.text = name
|
||||||
break
|
} else {
|
||||||
|
for (syncApi in accountManagers) {
|
||||||
|
val login = syncApi.loginInfo()
|
||||||
|
val pic = login?.profilePicture ?: continue
|
||||||
|
if (binding?.settingsProfilePic?.setImage(
|
||||||
|
pic,
|
||||||
|
errorImageDrawable = HomeFragment.errorProfilePic
|
||||||
|
) == true
|
||||||
|
) {
|
||||||
|
binding?.settingsProfileText?.text = login.name
|
||||||
|
binding?.settingsProfile?.isVisible = true
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding?.apply {
|
binding?.apply {
|
||||||
listOf(
|
listOf(
|
||||||
settingsGeneral to R.id.action_navigation_global_to_navigation_settings_general,
|
settingsGeneral to R.id.action_navigation_global_to_navigation_settings_general,
|
||||||
|
|
13
app/src/main/res/drawable/rounded_outline.xml
Normal file
13
app/src/main/res/drawable/rounded_outline.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="@android:color/white">
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<stroke
|
||||||
|
android:width="2dp"
|
||||||
|
android:color="?attr/white" />
|
||||||
|
<corners android:radius="@dimen/rounded_image_radius" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
|
@ -24,7 +24,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
|
@ -36,7 +35,11 @@
|
||||||
android:id="@+id/settings_profile_pic"
|
android:id="@+id/settings_profile_pic"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:ignore="ContentDescription" />
|
android:scaleType="centerCrop"
|
||||||
|
android:foreground="@drawable/rounded_outline"
|
||||||
|
tools:src="@drawable/profile_bg_orange"
|
||||||
|
android:contentDescription="@string/account"/>
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -50,7 +53,7 @@
|
||||||
android:textColor="?attr/textColor"
|
android:textColor="?attr/textColor"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
tools:text="Hello world" />
|
tools:text="Indus Aryan" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue