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

Deleted deprecated fields #50

Merged
merged 2 commits into from
Feb 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ class GetActivityStateEvent : RequestEvent() {
}

class GetActivityInfoEvent : RequestEvent() {
class ResultEvent(val info: ActivityInfo) : ResponseEvent() {
@Deprecated("Delete in next release")
val activityInfo = info
}
class ResultEvent(val info: ActivityInfo) : ResponseEvent()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,14 @@ class GetBiometricEncryptedValueEvent(val key: String, val config: BiometricConf
* Checks that the key exists in the storage.
*/
class HasBiometricEncryptedValueEvent(val key: String) : RequestEvent() {
class ResultEvent(val isExisting: Boolean) : ResponseEvent() {
@Deprecated("Delete in next release")
val exists = isExisting
}
class ResultEvent(val isExisting: Boolean) : ResponseEvent()
}

/**
* Deletes a value associated with the key.
*/
class DeleteBiometricEncryptedValueEvent(val key: String) : RequestEvent() {
class ResultEvent(val isDeleted: Boolean) : ResponseEvent() {
@Deprecated("Delete in next release")
val deleted = isDeleted
}
class ResultEvent(val isDeleted: Boolean) : ResponseEvent()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ class Rect(val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f, v
* Get OS and device versions.
*/
class GetDeviceInfoEvent : RequestEvent() {
class ResultEvent(val info: DeviceInfo) : ResponseEvent() {
@Deprecated("Delete in next release")
val deviceInfo = info
}
class ResultEvent(val info: DeviceInfo) : ResponseEvent()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ class GetAllDownloadsEvent : RequestEvent() {
* longer be accessible through the download manager. If there is a downloaded file, partial or complete, it is deleted.
*/
class RemoveDownloadEvent(var id: Long) : RequestEvent() {
class ResultEvent(val isRemoved: Boolean) : ResponseEvent() {
@Deprecated("Delete in next release")
val removed = isRemoved
}
class ResultEvent(val isRemoved: Boolean) : ResponseEvent()
}

open class DownloadPlugin(private val activity: ComponentActivity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,14 @@ class GetEncryptedValueEvent(val key: String, val password: String) : RequestEve
* Checks that the key exists in the storage.
*/
class HasEncryptedValueEvent(val key: String) : RequestEvent() {
class ResultEvent(val isExisting: Boolean) : ResponseEvent() {
@Deprecated("Delete in next release")
val exists = isExisting
}
class ResultEvent(val isExisting: Boolean) : ResponseEvent()
}

/**
* Deletes an encrypted value associated with the key.
*/
class DeleteEncryptedValueEvent(val key: String) : RequestEvent() {
class ResultEvent(val isDeleted: Boolean) : ResponseEvent() {
@Deprecated("Delete in next release")
val deleted = isDeleted
}
class ResultEvent(val isDeleted: Boolean) : ResponseEvent()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ class GooglePayIsTokenizedEvent(
* Open Google Pay app and reveal the card.
*/
class GooglePayViewTokenEvent(val tokenId: String, val tokenServiceProvider: Int) : RequestEvent() {
class ResultEvent(val isOpened: Boolean) : ResponseEvent() {
@Deprecated("Delete in next release")
val opened = isOpened
}
class ResultEvent(val isOpened: Boolean) : ResponseEvent()
}

/**
Expand Down
8 changes: 4 additions & 4 deletions web/example/src/examples/ActivityExample.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { activityManager, ActivityResult, ActivityState, Intent, permissionsManager } from 'racehorse';
import { FormattedJSON } from '../components/FormattedJSON';
import { useActivityState } from '@racehorse/react';
Expand All @@ -11,7 +11,7 @@ const activityStateLabel = {

export function ActivityExample() {
const activityState = useActivityState();
const [activityInfo] = useState(activityManager.getActivityInfo);
const activityInfo = useMemo(activityManager.getActivityInfo, []);
const [contactActivityResult, setContactActivityResult] = useState<ActivityResult | null>();

useEffect(
Expand Down Expand Up @@ -57,8 +57,8 @@ export function ActivityExample() {

<button
onClick={() => {
permissionsManager.askForPermission('android.permission.READ_CONTACTS').then(granted => {
if (granted) {
permissionsManager.askForPermission('android.permission.READ_CONTACTS').then(isGranted => {
if (isGranted) {
activityManager
.startActivityForResult({
// https://developer.android.com/guide/components/intents-common#Contacts
Expand Down
4 changes: 2 additions & 2 deletions web/example/src/examples/BiometricEncryptedStorageExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export function BiometricEncryptedStorageExample() {
</button>{' '}
<button
onClick={() => {
biometricEncryptedStorageManager.set(key, value, biometricConfig).then(ok => {
if (ok) {
biometricEncryptedStorageManager.set(key, value, biometricConfig).then(isSuccessful => {
if (isSuccessful) {
biometricEncryptedStorageManager.get(key, biometricConfig).then(setPersistedValue);
} else {
console.log('Cannot set biometric storage entry: ' + key);
Expand Down
6 changes: 3 additions & 3 deletions web/example/src/examples/BiometricExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export function BiometricExample() {
<p>
<button
onClick={() => {
biometricManager
.enrollBiometric(authenticators)
biometricManager.enrollBiometric(authenticators).then(() => {
// Trigger status update
.then(() => setAuthenticators(authenticators => [...authenticators]));
setAuthenticators(authenticators => [...authenticators]);
});
}}
>
{'Enroll biometric'}
Expand Down
8 changes: 4 additions & 4 deletions web/example/src/examples/DeviceExample.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from 'react';
import React, { useMemo } from 'react';
import { deviceManager } from 'racehorse';
import { FormattedJSON } from '../components/FormattedJSON';

export function DeviceExample() {
const [deviceInfo] = useState(deviceManager.getDeviceInfo);
const [preferredLocales] = useState(deviceManager.getPreferredLocales);
const [insets] = useState(deviceManager.getWindowInsets);
const deviceInfo = useMemo(deviceManager.getDeviceInfo, []);
const preferredLocales = useMemo(deviceManager.getPreferredLocales, []);
const insets = useMemo(deviceManager.getWindowInsets, []);

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions web/example/src/examples/EncryptedStorageExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export function EncryptedStorageExample() {
<p>
<button
onClick={() => {
encryptedStorageManager.set(key, value, password).then(ok => {
if (ok) {
encryptedStorageManager.set(key, value, password).then(isSuccessful => {
if (isSuccessful) {
encryptedStorageManager.get(key, password).then(setPersistedValue);
}
});
Expand Down
4 changes: 3 additions & 1 deletion web/example/src/examples/FileInputExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export function FileInputExample() {
<input
type="checkbox"
checked={multiple}
onChange={event => setMultiple(event.target.checked)}
onChange={event => {
setMultiple(event.target.checked);
}}
/>
</p>

Expand Down
4 changes: 3 additions & 1 deletion web/example/src/examples/GoogleSignInExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export function GoogleSignInExample() {
</button>{' '}
<button
onClick={() => {
googleSignInManager.signOut().then(() => setAccount(null));
googleSignInManager.signOut().then(() => {
setAccount(null);
});
}}
>
{'Sign out'}
Expand Down
8 changes: 5 additions & 3 deletions web/example/src/examples/NotificationsExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ export function NotificationsExample() {
const [areNotificationsEnabled, setAreNotificationsEnabled] = useState(notificationsManager.areNotificationsEnabled);

useEffect(() => {
const listener = () => setAreNotificationsEnabled(notificationsManager.areNotificationsEnabled());
const visibilityListener = () => {
setAreNotificationsEnabled(notificationsManager.areNotificationsEnabled());
};

window.addEventListener('visibilitychange', listener);
window.addEventListener('visibilitychange', visibilityListener);

return () => {
window.removeEventListener('visibilitychange', listener);
window.removeEventListener('visibilitychange', visibilityListener);
};
}, []);

Expand Down
2 changes: 1 addition & 1 deletion web/racehorse/src/main/createActivityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function createActivityManager(eventBridge: EventBridge, uiScheduler: Sch
return {
getActivityState: () => eventBridge.request({ type: 'org.racehorse.GetActivityStateEvent' }).payload.state,

getActivityInfo: () => eventBridge.request({ type: 'org.racehorse.GetActivityInfoEvent' }).payload.activityInfo,
getActivityInfo: () => eventBridge.request({ type: 'org.racehorse.GetActivityInfoEvent' }).payload.info,

startActivity: intent =>
eventBridge.request({ type: 'org.racehorse.StartActivityEvent', payload: { intent } }).payload.isStarted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export function createBiometricEncryptedStorageManager(
eventBridge.request({
type: 'org.racehorse.HasBiometricEncryptedValueEvent',
payload: { key },
}).payload.exists,
}).payload.isExisting,

delete: key =>
eventBridge.request({
type: 'org.racehorse.DeleteBiometricEncryptedValueEvent',
payload: { key },
}).payload.deleted,
}).payload.isDeleted,
};
}
2 changes: 1 addition & 1 deletion web/racehorse/src/main/createDeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function createDeviceManager(eventBridge: EventBridge): DeviceManager {
eventBridge.request({ type: 'org.racehorse.GetPreferredLocalesEvent' }).payload.locales;

return {
getDeviceInfo: () => eventBridge.request({ type: 'org.racehorse.GetDeviceInfoEvent' }).payload.deviceInfo,
getDeviceInfo: () => eventBridge.request({ type: 'org.racehorse.GetDeviceInfoEvent' }).payload.info,

getPreferredLocales,

Expand Down
2 changes: 1 addition & 1 deletion web/racehorse/src/main/createDownloadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,6 @@ export function createDownloadManager(eventBridge: EventBridge): DownloadManager
getAllDownloads: () => eventBridge.request({ type: 'org.racehorse.GetAllDownloadsEvent' }).payload.downloads,

removeDownload: id =>
eventBridge.request({ type: 'org.racehorse.RemoveDownloadEvent', payload: { id } }).payload.removed,
eventBridge.request({ type: 'org.racehorse.RemoveDownloadEvent', payload: { id } }).payload.isRemoved,
};
}
8 changes: 6 additions & 2 deletions web/racehorse/src/main/createEncryptedStorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ export function createEncryptedStorageManager(eventBridge: EventBridge): Encrypt
.requestAsync({ type: 'org.racehorse.GetEncryptedValueEvent', payload: { key, password } })
.then(event => event.payload.value),

has: key => eventBridge.request({ type: 'org.racehorse.HasEncryptedValueEvent', payload: { key } }).payload.exists,
has: key =>
eventBridge.request({
type: 'org.racehorse.HasEncryptedValueEvent',
payload: { key },
}).payload.isExisting,

delete: key =>
eventBridge.request({
type: 'org.racehorse.DeleteEncryptedValueEvent',
payload: { key },
}).payload.deleted,
}).payload.isDeleted,
};
}
2 changes: 1 addition & 1 deletion web/racehorse/src/main/createGooglePayManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export function createGooglePayManager(eventBridge: EventBridge, uiScheduler: Sc
type: 'org.racehorse.GooglePayViewTokenEvent',
payload: { tokenId, tokenServiceProvider },
})
.then(event => event.payload.opened)
.then(event => event.payload.isOpened)
),

pushTokenize: request =>
Expand Down
12 changes: 6 additions & 6 deletions web/racehorse/src/main/createScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ export interface Scheduler {
*
* @param operation The operation to schedule.
*/
schedule<T>(operation: () => Promise<T>): Promise<T>;
schedule<T>(operation: () => PromiseLike<T> | T): Promise<T>;
}

/**
* Schedules an operation callback invocation after all previously scheduled operations are completed.
*/
export function createScheduler(): Scheduler {
let promise: Promise<unknown> = Promise.resolve();
let pending = false;
let isPending = false;

return {
isPending: () => pending,
isPending: () => isPending,

schedule: operation => {
pending = true;
isPending = true;

const operationPromise = promise
.then(noop, noop)
.then(operation)
.then(
result => {
pending = promise !== operationPromise;
isPending = promise !== operationPromise;
return result;
},
reason => {
pending = promise !== operationPromise;
isPending = promise !== operationPromise;
throw reason;
}
);
Expand Down