Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?><!--
~
~ Copyright 2023 Einstein Blanco
~
~ Licensed under the GNU General Public License v3.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.gnu.org/licenses/gpl-3.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<resources>
<string name="add">Add</string>
<string name="update">Update</string>
<string name="cancel">Cancel</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
*
* Copyright 2023 Einstein Blanco
*
* Licensed under the GNU General Public License v3.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/gpl-3.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

syntax = "proto3";

option java_package = "com.android.geto.data.datastore.proto";
option java_multiple_files = true;

enum SortLauncherAppsActivityInfoProto {
SortName = 0;
SortUpdateTime = 1;
SortInstallTime = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
*
* Copyright 2023 Einstein Blanco
*
* Licensed under the GNU General Public License v3.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/gpl-3.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

syntax = "proto3";

option java_package = "com.android.geto.data.datastore.proto";
option java_multiple_files = true;

enum SortOrderLauncherAppsActivityInfoProto {
SortOrderAscending = 0;
SortOrderDescending = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@
syntax = "proto3";

import "com/android/geto/data/datastore/proto/theme.proto";
import "com/android/geto/data/datastore/proto/sort_launcher_apps_activity_info.proto";
import "com/android/geto/data/datastore/proto/sort_order_launcher_apps_activity_info.proto";

option java_package = "com.android.geto.data.datastore.proto";
option java_multiple_files = true;

message UserPreferences {
ThemeProto theme = 1;
bool dynamicTheme = 2;
SortLauncherAppsActivityInfoProto sortLauncherAppsActivityInfo = 3;
SortOrderLauncherAppsActivityInfoProto sortOrderLauncherAppsActivityInfo = 4;
bool showSystem = 5;
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@
package com.android.geto.data.datastore

import androidx.datastore.core.DataStore
import com.android.geto.data.datastore.proto.ThemeProto
import com.android.geto.data.datastore.mapper.asSortLauncherAppsActivityInfo
import com.android.geto.data.datastore.mapper.asSortLauncherAppsActivityInfoProto
import com.android.geto.data.datastore.mapper.asSortOrderLauncherAppsActivityInfo
import com.android.geto.data.datastore.mapper.asSortOrderLauncherAppsActivityInfoProto
import com.android.geto.data.datastore.mapper.asTheme
import com.android.geto.data.datastore.mapper.asThemeProto
import com.android.geto.data.datastore.proto.UserPreferences
import com.android.geto.data.datastore.proto.copy
import com.android.geto.domain.model.SortLauncherAppsActivityInfo
import com.android.geto.domain.model.SortOrderLauncherAppsActivityInfo
import com.android.geto.domain.model.Theme
import com.android.geto.domain.model.UserData
import kotlinx.coroutines.flow.map
Expand All @@ -29,18 +36,11 @@ import javax.inject.Inject
class UserPreferencesDataSource @Inject constructor(private val userPreferences: DataStore<UserPreferences>) {
val userData = userPreferences.data.map {
UserData(
theme = when (it.theme) {
null,
ThemeProto.THEME_UNSPECIFIED,
ThemeProto.UNRECOGNIZED,
ThemeProto.THEME_FOLLOW_SYSTEM,
-> Theme.FOLLOW_SYSTEM

ThemeProto.THEME_LIGHT -> Theme.LIGHT

ThemeProto.THEME_DARK -> Theme.DARK
},
theme = it.theme.asTheme(),
dynamicTheme = it.dynamicTheme,
sortLauncherAppsActivityInfo = it.sortLauncherAppsActivityInfo.asSortLauncherAppsActivityInfo(),
sortOrderLauncherAppsActivityInfo = it.sortOrderLauncherAppsActivityInfo.asSortOrderLauncherAppsActivityInfo(),
showSystem = it.showSystem,
)
}

Expand All @@ -53,11 +53,33 @@ class UserPreferencesDataSource @Inject constructor(private val userPreferences:
suspend fun updateTheme(theme: Theme) {
userPreferences.updateData {
it.copy {
this.theme = when (theme) {
Theme.FOLLOW_SYSTEM -> ThemeProto.THEME_FOLLOW_SYSTEM
Theme.LIGHT -> ThemeProto.THEME_LIGHT
Theme.DARK -> ThemeProto.THEME_DARK
}
this.theme = theme.asThemeProto()
}
}
}

suspend fun updateSortLauncherAppsActivityInfo(sortLauncherAppsActivityInfo: SortLauncherAppsActivityInfo) {
userPreferences.updateData {
it.copy {
this.sortLauncherAppsActivityInfo =
sortLauncherAppsActivityInfo.asSortLauncherAppsActivityInfoProto()
}
}
}

suspend fun updateSortOrderLauncherAppsActivityInfo(sortOrderLauncherAppsActivityInfo: SortOrderLauncherAppsActivityInfo) {
userPreferences.updateData {
it.copy {
this.sortOrderLauncherAppsActivityInfo =
sortOrderLauncherAppsActivityInfo.asSortOrderLauncherAppsActivityInfoProto()
}
}
}

suspend fun updateShowSystem(showSystem: Boolean) {
userPreferences.updateData {
it.copy {
this.showSystem = showSystem
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
*
* Copyright 2023 Einstein Blanco
*
* Licensed under the GNU General Public License v3.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/gpl-3.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.android.geto.data.datastore.mapper

import com.android.geto.data.datastore.proto.SortLauncherAppsActivityInfoProto
import com.android.geto.data.datastore.proto.SortOrderLauncherAppsActivityInfoProto
import com.android.geto.data.datastore.proto.ThemeProto
import com.android.geto.domain.model.SortLauncherAppsActivityInfo
import com.android.geto.domain.model.SortOrderLauncherAppsActivityInfo
import com.android.geto.domain.model.Theme

internal fun ThemeProto.asTheme(): Theme = when (this) {
ThemeProto.THEME_UNSPECIFIED,
ThemeProto.THEME_FOLLOW_SYSTEM,
ThemeProto.UNRECOGNIZED,
-> {
Theme.FOLLOW_SYSTEM
}

ThemeProto.THEME_LIGHT -> {
Theme.LIGHT
}

ThemeProto.THEME_DARK -> {
Theme.DARK
}
}

internal fun SortLauncherAppsActivityInfoProto.asSortLauncherAppsActivityInfo(): SortLauncherAppsActivityInfo = when (this) {
SortLauncherAppsActivityInfoProto.SortName -> {
SortLauncherAppsActivityInfo.Name
}

SortLauncherAppsActivityInfoProto.SortUpdateTime -> {
SortLauncherAppsActivityInfo.UpdateTime
}

SortLauncherAppsActivityInfoProto.SortInstallTime -> {
SortLauncherAppsActivityInfo.InstallTime
}

SortLauncherAppsActivityInfoProto.UNRECOGNIZED -> {
SortLauncherAppsActivityInfo.Name
}
}

internal fun SortOrderLauncherAppsActivityInfoProto.asSortOrderLauncherAppsActivityInfo(): SortOrderLauncherAppsActivityInfo = when (this) {
SortOrderLauncherAppsActivityInfoProto.SortOrderAscending -> {
SortOrderLauncherAppsActivityInfo.Ascending
}

SortOrderLauncherAppsActivityInfoProto.SortOrderDescending -> {
SortOrderLauncherAppsActivityInfo.Descending
}

SortOrderLauncherAppsActivityInfoProto.UNRECOGNIZED -> {
SortOrderLauncherAppsActivityInfo.Ascending
}
}

internal fun SortLauncherAppsActivityInfo.asSortLauncherAppsActivityInfoProto(): SortLauncherAppsActivityInfoProto = when (this) {
SortLauncherAppsActivityInfo.Name -> {
SortLauncherAppsActivityInfoProto.SortName
}

SortLauncherAppsActivityInfo.UpdateTime -> {
SortLauncherAppsActivityInfoProto.SortUpdateTime
}

SortLauncherAppsActivityInfo.InstallTime -> {
SortLauncherAppsActivityInfoProto.SortInstallTime
}
}

internal fun SortOrderLauncherAppsActivityInfo.asSortOrderLauncherAppsActivityInfoProto(): SortOrderLauncherAppsActivityInfoProto = when (this) {
SortOrderLauncherAppsActivityInfo.Ascending -> {
SortOrderLauncherAppsActivityInfoProto.SortOrderAscending
}

SortOrderLauncherAppsActivityInfo.Descending -> {
SortOrderLauncherAppsActivityInfoProto.SortOrderDescending
}
}

internal fun Theme.asThemeProto(): ThemeProto = when (this) {
Theme.FOLLOW_SYSTEM -> {
ThemeProto.THEME_FOLLOW_SYSTEM
}

Theme.LIGHT -> {
ThemeProto.THEME_LIGHT
}

Theme.DARK -> {
ThemeProto.THEME_DARK
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package com.android.geto.data.repository

import com.android.geto.data.datastore.UserPreferencesDataSource
import com.android.geto.domain.model.SortLauncherAppsActivityInfo
import com.android.geto.domain.model.SortOrderLauncherAppsActivityInfo
import com.android.geto.domain.model.Theme
import com.android.geto.domain.model.UserData
import com.android.geto.domain.repository.UserDataRepository
Expand All @@ -36,4 +38,18 @@ class DefaultUserDataRepository @Inject constructor(
override suspend fun updateDynamicTheme(dynamicTheme: Boolean) {
userPreferencesDataSource.updateDynamicColor(dynamicTheme = dynamicTheme)
}

override suspend fun updateSortLauncherAppsActivityInfo(sortLauncherAppsActivityInfo: SortLauncherAppsActivityInfo) {
userPreferencesDataSource.updateSortLauncherAppsActivityInfo(sortLauncherAppsActivityInfo = sortLauncherAppsActivityInfo)
}

override suspend fun updateSortOrderLauncherAppsActivityInfo(sortOrderLauncherAppsActivityInfo: SortOrderLauncherAppsActivityInfo) {
userPreferencesDataSource.updateSortOrderLauncherAppsActivityInfo(
sortOrderLauncherAppsActivityInfo = sortOrderLauncherAppsActivityInfo,
)
}

override suspend fun updateShowSystem(showSystem: Boolean) {
userPreferencesDataSource.updateShowSystem(showSystem = showSystem)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ package com.android.geto.designsystem.icon
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowForward
import androidx.compose.material.icons.automirrored.filled.Sort
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Android
import androidx.compose.material.icons.filled.AppShortcut
import androidx.compose.material.icons.filled.Apps
import androidx.compose.material.icons.filled.Filter
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.SettingsSuggest
import androidx.compose.material.icons.filled.Sort

object GetoIcons {
val Apps = Icons.Default.Apps
Expand All @@ -40,4 +43,5 @@ object GetoIcons {
val Add = Icons.Default.Add
val ArrowForward = Icons.AutoMirrored.Filled.ArrowForward
val Search = Icons.Default.Search
val Sort = Icons.AutoMirrored.Filled.Sort
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ package com.android.geto.domain.framework

interface PackageManagerWrapper {
suspend fun getActivityIcon(componentName: String): ByteArray?

fun getLastInstallTime(packageName: String): Long

fun isSystem(flags: Int): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ data class LauncherAppsActivityInfo(
val packageName: String,
val activityIcon: ByteArray?,
val activityLabel: String,
val firstInstallTime: Long,
val lastUpdateTime: Long,
val isSystem: Boolean,
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as LauncherAppsActivityInfo

if (firstInstallTime != other.firstInstallTime) return false
if (lastUpdateTime != other.lastUpdateTime) return false
if (isSystem != other.isSystem) return false
if (componentName != other.componentName) return false
if (packageName != other.packageName) return false
if (!activityIcon.contentEquals(other.activityIcon)) return false
Expand All @@ -38,7 +44,10 @@ data class LauncherAppsActivityInfo(
}

override fun hashCode(): Int {
var result = componentName.hashCode()
var result = firstInstallTime.hashCode()
result = 31 * result + lastUpdateTime.hashCode()
result = 31 * result + isSystem.hashCode()
result = 31 * result + componentName.hashCode()
result = 31 * result + packageName.hashCode()
result = 31 * result + (activityIcon?.contentHashCode() ?: 0)
result = 31 * result + activityLabel.hashCode()
Expand Down
Loading
Loading