Skip to content

Commit

Permalink
Add tablet layout and improve comprehension of different version (#360)
Browse files Browse the repository at this point in the history
* Remove chip icon and add better layout on tablet

* Add about layout for tablet

---------

Co-authored-by: Benjamin Falière <[email protected]>
  • Loading branch information
Jean-BaptisteC and Benjamin Falière authored Dec 6, 2023
1 parent e8665ff commit 0020b5a
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 206 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 @@ -172,7 +171,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 @@ -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 @@ -129,7 +130,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

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.

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>
19 changes: 3 additions & 16 deletions app/src/main/res/layout/fragment_app_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,13 @@
style="@style/Theme.Exodus.Chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@+id/permsChip"
app:layout_constraintEnd_toStartOf="@+id/versionChip"
app:layout_constraintTop_toBottomOf="@id/appNameTV"
android:layout_marginTop="20dp"
android:layout_marginStart="5dp"
android:layout_marginTop="20dp"
app:chipIcon="@drawable/ic_android"
tools:text="Google" />

<com.google.android.material.chip.Chip
android:id="@+id/versionChip"
style="@style/Theme.Exodus.Chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@+id/sourceChip"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/permsChip"
app:layout_constraintTop_toBottomOf="@id/appNameTV"
android:layout_marginTop="20dp"
app:chipIcon="@drawable/ic_match"
app:textEndPadding="0dp"
app:textStartPadding="0dp" />
tools:text="Google" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/appIVTV"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/fragment_apps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/title_apps" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone"
app:trackCornerRadius="4dp"
app:layout_constraintBottom_toBottomOf="@+id/toolbarApps" />

<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/shimmerLayout"
Expand Down
Loading

0 comments on commit 0020b5a

Please sign in to comment.