71 lines
2.7 KiB
TypeScript
71 lines
2.7 KiB
TypeScript
// Metro module 4736 (f4737).
|
|
import NativePermissionStore from "./NativePermissionStore";
|
|
import { NativePermissionStates, NativePermissionStatus, NativePermissionTypes } from "./NativePermissionConstants";
|
|
import { AnalyticEvents } from "../../Constants";
|
|
import AnalyticsUtils from "../../utils/AnalyticsUtils";
|
|
import NativePermissionActionCreators from "./NativePermissionActionCreators";
|
|
import { intl, t } from "../../intl/index.native";
|
|
class NativePermissionBaseUtils {
|
|
constructor() {
|
|
return {
|
|
__proto__: new.target.prototype,
|
|
storage: new NativePermissionStore()
|
|
};
|
|
}
|
|
async requestAuthorization(type, c14416_1, c14416_2) {
|
|
const _this = this;
|
|
let c25286_1;
|
|
c25286_1 = void 0;
|
|
if (typeof c14416_1 !== "function") {
|
|
throw new Error(`requestAuthorization: Was provided with not a function for ${type}.`);
|
|
}
|
|
AnalyticsUtils.track(AnalyticEvents.PERMISSIONS_REQUESTED, {
|
|
type
|
|
});
|
|
let c29435_0 = await c14416_1();
|
|
let c29435_1 = c29435_0 === NativePermissionStatus.AUTHORIZED || c29435_0 === NativePermissionStatus.LIMITED;
|
|
let c29435_2 = c29435_1 ? NativePermissionStates.ACCEPTED : NativePermissionStates.DENIED;
|
|
NativePermissionActionCreators.setPermission(type, c29435_2);
|
|
if (c29435_1 ? !c29435_1 : c14416_2.showAuthorizationError) {
|
|
_this.showAlert(type);
|
|
}
|
|
return c29435_1;
|
|
}
|
|
requestPermission(a0, a1) {
|
|
return this.requestPermissionCore(a0, NativePermissionBaseUtils.defaultNativePermissionsRequestOptions(a1));
|
|
}
|
|
hasPermission(a0, a1) {
|
|
return this.hasPermissionCore(a0, NativePermissionBaseUtils.defaultNativePermissionsRequestOptions(a1));
|
|
}
|
|
showAlert(a0) {
|
|
const r34 = `${intl.string(t["68G7fD"])}. ${intl.string(t["5Jvu1R"])}`;
|
|
const r35 = {};
|
|
r35[NativePermissionTypes.CAMERA] = r34;
|
|
r35[NativePermissionTypes.HEADSET_CAMERA] = r34;
|
|
r35[NativePermissionTypes.AUDIO] = `${intl.string(t.xisTfe)}. ${intl.string(t["5Jvu1R"])}`;
|
|
r35[NativePermissionTypes.PHOTOS] = `${intl.string(t.jQHU4M)}. ${intl.string(t["5Jvu1R"])}`;
|
|
r35[NativePermissionTypes.INPUT_MONITORING] = `${intl.string(t.UIBqsS)}. ${intl.string(t["5Jvu1R"])}`;
|
|
r35[NativePermissionTypes.CONTACTS] = `${intl.string(t.kTtf7o)}. ${intl.string(t["5Jvu1R"])}`;
|
|
const body = r35[a0];
|
|
if (body != null) {
|
|
this.openAlertModal({
|
|
title: intl.string(t.u1Gxpu),
|
|
body,
|
|
onConfirm: () => this.openSettings(a0),
|
|
cancelText: intl.string(t["ETE/oC"]),
|
|
confirmText: intl.string(t["XgZk+u"])
|
|
});
|
|
}
|
|
}
|
|
static defaultNativePermissionsRequestOptions(a0) {
|
|
const r4 = {
|
|
showAuthorizationError: true
|
|
};
|
|
return a0 != null ? {
|
|
...r4,
|
|
...a0
|
|
} : r4;
|
|
}
|
|
}
|
|
export { NativePermissionBaseUtils };
|