Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates #58

Merged
merged 4 commits into from
Nov 26, 2023
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: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ repositories {
buildConfig {
buildConfigField("String", "APP_NAME", "\"${project.name}\"")
buildConfigField("String", "APP_VERSION", provider { "\"${project.version}\"" })
buildConfigField("String", "KOTLIN_VERSION", "\"" + embeddedKotlinVersion + "\"")
buildConfigField("String", "PROJECT_VERSION", "\"${project.version}\"")
try
{
Expand Down Expand Up @@ -130,6 +129,8 @@ compose.desktop {
macOS {
println("iconFile=" + iconsRoot.resolve("icon-mac.icns"))
iconFile.set(iconsRoot.resolve("icon-mac.icns"))
bundleID = "com.zoffcc.applications.trifa_material"
// dockName = ""
}
windows {
iconFile.set(iconsRoot.resolve("icon-windows.ico"))
Expand All @@ -143,6 +144,7 @@ compose.desktop {
iconFile.set(iconsRoot.resolve("icon-linux.png"))
println("iconFile=" + iconsRoot.resolve("icon-linux.png"))
}
println("targetFormats=" + targetFormats)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ org.jetbrains.compose.experimental.uikit.enabled=true
android.defaults.buildfeatures.buildconfig=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
compose.version=1.6.0-dev1282
kotlin.version=1.9.20
multiplatform.version=1.9.20
compose.version=1.5.11
kotlin.version=1.9.21
multiplatform.version=1.9.21
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class TRIFADatabaseGlobalsNew
private static final String TAG = "DB.TRIFADatabaseGlobalsNew";

@PrimaryKey
String key;
public String key;

@Column(indexed = true, helpers = Column.Helpers.ALL)
String value;
public String value;

static TRIFADatabaseGlobalsNew deep_copy(TRIFADatabaseGlobalsNew in)
{
Expand Down
75 changes: 75 additions & 0 deletions src/main/java/com/zoffcc/applications/trifa/HelperFriend.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.zoffcc.applications.trifa;

import com.zoffcc.applications.sorm.TRIFADatabaseGlobalsNew;
import org.sqlite.SQLiteException;

import java.nio.ByteBuffer;

public class HelperFriend {
Expand Down Expand Up @@ -52,4 +55,76 @@ static void delete_friend(final String friend_pubkey)
tox_public_key_stringEq(friend_pubkey).
execute();
}

public static String get_g_opts(String key)
{
try
{
if (TrifaToxService.Companion.getOrma().selectFromTRIFADatabaseGlobalsNew().keyEq(key).count() == 1)
{
TRIFADatabaseGlobalsNew g_opts = TrifaToxService.Companion.getOrma().selectFromTRIFADatabaseGlobalsNew().keyEq(key).get(0);
// Log.i(TAG, "get_g_opts:(SELECT):key=" + key);
return g_opts.value;
}
else
{
return null;
}
}
catch (Exception e)
{
e.printStackTrace();
Log.i(TAG, "get_g_opts:EE1:" + e.getMessage());
return null;
}
}

public static void set_g_opts(String key, String value)
{
try
{
TRIFADatabaseGlobalsNew g_opts = new TRIFADatabaseGlobalsNew();
g_opts.key = key;
g_opts.value = value;

try
{
TrifaToxService.Companion.getOrma().insertIntoTRIFADatabaseGlobalsNew(g_opts);
Log.i(TAG, "set_g_opts:(INSERT):key=" + key + " value=" + "xxxxxxxxxxxxx");
}
catch (Exception e)
{
// e.printStackTrace();
try
{
TrifaToxService.Companion.getOrma().updateTRIFADatabaseGlobalsNew().keyEq(key).value(value).execute();
Log.i(TAG, "set_g_opts:(UPDATE):key=" + key + " value=" + "xxxxxxxxxxxxxxx");
}
catch (Exception e2)
{
e2.printStackTrace();
Log.i(TAG, "set_g_opts:EE1:" + e2.getMessage());
}
}
}
catch (Exception e)
{
e.printStackTrace();
Log.i(TAG, "set_g_opts:EE2:" + e.getMessage());
}
}

public static void del_g_opts(String key)
{
try
{
TrifaToxService.Companion.getOrma().deleteFromTRIFADatabaseGlobalsNew().keyEq(key).execute();
Log.i(TAG, "del_g_opts:(DELETE):key=" + key);
}
catch (Exception e)
{
e.printStackTrace();
Log.i(TAG, "del_g_opts:EE2:" + e.getMessage());
}
}
}
24 changes: 18 additions & 6 deletions src/main/java/com/zoffcc/applications/trifa/HelperOSFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void show_containing_dir_in_explorer(final String filename_with_pa
}
}

public static void show_file_in_explorer(String filename_with_path)
public static void show_file_in_explorer_or_open(String filename_with_path)
{
if (OperatingSystem.getCurrent() == OperatingSystem.WINDOWS)
{
Expand All @@ -47,14 +47,26 @@ public static void show_file_in_explorer(String filename_with_path)
}
else if (OperatingSystem.getCurrent() == OperatingSystem.LINUX)
{
try
if (MainActivity.getDB_PREF__open_files_directly())
{
Desktop.getDesktop().browseFileDirectory(new File(filename_with_path));
try {
Desktop.getDesktop().open(new File(filename_with_path));
} catch (Exception e2) {
e2.printStackTrace();
show_containing_dir_in_explorer(filename_with_path);
}
}
catch (Exception e)
else
{
e.printStackTrace();
show_containing_dir_in_explorer(filename_with_path);
try
{
Desktop.getDesktop().browseFileDirectory(new File(filename_with_path));
}
catch (Exception e)
{
e.printStackTrace();
show_containing_dir_in_explorer(filename_with_path);
}
}
}
else if (OperatingSystem.getCurrent() == OperatingSystem.MACOS)
Expand Down
13 changes: 12 additions & 1 deletion src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class MainActivity
// --------- global config ---------
var native_lib_loaded = false
@JvmStatic var native_notification_lib_loaded_error = -1
@JvmStatic var native_ffmpegav_lib_loaded_error = -1
var tox_service_fg: TrifaToxService? = null
var tox_savefile_directory = "."
var PREF__udp_enabled = 1
Expand All @@ -127,6 +128,7 @@ class MainActivity
var PREF__local_discovery_enabled = 1
var PREF__ipv6_enabled = 1
var PREF__force_udp_only = 0
@JvmStatic var DB_PREF__open_files_directly = false
var incoming_messages_queue: BlockingQueue<String> = LinkedBlockingQueue()
@JvmStatic var video_play_count_frames: Long = 0
@JvmStatic var video_play_last_timestamp: Long = 0
Expand Down Expand Up @@ -323,7 +325,16 @@ class MainActivity

val libdir2: String = resourcesDir.path
System.out.println("XXXXX7:" + libdir2)
ffmpegav_loadjni(libdir2)

native_ffmpegav_lib_loaded_error = -1
try
{
native_ffmpegav_lib_loaded_error = ffmpegav_loadjni(libdir2)
}
catch(_: Exception)
{
}

if (OperatingSystem.getCurrent() == OperatingSystem.LINUX)
{
native_notification_lib_loaded_error = jninotifications_loadjni(libdir2)
Expand Down
20 changes: 20 additions & 0 deletions src/main/kotlin/com/zoffcc/applications/trifa/TrifaToxService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TrifaToxService
com.zoffcc.applications.sorm.OrmaDatabase.init()
// ------ correct startup order ------
orma = com.zoffcc.applications.sorm.OrmaDatabase()
load_db_prefs()
val old_is_tox_started = is_tox_started
Log.i(TAG, "is_tox_started:==============================")
Log.i(TAG, "is_tox_started=" + is_tox_started)
Expand Down Expand Up @@ -180,6 +181,7 @@ class TrifaToxService
set_tox_running_state("stopped")
clear_friends()
clear_groups()
orma = null
com.zoffcc.applications.sorm.OrmaDatabase.shutdown()
unlock_data_dir_input()
try
Expand All @@ -193,6 +195,24 @@ class TrifaToxService
(ToxServiceThread as Thread).start()
}

private fun load_db_prefs()
{
MainActivity.DB_PREF__open_files_directly = false
try
{
if (HelperFriend.get_g_opts("DB_PREF__open_files_directly") != null)
{
if (HelperFriend.get_g_opts("DB_PREF__open_files_directly").equals("true"))
{
MainActivity.DB_PREF__open_files_directly = true
}
}
} catch (e: java.lang.Exception)
{
e.printStackTrace()
}
}

companion object
{
const val TAG = "trifa.ToxService"
Expand Down
11 changes: 5 additions & 6 deletions src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.compose.material.icons.filled.Attachment
import androidx.compose.material.icons.filled.BrokenImage
import androidx.compose.material.icons.filled.Cancel
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Start
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
Expand All @@ -44,7 +43,7 @@ import com.zoffcc.applications.trifa.HelperGeneric
import com.zoffcc.applications.trifa.HelperGeneric.cancel_ft_from_ui
import com.zoffcc.applications.trifa.HelperMessage.set_message_queueing_from_id
import com.zoffcc.applications.trifa.HelperOSFile.show_containing_dir_in_explorer
import com.zoffcc.applications.trifa.HelperOSFile.show_file_in_explorer
import com.zoffcc.applications.trifa.HelperOSFile.show_file_in_explorer_or_open
import com.zoffcc.applications.trifa.TRIFAGlobals
import com.zoffcc.applications.trifa.TRIFAGlobals.TRIFA_MSG_TYPE
import com.zoffcc.applications.trifa.ToxVars
Expand Down Expand Up @@ -164,15 +163,15 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float
contentDescription = "Image",
modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp).
combinedClickable(
onClick = { show_file_in_explorer(message.filename_fullpath) },
onClick = { show_file_in_explorer_or_open(message.filename_fullpath) },
onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) }))
}
else
{
Icon(
modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp).
combinedClickable(
onClick = { show_file_in_explorer(message.filename_fullpath) },
onClick = { show_file_in_explorer_or_open(message.filename_fullpath) },
onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) }),
imageVector = Icons.Default.Attachment,
contentDescription = "File",
Expand Down Expand Up @@ -232,15 +231,15 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float
contentDescription = "Image",
modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp).
combinedClickable(
onClick = { show_file_in_explorer(message.filename_fullpath) },
onClick = { show_file_in_explorer_or_open(message.filename_fullpath) },
onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) }))
}
else
{
Icon(
modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp).
combinedClickable(
onClick = { show_file_in_explorer(message.filename_fullpath) },
onClick = { show_file_in_explorer_or_open(message.filename_fullpath) },
onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) }),
imageVector = Icons.Default.Attachment,
contentDescription = "File",
Expand Down
14 changes: 3 additions & 11 deletions src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -13,7 +10,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Icon
Expand All @@ -33,7 +29,6 @@ import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -43,13 +38,10 @@ import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.zoffcc.applications.trifa.HelperFiletransfer
import com.zoffcc.applications.trifa.HelperGeneric
import com.zoffcc.applications.trifa.HelperGeneric.AsyncImage
import com.zoffcc.applications.trifa.HelperGeneric.loadImageBitmap
import com.zoffcc.applications.trifa.HelperMessage
import com.zoffcc.applications.trifa.HelperOSFile
import com.zoffcc.applications.trifa.HelperOSFile.show_containing_dir_in_explorer
import com.zoffcc.applications.trifa.HelperOSFile.show_file_in_explorer
import com.zoffcc.applications.trifa.HelperOSFile.show_file_in_explorer_or_open
import com.zoffcc.applications.trifa.TRIFAGlobals
import java.io.File

Expand Down Expand Up @@ -133,15 +125,15 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage,
contentDescription = "Image",
modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp).
combinedClickable(
onClick = { show_file_in_explorer(groupmessage.filename_fullpath) },
onClick = { show_file_in_explorer_or_open(groupmessage.filename_fullpath) },
onLongClick = { show_containing_dir_in_explorer(groupmessage.filename_fullpath) }))
}
else
{
Icon(
modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp).
combinedClickable(
onClick = { show_file_in_explorer(groupmessage.filename_fullpath) },
onClick = { show_file_in_explorer_or_open(groupmessage.filename_fullpath) },
onLongClick = { show_containing_dir_in_explorer(groupmessage.filename_fullpath) }),
imageVector = Icons.Default.Attachment,
contentDescription = "File",
Expand Down
Loading
Loading