Skip to content

Commit

Permalink
Added FOSS tag in Apps Sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Nov 7, 2023
1 parent 8de4de4 commit 31933c2
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/src/main/assets/html/changelogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ <h4>User Interface</h4>
<li>Updated trackers selector interface.</li>
<li>Added Xposed Module information in <b>App Information</b> panel.</li>
<li>Lyrics will now scroll while seeking.</li>
<li>Added <i>FOSS</i> tag in <b>Apps Sort</b> dialog.
<br>
<small>You may have to reset the sorting filters in the <b>Apps</b> panel.</small>
</li>
</ul>

<h4>Bug Fixes</h4>
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/app/simple/inure/constants/SortConstant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ object SortConstant {
const val ASCENDING = "ascending"
const val DESCENDING = "descending"

const val DISABLED = 1
const val ENABLED = 2
const val APK = 4
const val SPLIT = 8
const val UNINSTALLED = 16
const val COMBINE_FLAGS = 32
const val DISABLED = 1 shl 1
const val ENABLED = 1 shl 2
const val APK = 1 shl 3
const val SPLIT = 1 shl 4
const val UNINSTALLED = 1 shl 5
const val FOSS = 1 shl 6
const val COMBINE_FLAGS = 1 shl 7
const val ALL = DISABLED or ENABLED or APK or SPLIT

const val CATEGORY_UNSPECIFIED = 1L shl 1
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/app/simple/inure/dialogs/apps/AppsSort.kt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ class AppsSort : ScopedBottomSheetFragment() {
FlagUtils.unsetFlag(sourceFlags, SortConstant.UNINSTALLED)
}

sourceFlags = if (checkedIds.contains(R.id.foss)) {
FlagUtils.setFlag(sourceFlags, SortConstant.FOSS)
} else {
FlagUtils.unsetFlag(sourceFlags, SortConstant.FOSS)
}

sourceFlags = if (checkedIds.contains(R.id.combine_flags)) {
FlagUtils.setFlag(sourceFlags, SortConstant.COMBINE_FLAGS)
} else {
Expand Down Expand Up @@ -325,6 +331,10 @@ class AppsSort : ScopedBottomSheetFragment() {
filterChipGroup.check(R.id.uninstalled)
}

if (FlagUtils.isFlagSet(AppsPreferences.getAppsFilter(), SortConstant.FOSS)) {
filterChipGroup.check(R.id.foss)
}

if (FlagUtils.isFlagSet(AppsPreferences.getAppsFilter(), SortConstant.COMBINE_FLAGS)) {
filterChipGroup.check(R.id.combine_flags)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.os.Build
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import app.simple.inure.apk.parsers.FOSSParser
import app.simple.inure.constants.SortConstant
import app.simple.inure.events.AppsEvent
import app.simple.inure.extensions.viewmodels.DataGeneratorViewModel
Expand Down Expand Up @@ -196,6 +197,10 @@ class AppsViewModel(application: Application) : DataGeneratorViewModel(applicati
packageInfo.applicationInfo.flags and ApplicationInfo.FLAG_INSTALLED == 0
} else {
true
} && if (FlagUtils.isFlagSet(AppsPreferences.getAppsFilter(), SortConstant.FOSS)) {
FOSSParser.isPackageFOSS(packageInfo.packageName)
} else {
true
}
}.collect(Collectors.toList()) as ArrayList<PackageInfo>)
} else {
Expand Down Expand Up @@ -241,6 +246,14 @@ class AppsViewModel(application: Application) : DataGeneratorViewModel(applicati
}
}
}

if (FlagUtils.isFlagSet(AppsPreferences.getAppsFilter(), SortConstant.FOSS)) {
if (FOSSParser.isPackageFOSS(packageInfo.packageName)) {
if (!filteredList.contains(packageInfo)) {
filteredList.add(packageInfo)
}
}
}
}

// Remove duplicate elements
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/dialog_sort_apps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@
android:layout_height="wrap_content"
android:text="@string/split_packages" />

<app.simple.inure.decorations.views.Chip
android:id="@+id/foss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/foss" />

<app.simple.inure.decorations.views.Chip
android:id="@+id/combine_flags"
android:layout_width="wrap_content"
Expand Down
5 changes: 5 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/95.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Added Batch Trackers
- Added Batch Profiles
- Fixed locale issue in Tags

For full list of changes, see the changelogs in the app.
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ kotlin.code.style=official
org.gradle.unsafe.configuration-cache=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.nonFinalResIds=false
android.enableR8=true

0 comments on commit 31933c2

Please sign in to comment.