From 8c4e2e57f985038d6ff4d7928a8c3e3028c8ffce Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:51:23 +0300 Subject: [PATCH 1/6] android: Show lockscreen faster (#1822) Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../java/chat/simplex/app/MainActivity.kt | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt index c868a9731..efe6b022c 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt @@ -39,9 +39,8 @@ import chat.simplex.app.views.database.DatabaseErrorView import chat.simplex.app.views.helpers.* import chat.simplex.app.views.newchat.* import chat.simplex.app.views.onboarding.* -import kotlinx.coroutines.delay +import kotlinx.coroutines.* import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.launch class MainActivity: FragmentActivity() { companion object { @@ -109,8 +108,8 @@ class MainActivity: FragmentActivity() { processExternalIntent(intent, vm.chatModel) } - override fun onStart() { - super.onStart() + override fun onResume() { + super.onResume() val enteredBackgroundVal = enteredBackground.value if (enteredBackgroundVal == null || elapsedRealtime() - enteredBackgroundVal >= 30_000) { runAuthenticate() @@ -160,25 +159,31 @@ class MainActivity: FragmentActivity() { } else { userAuthorized.value = false ModalManager.shared.closeModals() - authenticate( - generalGetString(R.string.auth_unlock), - generalGetString(R.string.auth_log_in_using_credential), - this@MainActivity, - completed = { laResult -> - when (laResult) { - LAResult.Success -> - userAuthorized.value = true - is LAResult.Error, LAResult.Failed -> - laFailed.value = true - LAResult.Unavailable -> { - userAuthorized.value = true - m.performLA.value = false - m.controller.appPrefs.performLA.set(false) - laUnavailableTurningOffAlert() + // To make Main thread free in order to allow to Compose to show blank view that hiding content underneath of it faster on slow devices + CoroutineScope(Dispatchers.Default).launch { + delay(50) + withContext(Dispatchers.Main) { + authenticate( + generalGetString(R.string.auth_unlock), + generalGetString(R.string.auth_log_in_using_credential), + this@MainActivity, + completed = { laResult -> + when (laResult) { + LAResult.Success -> + userAuthorized.value = true + is LAResult.Error, LAResult.Failed -> + laFailed.value = true + LAResult.Unavailable -> { + userAuthorized.value = true + m.performLA.value = false + m.controller.appPrefs.performLA.set(false) + laUnavailableTurningOffAlert() + } + } } - } + ) } - ) + } } } @@ -261,14 +266,6 @@ fun MainPage( setPerformLA: (Boolean) -> Unit, showLANotice: () -> Unit ) { - // this with LaunchedEffect(userAuthorized.value) fixes bottom sheet visibly collapsing after authentication - var chatsAccessAuthorized by rememberSaveable { mutableStateOf(false) } - LaunchedEffect(userAuthorized.value) { - if (chatModel.controller.appPrefs.performLA.get()) { - delay(500L) - } - chatsAccessAuthorized = userAuthorized.value == true - } var showChatDatabaseError by rememberSaveable { mutableStateOf(chatModel.chatDbStatus.value != DBMigrationResult.OK && chatModel.chatDbStatus.value != null) } @@ -327,7 +324,7 @@ fun MainPage( } } onboarding == null || userCreated == null -> SplashView() - !chatsAccessAuthorized -> { + userAuthorized.value != true -> { if (chatModel.controller.appPrefs.performLA.get() && laFailed.value) { authView() } else { From d9571c70f2845eed80206015ca4e742c06cec230 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 23 Mar 2023 10:06:13 +0000 Subject: [PATCH 2/6] update script to unpack ios libs --- scripts/ios/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ios/prepare.sh b/scripts/ios/prepare.sh index 3e4157b4c..1043af4bd 100755 --- a/scripts/ios/prepare.sh +++ b/scripts/ios/prepare.sh @@ -3,7 +3,7 @@ # the binaries folder should be in ~/Downloads folder rm -rf ./apps/ios/Libraries/mac ./apps/ios/Libraries/ios ./apps/ios/Libraries/sim mkdir -p ./apps/ios/Libraries/mac ./apps/ios/Libraries/ios ./apps/ios/Libraries/sim -cp ~/Downloads/pkg-ios-aarch64-swift-json/* ./apps/ios/Libraries/mac +unzip -o ~/Downloads/pkg-ios-aarch64-swift-json.zip -d ./apps/ios/Libraries/mac chmod +w ./apps/ios/Libraries/mac/* cp ./apps/ios/Libraries/mac/* ./apps/ios/Libraries/ios cp ./apps/ios/Libraries/mac/* ./apps/ios/Libraries/sim From 36bcb1b26e3b61cb684093076ad3716cb38a997c Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Thu, 23 Mar 2023 19:04:53 +0300 Subject: [PATCH 3/6] android: downgrade target sdk (#2065) --- apps/android/app/build.gradle | 4 ++-- apps/android/app/src/main/AndroidManifest.xml | 2 +- .../chat/simplex/app/views/helpers/Util.kt | 16 ++++++------- .../app/views/usersettings/Appearance.kt | 24 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/android/app/build.gradle b/apps/android/app/build.gradle index 1b81bf7d5..8c8e7fac9 100644 --- a/apps/android/app/build.gradle +++ b/apps/android/app/build.gradle @@ -5,12 +5,12 @@ plugins { } android { - compileSdk 33 + compileSdk 32 defaultConfig { applicationId "chat.simplex.app" minSdk 29 - targetSdk 33 + targetSdk 32 versionCode 104 versionName "4.6-beta.0" diff --git a/apps/android/app/src/main/AndroidManifest.xml b/apps/android/app/src/main/AndroidManifest.xml index 3476fe605..6d090e381 100644 --- a/apps/android/app/src/main/AndroidManifest.xml +++ b/apps/android/app/src/main/AndroidManifest.xml @@ -30,8 +30,8 @@ android:label="${app_name}" android:extractNativeLibs="${extract_native_libs}" android:supportsRtl="true" - android:localeConfig="@xml/locales_config" android:theme="@style/Theme.SimpleX"> + serializableSaver(): Saver = Saver( ) fun saveAppLocale(pref: SharedPreference, activity: Activity, languageCode: String? = null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - val localeManager = SimplexApp.context.getSystemService(LocaleManager::class.java) - localeManager.applicationLocales = LocaleList(Locale.forLanguageTag(languageCode ?: return)) - } else { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { +// val localeManager = SimplexApp.context.getSystemService(LocaleManager::class.java) +// localeManager.applicationLocales = LocaleList(Locale.forLanguageTag(languageCode ?: return)) +// } else { pref.set(languageCode) if (languageCode == null) { activity.applyLocale(SimplexApp.context.defaultLocale) } activity.recreate() - } +// } } fun Activity.applyAppLocale(pref: SharedPreference) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { +// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { val lang = pref.get() if (lang == null || lang == Locale.getDefault().language) return applyLocale(Locale.forLanguageTag(lang)) - } +// } } private fun Activity.applyLocale(locale: Locale) { diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Appearance.kt b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Appearance.kt index 2ff6c498b..827d5e883 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Appearance.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Appearance.kt @@ -97,14 +97,14 @@ fun AppearanceView(m: ChatModel) { AppBarTitle(stringResource(R.string.appearance_settings)) SectionView(stringResource(R.string.settings_section_title_language), padding = PaddingValues()) { val context = LocalContext.current - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - SectionItemWithValue( - generalGetString(R.string.settings_section_title_language).lowercase().replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.US) else it.toString() }, - remember { mutableStateOf("system") }, - listOf(ValueTitleDesc("system", generalGetString(R.string.change_verb), "")), - onSelected = { openSystemLangPicker(context as? Activity ?: return@SectionItemWithValue) } - ) - } else { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { +// SectionItemWithValue( +// generalGetString(R.string.settings_section_title_language).lowercase().replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.US) else it.toString() }, +// remember { mutableStateOf("system") }, +// listOf(ValueTitleDesc("system", generalGetString(R.string.change_verb), "")), +// onSelected = { openSystemLangPicker(context as? Activity ?: return@SectionItemWithValue) } +// ) +// } else { val state = rememberSaveable { mutableStateOf(languagePref.get() ?: "system") } SectionItemView { LangSelector(state) { @@ -122,7 +122,7 @@ fun AppearanceView(m: ChatModel) { } } } - } +// } } SectionSpacer() @@ -264,9 +264,9 @@ private fun ThemeSelector(state: State, onSelected: (DefaultTheme) ) } -private fun openSystemLangPicker(activity: Activity) { - activity.startActivity(Intent(Settings.ACTION_APP_LOCALE_SETTINGS, Uri.parse("package:" + SimplexApp.context.packageName))) -} +//private fun openSystemLangPicker(activity: Activity) { +// activity.startActivity(Intent(Settings.ACTION_APP_LOCALE_SETTINGS, Uri.parse("package:" + SimplexApp.context.packageName))) +//} private fun findEnabledIcon(): AppIcon = AppIcon.values().first { icon -> SimplexApp.context.packageManager.getComponentEnabledSetting( From 8212d7a00eeac91b06bad0eb5264374d11a3f6a1 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 23 Mar 2023 18:47:55 +0000 Subject: [PATCH 4/6] mobile: fix "delete for me" moderating the received item in group (#2067) --- .../app/src/main/java/chat/simplex/app/views/chat/ChatView.kt | 2 +- apps/ios/Shared/Views/Chat/ChatView.swift | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt index f875f31ae..9558f6254 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt @@ -204,7 +204,7 @@ fun ChatView(chatId: String, chatModel: ChatModel, onComposed: () -> Unit) { val groupMember = toModerate?.second val deletedChatItem: ChatItem? val toChatItem: ChatItem? - if (groupInfo != null && groupMember != null) { + if (mode == CIDeleteMode.cidmBroadcast && groupInfo != null && groupMember != null) { val r = chatModel.controller.apiDeleteMemberChatItem( groupId = groupInfo.groupId, groupMemberId = groupMember.groupMemberId, diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 21fcb66dd..8d189bd4d 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -667,7 +667,8 @@ struct ChatView: View { if let di = deletingItem { var deletedItem: ChatItem var toItem: ChatItem? - if let (groupInfo, groupMember) = di.memberToModerate(chat.chatInfo) { + if case .cidmBroadcast = mode, + let (groupInfo, groupMember) = di.memberToModerate(chat.chatInfo) { (deletedItem, toItem) = try await apiDeleteMemberChatItem( groupId: groupInfo.apiId, groupMemberId: groupMember.groupMemberId, From f349f124d8754d59cf6b6b7da8b29b8de76f5e57 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 23 Mar 2023 22:02:45 +0000 Subject: [PATCH 5/6] 4.6-beta.1: Android 105, iOS 132 --- apps/android/app/build.gradle | 4 ++-- apps/ios/SimpleX.xcodeproj/project.pbxproj | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/android/app/build.gradle b/apps/android/app/build.gradle index 8c8e7fac9..aca945b71 100644 --- a/apps/android/app/build.gradle +++ b/apps/android/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId "chat.simplex.app" minSdk 29 targetSdk 32 - versionCode 104 - versionName "4.6-beta.0" + versionCode 105 + versionName "4.6-beta.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { diff --git a/apps/ios/SimpleX.xcodeproj/project.pbxproj b/apps/ios/SimpleX.xcodeproj/project.pbxproj index b37d37ab8..1ff2641c2 100644 --- a/apps/ios/SimpleX.xcodeproj/project.pbxproj +++ b/apps/ios/SimpleX.xcodeproj/project.pbxproj @@ -1396,7 +1396,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "SimpleX (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEVELOPMENT_TEAM = 5NN7GUYB6T; ENABLE_BITCODE = NO; ENABLE_PREVIEWS = YES; @@ -1438,7 +1438,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "SimpleX (iOS).entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEVELOPMENT_TEAM = 5NN7GUYB6T; ENABLE_BITCODE = NO; ENABLE_PREVIEWS = YES; @@ -1518,7 +1518,7 @@ CODE_SIGN_ENTITLEMENTS = "SimpleX NSE/SimpleX NSE.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEVELOPMENT_TEAM = 5NN7GUYB6T; ENABLE_BITCODE = NO; GENERATE_INFOPLIST_FILE = YES; @@ -1550,7 +1550,7 @@ CODE_SIGN_ENTITLEMENTS = "SimpleX NSE/SimpleX NSE.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEVELOPMENT_TEAM = 5NN7GUYB6T; ENABLE_BITCODE = NO; GENERATE_INFOPLIST_FILE = YES; From b665dce383d97c0f15671b9a9af6e08f32ec90b9 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:09:37 +0000 Subject: [PATCH 6/6] ios: show muted user profiles in user menu, do not show badge on messages in hidden profiles (#2068) --- apps/ios/Shared/Views/ChatList/ChatListView.swift | 2 +- apps/ios/Shared/Views/ChatList/UserPicker.swift | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index d23418101..0b2a3f1a9 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -85,7 +85,7 @@ struct ChatListView: View { .frame(width: 32, height: 32) .padding(.trailing, 4) let allRead = chatModel.users - .filter { !$0.user.activeUser } + .filter { u in !u.user.activeUser && !u.user.hidden } .allSatisfy { u in u.unreadCount == 0 } if !allRead { unreadBadge(size: 12) diff --git a/apps/ios/Shared/Views/ChatList/UserPicker.swift b/apps/ios/Shared/Views/ChatList/UserPicker.swift index 76bac7a28..bb88f5c38 100644 --- a/apps/ios/Shared/Views/ChatList/UserPicker.swift +++ b/apps/ios/Shared/Views/ChatList/UserPicker.swift @@ -126,7 +126,9 @@ struct UserPicker: View { if user.activeUser { Image(systemName: "checkmark") } else if u.unreadCount > 0 { - unreadCounter(u.unreadCount) + unreadCounter(u.unreadCount, color: user.showNtfs ? .accentColor : .secondary) + } else if !user.showNtfs { + Image(systemName: "speaker.slash") } } .padding(.trailing) @@ -152,13 +154,13 @@ struct UserPicker: View { } } -func unreadCounter(_ unread: Int) -> some View { +private func unreadCounter(_ unread: Int, color: Color) -> some View { unreadCountText(unread) .font(.caption) .foregroundColor(.white) .padding(.horizontal, 4) .frame(minWidth: 18, minHeight: 18) - .background(Color.accentColor) + .background(color) .cornerRadius(10) }