Skip to content

Commit

Permalink
Merge branch 'master' into improve_appdetail
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Falière authored Dec 8, 2023
2 parents 7636671 + 71efb01 commit 84a0496
Show file tree
Hide file tree
Showing 27 changed files with 224 additions and 261 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.eu.exodus_privacy.exodusprivacy.R
import org.eu.exodus_privacy.exodusprivacy.databinding.FragmentAppDetailBinding
import org.eu.exodus_privacy.exodusprivacy.fragments.appdetail.model.AppDetailVPAdapter
import org.eu.exodus_privacy.exodusprivacy.utils.setExodusColor
import org.eu.exodus_privacy.exodusprivacy.utils.setVersionReport
import javax.inject.Inject

@AndroidEntryPoint
Expand Down Expand Up @@ -176,7 +175,6 @@ class AppDetailFragment : Fragment(R.layout.fragment_app_detail) {
text = permsNum.toString()
setExodusColor(permsNum)
}
versionChip.setVersionReport(app)

sourceChip.text = app.source.name.lowercase().replaceFirstChar { it.uppercase() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ADPermissionsDiffUtil : DiffUtil.ItemCallback<Permission>() {
return when {
oldItem.shortName != newItem.shortName -> false
oldItem.label != newItem.label -> false
oldItem.description != newItem.description -> false
else -> true
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package org.eu.exodus_privacy.exodusprivacy.fragments.appdetail.model

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.eu.exodus_privacy.exodusprivacy.R
import org.eu.exodus_privacy.exodusprivacy.databinding.RecyclerViewPermissionItemBinding
import org.eu.exodus_privacy.exodusprivacy.objects.Permission

Expand All @@ -32,21 +29,6 @@ class ADPermissionsRVAdapter :
holder.binding.apply {
permissionTitleTV.text = app.shortName
permissionSubTitleTV.text = app.label.replaceFirstChar { it.uppercase() }
if (app.description.isEmpty() || app.description == "null") {
permissionDescTV.visibility = View.GONE
expandBT.visibility = View.GONE
} else {
expandBT.setOnClickListener {
if (permissionDescTV.isVisible) {
expandBT.setIconResource(R.drawable.ic_down)
permissionDescTV.visibility = View.GONE
} else {
expandBT.setIconResource(R.drawable.ic_up)
permissionDescTV.text = app.description
permissionDescTV.visibility = View.VISIBLE
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.eu.exodus_privacy.exodusprivacy.fragments.apps

import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
Expand All @@ -12,8 +13,8 @@ import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.google.android.material.transition.MaterialFadeThrough
import dagger.hilt.android.AndroidEntryPoint
import org.eu.exodus_privacy.exodusprivacy.ExodusUpdateService
Expand Down Expand Up @@ -67,7 +68,13 @@ class AppsFragment : Fragment(R.layout.fragment_apps) {
val appsRVAdapter = AppsRVAdapter(findNavController().currentDestination!!.id)
binding.appListRV.apply {
adapter = appsRVAdapter
layoutManager = LinearLayoutManager(view.context)
val column: Int =
if (resources.configuration.smallestScreenWidthDp >= 600 && resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
2
} else {
1
}
layoutManager = StaggeredGridLayoutManager(column, 1)
addOnScrollListener(
object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.eu.exodus_privacy.exodusprivacy.fragments.apps.model

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.graphics.drawable.toDrawable
import androidx.navigation.findNavController
Expand All @@ -12,7 +13,6 @@ import org.eu.exodus_privacy.exodusprivacy.fragments.apps.AppsFragmentDirections
import org.eu.exodus_privacy.exodusprivacy.fragments.trackerdetail.TrackerDetailFragmentDirections
import org.eu.exodus_privacy.exodusprivacy.manager.database.app.ExodusApplication
import org.eu.exodus_privacy.exodusprivacy.utils.setExodusColor
import org.eu.exodus_privacy.exodusprivacy.utils.setVersionReport

class AppsRVAdapter(
private val currentDestinationId: Int
Expand Down Expand Up @@ -48,7 +48,18 @@ class AppsRVAdapter(
}
appIconIV.background = app.icon.toDrawable(context.resources)
appNameTV.text = app.name
appVersionTV.text = context.getString(R.string.app_version, app.versionName)
when (app.exodusVersionCode) {
0L -> appVersionTV.apply {
text = context.resources.getString(R.string.version_unavailable)
visibility = View.VISIBLE
}

app.versionCode -> appVersionTV.visibility = View.GONE
else -> appVersionTV.apply {
text = context.resources.getString(R.string.version_mismatch)
visibility = View.VISIBLE
}
}
trackersChip.apply {
val trackerNum = app.exodusTrackers.size
text = if (app.exodusVersionCode == 0L) "?" else trackerNum.toString()
Expand All @@ -59,7 +70,6 @@ class AppsRVAdapter(
text = permsNum.toString()
setExodusColor(permsNum)
}
versionChip.setVersionReport(app)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.eu.exodus_privacy.exodusprivacy.fragments.trackerdetail

import android.content.res.Configuration
import android.net.Uri
import android.os.Bundle
import android.text.method.LinkMovementMethod
Expand All @@ -11,7 +12,7 @@ import androidx.fragment.app.viewModels
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipDrawable
import com.google.android.material.transition.MaterialFadeThrough
Expand Down Expand Up @@ -116,8 +117,11 @@ class TrackerDetailFragment : Fragment(R.layout.fragment_tracker_detail) {
codeSignTV.text = tracker.code_signature
if (tracker.network_signature.isNotEmpty()) {
networkSignTV.text = tracker.network_signature
networkDetectTV.visibility = View.VISIBLE
networkSignTV.visibility = View.VISIBLE
} else {
networkSignTV.text = "NC"
networkDetectTV.visibility = View.GONE
networkSignTV.visibility = View.GONE
}
}
}
Expand All @@ -129,7 +133,13 @@ class TrackerDetailFragment : Fragment(R.layout.fragment_tracker_detail) {
binding.appsListRV.apply {
visibility = View.VISIBLE
adapter = appsRVAdapter
layoutManager = object : LinearLayoutManager(view.context) {
val column: Int =
if (resources.configuration.smallestScreenWidthDp >= 600 && resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
2
} else {
1
}
layoutManager = object : StaggeredGridLayoutManager(column, 1) {
override fun canScrollVertically(): Boolean {
return false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.eu.exodus_privacy.exodusprivacy.fragments.trackers

import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.core.view.doOnPreDraw
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.GridLayoutManager
import com.google.android.material.transition.MaterialFadeThrough
import dagger.hilt.android.AndroidEntryPoint
import org.eu.exodus_privacy.exodusprivacy.ExodusUpdateService
Expand Down Expand Up @@ -38,7 +39,13 @@ class TrackersFragment : Fragment(R.layout.fragment_trackers) {
TrackersRVAdapter(false, findNavController().currentDestination!!.id)
binding.trackersListRV.apply {
adapter = trackersRVAdapter
layoutManager = LinearLayoutManager(view.context)
val column: Int =
if (resources.configuration.smallestScreenWidthDp >= 600 && resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
2
} else {
1
}
layoutManager = GridLayoutManager(context, column)
}

// Setup Shimmer Layout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ class ExodusPackageRepository @Inject constructor(
return Permission(
shortName,
longName,
label.toString(),
permInfo.loadDescription(packageManager)?.toString() ?: ""
label.toString()
)
} ?: run {
return Permission(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ package org.eu.exodus_privacy.exodusprivacy.objects
data class Permission(
val shortName: String = String(),
val longName: String = String(),
val label: String = String(),
val description: String = String()
val label: String = String()
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.content.res.ColorStateList
import android.os.Build
import android.widget.Toast
import androidx.core.content.ContextCompat
import com.google.android.material.chip.Chip
import org.eu.exodus_privacy.exodusprivacy.R
import org.eu.exodus_privacy.exodusprivacy.manager.database.app.ExodusApplication
import org.eu.exodus_privacy.exodusprivacy.objects.VersionReport
import java.util.Locale

fun Chip.setExodusColor(size: Int) {
Expand Down Expand Up @@ -50,24 +47,6 @@ fun Chip.setExodusColor(size: Int) {
}
}

fun Chip.setVersionReport(app: ExodusApplication) {
val versionReport = when (app.exodusVersionCode) {
0L -> VersionReport.UNAVAILABLE
app.versionCode -> VersionReport.MATCH
else -> VersionReport.MISMATCH
}
chipIcon = ContextCompat.getDrawable(context, versionReport.iconIdRes)
setOnClickListener {
Toast.makeText(
context,
context.getString(
versionReport.stringIdRes
),
Toast.LENGTH_LONG
).show()
}
}

fun getLanguage(): String {
return Locale.getDefault().language
}
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_match.xml

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_mismatch.xml

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_unavailable.xml

This file was deleted.

7 changes: 7 additions & 0 deletions app/src/main/res/drawable/splash_inset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_launcher_foreground"
android:insetLeft="5dp"
android:insetTop="5dp"
android:insetRight="5dp"
android:insetBottom="5dp" />
66 changes: 66 additions & 0 deletions app/src/main/res/layout-sw600dp-land/fragment_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="80dp"
android:gravity="start"
tools:context=".fragments.about.AboutFragment"
tools:theme="@style/Theme.Exodus">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/title_about" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/imageView"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_marginStart="80dp"
android:contentDescription="@string/app_logo"
android:src="@drawable/ic_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appNameTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAlignment="center"
android:textColor="?android:textColorPrimary"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="@id/imageView"
app:layout_constraintStart_toStartOf="@id/imageView"
app:layout_constraintTop_toBottomOf="@id/imageView" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/appVersionTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAlignment="center"
android:textColor="?android:textColorPrimary"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="@id/imageView"
app:layout_constraintStart_toStartOf="@id/imageView"
app:layout_constraintTop_toBottomOf="@id/appNameTV" />
<!--
Required ViewGroup for PreferenceFragmentCompat
False positive for id not in API < 24
-->
<FrameLayout
android:id="@android:id/list_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/imageView"
app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:targetApi="n" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 84a0496

Please sign in to comment.