Skip to content

Commit

Permalink
feat: test user permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
lighttigerXIV committed Oct 11, 2023
1 parent dbf913b commit ead2da0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
60 changes: 33 additions & 27 deletions src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { preferences } from "user-settings";
import * as simpleSettings from "./simple/device-settings";
import { getFlavor } from "./colors";
import { applySettings, hideElement, showElement, InfoSection } from "./settings";

import { me as appbit } from "appbit"

clock.granularity = "seconds";

Expand Down Expand Up @@ -82,13 +82,17 @@ document.getElementById("displayButton").addEventListener("click", (e) => {
// Heart Rate
// ===========================

const heartRateMonitor = new HeartRateSensor({ frequency: 1 });
if (appbit.permissions.granted("access_activity")) {
const heartRateMonitor = new HeartRateSensor({ frequency: 1 });

heartRateMonitor.addEventListener("reading", () => {
heartText.text = heartRateMonitor.heartRate;
});
heartRateMonitor.addEventListener("reading", () => {
heartText.text = heartRateMonitor.heartRate;
});

heartRateMonitor.start();
heartRateMonitor.start();
} else {
heartText.text = "-- "
}



Expand Down Expand Up @@ -123,8 +127,10 @@ clock.ontick = (event) => {
minutesText.text = minutes;
setDate();

if (todayActivity) {
if (todayActivity && appbit.permissions.granted("access_heart_rate")) {
stepsText.text = todayActivity.adjusted.steps;
} else {
stepsText.text = "-- ";
}
}

Expand Down Expand Up @@ -165,25 +171,25 @@ function settingsCallback(data) {
return;
}

applySettings(
getFlavor(data.flavor),
data.latteAccent,
data.frappeAccent,
data.macchiatoAccent,
data.mochaAccent,
data.oledAccent,
data.showClockDivider,
data.tintHours,
data.tintMinutes,
);

useAmericanDate = data.useAmericanDate;

if(useAmericanDate === undefined){
useAmericanDate = false;
}
setDate();
applySettings(
getFlavor(data.flavor),
data.latteAccent,
data.frappeAccent,
data.macchiatoAccent,
data.mochaAccent,
data.oledAccent,
data.showClockDivider,
data.tintHours,
data.tintMinutes,
);

useAmericanDate = data.useAmericanDate;

if (useAmericanDate === undefined) {
useAmericanDate = false;
}

setDate();

}
simpleSettings.initialize(settingsCallback);
Binary file modified src/build/app.fba
Binary file not shown.
8 changes: 4 additions & 4 deletions src/resources/index.view
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<text id="minutes" />

<image href="icons/mocha-calendar.png" id="dateIcon" class="infoIcon" x="28%" />
<text id="dateText" class="infoText" x="40%">XX-XX-XXXX</text>
<text id="dateText" class="infoText" x="40%">-- </text>

<image href="icons/mocha-shoe-prints.png" id="stepsIcon" class="infoIcon" x="38%" />
<text id="stepsText" class="infoText" x="50%" >XXXXX</text>
<text id="stepsText" class="infoText" x="50%" >-- </text>

<image href="icons/mocha-heart.png" id="heartIcon" class="infoIcon" x="38%" />
<text id="heartText" class="infoText" x="50%" >XXX</text>
<text id="heartText" class="infoText" x="50%" >-- </text>

<image href="icons/mocha-battery.png" id="batteryIcon" class="infoIcon" x="38%"/>
<text id="batteryText" class="infoText" x="50%">XXXX</text>
<text id="batteryText" class="infoText" x="50%">-- </text>


<rect id="displayButton" width="100%" height="100%" pointer-events="visible" opacity="0" />
Expand Down

0 comments on commit ead2da0

Please sign in to comment.