From 34b265475d7a52196cf56ffa79d1a013ac6445bc Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Thu, 25 Apr 2024 05:53:46 -0700 Subject: [PATCH] Mobile: Support copying app information (#10336) --- .eslintignore | 1 + .gitignore | 1 + .../screens/ConfigScreen/ConfigScreen.tsx | 24 ++++++++++++------- packages/app-mobile/utils/getPackageInfo.ts | 17 +++++++++++++ packages/lib/versionInfo.ts | 5 ++-- 5 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 packages/app-mobile/utils/getPackageInfo.ts diff --git a/.eslintignore b/.eslintignore index 165384b7e..3539b92b2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -666,6 +666,7 @@ packages/app-mobile/utils/fs-driver/tarExtract.test.js packages/app-mobile/utils/fs-driver/tarExtract.js packages/app-mobile/utils/fs-driver/testUtil/createFilesFromPathRecord.js packages/app-mobile/utils/fs-driver/testUtil/verifyDirectoryMatches.js +packages/app-mobile/utils/getPackageInfo.js packages/app-mobile/utils/initializeCommandService.js packages/app-mobile/utils/ipc/RNToWebViewMessenger.js packages/app-mobile/utils/ipc/WebViewToRNMessenger.js diff --git a/.gitignore b/.gitignore index 01090396f..626e6f23d 100644 --- a/.gitignore +++ b/.gitignore @@ -646,6 +646,7 @@ packages/app-mobile/utils/fs-driver/tarExtract.test.js packages/app-mobile/utils/fs-driver/tarExtract.js packages/app-mobile/utils/fs-driver/testUtil/createFilesFromPathRecord.js packages/app-mobile/utils/fs-driver/testUtil/verifyDirectoryMatches.js +packages/app-mobile/utils/getPackageInfo.js packages/app-mobile/utils/initializeCommandService.js packages/app-mobile/utils/ipc/RNToWebViewMessenger.js packages/app-mobile/utils/ipc/WebViewToRNMessenger.js diff --git a/packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.tsx b/packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.tsx index e73d4d650..efb50284f 100644 --- a/packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.tsx +++ b/packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.tsx @@ -8,7 +8,6 @@ import setIgnoreTlsErrors from '../../../utils/TlsUtils'; import { reg } from '@joplin/lib/registry'; import { State } from '@joplin/lib/reducer'; const { BackButtonService } = require('../../../services/back-button.js'); -const VersionInfo = require('react-native-version-info').default; import { connect } from 'react-redux'; import ScreenHeader from '../../ScreenHeader'; import { _ } from '@joplin/lib/locale'; @@ -33,6 +32,8 @@ import PluginStates, { getSearchText as getPluginStatesSearchText } from './plug import PluginUploadButton, { canInstallPluginsFromFile, buttonLabel as pluginUploadButtonSearchText } from './plugins/PluginUploadButton'; import NoteImportButton, { importButtonDefaultTitle, importButtonDescription } from './NoteExportSection/NoteImportButton'; import SectionDescription from './SectionDescription'; +import getPackageInfo from '../../../utils/getPackageInfo'; +import versionInfo from '@joplin/lib/versionInfo'; interface ConfigScreenState { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied @@ -602,13 +603,20 @@ class ConfigScreenComponent extends BaseScreenComponent { + Clipboard.setString(versionInfoText); + }); const featureFlagKeys = Setting.featureFlagKeys(AppType.Mobile); if (featureFlagKeys.length) { diff --git a/packages/app-mobile/utils/getPackageInfo.ts b/packages/app-mobile/utils/getPackageInfo.ts new file mode 100644 index 000000000..33cdb9ef5 --- /dev/null +++ b/packages/app-mobile/utils/getPackageInfo.ts @@ -0,0 +1,17 @@ +import shim from '@joplin/lib/shim'; +import { PackageInfo } from '@joplin/lib/versionInfo'; +import ReactNativeVersionInfo from 'react-native-version-info'; + +const getPackageInfo = (): PackageInfo => { + const version = shim.appVersion(); + return { + description: 'Joplin for Mobile', + name: 'Joplin', + version, + build: { + appId: ReactNativeVersionInfo.bundleIdentifier, + }, + }; +}; + +export default getPackageInfo; diff --git a/packages/lib/versionInfo.ts b/packages/lib/versionInfo.ts index 928518b97..eae0e6b35 100644 --- a/packages/lib/versionInfo.ts +++ b/packages/lib/versionInfo.ts @@ -2,6 +2,7 @@ import { _ } from './locale'; import Setting from './models/Setting'; import { reg } from './registry'; import { Plugins } from './services/plugins/PluginService'; +import shim from './shim'; export interface PackageInfo { name: string; @@ -10,7 +11,7 @@ export interface PackageInfo { build: { appId: string; }; - git: { + git?: { branch: string; hash: string; }; @@ -70,7 +71,7 @@ export default function versionInfo(packageInfo: PackageInfo, plugins: Plugins) ]; const body = [ - _('%s %s (%s, %s)', p.name, p.version, Setting.value('env'), process.platform), + _('%s %s (%s, %s)', p.name, p.version, Setting.value('env'), shim.platformName()), '', _('Client ID: %s', Setting.value('clientId')), _('Sync Version: %s', Setting.value('syncVersion')),