download settings
This commit is contained in:
parent
e847ec21c3
commit
33bb60baad
3 changed files with 244 additions and 64 deletions
|
@ -15,15 +15,21 @@ import android.widget.ArrayAdapter
|
|||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.exoplayer.offline.DownloadService
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.connections.discord.Discord
|
||||
import ani.dantotsu.connections.mal.MAL
|
||||
import ani.dantotsu.databinding.ActivitySettingsBinding
|
||||
import ani.dantotsu.download.DownloadedType
|
||||
import ani.dantotsu.download.DownloadsManager
|
||||
import ani.dantotsu.download.video.ExoplayerDownloadService
|
||||
import ani.dantotsu.others.AppUpdater
|
||||
import ani.dantotsu.others.CustomBottomDialog
|
||||
import ani.dantotsu.others.LangSet
|
||||
|
@ -61,7 +67,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListen
|
|||
private val networkPreferences = Injekt.get<NetworkPreferences>()
|
||||
private var cursedCounter = 0
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@OptIn(UnstableApi::class) @SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
LangSet.setLocale(this)
|
||||
|
@ -242,6 +248,58 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListen
|
|||
dialog.window?.setDimAmount(0.8f)
|
||||
}
|
||||
|
||||
binding.purgeAnimeDownloads.setOnClickListener {
|
||||
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||
.setTitle("Purge Anime Downloads")
|
||||
.setMessage("Are you sure you want to purge all anime downloads?")
|
||||
.setPositiveButton("Yes") { dialog, _ ->
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
downloadsManager.purgeDownloads(DownloadedType.Type.ANIME)
|
||||
DownloadService.sendRemoveAllDownloads(this, ExoplayerDownloadService::class.java, false)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton("No") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.create()
|
||||
dialog.window?.setDimAmount(0.8f)
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
binding.purgeMangaDownloads.setOnClickListener {
|
||||
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||
.setTitle("Purge Manga Downloads")
|
||||
.setMessage("Are you sure you want to purge all manga downloads?")
|
||||
.setPositiveButton("Yes") { dialog, _ ->
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
downloadsManager.purgeDownloads(DownloadedType.Type.MANGA)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton("No") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.create()
|
||||
dialog.window?.setDimAmount(0.8f)
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
binding.purgeNovelDownloads.setOnClickListener {
|
||||
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||
.setTitle("Purge Novel Downloads")
|
||||
.setMessage("Are you sure you want to purge all novel downloads?")
|
||||
.setPositiveButton("Yes") { dialog, _ ->
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
downloadsManager.purgeDownloads(DownloadedType.Type.NOVEL)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton("No") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.create()
|
||||
dialog.window?.setDimAmount(0.8f)
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
binding.settingsForceLegacyInstall.isChecked =
|
||||
extensionInstaller.get() == BasePreferences.ExtensionInstaller.LEGACY
|
||||
binding.settingsForceLegacyInstall.setOnCheckedChangeListener { _, isChecked ->
|
||||
|
|
|
@ -225,11 +225,12 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Requires Android 12+"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:gravity="center"
|
||||
android:padding="16dp"/>
|
||||
android:padding="16dp"
|
||||
android:text="Requires Android 12+"
|
||||
android:textColor="?attr/colorSecondary" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/settingsUseMaterialYou"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -271,7 +272,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:alpha="0.58"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/custom_theme"/>
|
||||
android:text="@string/custom_theme" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/settingsUseCustomTheme"
|
||||
|
@ -345,6 +346,7 @@
|
|||
android:id="@+id/settingsIncognito"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:checked="false"
|
||||
android:drawableStart="@drawable/ic_incognito_24"
|
||||
android:drawablePadding="16dp"
|
||||
|
@ -354,7 +356,6 @@
|
|||
android:text="@string/incognito_mode"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
android:layout_marginStart="4dp"
|
||||
app:cornerRadius="0dp"
|
||||
app:drawableTint="?attr/colorPrimary"
|
||||
app:showText="false"
|
||||
|
@ -372,8 +373,8 @@
|
|||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:contentDescription="@string/anilist"
|
||||
app:tint="?attr/colorPrimary"
|
||||
app:srcCompat="@drawable/ic_anilist" />
|
||||
app:srcCompat="@drawable/ic_anilist"
|
||||
app:tint="?attr/colorPrimary" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -391,8 +392,8 @@
|
|||
android:fontFamily="@font/poppins_bold"
|
||||
android:gravity="center"
|
||||
android:text="@string/username"
|
||||
android:textSize="16sp"
|
||||
android:textColor="?attr/colorSecondary"/>
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settingsAnilistLogin"
|
||||
|
@ -439,8 +440,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:contentDescription="@string/myanimelist"
|
||||
app:tint="?attr/colorPrimary"
|
||||
app:srcCompat="@drawable/ic_myanimelist" />
|
||||
app:srcCompat="@drawable/ic_myanimelist"
|
||||
app:tint="?attr/colorPrimary" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -468,8 +469,8 @@
|
|||
android:fontFamily="@font/poppins_bold"
|
||||
android:gravity="center"
|
||||
android:text="@string/username"
|
||||
android:textSize="16sp"
|
||||
android:textColor="?attr/colorSecondary"/>
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settingsMALLogin"
|
||||
|
@ -536,8 +537,8 @@
|
|||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:text="@string/username"
|
||||
android:textSize="16sp"
|
||||
android:textColor="?attr/colorSecondary"/>
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settingsDiscordLogin"
|
||||
|
@ -708,6 +709,171 @@
|
|||
|
||||
</ani.dantotsu.others.Xpandable>
|
||||
|
||||
<ani.dantotsu.others.Xpandable
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/downloads"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24"
|
||||
tools:ignore="TextContrastCheck" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/settingsDownloadManager"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="-32dp"
|
||||
android:layout_marginEnd="-32dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/download_manager_select"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_download_24"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:alpha="0.58"
|
||||
android:fontFamily="@font/poppins_family"
|
||||
android:text="@string/long_press_download"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!--TODO: Add support for SD card-->
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/settingsDownloadInSd"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
android:drawableStart="@drawable/ic_round_sd_card_24"
|
||||
android:drawablePadding="16dp"
|
||||
android:elegantTextHeight="true"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:minHeight="64dp"
|
||||
android:text="@string/downloadInSd"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:drawableTint="?attr/colorPrimary"
|
||||
app:showText="false"
|
||||
android:visibility="gone"
|
||||
app:thumbTint="@color/button_switch_track" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="-16dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/purgeAnimeDownloads"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="-32dp"
|
||||
android:layout_marginEnd="-32dp"
|
||||
android:background="@drawable/ui_bg"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/purge_anime_downloads"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_new_releases_24"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginEnd="-16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/purgeMangaDownloads"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="-32dp"
|
||||
android:layout_marginEnd="-32dp"
|
||||
android:background="@drawable/ui_bg"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/purge_manga_downloads"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_new_releases_24"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginEnd="-16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/purgeNovelDownloads"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="-32dp"
|
||||
android:layout_marginEnd="-32dp"
|
||||
android:background="@drawable/ui_bg"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/purge_novel_downloads"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_new_releases_24"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginEnd="-16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
</ani.dantotsu.others.Xpandable>
|
||||
|
||||
<ani.dantotsu.others.Xpandable
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -868,54 +1034,6 @@
|
|||
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:alpha="0.58"
|
||||
android:fontFamily="@font/poppins_family"
|
||||
android:text="@string/dns_info"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/settingsDownloadManager"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="-32dp"
|
||||
android:layout_marginEnd="-32dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/download_manager_select"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_download_24"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/settingsDownloadInSd"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
android:drawableStart="@drawable/ic_round_sd_card_24"
|
||||
android:drawablePadding="16dp"
|
||||
android:elegantTextHeight="true"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:minHeight="64dp"
|
||||
android:text="@string/downloadInSd"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:drawableTint="?attr/colorPrimary"
|
||||
app:showText="false"
|
||||
app:thumbTint="@color/button_switch_track" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/settingsContinueMedia"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -646,5 +646,9 @@
|
|||
<string name="app_widget_description">This is an app widget description</string>
|
||||
<string name="airing_image">Airing Image</string>
|
||||
<string name="anime_downloads">animeDownloads</string>
|
||||
<string name="long_press_download">Long press the download button to download using the selected download manager</string>
|
||||
<string name="purge_anime_downloads">Purge anime downloads</string>
|
||||
<string name="purge_manga_downloads">Purge Manga Downloads</string>
|
||||
<string name="purge_novel_downloads">Purge Novel Downloads</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue