Compare commits
11 Commits
1.3.1
...
release/gt
| Author | SHA1 | Date | |
|---|---|---|---|
| a852f233ee | |||
| d946e1256e | |||
| 7264cce5b8 | |||
| 6d098c9f76 | |||
| 2101aa7b14 | |||
| 65b3b9013a | |||
| 7056a7f836 | |||
| fd3660858e | |||
| 45285892de | |||
| 64d7394ffa | |||
| 69892a4d08 |
114
.gitea/workflows/android-release.yaml
Normal file
114
.gitea/workflows/android-release.yaml
Normal file
@@ -0,0 +1,114 @@
|
||||
name: Android Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'release/android/*'
|
||||
|
||||
env:
|
||||
ANDROID_SDK_ROOT: ${{ gitea.workspace }}/android-sdk
|
||||
ANDROID_HOME: ${{ gitea.workspace }}/android-sdk
|
||||
|
||||
jobs:
|
||||
build-android-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Gitea's default act_runner labels map ubuntu-latest to node:16-bullseye,
|
||||
# so keep the GitHub-hosted actions on their Node 16-compatible v3 line.
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
set -eu
|
||||
apt-get update
|
||||
apt-get install -y ca-certificates git openjdk-17-jdk unzip wget
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Android SDK components
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/android-commandlinetools.zip
|
||||
|
||||
rm -rf "$ANDROID_SDK_ROOT"
|
||||
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||
|
||||
unzip -q /tmp/android-commandlinetools.zip -d /tmp/android-commandlinetools
|
||||
mv /tmp/android-commandlinetools/cmdline-tools "$ANDROID_SDK_ROOT/cmdline-tools/latest"
|
||||
|
||||
# sdkmanager exits successfully once it has consumed all input, which
|
||||
# causes `yes` to receive SIGPIPE and return 141 under `pipefail`.
|
||||
set +o pipefail
|
||||
yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" --licenses
|
||||
set -o pipefail
|
||||
|
||||
"$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" \
|
||||
"platform-tools" \
|
||||
"build-tools;33.0.1" \
|
||||
"platforms;android-33"
|
||||
|
||||
- name: Build Android release APKs
|
||||
working-directory: android
|
||||
run: ./gradlew assembleRelease
|
||||
|
||||
- name: Prepare release assets
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
version="${RELEASE_TAG#release/android/}"
|
||||
if [ -z "$version" ] || [ "$version" = "$RELEASE_TAG" ]; then
|
||||
echo "Expected tag in the form release/android/{version}, got: $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
assets_dir="${{ gitea.workspace }}/release-assets/android"
|
||||
rm -rf "$assets_dir"
|
||||
mkdir -p "$assets_dir"
|
||||
|
||||
found_apk=0
|
||||
for apk in android/app/build/outputs/apk/release/*.apk; do
|
||||
if [ ! -e "$apk" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
found_apk=1
|
||||
base="$(basename "$apk")"
|
||||
|
||||
case "$base" in
|
||||
app-*-release*.apk)
|
||||
arch="${base#app-}"
|
||||
arch="${arch%%-release*}"
|
||||
;;
|
||||
app-release*.apk)
|
||||
arch="universal"
|
||||
;;
|
||||
*)
|
||||
echo "Unexpected APK filename: $base" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
cp "$apk" "$assets_dir/kordophone-${arch}-${version}.apk"
|
||||
done
|
||||
|
||||
if [ "$found_apk" -ne 1 ]; then
|
||||
echo "No release APKs were produced." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
{
|
||||
printf 'RELEASE_VERSION=%s\n' "$version"
|
||||
printf 'RELEASE_ASSETS_DIR=%s\n' "$assets_dir"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: Create Gitea release
|
||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||
with:
|
||||
name: Kordophone Android ${{ env.RELEASE_VERSION }}
|
||||
tag_name: ${{ github.ref_name }}
|
||||
target_commitish: ${{ github.sha }}
|
||||
files: |
|
||||
${{ env.RELEASE_ASSETS_DIR }}/*.apk
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
ext/
|
||||
target/
|
||||
|
||||
2
server/.gitmodules → .gitmodules
vendored
2
server/.gitmodules → .gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "CocoaHTTPServer"]
|
||||
path = CocoaHTTPServer
|
||||
path = server/CocoaHTTPServer
|
||||
url = https://github.com/robbiehanson/CocoaHTTPServer.git
|
||||
2
android/.idea/gradle.xml
generated
2
android/.idea/gradle.xml
generated
@@ -5,7 +5,7 @@
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
||||
1
android/.idea/vcs.xml
generated
1
android/.idea/vcs.xml
generated
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -24,7 +24,7 @@ data class ServerConfig(
|
||||
fun loadFromSettings(context: Context): ServerConfig {
|
||||
val prefs = getSharedPreferences(context)
|
||||
return ServerConfig(
|
||||
serverName = prefs.getString("serverName", null),
|
||||
serverName = prefs.getString("serverName", null).normalizedBaseUrl(),
|
||||
authentication = ServerAuthentication.loadFromEncryptedSettings(context)
|
||||
)
|
||||
}
|
||||
@@ -37,7 +37,7 @@ data class ServerConfig(
|
||||
fun saveToSettings(context: Context) {
|
||||
val prefs = getSharedPreferences(context)
|
||||
prefs.edit {
|
||||
putString("serverName", serverName)
|
||||
putString("serverName", serverName.normalizedBaseUrl())
|
||||
apply()
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ data class ServerConfig(
|
||||
}
|
||||
}
|
||||
|
||||
fun String?.normalizedBaseUrl(): String? {
|
||||
val value = this?.trim()?.takeIf { it.isNotEmpty() } ?: return null
|
||||
return if (value.endsWith("/")) value else "$value/"
|
||||
}
|
||||
|
||||
data class ServerAuthentication(
|
||||
val username: String,
|
||||
val password: String,
|
||||
@@ -101,7 +106,9 @@ class ServerConfigRepository @Inject constructor(
|
||||
|
||||
fun applyConfig(applicator: ServerConfig.() -> Unit) {
|
||||
val config = _serverConfig.value.copy()
|
||||
_serverConfig.value = config.apply(applicator)
|
||||
_serverConfig.value = config.apply(applicator).also {
|
||||
it.serverName = it.serverName.normalizedBaseUrl()
|
||||
}
|
||||
_serverConfig.value.saveToSettings(context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +104,10 @@ class APIClientFactory {
|
||||
return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.NOT_CONFIGURED)
|
||||
}
|
||||
|
||||
val normalizedServerString = serverString.ensureTrailingSlash()
|
||||
|
||||
// Try to parse server string
|
||||
val serverURL = HttpUrl.parse(serverString)
|
||||
val serverURL = HttpUrl.parse(normalizedServerString)
|
||||
?: return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.INVALID_HOST_URL)
|
||||
|
||||
return RetrofitAPIClient(serverURL.url(), authentication)
|
||||
@@ -113,6 +115,10 @@ class APIClientFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private fun String.ensureTrailingSlash(): String {
|
||||
return if (endsWith("/")) this else "$this/"
|
||||
}
|
||||
|
||||
// TODO: Is this a dumb idea?
|
||||
class InvalidConfigurationAPIClient(val issue: Issue): APIClient {
|
||||
enum class Issue {
|
||||
@@ -215,4 +221,4 @@ fun URL.authenticatedWebSocketURL(serverPath: String, params: Map<String, String
|
||||
}
|
||||
|
||||
return URL(requestURL.build().toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,13 +55,13 @@ data class UploadAttachmentResponse(
|
||||
)
|
||||
|
||||
interface APIInterface {
|
||||
@GET("/version")
|
||||
@GET("version")
|
||||
suspend fun getVersion(): ResponseBody
|
||||
|
||||
@GET("/conversations")
|
||||
@GET("conversations")
|
||||
suspend fun getConversations(): Response<List<Conversation>>
|
||||
|
||||
@GET("/messages")
|
||||
@GET("messages")
|
||||
suspend fun getMessages(
|
||||
@Query("guid") conversationGUID: String,
|
||||
@Query("limit") limit: Int? = null,
|
||||
@@ -69,19 +69,19 @@ interface APIInterface {
|
||||
@Query("afterMessageGUID") afterMessageGUID: GUID? = null,
|
||||
): Response<List<Message>>
|
||||
|
||||
@POST("/sendMessage")
|
||||
@POST("sendMessage")
|
||||
suspend fun sendMessage(@Body request: SendMessageRequest): Response<SendMessageResponse>
|
||||
|
||||
@POST("/markConversation")
|
||||
@POST("markConversation")
|
||||
suspend fun markConversation(@Query("guid") conversationGUID: String): Response<Void>
|
||||
|
||||
@GET("/attachment")
|
||||
@GET("attachment")
|
||||
suspend fun fetchAttachment(@Query("guid") guid: String, @Query("preview") preview: Boolean = false): ResponseBody
|
||||
|
||||
@POST("/uploadAttachment")
|
||||
@POST("uploadAttachment")
|
||||
suspend fun uploadAttachment(@Query("filename") filename: String, @Body body: RequestBody): Response<UploadAttachmentResponse>
|
||||
|
||||
@POST("/authenticate")
|
||||
@POST("authenticate")
|
||||
suspend fun authenticate(@Body request: AuthenticationRequest): Response<AuthenticationResponse>
|
||||
}
|
||||
|
||||
@@ -93,4 +93,4 @@ fun <T> Response<T>.bodyOnSuccessOrThrow(): T {
|
||||
}
|
||||
|
||||
throw ResponseDecodeError(errorBody()!!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.buzzert.kordophone.backend.db.CachedChatDatabase
|
||||
import net.buzzert.kordophone.backend.model.Message
|
||||
import net.buzzert.kordophone.backend.model.OutgoingMessage
|
||||
import net.buzzert.kordophone.backend.server.APIClient
|
||||
import net.buzzert.kordophone.backend.server.APIClientFactory
|
||||
import net.buzzert.kordophone.backend.server.APIInterface
|
||||
import net.buzzert.kordophone.backend.server.Authentication
|
||||
import net.buzzert.kordophone.backend.server.ChatRepository
|
||||
@@ -38,6 +39,16 @@ class BackendTests {
|
||||
return Pair(repository, mockServer)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCreateClientAcceptsBaseUrlWithoutTrailingSlash() {
|
||||
val client = APIClientFactory.createClient(
|
||||
"https://example.com/api",
|
||||
Authentication("test", "test")
|
||||
)
|
||||
|
||||
assertTrue(client.isConfigured)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetVersion() = runBlocking {
|
||||
val (repository, mockServer) = mockRepository()
|
||||
@@ -342,4 +353,4 @@ class BackendTests {
|
||||
assertEquals(messagesToGenerate, allMessages.count())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
gtk/dist/rpm/kordophone.spec
vendored
3
gtk/dist/rpm/kordophone.spec
vendored
@@ -1,6 +1,5 @@
|
||||
%global app_version %{!?app_version:1.3.0}
|
||||
Name: kordophone
|
||||
Version: %{app_version}
|
||||
Version: %{?app_version}%{!?app_version:1.3.0}
|
||||
Release: 1%{?dist}
|
||||
Summary: GTK4/Libadwaita client for Kordophone
|
||||
|
||||
|
||||
@@ -327,8 +327,8 @@ private class TranscriptDrawingArea : Widget
|
||||
|
||||
private void recompute_message_layouts() {
|
||||
var container_width = get_width();
|
||||
float max_width = container_width * 0.90f;
|
||||
float image_max_width = max_width * 0.75f;
|
||||
float max_width = container_width * 0.80f;
|
||||
float image_max_width = max_width * 0.70f;
|
||||
|
||||
DateTime? last_date = null;
|
||||
string? last_sender = null;
|
||||
@@ -383,6 +383,10 @@ private class TranscriptDrawingArea : Widget
|
||||
items.add(image_layout);
|
||||
}
|
||||
|
||||
// New-message animation is a one-shot effect. Clear the flag after
|
||||
// scheduling bubble animations so later relayouts do not replay it.
|
||||
message.should_animate = false;
|
||||
|
||||
last_sender = message.sender;
|
||||
last_date = date;
|
||||
|
||||
|
||||
@@ -159,7 +159,6 @@ public class TranscriptView : Adw.Bin
|
||||
}
|
||||
|
||||
delegate void OpenPath(string path);
|
||||
private ulong attachment_downloaded_handler_id = 0;
|
||||
private void open_attachment(string attachment_guid) {
|
||||
OpenPath open_path = (path) => {
|
||||
try {
|
||||
@@ -180,10 +179,17 @@ public class TranscriptView : Adw.Bin
|
||||
|
||||
// TODO: Should probably indicate progress here.
|
||||
|
||||
attachment_downloaded_handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
|
||||
ulong handler_id = 0;
|
||||
handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
|
||||
if (guid == attachment_guid) {
|
||||
open_path(attachment_info.path);
|
||||
Repository.get_instance().disconnect(attachment_downloaded_handler_id);
|
||||
try {
|
||||
var updated_attachment_info = Repository.get_instance().get_attachment_info(attachment_guid);
|
||||
open_path(updated_attachment_info.path);
|
||||
} catch (GLib.Error e) {
|
||||
warning("Failed to get attachment info after download: %s", e.message);
|
||||
}
|
||||
|
||||
Repository.get_instance().disconnect(handler_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user