cleaned code
This commit is contained in:
parent
58be4cec5c
commit
61b35bb075
2 changed files with 26 additions and 37 deletions
|
@ -34,8 +34,8 @@ export const myMixin = {
|
||||||
let hr = localize('hr')
|
let hr = localize('hr')
|
||||||
let min = localize('min')
|
let min = localize('min')
|
||||||
let mins = h * 60 + m
|
let mins = h * 60 + m
|
||||||
h = h && this.getLocaleN(h)
|
h = h && this.localeN(h)
|
||||||
m = m && this.getLocaleN(m)
|
m = m && this.localeN(m)
|
||||||
return {
|
return {
|
||||||
time: h ? (m ? `${h} ${hr} ${m} ${min}` : `${h} ${hr}`) : `${m} ${min}`,
|
time: h ? (m ? `${h} ${hr} ${m} ${min}` : `${h} ${hr}`) : `${m} ${min}`,
|
||||||
duration: `${mins}`,
|
duration: `${mins}`,
|
||||||
|
@ -44,7 +44,7 @@ export const myMixin = {
|
||||||
setGravity(args) {
|
setGravity(args) {
|
||||||
;(args.object || args).android.setGravity(this.RTL ? 5 : 3)
|
;(args.object || args).android.setGravity(this.RTL ? 5 : 3)
|
||||||
},
|
},
|
||||||
getLocaleN(n) {
|
localeN(n) {
|
||||||
return new Intl.NumberFormat(null).format(Number(n))
|
return new Intl.NumberFormat(null).format(Number(n))
|
||||||
},
|
},
|
||||||
touchFade(object, action) {
|
touchFade(object, action) {
|
||||||
|
@ -56,7 +56,7 @@ export const myMixin = {
|
||||||
: c.replace(/ fade/g, '')
|
: c.replace(/ fade/g, '')
|
||||||
},
|
},
|
||||||
swipeBack({ direction }, method) {
|
swipeBack({ direction }, method) {
|
||||||
if (this.$store.state.edgeSwipe)
|
if (this.$store.state.edgeS)
|
||||||
if (direction == 1) method ? method(0) : this.$navigateBack()
|
if (direction == 1) method ? method(0) : this.$navigateBack()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,16 +21,12 @@ const wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, 'Timers')
|
||||||
const sdkv = parseInt(Device.sdkVersion)
|
const sdkv = parseInt(Device.sdkVersion)
|
||||||
|
|
||||||
export function hasAccelerometer() {
|
export function hasAccelerometer() {
|
||||||
// let ctx = Utils.ad.getApplicationContext()
|
return ctx
|
||||||
let sensorManager = ctx.getSystemService(
|
.getSystemService(android.content.Context.SENSOR_SERVICE)
|
||||||
android.content.Context.SENSOR_SERVICE
|
.getDefaultSensor(android.hardware.Sensor.TYPE_ACCELEROMETER)
|
||||||
)
|
|
||||||
return sensorManager.getDefaultSensor(
|
|
||||||
android.hardware.Sensor.TYPE_ACCELEROMETER
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
export function vibrate(duration) {
|
export function vibrate(duration) {
|
||||||
let vibratorService = Application.android.context.getSystemService(
|
let vibratorService = ctx.getSystemService(
|
||||||
android.content.Context.VIBRATOR_SERVICE
|
android.content.Context.VIBRATOR_SERVICE
|
||||||
)
|
)
|
||||||
if (vibratorService.hasVibrator()) vibratorService.vibrate(duration)
|
if (vibratorService.hasVibrator()) vibratorService.vibrate(duration)
|
||||||
|
@ -83,10 +79,13 @@ export function getRecipePhoto() {
|
||||||
export function copyPhotoToCache(src: string, dest: string) {
|
export function copyPhotoToCache(src: string, dest: string) {
|
||||||
const ContentResolver = Application.android.nativeApp.getContentResolver()
|
const ContentResolver = Application.android.nativeApp.getContentResolver()
|
||||||
const isURI = src.includes('content://')
|
const isURI = src.includes('content://')
|
||||||
|
console.log(src, dest, isURI)
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (isURI) {
|
if (isURI) {
|
||||||
|
const uri = new android.net.Uri.parse(src)
|
||||||
const input = new java.io.BufferedInputStream(
|
const input = new java.io.BufferedInputStream(
|
||||||
ContentResolver.openInputStream(src)
|
ContentResolver.openInputStream(uri)
|
||||||
)
|
)
|
||||||
let size = input.available()
|
let size = input.available()
|
||||||
let buffer = Array.create('byte', size)
|
let buffer = Array.create('byte', size)
|
||||||
|
@ -260,7 +259,6 @@ export class Zip {
|
||||||
// ShareOperations
|
// ShareOperations
|
||||||
|
|
||||||
function share(intent, subject) {
|
function share(intent, subject) {
|
||||||
// const ctx = Application.android.context
|
|
||||||
const shareIntent = android.content.Intent.createChooser(intent, subject)
|
const shareIntent = android.content.Intent.createChooser(intent, subject)
|
||||||
shareIntent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
|
shareIntent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
ctx.startActivity(shareIntent)
|
ctx.startActivity(shareIntent)
|
||||||
|
@ -276,7 +274,6 @@ export function shareText(text, subject) {
|
||||||
share(intent, subject)
|
share(intent, subject)
|
||||||
}
|
}
|
||||||
export function shareImage(image, subject, title) {
|
export function shareImage(image, subject, title) {
|
||||||
// let ctx = Application.android.context
|
|
||||||
const intent = getSendIntent('image/jpeg')
|
const intent = getSendIntent('image/jpeg')
|
||||||
const baos = new java.io.ByteArrayOutputStream()
|
const baos = new java.io.ByteArrayOutputStream()
|
||||||
image.android.compress(android.graphics.Bitmap.CompressFormat.JPEG, 100, baos)
|
image.android.compress(android.graphics.Bitmap.CompressFormat.JPEG, 100, baos)
|
||||||
|
@ -295,7 +292,7 @@ export function shareImage(image, subject, title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function keepScreenOn(n: number) {
|
export function keepScreenOn(n: number) {
|
||||||
let ctx =
|
const ctx =
|
||||||
Application.android.foregroundActivity || Application.android.startActivity
|
Application.android.foregroundActivity || Application.android.startActivity
|
||||||
let window = ctx.getWindow()
|
let window = ctx.getWindow()
|
||||||
let flag = android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
let flag = android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||||
|
@ -327,15 +324,12 @@ export class TimerNotif {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
static clear(nID) {
|
static clear(nID) {
|
||||||
// let ctx = Utils.ad.getApplicationContext()
|
|
||||||
const NotifySrv = ctx.getSystemService(
|
const NotifySrv = ctx.getSystemService(
|
||||||
android.content.Context.NOTIFICATION_SERVICE
|
android.content.Context.NOTIFICATION_SERVICE
|
||||||
)
|
)
|
||||||
// nID ? NotifySrv.cancel(nID) : NotifySrv.cancelAll()
|
|
||||||
NotifySrv.cancel(nID)
|
NotifySrv.cancel(nID)
|
||||||
}
|
}
|
||||||
static getNotification(
|
static getNotification({
|
||||||
{
|
|
||||||
multi,
|
multi,
|
||||||
actions,
|
actions,
|
||||||
bID,
|
bID,
|
||||||
|
@ -346,9 +340,7 @@ export class TimerNotif {
|
||||||
sound,
|
sound,
|
||||||
title,
|
title,
|
||||||
vibrate,
|
vibrate,
|
||||||
}: INotification,
|
}: INotification) {
|
||||||
ctx
|
|
||||||
) {
|
|
||||||
let soundUri: any
|
let soundUri: any
|
||||||
if (sound) soundUri = new android.net.Uri.parse(sound)
|
if (sound) soundUri = new android.net.Uri.parse(sound)
|
||||||
const NotifyMgr = android.app.NotificationManager
|
const NotifyMgr = android.app.NotificationManager
|
||||||
|
@ -458,11 +450,10 @@ export class TimerNotif {
|
||||||
return notification
|
return notification
|
||||||
}
|
}
|
||||||
static show(data: INotification) {
|
static show(data: INotification) {
|
||||||
// const ctx = Utils.ad.getApplicationContext()
|
|
||||||
const NotifySrv = ctx.getSystemService(
|
const NotifySrv = ctx.getSystemService(
|
||||||
android.content.Context.NOTIFICATION_SERVICE
|
android.content.Context.NOTIFICATION_SERVICE
|
||||||
)
|
)
|
||||||
NotifySrv.notify(data.nID, this.getNotification(data, ctx))
|
NotifySrv.notify(data.nID, this.getNotification(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class Printer {
|
export class Printer {
|
||||||
|
@ -501,7 +492,6 @@ export class Printer {
|
||||||
// GetRingtonesList
|
// GetRingtonesList
|
||||||
export function getTones() {
|
export function getTones() {
|
||||||
const RingtoneManager = android.media.RingtoneManager
|
const RingtoneManager = android.media.RingtoneManager
|
||||||
// let ctx = Utils.ad.getApplicationContext()
|
|
||||||
const ringtonesMgr = new RingtoneManager(ctx)
|
const ringtonesMgr = new RingtoneManager(ctx)
|
||||||
ringtonesMgr.setType(RingtoneManager.TYPE_ALARM)
|
ringtonesMgr.setType(RingtoneManager.TYPE_ALARM)
|
||||||
const cursor = ringtonesMgr.getCursor()
|
const cursor = ringtonesMgr.getCursor()
|
||||||
|
@ -557,7 +547,6 @@ export function updateLocale() {
|
||||||
let lang = ApplicationSettings.getString('appLocale', 'none').split('-')
|
let lang = ApplicationSettings.getString('appLocale', 'none').split('-')
|
||||||
const l = lang[0]
|
const l = lang[0]
|
||||||
const c = lang[1]
|
const c = lang[1]
|
||||||
// const ctx = Utils.android.getApplicationContext()
|
|
||||||
const res = ctx.getResources()
|
const res = ctx.getResources()
|
||||||
const config = res.getConfiguration()
|
const config = res.getConfiguration()
|
||||||
if (l !== 'none') {
|
if (l !== 'none') {
|
||||||
|
|
Loading…
Reference in a new issue