Skip to content

Commit

Permalink
Improve About Screen
Browse files Browse the repository at this point in the history
Tweaked the icon a bit
Remove unneeded receiver
  • Loading branch information
rumboalla committed Aug 18, 2023
1 parent 50ec069 commit b483dcb
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 80 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The 3.x branch is a full rewrite using modern technologies like **Jetpack Compos
* **Direct install** of updates for sources that support it.
* Supports **installs without user interaction** on Android 12+.
* **Root install** of updates.
* No ads. No tracking.
* **Languages**: English, Spanish, Dutch, German, Traditional Chinese, Simplified Chinese, Romanian, Italian.

# Download
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.apkupdater"
minSdk 24
targetSdk 34
versionCode 46
versionName "3.0.0-beta-03"
versionCode 47
versionName "3.0.0-beta-04"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables { useSupportLibrary true }
}
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
Expand Down Expand Up @@ -36,10 +35,5 @@
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".receiver.BootReceiver" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
4 changes: 4 additions & 0 deletions app/src/main/java/com/apkupdater/data/ui/AppInstalled.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ fun List<AppInstalled>.getVersionCode(packageName: String) = getApp(packageName)
?.versionCode
?: 0L

fun List<AppInstalled>.getVersion(packageName: String) = getApp(packageName)
?.version
?: ""

fun List<AppInstalled>.getSignature(packageName: String) = getApp(packageName)
?.signature
.orEmpty()
Expand Down
17 changes: 0 additions & 17 deletions app/src/main/java/com/apkupdater/receiver/BootReceiver.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import com.apkupdater.data.aptoide.ListSearchAppsRequest
import com.apkupdater.data.aptoide.toAppUpdate
import com.apkupdater.data.ui.AppInstalled
import com.apkupdater.data.ui.getApp
import com.apkupdater.data.ui.getVersion
import com.apkupdater.data.ui.toApksData
import com.apkupdater.prefs.Prefs
import com.apkupdater.service.AptoideService
import com.apkupdater.util.isAndroidTv
import com.apkupdater.util.randomUUID
import io.github.g00fy2.versioncompare.Version
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow

Expand All @@ -41,8 +43,11 @@ class AptoideRepository(

suspend fun updates(apps: List<AppInstalled>) = flow {
val data = apps.map(AppInstalled::toApksData)
val r = service.findUpdates(ListAppsUpdatesRequest(data, query, buildFilterList(), buildStoreList()))
emit(r.list.map { it.toAppUpdate(apps.getApp(it.packageName)) })
val r = service
.findUpdates(ListAppsUpdatesRequest(data, query, buildFilterList(), buildStoreList()))
.list
.filter { Version(it.file.vername) > Version(apps.getVersion(it.packageName)) }
emit(r.map { it.toAppUpdate(apps.getApp(it.packageName)) })
}.catch {
emit(emptyList())
Log.e("AptoideRepository", "Error looking for updates.", it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class GitHubRepository(
val releases = service.getReleases().filter { filterPreRelease(it) }
val versions = getVersions(releases[0].name)

if (versions.second != BuildConfig.VERSION_CODE.toLong()) {
if (versions.second > BuildConfig.VERSION_CODE.toLong()) {
emit(listOf(AppUpdate(
name = "APKUpdater",
packageName = BuildConfig.APPLICATION_ID,
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/apkupdater/ui/component/Text.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ fun SmallText(text: String, modifier: Modifier = Modifier) = Text(
@Composable
fun MediumText(
text: String,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
maxLines: Int = 1
) = Text(
text = text,
style = MaterialTheme.typography.bodyMedium,
maxLines = 1,
maxLines = maxLines,
modifier = modifier,
overflow = TextOverflow.Ellipsis
)
Expand Down
96 changes: 80 additions & 16 deletions app/src/main/java/com/apkupdater/ui/screen/SettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
Expand All @@ -16,26 +19,31 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.minimumInteractiveComponentSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.platform.UriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil.compose.AsyncImage
import com.apkupdater.BuildConfig
import com.apkupdater.R
import com.apkupdater.data.ui.GitHubSource
import com.apkupdater.data.ui.SettingsUiState
import com.apkupdater.ui.component.LargeTitle
import com.apkupdater.ui.component.LoadingImageApp
import com.apkupdater.ui.component.MediumText
import com.apkupdater.ui.component.MediumTitle
import com.apkupdater.ui.component.SegmentedButtonSetting
import com.apkupdater.ui.component.SliderSetting
import com.apkupdater.ui.component.SourceIcon
Expand All @@ -44,6 +52,7 @@ import com.apkupdater.ui.theme.statusBarColor
import com.apkupdater.viewmodel.SettingsViewModel
import org.koin.androidx.compose.koinViewModel


@Composable
fun SettingsScreen(viewModel: SettingsViewModel = koinViewModel()) = Column {
if (viewModel.state.collectAsStateWithLifecycle().value == SettingsUiState.Settings) {
Expand All @@ -56,23 +65,78 @@ fun SettingsScreen(viewModel: SettingsViewModel = koinViewModel()) = Column {
}

@Composable
fun About() = Box(Modifier.fillMaxSize()) {
val launcher = LocalUriHandler.current
Column(Modifier.align(Alignment.Center)) {
LoadingImageApp(BuildConfig.APPLICATION_ID)
LargeTitle(stringResource(R.string.app_name), Modifier.align(CenterHorizontally))
MediumText("${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})", Modifier.align(CenterHorizontally))
MediumText("Copyright © 2016-2023 rumboalla", Modifier.align(CenterHorizontally))
SourceIcon(
GitHubSource,
Modifier
.size(32.dp)
.align(CenterHorizontally)
.padding(top = 8.dp)
.clickable {
launcher.openUri("https://github.com/rumboalla/apkupdater")
}
fun About() = LazyColumn(
Modifier.fillMaxSize().padding(horizontal = 8.dp)) {
item {
Column(Modifier.padding(vertical = 16.dp)) {
LoadingImageApp(BuildConfig.APPLICATION_ID)
LargeTitle(stringResource(R.string.app_name), Modifier.align(CenterHorizontally))
MediumText("${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})", Modifier.align(CenterHorizontally))
MediumText("Copyright © 2016-2023 rumboalla", Modifier.align(CenterHorizontally))
}
}
item {
AboutItem(
"GitHub - APKUpdater",
stringResource(R.string.about_github),
"https://github.com/rumboalla/apkupdater",
{ SourceIcon(GitHubSource, Modifier.size(64.dp).align(CenterVertically)) }
)
AboutItem(
"Donate - Malaria Consortium",
stringResource(R.string.about_donate),
"https://www.malariaconsortium.org/support-us/donate.htm",
{
AsyncImage(
"https://www.malariaconsortium.org/website-2017/_images/logo-mc.png",
"Malaria Consortium",
Modifier.size(64.dp).align(CenterVertically)
)
}
)
AboutItem(
"Donate - New Incentives",
stringResource(R.string.about_donate),
"https://www.newincentives.org/donate",
{
AsyncImage(
"https://i.vimeocdn.com/portrait/81193504_60x60",
"New Incentives",
Modifier.size(64.dp).align(CenterVertically)
)
}
)
AboutItem(
"Donate - Sightsavers",
stringResource(R.string.about_donate),
"https://donate.sightsavers.org/smxpatron/global/donate.html",
{
AsyncImage(
"https://www.sightsavers.org/wp-content/uploads/2017/10/Sightsavers-Author-Placeholder.png",
"Sightsavers",
Modifier.size(64.dp).align(CenterVertically)
)
}
)
}
}


@Composable
fun AboutItem(
title: String,
body: String,
link: String,
icon: @Composable RowScope.() -> Unit,
handler: UriHandler = LocalUriHandler.current
) = OutlinedCard(
Modifier.fillMaxWidth().padding(bottom = 8.dp).clickable { handler.openUri(link) }) {
Row(Modifier.padding(8.dp)) {
icon()
Column(Modifier.padding(start = 16.dp)) {
MediumTitle(title)
MediumText(body, maxLines = 2)
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions app/src/main/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<vector android:height="24dp" android:tint="#ECBB48"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FCEA00" android:pathData="M3,3h18v18h-18z"/>
<vector android:height="24dp" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ECBB48" android:pathData="M3,3h18v18h-18z"/>
</vector>
44 changes: 14 additions & 30 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="500dp"
android:height="500dp"
android:viewportWidth="500"
android:viewportHeight="500">
<path
android:pathData="M200,255.68L179.7,255.68L171.63,232.92L134.7,232.92L127.07,255.68L107.28,255.68L143.27,155.48L163,155.48L200,255.68ZM165.65,216.04L152.91,178.86L140.43,216.04L165.65,216.04Z"
android:strokeWidth="4"
android:fillColor="#383434"
android:strokeColor="#383535"
android:fillType="nonZero"/>
<path
android:pathData="M209.89,255.68L209.89,155.48L239.83,155.48C251.17,155.48 258.57,155.98 262.01,156.98C267.31,158.49 271.74,161.76 275.31,166.79C278.89,171.83 280.67,178.33 280.67,186.31C280.67,192.46 279.64,197.63 277.58,201.82C275.52,206.02 272.91,209.31 269.74,211.7C266.56,214.09 263.34,215.68 260.06,216.45C255.61,217.41 249.16,217.89 240.71,217.89L228.55,217.89L228.55,255.68L209.89,255.68ZM228.55,172.43L228.55,200.87L238.76,200.87C246.11,200.87 251.03,200.34 253.51,199.29C255.99,198.25 257.93,196.61 259.34,194.37C260.74,192.14 261.45,189.54 261.45,186.58C261.45,182.94 260.46,179.93 258.49,177.56C256.51,175.19 254.01,173.71 250.98,173.12C248.76,172.66 244.28,172.43 237.56,172.43L228.55,172.43Z"
android:strokeWidth="4"
android:fillColor="#383434"
android:strokeColor="#383535"
android:fillType="nonZero"/>
<path
android:pathData="M296.24,255.68L296.24,155.48L314.9,155.48L314.9,199.98L352.59,155.48L377.67,155.48L342.88,194.51L379.56,255.68L355.42,255.68L330.02,208.66L314.9,225.4L314.9,255.68L296.24,255.68Z"
android:strokeWidth="4"
android:fillColor="#383434"
android:strokeColor="#383535"
android:fillType="nonZero"/>
<path
android:pathData="M272.11,379.69L227.89,379.69L227.89,320.27L199.87,320.27L250,263.85L300.13,320.27L272.11,320.27L272.11,379.69Z"
android:strokeWidth="4"
android:fillColor="#383535"
android:strokeColor="#393534"
android:fillType="nonZero"
android:strokeLineCap="round"/>
<vector android:height="108dp" android:viewportHeight="1080"
android:viewportWidth="1080" android:width="108dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#303030" android:fillType="nonZero"
android:pathData="M593.1,821.3L445.7,821.3L475.4,652.7L574.2,566L588,577.4C590.1,579.7 591.6,582.2 592.6,584.9C593.5,587.5 593.6,590.7 592.9,594.6L592.9,594.5L569.1,652.7L668.1,652.7C675.7,652.7 682,655.7 686.8,661.7C691.6,667.7 693.4,674.3 692.1,681.5L690,693.3C689.6,695.9 688.7,699 687.3,702.5C686,706 684.7,708.8 683.5,710.9L630,799.1C626.5,805.3 621.2,810.5 614.2,814.8C607.2,819.2 600.2,821.3 593.1,821.3ZM456.4,652.7L426.7,821.3L387.5,821.3L417.2,652.7L456.4,652.7Z"
android:strokeColor="#303030" android:strokeWidth="10"/>
<path android:fillColor="#303030" android:fillType="nonZero"
android:pathData="M394.5,500.4L327.4,500.4L307.6,540L265,540L367.7,347.8L403.5,347.8L440.1,540L400.6,540L394.5,500.4ZM343.3,468.3L389.6,468.3L378.8,396.8L343.3,468.3Z"
android:strokeColor="#303030" android:strokeWidth="10"/>
<path android:fillColor="#303030" android:fillType="nonZero"
android:pathData="M509.9,472.3L498,540L459.3,540L492.7,347.8L560.1,347.9C580.8,347.9 597.2,353.7 609,365.2C620.9,376.7 626.1,391.8 624.6,410.4C623.2,429.2 615.4,444.2 601.1,455.5C586.8,466.8 568.5,472.4 546.3,472.4L509.9,472.3ZM515.3,440.2L547.5,440.5C557.9,440.5 566.5,437.8 573.4,432.4C580.3,427 584.4,419.8 585.7,410.6C587,401.5 585.5,394.2 581.3,388.7C577,383.2 570.7,380.3 562.3,380L525.9,379.9L515.3,440.2Z"
android:strokeColor="#303030" android:strokeWidth="10"/>
<path android:fillColor="#303030" android:fillType="nonZero"
android:pathData="M703,463.3L677.7,486.8L668.5,540L629.8,540L663.2,347.8L701.9,347.8L687.1,432.5L706.7,410.4L764.6,347.8L815,347.8L732,435.2L781.5,540L737.4,540L703,463.3Z"
android:strokeColor="#303030" android:strokeWidth="10"/>
</vector>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<string name="theme_system">System</string>
<string name="theme_dark">Dark</string>
<string name="theme_light">Light</string>
<string name="about_github">Get the source code, report bugs, request new features and add translations.</string>
<string name="about_donate">If you like the app, consider donating to a worthy cause.</string>

// Notifications
<string name="notification_channel_name">Updates</string>
Expand Down

0 comments on commit b483dcb

Please sign in to comment.