Skip to content

Commit

Permalink
Remove chip icon and add better layout on tablet
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-BaptisteC committed Nov 27, 2023
1 parent 9087fd0 commit 56f3fd4
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 204 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)
var 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,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)
var 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.

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 56f3fd4

Please sign in to comment.