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
33 changes: 26 additions & 7 deletions app/src/main/java/net/megaproxy487/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package net.megaproxy487

import android.Manifest
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.net.VpnService
import android.os.Build
import android.os.Bundle
Expand All @@ -23,6 +25,8 @@ import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.heightIn
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -235,7 +239,7 @@ private fun ProfileSelectorLabel(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@Composable
internal fun MainScreen(
activity: Activity,
Expand Down Expand Up @@ -667,12 +671,27 @@ internal fun MainScreen(
connectionStats?.let { stats ->
ConnectionStatsCard(stats, quic = transportProtocol == VpnTransportProtocol.HTTP_3)
}
Text(
stringResource(R.string.version_and_commit, BuildConfig.VERSION_NAME, BuildConfig.GIT_COMMIT_HASH),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.align(Alignment.CenterHorizontally).padding(top = 8.dp),
)
FlowRow(
horizontalArrangement = Arrangement.Center,
modifier = Modifier.fillMaxWidth().padding(top = 8.dp),
) {
Text(
stringResource(R.string.version_and_commit, BuildConfig.VERSION_NAME, BuildConfig.GIT_COMMIT_HASH),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.align(Alignment.CenterVertically),
)
TextButton(onClick = {
try {
activity.startActivity(Intent(Intent.ACTION_VIEW,
Uri.parse("https://github.com/andre487/AndroidMegaProxy")))
} catch (_: ActivityNotFoundException) {
error = activity.uiText(R.string.no_browser)
}
}) {
Text(stringResource(R.string.update_github), style = MaterialTheme.typography.bodySmall)
}
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/test/java/net/megaproxy487/MainScreenUiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ class MainScreenUiTest : MainUiTestBase() {
assertNull(shadowOf(activity.application as Application).nextStartedService)
}

@Test fun githubLinkNextToVersionOpensApplicationRepository() {
screen()
compose.onNodeWithText(activity.getString(R.string.version_and_commit,
BuildConfig.VERSION_NAME, BuildConfig.GIT_COMMIT_HASH)).performScrollTo().assertIsDisplayed()
node(R.string.update_github).performScrollTo().assertIsDisplayed().performClick()
val intent = shadowOf(activity).nextStartedActivity
assertEquals(Intent.ACTION_VIEW, intent?.action)
assertEquals("https://github.com/andre487/AndroidMegaProxy", intent?.dataString)
noCommand()
}

@Test fun connectDispatchesStartAndPersistsDesiredState() {
screen()
node(R.string.connect).performScrollTo().assertIsEnabled().performClick()
Expand Down
Loading