Skip to content

Commit

Permalink
Merge branch 'onboarding_routing_sept_2023' into dashboard-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
JGreenlee authored Sep 25, 2023
2 parents 8f5fb89 + 80b4794 commit ab26e18
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 58 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/android-automated-sdk-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ jobs:
- name: Install to a new SDK root
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
printf "Y\nY\nY\nY\nY\n" | bash setup/prereq_android_sdk_install.sh
- name: Verify that all packages are as expected
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
echo "Comparing $ANDROID_SDK_ROOT and $NEW_ANDROID_SDK_ROOT"
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed > /tmp/existing_packages
$NEW_ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed > /tmp/new_packages
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Verify that directory structure is consistent
shell: bash -l -x {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
ls -al $ANDROID_SDK_ROOT
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Ensure that the path is correct and installed programs are runnable
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
echo "About to run the emulator at $ANDROID_SDK_ROOT/emulator/emulator"
Expand All @@ -84,14 +84,14 @@ jobs:
- name: Setup the cordova environment
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
bash setup/setup_android_native.sh
- name: Ensure that the path is correct and the project can be activated
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
source setup/activate_native.sh
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/serve-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ jobs:
echo "ionic version"
npx ionic --version
- name: Run Jest tests
shell: bash -l {0}
run: |
npx jest
# TODO: figure out how to check that a server started correctly
# - name: Try starting it
# run: npx run serve
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Pre-requisites
- or this [supposedly easier to use repo](https://github.com/xcpretty/xcode-install)
- **NOTE**: the basic xcode install on Catalina was messed up for me due to a prior installation of command line tools. [These workarounds helped](https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md).
- git
- Java 11. Tested with [OpenJDK 11 (Temurin) using AdoptOpenJDK](https://adoptopenjdk.net/releases.html).
- Java 17. Tested with [OpenJDK 17 (Temurin) using Adoptium](https://adoptium.net).
- android SDK; install manually or use setup script below. Note that you only need to run this once **per computer**.
```
$ bash setup/prereq_android_sdk_install.sh
Expand Down
15 changes: 15 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"testPathIgnorePatterns": [
"/node_modules/",
"/platforms/",
"/plugins/",
"/lib/",
"/manual_lib/"
],
"transform": {
"^.+\\.(ts|tsx|js|jsx)$": "ts-jest"
},
"moduleNameMapper": {
"^react-native$": "react-native-web"
}
}
6 changes: 5 additions & 1 deletion package.serve.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"setup-serve": "./bin/download_settings_controls.js && ./bin/setup_autodeploy.js",
"serve": "webpack --config webpack.dev.js && concurrently -k \"phonegap --verbose serve\" \"webpack --config webpack.dev.js --watch\"",
"serve-prod": "webpack --config webpack.prod.js && concurrently -k \"phonegap --verbose serve\" \"webpack --config webpack.prod.js --watch\"",
"serve-only": "phonegap --verbose serve"
"serve-only": "phonegap --verbose serve",
"test": "npx jest"
},
"devDependencies": {
"@babel/core": "^7.21.3",
Expand All @@ -33,11 +34,13 @@
"exports-loader": "^4.0.0",
"expose-loader": "^4.1.0",
"file-loader": "^6.2.0",
"jest": "^29.7.0",
"phonegap": "9.0.0+cordova.9.0.0",
"process": "^0.11.10",
"sass": "^1.62.1",
"sass-loader": "^13.3.1",
"style-loader": "^3.3.3",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.2",
"typescript": "^5.0.3",
"url-loader": "^4.1.1",
Expand All @@ -48,6 +51,7 @@
"@react-navigation/native": "^6.1.7",
"@react-navigation/stack": "^6.3.17",
"@shopify/flash-list": "^1.3.1",
"@types/jest": "^29.5.5",
"angular": "1.6.7",
"angular-animate": "1.6.7",
"angular-local-storage": "^0.7.1",
Expand Down
5 changes: 4 additions & 1 deletion setup/android_sdk_packages
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
build-tools;31.0.0
build-tools;32.0.0
build-tools;33.0.2
build-tools;34.0.0
emulator
extras;google;google_play_services
extras;intel;Hardware_Accelerated_Execution_Manager
patcher;v4
platform-tools
platforms;android-30
platforms;android-31
platforms;android-32
platforms;android-33
platforms;android-34
system-images;android-22;google_apis;x86_64
system-images;android-23;google_apis;x86_64
system-images;android-24;google_apis_playstore;x86
Expand All @@ -24,3 +25,5 @@ system-images;android-32;google_apis;x86_64
system-images;android-32;google_apis_playstore;x86_64
system-images;android-33;google_apis;x86_64
system-images;android-33;google_apis_playstore;x86_64
system-images;android-34;google_apis;x86_64
system-images;android-34;google_apis_playstore;x86_64
2 changes: 1 addition & 1 deletion setup/prereq_android_sdk_install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TOOLS_VERSION=9477386
TOOLS_VERSION=10406996
TOOLS_ZIP_FILENAME=commandlinetools-mac-${TOOLS_VERSION}_latest.zip

echo "Installing command line tools from $TOOLS_ZIP_FILENAME"
Expand Down
63 changes: 63 additions & 0 deletions www/__tests__/diaryHelper.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { getFormattedDate, isMultiDay, getFormattedDateAbbr, getFormattedTimeRange, getDetectedModes, getBaseModeByKey, modeColors } from "../js/diary/diaryHelper";

it('returns a formatted date', () => {
expect(getFormattedDate("2023-09-18T00:00:00-07:00")).toBe("Mon September 18, 2023");
expect(getFormattedDate("")).toBeUndefined();
expect(getFormattedDate("2023-09-18T00:00:00-07:00", "2023-09-21T00:00:00-07:00")).toBe("Mon September 18, 2023 - Thu September 21, 2023");
});

it('returns an abbreviated formatted date', () => {
expect(getFormattedDateAbbr("2023-09-18T00:00:00-07:00")).toBe("Mon, Sep 18");
expect(getFormattedDateAbbr("")).toBeUndefined();
expect(getFormattedDateAbbr("2023-09-18T00:00:00-07:00", "2023-09-21T00:00:00-07:00")).toBe("Mon, Sep 18 - Thu, Sep 21");
});

it('returns a human readable time range', () => {
expect(getFormattedTimeRange("2023-09-18T00:00:00-07:00", "2023-09-18T00:00:00-09:20")).toBe("2 hours");
expect(getFormattedTimeRange("2023-09-18T00:00:00-07:00", "2023-09-18T00:00:00-09:30")).toBe("3 hours");
expect(getFormattedTimeRange("", "2023-09-18T00:00:00-09:30")).toBeFalsy();
});

it("returns a Base Mode for a given key", () => {
expect(getBaseModeByKey("WALKING")).toEqual({ name: "WALKING", icon: "walk", color: modeColors.blue });
expect(getBaseModeByKey("MotionTypes.WALKING")).toEqual({ name: "WALKING", icon: "walk", color: modeColors.blue });
expect(getBaseModeByKey("I made this type up")).toEqual({ name: "UNKNOWN", icon: "help", color: modeColors.grey });
});

it('returns true/false is multi day', () => {
expect(isMultiDay("2023-09-18T00:00:00-07:00", "2023-09-19T00:00:00-07:00")).toBeTruthy();
expect(isMultiDay("2023-09-18T00:00:00-07:00", "2023-09-18T00:00:00-09:00")).toBeFalsy();
expect(isMultiDay("", "2023-09-18T00:00:00-09:00")).toBeFalsy();
});

//created a fake trip with relevant sections by examining log statements
let myFakeTrip = {sections: [
{ "sensed_mode_str": "BICYCLING", "distance": 6013.73657416706 },
{ "sensed_mode_str": "WALKING", "distance": 715.3078629361006 }
]};
let myFakeTrip2 = {sections: [
{ "sensed_mode_str": "BICYCLING", "distance": 6013.73657416706 },
{ "sensed_mode_str": "BICYCLING", "distance": 715.3078629361006 }
]};

let myFakeDetectedModes = [
{ mode: "BICYCLING",
icon: "bike",
color: modeColors.green,
pct: 89 },
{ mode: "WALKING",
icon: "walk",
color: modeColors.blue,
pct: 11 }];

let myFakeDetectedModes2 = [
{ mode: "BICYCLING",
icon: "bike",
color: modeColors.green,
pct: 100 }];

it('returns the detected modes, with percentages, for a trip', () => {
expect(getDetectedModes(myFakeTrip)).toEqual(myFakeDetectedModes);
expect(getDetectedModes(myFakeTrip2)).toEqual(myFakeDetectedModes2);
expect(getDetectedModes({})).toEqual([]); // empty trip, no sections, no modes
})
3 changes: 2 additions & 1 deletion www/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@
"name": "Unused apps disabled",
"description": {
"android-disable-lt-12": "On the app settings page, go to 'Permissions' and ensure that the app permissions will not be automatically reset.",
"android-disable-gte-12": "On the app settings page, turn off 'Remove permissions and free up space.'",
"android-disable-12": "On the app settings page, turn off 'Remove permissions and free up space.'",
"android-disable-gte-13": "On the app settings page, turn off 'Pause app activity if unused.'",
"ios": "Please allow."
}
},
Expand Down
7 changes: 5 additions & 2 deletions www/js/appstatus/permissioncheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,11 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
return checkOrFix(ignoreBatteryOptCheck, $window.cordova.plugins.BEMDataCollection.isIgnoreBatteryOptimizations,
$scope.recomputeBackgroundRestrictionStatus, false);
};
var androidUnusedDescTag = "intro.appstatus.unusedapprestrict.description.android-disable-gte-12";
if ($scope.osver < 12) {
var androidUnusedDescTag = "intro.appstatus.unusedapprestrict.description.android-disable-gte-13";
if ($scope.osver == 12) {
androidUnusedDescTag= "intro.appstatus.unusedapprestrict.description.android-disable-12";
}
else if ($scope.osver < 12) {
androidUnusedDescTag= "intro.appstatus.unusedapprestrict.description.android-disable-lt-12";
}
let unusedAppsUnrestrictedCheck = {
Expand Down
19 changes: 7 additions & 12 deletions www/js/control/AppStatusModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const AppStatusModal = ({permitVis, setPermitVis, dialogStyle, settingsScope}) =

const [explainVis, setExplainVis] = useState<boolean>(false);

const [backgroundRestricted, setBackgroundRestricted] = useState<boolean>(false);
const [allowBackgroundInstructions, setAllowBackgroundInstructions] = useState<Array<any>>([]);

const [checkList, setCheckList] = useState([]);
const [explanationList, setExplanationList] = useState<Array<any>>([]);
const [haveSetText, setHaveSetText] = useState<boolean>(false);
Expand Down Expand Up @@ -272,8 +269,11 @@ const AppStatusModal = ({permitVis, setPermitVis, dialogStyle, settingsScope}) =
return checkOrFix(ignoreBatteryOptCheck, window['cordova'].plugins.BEMDataCollection.isIgnoreBatteryOptimizations,
false);
};
var androidUnusedDescTag = "intro.appstatus.unusedapprestrict.description.android-disable-gte-12";
if (osver < 12) {
var androidUnusedDescTag = "intro.appstatus.unusedapprestrict.description.android-disable-gte-13";
if (osver == 12) {
androidUnusedDescTag= "intro.appstatus.unusedapprestrict.description.android-disable-12";
}
else if (osver < 12) {
androidUnusedDescTag= "intro.appstatus.unusedapprestrict.description.android-disable-lt-12";
}
let unusedAppsUnrestrictedCheck = {
Expand Down Expand Up @@ -313,13 +313,8 @@ const AppStatusModal = ({permitVis, setPermitVis, dialogStyle, settingsScope}) =

setExplanationList(tempExplanations);

//waiting on samsung feedback, need more information
setBackgroundRestricted(false);
if(window['device'].manufacturer.toLowerCase() == "samsung") {
setBackgroundRestricted(true);
setAllowBackgroundInstructions(t("intro.allow_background.samsung"));
}

//TODO - update samsung handling based on feedback

console.log("Explanation = "+explanationList);
}

Expand Down
3 changes: 1 addition & 2 deletions www/js/control/DataDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DatePickerModal } from 'react-native-paper-dates';
import { useTranslation } from "react-i18next";
import { getAngularService } from "../angular-react-helper";

const DataDatePicker = ({date, setDate, open, setOpen}) => {
const DataDatePicker = ({date, setDate, open, setOpen, minDate}) => {
const { t, i18n } = useTranslation(); //able to pull lang from this
const ControlHelper = getAngularService("ControlHelper");

Expand All @@ -23,7 +23,6 @@ const DataDatePicker = ({date, setDate, open, setOpen}) => {
[setOpen, setDate]
);

const minDate = new Date(2015, 1, 1);
const maxDate = new Date();

return (
Expand Down
8 changes: 2 additions & 6 deletions www/js/control/PopOpCode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next";
import QrCode from "../components/QrCode";
import AlertBar from "./AlertBar";

const PopOpCode = ({visibilityValue, tokenURL, action, setVis}) => {
const PopOpCode = ({visibilityValue, tokenURL, action, setVis, dialogStyle}) => {
const { t } = useTranslation();
const { colors } = useTheme();

Expand All @@ -31,7 +31,7 @@ const PopOpCode = ({visibilityValue, tokenURL, action, setVis}) => {
transparent={true}>
<Dialog visible={visibilityValue}
onDismiss={() => setVis(false)}
style={styles.dialog(colors.elevation.level3)}>
style={dialogStyle}>
<Dialog.Title>{t("general-settings.qrcode")}</Dialog.Title>
<Dialog.Content style={styles.content}>
<Text style={styles.text}>{t("general-settings.qrcode-share-title")}</Text>
Expand All @@ -51,10 +51,6 @@ const PopOpCode = ({visibilityValue, tokenURL, action, setVis}) => {
)
}
const styles = StyleSheet.create({
dialog: (surfaceColor) => ({
backgroundColor: surfaceColor,
margin: 1,
}),
title:
{
alignItems: 'center',
Expand Down
15 changes: 11 additions & 4 deletions www/js/control/ProfileSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ProfileSettings = () => {
const [syncSettings, setSyncSettings] = useState({});
const [cacheResult, setCacheResult] = useState("");
const [connectSettings, setConnectSettings] = useState({});
const [appVersion, setAppVersion] = useState({});
const [appVersion, setAppVersion] = useState("");
const [uiConfig, setUiConfig] = useState({});
const [consentDoc, setConsentDoc] = useState({});
const [dumpDate, setDumpDate] = useState(new Date());
Expand Down Expand Up @@ -111,6 +111,11 @@ const ProfileSettings = () => {
setAppVersion(ClientStats.getAppVersion());
}

//previously not loaded on regular refresh, this ensures it stays caught up
useEffect(() => {
refreshNotificationSettings();
}, [uiConfig])

const whenReady = function(newAppConfig){
var tempUiConfig = newAppConfig;

Expand Down Expand Up @@ -507,8 +512,8 @@ const ProfileSettings = () => {
<ControlDataTable controlData={collectSettings.config}></ControlDataTable>
<SettingRow textKey="control.sync" iconName="pencil" action={editSyncConfig}></SettingRow>
<ControlDataTable controlData={syncSettings.show_config}></ControlDataTable>
<SettingRow textKey="control.app-version" iconName="application" action={()=>console.log("")} desc={appVersion}></SettingRow>
</ExpansionSection>
<SettingRow textKey="control.app-version" iconName="application" action={()=>console.log("")} desc={appVersion}></SettingRow>
</ScrollView>

{/* menu for "nuke data" */}
Expand Down Expand Up @@ -594,7 +599,7 @@ const ProfileSettings = () => {
</Modal>

{/* opcode viewing popup */}
<PopOpCode visibilityValue = {opCodeVis} setVis = {setOpCodeVis} tokenURL = {"emission://login_token?token="+authSettings.opcode} action={shareQR}></PopOpCode>
<PopOpCode visibilityValue = {opCodeVis} setVis = {setOpCodeVis} tokenURL = {"emission://login_token?token="+authSettings.opcode} action={shareQR} dialogStyle={styles.dialog(colors.elevation.level3)}></PopOpCode>

{/* {view permissions} */}
<AppStatusModal permitVis={permitVis} setPermitVis={setPermitVis} settingsScope={settingsScope} dialogStyle={styles.dialog(colors.elevation.level3)}></AppStatusModal>
Expand Down Expand Up @@ -683,7 +688,9 @@ const ProfileSettings = () => {
</Dialog>
</Modal>

<DataDatePicker date={dumpDate} setDate={setDumpDate} open={dateDumpVis} setOpen={setDateDumpVis}></DataDatePicker>
<DataDatePicker date={dumpDate} setDate={setDumpDate} open={dateDumpVis} setOpen={setDateDumpVis}
minDate={new Date(appConfig?.intro?.start_year, appConfig?.intro?.start_month - 1, 1)}>
</DataDatePicker>

<AlertBar visible={dataPushedVis} setVisible={setDataPushedVis} messageKey='all data pushed!'></AlertBar>
<AlertBar visible={invalidateSuccessVis} setVisible={setInvalidateSuccessVis} messageKey='success -> ' messageAddition={cacheResult}></AlertBar>
Expand Down
2 changes: 1 addition & 1 deletion www/js/diary/diaryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type BaseModeKey = keyof typeof BaseModes;
export function getBaseModeByKey(motionName: BaseModeKey | MotionTypeKey | `MotionTypes.${MotionTypeKey}`) {
let key = ('' + motionName).toUpperCase();
key = key.split(".").pop(); // if "MotionTypes.WALKING", then just take "WALKING"
return BaseModes[motionName] || BaseModes.UNKNOWN;
return BaseModes[key] || BaseModes.UNKNOWN;
}

export function getBaseModeOfLabeledTrip(trip, labelOptions) {
Expand Down
Loading

0 comments on commit ab26e18

Please sign in to comment.