Skip to content

Commit

Permalink
Better incognito (visually)
Browse files Browse the repository at this point in the history
toggle for navbar in list
  • Loading branch information
aayush2622 committed Dec 11, 2023
1 parent b180625 commit 5c4e9d7
Show file tree
Hide file tree
Showing 18 changed files with 125 additions and 30 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
materialCardView.setCardBackgroundColor((color and 0x00FFFFFF) or 0x28000000.toInt())
}

val settings = loadData("incognito") ?: false
if(settings) {
binding.incognitoTextView.visibility = View.VISIBLE
binding.incognitoView.visibility = View.VISIBLE
}

binding.animeTitleContainer.updatePadding(top = statusBarHeight)

if (uiSettings.smallView) binding.animeTrendingContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/ani/dantotsu/home/HomeFragment.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ani.dantotsu.home

import android.animation.ObjectAnimator
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.graphics.drawable.Animatable
import android.os.Build
Expand Down Expand Up @@ -71,6 +73,7 @@ class HomeFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val scope = lifecycleScope
var uiSettings = loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()

fun load() {
if (activity != null && _binding != null) lifecycleScope.launch(Dispatchers.Main) {
binding.homeUserName.text = Anilist.username
Expand Down Expand Up @@ -111,7 +114,11 @@ class HomeFragment : Fragment() {
snackString(currContext()?.getString(R.string.please_reload))
}
}

val settings = loadData("incognito") ?: false
if(settings) {
binding.incognitoTextView.visibility = View.VISIBLE
binding.incognitoView.visibility = View.VISIBLE
}
binding.homeUserAvatarContainer.setSafeOnClickListener {
val dialogFragment =
SettingsDialogFragment.newInstance(SettingsDialogFragment.Companion.PageType.HOME)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
materialCardView.setCardBackgroundColor((color and 0x00FFFFFF) or 0x28000000.toInt())
}

val settings = loadData("incognito") ?: false
if(settings) {
binding.incognitoTextView.visibility = View.VISIBLE
binding.incognitoView.visibility = View.VISIBLE
}

binding.mangaTitleContainer.updatePadding(top = statusBarHeight)

if (uiSettings.smallView) binding.mangaTrendingContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1156,14 +1156,17 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
}

preloading = false
val setting = loadData("incognito") ?: false
val showProgressDialog =
if (settings.askIndividual) loadData<Boolean>("${media.id}_progressDialog")
?: true else false
if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true)
AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.auto_update, media.userPreferredName))
.setMessage(getString(R.string.incognito_will_not_update))
.apply {
if (setting) {
setMessage(getString(R.string.incognito_will_not_update))
}
setOnCancelListener { hideSystemBars() }
setCancelable(false)
setPositiveButton(getString(R.string.yes)) { dialog, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,22 @@ class MangaReaderActivity : AppCompatActivity() {
private fun progress(runnable: Runnable) {
if (maxChapterPage - currentChapterPage <= 1 && Anilist.userid != null) {
if (showProgressDialog) {

val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null)
val checkbox = dialogView.findViewById<CheckBox>(R.id.dialog_checkbox)
checkbox.text = getString(R.string.dont_ask_again, media.userPreferredName)
checkbox.setOnCheckedChangeListener { _, isChecked ->
saveData("${media.id}_progressDialog", isChecked)
showProgressDialog = !isChecked
}

val setting = loadData("incognito") ?: false
AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.title_update_progress))
.apply {
if (setting) {
setMessage(getString(R.string.incognito_will_not_update))
}
}
.setView(dialogView)
.setCancelable(false)
.setPositiveButton(getString(R.string.yes)) { dialog, _ ->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ani/dantotsu/media/user/ListActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ListActivity : AppCompatActivity() {
binding.listTabLayout.setTabTextColors(secondaryTextColor, primaryTextColor)
binding.listTabLayout.setSelectedTabIndicatorColor(primaryTextColor)
val uiSettings = loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()
if (!uiSettings.immersiveMode) {
if (!uiSettings.immersiveModeList) {
this.window.statusBarColor =
ContextCompat.getColor(this, R.color.nav_bg_inv)
binding.root.fitsSystemWindows = true
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListen
binding.settingsIncognito.setOnCheckedChangeListener { _, isChecked ->
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
.putBoolean("incognito", isChecked).apply()
saveData("incognito", isChecked)
restartApp()
}

var previousStart: View = when (uiSettings.defaultStartUpTab) {
Expand Down
16 changes: 3 additions & 13 deletions app/src/main/java/ani/dantotsu/settings/SettingsDialogFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,9 @@ class SettingsDialogFragment() : BottomSheetDialogFragment() {
}

PageType.HOME -> {
try {
val arrayOfFiles =
ContextCompat.getExternalFilesDirs(requireContext(), null)
startActivity(
if (loadData<Boolean>("sd_dl") == true && arrayOfFiles.size > 1 && arrayOfFiles[0] != null && arrayOfFiles[1] != null) {
val parentDirectory = arrayOfFiles[1].toString()
val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(Uri.parse(parentDirectory), "resource/folder")
} else Intent(DownloadManager.ACTION_VIEW_DOWNLOADS)
)
} catch (e: ActivityNotFoundException) {
toast(getString(R.string.file_manager_not_found))
}
val intent = Intent(activity, DownloadContainerActivity::class.java)
intent.putExtra("FRAGMENT_CLASS_NAME", OfflineMangaFragment::class.java.name)
startActivity(intent)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data class UserInterfaceSettings(

//App
var immersiveMode: Boolean = false,
var immersiveModeList: Boolean = false,
var smallView: Boolean = true,
var defaultStartUpTab: Int = 1,
var homeLayoutShow: MutableList<Boolean> = mutableListOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
saveData(ui, settings)
restartApp()
}
binding.uiSettingsImmersiveList.isChecked = settings.immersiveModeList
binding.uiSettingsImmersiveList.setOnCheckedChangeListener { _, isChecked ->
settings.immersiveModeList = isChecked
saveData(ui, settings)
restartApp()
}

binding.uiSettingsBannerAnimation.isChecked = settings.bannerAnimations
binding.uiSettingsBannerAnimation.setOnCheckedChangeListener { _, isChecked ->
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/res/layout/activity_user_interface_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@

</com.google.android.material.switchmaterial.SwitchMaterial>

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/uiSettingsImmersiveList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:checked="true"
android:drawableStart="@drawable/ic_round_fullscreen_24"
android:drawablePadding="16dp"
app:drawableTint="?attr/colorPrimary"
android:elegantTextHeight="true"
android:fontFamily="@font/poppins_bold"
android:minHeight="64dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/immersive_modelist"
android:textAlignment="viewStart"
android:textColor="?attr/colorOnBackground"
app:cornerRadius="0dp"
app:showText="false"
app:thumbTint="@color/button_switch_track">

</com.google.android.material.switchmaterial.SwitchMaterial>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
Expand Down
21 changes: 19 additions & 2 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,34 @@
android:id="@+id/homeScroll"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/homeContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/incognitoView"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:orientation="horizontal"
android:visibility="gone"/>

<TextView
android:id="@+id/incognitoTextView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Incognito Mode"
android:fontFamily="@font/poppins_bold"
android:textSize="11sp"
android:textColor="#4f2dbd"
android:layout_gravity="bottom|center_horizontal"
android:background="#00FFFFFF"
android:padding="8dp"
android:visibility="gone"/>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.flaviofaria.kenburnsview.KenBurnsView
android:id="@+id/homeUserBg"
android:layout_width="match_parent"
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/layout/item_anime_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,26 @@
android:layout_marginStart="-16dp"
android:layout_marginEnd="-16dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/incognitoView"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:orientation="horizontal"
android:background="?attr/colorPrimary"
android:visibility="gone"/>

<TextView
android:id="@+id/incognitoTextView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Incognito Mode"
android:fontFamily="@font/poppins_bold"
android:textSize="11sp"
android:textColor="#4f2dbd"
android:layout_gravity="bottom|center_horizontal"
android:background="#00FFFFFF"
android:padding="8dp"
android:visibility="gone"/>
<FrameLayout
android:id="@+id/animeTrendingContainer"
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_anime_watch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:fontFamily="@font/poppins_bold"
app:cornerRadius="12dp"
app:icon="@drawable/ic_round_play_circle_24"
android:drawableTint="@color/bg_white"
app:iconTint="@color/bg_white"
tools:ignore="TextContrastCheck" />

<TextView
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/layout/item_custom_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@
android:orientation="vertical"
android:padding="16dp">

<TextView
android:id="@+id/dialog_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/incognito_will_not_update"
android:paddingBottom="16dp"
android:textSize="12sp"
android:fontFamily="@font/poppins_bold"/>

<CheckBox
android:id="@+id/dialog_checkbox"
android:layout_width="match_parent"
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/layout/item_manga_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,26 @@
android:layout_marginStart="-16dp"
android:layout_marginEnd="-16dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/incognitoView"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:orientation="horizontal"
android:background="?attr/colorPrimary"
android:visibility="gone"/>

<TextView
android:id="@+id/incognitoTextView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Incognito Mode"
android:fontFamily="@font/poppins_bold"
android:textSize="11sp"
android:textColor="#4f2dbd"
android:layout_gravity="bottom|center_horizontal"
android:background="#00FFFFFF"
android:padding="8dp"
android:visibility="gone"/>
<FrameLayout
android:id="@+id/mangaTrendingContainer"
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@

<string name="app">App</string>
<string name="immersive_mode">Hide Status Bar</string>
<string name="immersive_modelist">Hide Status Bar for list</string>
<string name="immersive_mode_info">Requires App restart to fully apply.</string>
<string name="home_layout_show">Show/Hide Layouts on Home</string>
<string-array name="home_layouts">
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:textSize">14sp</item>
</style>

<style name="BottomNavBar" parent="">
Expand Down

0 comments on commit 5c4e9d7

Please sign in to comment.