version 0.4.2 #44
|
@ -46,8 +46,8 @@ dependencies {
|
|||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
||||
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ object AoDParser {
|
|||
private const val baseUrl = "https://www.anime-on-demand.de"
|
||||
private const val loginPath = "/users/sign_in"
|
||||
private const val libraryPath = "/animes"
|
||||
private const val subscriptionPath = "/mypools"
|
||||
|
||||
private const val userAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0"
|
||||
|
||||
|
@ -117,6 +118,25 @@ object AoDParser {
|
|||
return media
|
||||
}
|
||||
|
||||
/**
|
||||
* get subscription info from aod website, remove "Anime-Abo" Prefix and trim
|
||||
*/
|
||||
fun getSubscriptionInfoAsync(): Deferred<String> {
|
||||
return GlobalScope.async(Dispatchers.IO) {
|
||||
// get the subscription page
|
||||
val res = Jsoup.connect(baseUrl + subscriptionPath)
|
||||
.cookies(sessionCookies)
|
||||
.get()
|
||||
|
||||
return@async res.select("a:contains(Anime-Abo)").text()
|
||||
.removePrefix("Anime-Abo").trim()
|
||||
}
|
||||
}
|
||||
|
||||
fun getSubscriptionUrl(): String {
|
||||
return baseUrl + subscriptionPath
|
||||
}
|
||||
|
||||
fun markAsWatched(mediaId: Int, episodeId: Int) = GlobalScope.launch {
|
||||
val episode = getMediaById(mediaId).getEpisodeById(episodeId)
|
||||
episode.watched = true
|
||||
|
@ -261,6 +281,8 @@ object AoDParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* TODO rework the media loading process, don't modify media object
|
||||
* TODO catch SocketTimeoutException from loading to show a waring dialog
|
||||
* load streams for the media path, movies have one episode
|
||||
* @param media is used as call ba reference
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.mosad.teapod.ui.activity.main.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
|
@ -8,6 +10,8 @@ import android.view.ViewGroup
|
|||
import androidx.fragment.app.Fragment
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.mosad.teapod.BuildConfig
|
||||
import org.mosad.teapod.ui.activity.main.MainActivity
|
||||
import org.mosad.teapod.R
|
||||
|
@ -31,6 +35,15 @@ class AccountFragment : Fragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
// load subscription (async) info before anything else
|
||||
binding.textAccountSubscription.text = getString(R.string.account_subscription, getString(R.string.loading))
|
||||
GlobalScope.launch {
|
||||
binding.textAccountSubscription.text = getString(
|
||||
R.string.account_subscription,
|
||||
AoDParser.getSubscriptionInfoAsync().await()
|
||||
)
|
||||
}
|
||||
|
||||
binding.textAccountLogin.text = EncryptedPreferences.login
|
||||
binding.textInfoAboutDesc.text = getString(R.string.info_about_desc, BuildConfig.VERSION_NAME, getString(R.string.build_time))
|
||||
binding.textThemeSelected.text = when (Preferences.theme) {
|
||||
|
@ -49,6 +62,10 @@ class AccountFragment : Fragment() {
|
|||
showLoginDialog(true)
|
||||
}
|
||||
|
||||
binding.linearAccountSubscription.setOnClickListener {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(AoDParser.getSubscriptionUrl())))
|
||||
}
|
||||
|
||||
binding.linearTheme.setOnClickListener {
|
||||
showThemeDialog()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z"/>
|
||||
</vector>
|
|
@ -79,8 +79,52 @@
|
|||
android:text="@string/account_login_desc"
|
||||
android:textColor="?textSecondary" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_account_subscription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:foreground="?android:selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="7dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/account"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:padding="9dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_baseline_access_time_24"
|
||||
app:tint="?iconColor" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_account_subscription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/account_subscription"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_account_subscription_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/account_subscription_desc"
|
||||
android:textColor="?textSecondary" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
<!-- settings fragment -->
|
||||
<string name="account">Account</string>
|
||||
<string name="account_login_desc">Zum bearbeiten tippen</string>
|
||||
<string name="account_subscription">Abo %1$s</string>
|
||||
<string name="account_subscription_desc">Zum verlängern tippen</string>
|
||||
<string name="info">Info</string>
|
||||
<string name="info_about_desc">Version %1$s (%2$s)</string>
|
||||
<string name="settings">Einstellungen</string>
|
||||
|
@ -77,6 +79,7 @@
|
|||
<!-- dialogs -->
|
||||
<string name="save">speichern</string>
|
||||
<string name="cancel">@android:string/cancel</string>
|
||||
<string name="loading">lädt…</string>
|
||||
<string name="dialog_timeout_head">Anmelden fehlgeschlagen</string>
|
||||
<string name="dialog_timeout_desc">Der Server scheint langsam zu antworten. Bitte versuche es später noch einmal.</string>
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
<string name="account">Account</string>
|
||||
<string name="account_login_ex" translatable="false">user@example.com</string>
|
||||
<string name="account_login_desc">Tap to edit</string>
|
||||
<string name="account_subscription">Subscription %1$s</string>
|
||||
<string name="account_subscription_desc">Tap to extend</string>
|
||||
<string name="info">Info</string>
|
||||
<string name="info_about" translatable="false">Teapod by @Seil0</string>
|
||||
<string name="info_about_desc">Version %1$s (%2$s)</string>
|
||||
|
@ -97,6 +99,7 @@
|
|||
<!-- dialogs -->
|
||||
<string name="save">save</string>
|
||||
<string name="cancel">@android:string/cancel</string>
|
||||
<string name="loading">loading…</string>
|
||||
<string name="dialog_timeout_head">Login failed</string>
|
||||
<string name="dialog_timeout_desc">Looks like the server is taking to long to respond. Please try again later.</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue