diff --git a/app/build.gradle b/app/build.gradle index 17f6e2eae5..d9d0fa9ea0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId 'com.discord' minSdkVersion 21 targetSdkVersion 29 - versionCode 89109 - versionName "89.9 - Beta" + versionCode 89110 + versionName "89.10 - Beta" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 409dc6625a..b664ff9ec4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/app/src/main/java/com/discord/widgets/chat/input/autocomplete/AutocompleteViewModel.java b/app/src/main/java/com/discord/widgets/chat/input/autocomplete/AutocompleteViewModel.java index 35cd04ab03..ee64b5356d 100644 --- a/app/src/main/java/com/discord/widgets/chat/input/autocomplete/AutocompleteViewModel.java +++ b/app/src/main/java/com/discord/widgets/chat/input/autocomplete/AutocompleteViewModel.java @@ -21,6 +21,7 @@ import com.discord.models.commands.ApplicationCommand; import com.discord.models.commands.ApplicationCommandOption; import com.discord.models.commands.ApplicationSubCommand; import com.discord.models.user.User; +import com.discord.stores.StoreAnalytics; import com.discord.stores.StoreApplicationCommands; import com.discord.stores.StoreGuilds; import com.discord.stores.StoreStream; @@ -843,6 +844,15 @@ public final class AutocompleteViewModel extends AppViewModel { autocompleteViewState = AutocompleteViewState.Hidden.INSTANCE; } SelectedCommandViewState selectedCommandViewState = getSelectedCommandViewState(autocompleteInputSelectionModel); + ApplicationCommand newSelectedCommand = newSelectedCommand(autocompleteInputSelectionModel, this.lastAutocompleteInputSelectionModel); + if (newSelectedCommand != null) { + StoreStream.Companion companion = StoreStream.Companion; + StoreAnalytics analytics = companion.getAnalytics(); + long id2 = companion.getChannelsSelected().getId(); + long applicationId = newSelectedCommand.getApplicationId(); + Long longOrNull = s.toLongOrNull(newSelectedCommand.getId()); + analytics.trackApplicationCommandSelected(id2, applicationId, longOrNull != null ? longOrNull.longValue() : 0); + } this.lastAutocompleteInputSelectionModel = autocompleteInputSelectionModel; updateViewState(new ViewState(autocompleteViewState, selectedCommandViewState)); } @@ -953,6 +963,29 @@ public final class AutocompleteViewModel extends AppViewModel { onDataUpdated(this.inputState, storeState); } + private final ApplicationCommand newSelectedCommand(AutocompleteInputSelectionModel autocompleteInputSelectionModel, AutocompleteInputSelectionModel autocompleteInputSelectionModel2) { + MentionInputModel.VerifiedCommandInputModel inputModel; + InputCommandContext inputCommandContext; + MentionInputModel.VerifiedCommandInputModel inputModel2; + InputCommandContext inputCommandContext2; + InputSelectionModel inputSelectionModel = autocompleteInputSelectionModel.getInputSelectionModel(); + if (!(inputSelectionModel instanceof InputSelectionModel.CommandInputSelectionModel)) { + inputSelectionModel = null; + } + InputSelectionModel.CommandInputSelectionModel commandInputSelectionModel = (InputSelectionModel.CommandInputSelectionModel) inputSelectionModel; + ApplicationCommand selectedCommand = (commandInputSelectionModel == null || (inputModel2 = commandInputSelectionModel.getInputModel()) == null || (inputCommandContext2 = inputModel2.getInputCommandContext()) == null) ? null : inputCommandContext2.getSelectedCommand(); + InputSelectionModel inputSelectionModel2 = autocompleteInputSelectionModel2 != null ? autocompleteInputSelectionModel2.getInputSelectionModel() : null; + if (!(inputSelectionModel2 instanceof InputSelectionModel.CommandInputSelectionModel)) { + inputSelectionModel2 = null; + } + InputSelectionModel.CommandInputSelectionModel commandInputSelectionModel2 = (InputSelectionModel.CommandInputSelectionModel) inputSelectionModel2; + ApplicationCommand selectedCommand2 = (commandInputSelectionModel2 == null || (inputModel = commandInputSelectionModel2.getInputModel()) == null || (inputCommandContext = inputModel.getInputCommandContext()) == null) ? null : inputCommandContext.getSelectedCommand(); + if (!m.areEqual(selectedCommand != null ? selectedCommand.getId() : null, selectedCommand2 != null ? selectedCommand2.getId() : null)) { + return selectedCommand; + } + return null; + } + @MainThread private final InputEditTextAction onPreAutocompleteCompute(CharSequence charSequence) { return replacementSpanCommandParamDeletion(charSequence); diff --git a/app/src/main/java/com/discord/widgets/chat/input/autocomplete/InputAutocomplete.java b/app/src/main/java/com/discord/widgets/chat/input/autocomplete/InputAutocomplete.java index 7a7868b3d7..606024568b 100644 --- a/app/src/main/java/com/discord/widgets/chat/input/autocomplete/InputAutocomplete.java +++ b/app/src/main/java/com/discord/widgets/chat/input/autocomplete/InputAutocomplete.java @@ -68,6 +68,7 @@ public final class InputAutocomplete { private final ChatInputApplicationsAdapter categoriesAdapter; private final Long channel; private final RecyclerView commandBrowserAppsRecyclerView; + private boolean commandBrowserOpen; private final FlexEditText editText; private final AppFragment fragment; private final SelectedApplicationCommandAdapter selectedApplicationCommandAdapter; @@ -412,6 +413,9 @@ public final class InputAutocomplete { } else if (m.areEqual(autocompleteViewState, AutocompleteViewState.Hidden.INSTANCE)) { hideAutocomplete(); } + if (!(autocompleteViewState instanceof AutocompleteViewState.CommandBrowser)) { + this.commandBrowserOpen = false; + } StoreStream.Companion.getAutocomplete().setAutocompleteVisible(!(autocompleteViewState instanceof AutocompleteViewState.Hidden)); } @@ -455,6 +459,11 @@ public final class InputAutocomplete { this.stickersContainer.setVisibility(8); List flattenCommandsModel = commandBrowser.getDiscoverCommands().getFlattenCommandsModel(); boolean z2 = (flattenCommandsModel.isEmpty() ^ true) || commandBrowser.getDiscoverCommands().getLoadState().isLoading(); + if (!this.commandBrowserOpen && z2) { + this.commandBrowserOpen = true; + StoreStream.Companion companion = StoreStream.Companion; + companion.getAnalytics().trackApplicationCommandBrowserOpened(companion.getChannelsSelected().getId()); + } if ((this.autocompleteRecyclerView.getVisibility() == 0) != z2) { this.autocompleteRecyclerView.setVisibility(z2 ? 0 : 8); } @@ -571,7 +580,9 @@ public final class InputAutocomplete { Event.ScrollAutocompletablesToApplication scrollAutocompletablesToApplication = (Event.ScrollAutocompletablesToApplication) event; ChatInputAutocompleteAdapter.scrollToPosition$default(this.autocompleteAdapter, scrollAutocompletablesToApplication.getTargetPosition(), 0, false, 6, null); this.categoriesAdapter.selectApplication(scrollAutocompletablesToApplication.getApplicationId()); - this.commandBrowserAppsRecyclerView.smoothScrollToPosition(this.categoriesAdapter.getPositionOfApplication(scrollAutocompletablesToApplication.getApplicationId())); + if (this.categoriesAdapter.getPositionOfApplication(scrollAutocompletablesToApplication.getApplicationId()) != -1) { + this.commandBrowserAppsRecyclerView.smoothScrollToPosition(this.categoriesAdapter.getPositionOfApplication(scrollAutocompletablesToApplication.getApplicationId())); + } } } diff --git a/app/src/main/java/com/discord/widgets/settings/WidgetSettings.java b/app/src/main/java/com/discord/widgets/settings/WidgetSettings.java index 22c5df59a3..07985d47f1 100644 --- a/app/src/main/java/com/discord/widgets/settings/WidgetSettings.java +++ b/app/src/main/java/com/discord/widgets/settings/WidgetSettings.java @@ -321,7 +321,7 @@ public final class WidgetSettings extends AppFragment implements OnTabSelectedLi TextView textView = binding.f; m.checkNotNullExpressionValue(textView, "appInfoHeader"); String string = getString(R.string.app_information); - textView.setText(string + " - 89.9 - Beta (89109)"); + textView.setText(string + " - 89.10 - Beta (89110)"); binding.f1972z.setOnClickListener(new WidgetSettings$onViewBound$$inlined$with$lambda$3(this)); binding.u.setOnClickListener(WidgetSettings$onViewBound$1$5.INSTANCE); binding.q.setOnClickListener(WidgetSettings$onViewBound$1$6.INSTANCE); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8fcd092ae8..3de7f326c4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1374,7 +1374,7 @@ Select a color Transparency Use Default - ff2cb8672d254680a075ca7644953ef6 + 737bc2c2411d4715b57c2962400cce18 Coming Soon Slash command application {applicationName} {applicationName} application