Skip to content

Commit

Permalink
Merge pull request #32 from reedu-reengineering-education/fix/android…
Browse files Browse the repository at this point in the history
…-working

Fix/android working
  • Loading branch information
felixerdy authored Nov 16, 2023
2 parents 0e9fcb6 + e6ab88c commit 7567526
Show file tree
Hide file tree
Showing 33 changed files with 207 additions and 114 deletions.
16 changes: 14 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"extends": ["next", "prettier"],
"rules": {
"react-hooks/exhaustive-deps": "off"
}
"react-hooks/exhaustive-deps": "off",
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
]
},
"plugins": ["unused-imports"]
}
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
applicationId "de.reedu.senseboxbike"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 4
versionCode 5
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
Expand Down
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
implementation project(':capacitor-community-bluetooth-le')
implementation project(':capacitor-app')
implementation project(':capacitor-geolocation')
implementation project(':capacitor-haptics')
implementation project(':capacitor-preferences')
implementation project(':felixerdy-background-geolocation')

Expand Down
20 changes: 20 additions & 0 deletions android/app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "de.reedu.senseboxbike",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 5,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
11 changes: 9 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name=".MainActivity"
Expand All @@ -32,5 +33,11 @@

<!-- Permissions -->

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

</manifest>
21 changes: 21 additions & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,25 @@
<string name="title_activity_main">senseBox:Bike</string>
<string name="package_name">de.reedu.senseboxbike</string>
<string name="custom_url_scheme">de.reedu.senseboxbike</string>
<!--
The channel name for the background notification. This will be visible
when the user presses & holds the notification. It defaults to
"Background Tracking".
-->
<string name="capacitor_background_geolocation_notification_channel_name">
Background Tracking
</string>

<!--
The icon to use for the background notification. Note the absence of a
leading "@". It defaults to "mipmap/ic_launcher", the app's launch icon.
If a raster image is used to generate the icon (as opposed to a vector
image), it must have a transparent background. To make sure your image
is compatible, select "Notification Icons" as the Icon Type when
creating the image asset in Android Studio.
-->
<string name="capacitor_background_geolocation_notification_icon">
drawable/ic_tracking
</string>
</resources>
1 change: 1 addition & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorSurface">@color/design_default_color_surface</item>
</style>

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
Expand Down
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/
include ':capacitor-geolocation'
project(':capacitor-geolocation').projectDir = new File('../node_modules/@capacitor/geolocation/android')

include ':capacitor-haptics'
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')

include ':capacitor-preferences'
project(':capacitor-preferences').projectDir = new File('../node_modules/@capacitor/preferences/android')

Expand Down
6 changes: 4 additions & 2 deletions ios/App/App/capacitor.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"appId": "de.reedu.sensebox-bike",
"appId": "de.reedu.senseboxbike",
"appName": "senseBox:Bike",
"webDir": "out",
"server": {}
"server": {
"url": "http://192.168.2.135:3000"
}
}
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def capacitor_pods
pod 'CapacitorCommunityBluetoothLe', :path => '../../node_modules/@capacitor-community/bluetooth-le'
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorGeolocation', :path => '../../node_modules/@capacitor/geolocation'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
pod 'CapacitorPreferences', :path => '../../node_modules/@capacitor/preferences'
pod 'FelixerdyBackgroundGeolocation', :path => '../../node_modules/@felixerdy/background-geolocation'
end
Expand Down
8 changes: 7 additions & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ PODS:
- CapacitorCordova (5.5.1)
- CapacitorGeolocation (5.0.6):
- Capacitor
- CapacitorHaptics (5.0.6):
- Capacitor
- CapacitorPreferences (5.0.6):
- Capacitor
- FelixerdyBackgroundGeolocation (0.0.1):
Expand All @@ -19,6 +21,7 @@ DEPENDENCIES:
- "CapacitorCommunityBluetoothLe (from `../../node_modules/@capacitor-community/bluetooth-le`)"
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
- "CapacitorGeolocation (from `../../node_modules/@capacitor/geolocation`)"
- "CapacitorHaptics (from `../../node_modules/@capacitor/haptics`)"
- "CapacitorPreferences (from `../../node_modules/@capacitor/preferences`)"
- "FelixerdyBackgroundGeolocation (from `../../node_modules/@felixerdy/background-geolocation`)"

Expand All @@ -33,6 +36,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor/ios"
CapacitorGeolocation:
:path: "../../node_modules/@capacitor/geolocation"
CapacitorHaptics:
:path: "../../node_modules/@capacitor/haptics"
CapacitorPreferences:
:path: "../../node_modules/@capacitor/preferences"
FelixerdyBackgroundGeolocation:
Expand All @@ -44,9 +49,10 @@ SPEC CHECKSUMS:
CapacitorCommunityBluetoothLe: 86ca83c89199336039bad94f45f8363114ae1464
CapacitorCordova: e128cc7688c070ca0bfa439898a5f609da8dbcfe
CapacitorGeolocation: 7be5f77abc205c0efe319fff8587a7183e7b0240
CapacitorHaptics: 1fffc1217c7e64a472d7845be50fb0c2f7d4204c
CapacitorPreferences: f03954bcb0ff09c792909e46bff88e3183c16b10
FelixerdyBackgroundGeolocation: 1e6a92a836b58a62b20e0eb6b78bff201265deb8

PODFILE CHECKSUM: cd5890a32fa9a1bf24ccec4e54b55f6d47a564c8
PODFILE CHECKSUM: bba8950299207db0030e4a5579a05b0a869d2434

COCOAPODS: 1.14.0
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"@capacitor/app": "^5.0.6",
"@capacitor/core": "^5.5.1",
"@capacitor/geolocation": "^5.0.6",
"@capacitor/haptics": "^5.0.6",
"@capacitor/ios": "^5.5.1",
"@capacitor/preferences": "^5.0.6",
"@felixerdy/background-geolocation": "1.2.16",
"@felixerdy/background-geolocation": "1.2.17",
"@heroicons/react": "^2.0.18",
"@hookform/resolvers": "^3.3.1",
"@radix-ui/react-dialog": "^1.0.4",
Expand All @@ -34,19 +35,19 @@
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-toggle": "^1.0.3",
"@react-spring/web": "^9.7.3",
"@tremor/react": "^3.11.0",
"@tremor/react": "^3.11.1",
"@turf/circle": "^6.5.0",
"@turf/helpers": "^6.5.0",
"autoprefixer": "10.4.16",
"axios": "^1.6.1",
"axios": "^1.6.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"eslint": "8.53.0",
"eslint-config-next": "14.0.2",
"geist": "^1.1.0",
"lodash.debounce": "^4.0.8",
"lucide-react": "^0.292.0",
"maplibre-gl": "^3.6.0",
"maplibre-gl": "^3.6.1",
"next": "14.0.2",
"next-themes": "^0.2.1",
"postcss": "8.4.31",
Expand All @@ -71,6 +72,7 @@
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"husky": "^8.0.3",
"prettier": "^3.1.0",
"prettier-plugin-tailwindcss": "^0.5.7",
Expand Down
10 changes: 6 additions & 4 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export const viewport: Viewport = {
}

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
title: 'senseBox:bike',
}

export default function RootLayout({
Expand All @@ -27,10 +26,13 @@ export default function RootLayout({
}) {
return (
<html lang="en" className="h-full w-full" suppressHydrationWarning>
<body className={cn(GeistMono.className, '!h-full w-full')}>
<body className={cn(GeistMono.className, '!h-full w-full antialiased')}>
<AuthChecker />
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<div className="flex h-full max-h-full w-full flex-col px-safe pt-safe landscape:px-0">
<div
className="flex h-full max-h-full w-full flex-col px-safe pt-safe landscape:px-0"
vaul-data-wrapper=""
>
<header>
<TopBar />
</header>
Expand Down
25 changes: 7 additions & 18 deletions src/components/Device/SettingsDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
'use client'
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '@/components/ui/dialog'

import { zodResolver } from '@hookform/resolvers/zod'
import {
Cog,
ExternalLinkIcon,
Settings2Icon,
SettingsIcon,
UserCog2,
} from 'lucide-react'
import { Cog, ExternalLinkIcon } from 'lucide-react'
import { useForm } from 'react-hook-form'
import * as z from 'zod'
import {
Expand All @@ -31,7 +18,6 @@ import { useSettingsStore } from '@/lib/store/useSettingsStore'
import { Button } from '../ui/button'
import { DialogClose } from '@radix-ui/react-dialog'
import useSenseBox, { BackgroundGeolocation } from '@/lib/useSenseBox'
import { numbersToDataView } from '@capacitor-community/bluetooth-le'
import { Drawer } from 'vaul'
import { useEffect, useState } from 'react'

Expand Down Expand Up @@ -83,9 +69,12 @@ export default function SettingsDrawer() {
<Drawer.Root open={open} onClose={() => setOpen(false)}>
<Drawer.Trigger
onClick={() => setOpen(true)}
className="focus:outline-none"
className="h-full focus:outline-none"
asChild
>
<Cog className="w-6" />
<div className="h-full w-6">
<Cog />
</div>
</Drawer.Trigger>
<Drawer.Portal>
<Drawer.Overlay className="fixed inset-0 z-20 bg-black/60" />
Expand Down
1 change: 0 additions & 1 deletion src/components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { MapProps, MapRef, Map as ReactMap } from 'react-map-gl/maplibre'
import 'maplibre-gl/dist/maplibre-gl.css'
import { forwardRef } from 'react'
import { useTheme } from 'next-themes'
import { useThemeDetector } from '@/lib/useThemeDetector'

const Map = forwardRef<MapRef, MapProps>(
Expand Down
27 changes: 11 additions & 16 deletions src/components/Map/MeasurementsGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { useAuthStore } from '@/lib/store/useAuthStore'
import { useUIStore } from '@/lib/store/useUIStore'
import useSenseBox from '@/lib/useSenseBox'
import { AreaChart, AreaChartProps } from '@tremor/react'
import AnimatedNumber from '../ui/animated-number'
import { Button } from '../ui/button'
import useUploadToOpenSenseMap from '@/lib/useUploadToOpenSenseMap'
import { cn } from '@/lib/utils'
import { SparkAreaChart, SparkAreaChartProps } from '@tremor/react'
import {
Bluetooth,
BluetoothOff,
Expand All @@ -11,12 +13,10 @@ import {
UploadCloud,
UserCog2,
} from 'lucide-react'
import { useAuthStore } from '@/lib/store/useAuthStore'
import useUploadToOpenSenseMap from '@/lib/useUploadToOpenSenseMap'
import { useEffect, useState } from 'react'
import { cn } from '@/lib/utils'
import { useUIStore } from '@/lib/store/useUIStore'
import colors from 'tailwindcss/colors'
import AnimatedNumber from '../ui/animated-number'
import { Button } from '../ui/button'

export default function MeasurementsGrid() {
const { values: allValues, connect, isConnected, disconnect } = useSenseBox()
Expand Down Expand Up @@ -222,7 +222,7 @@ function GridItem({
value: number | (number | undefined)[] | undefined
labels?: string[]
unit: string
chartProps: AreaChartProps
chartProps: SparkAreaChartProps
decimals?: number
}) {
const [selectedValue, setSelectedValue] = useState<number>()
Expand Down Expand Up @@ -253,7 +253,7 @@ function GridItem({

return (
<div
className="relative flex min-w-[33%] max-w-[50%] flex-1 flex-col justify-between overflow-hidden rounded-md bg-muted/25 px-4 py-3"
className="relative flex min-w-[33%] max-w-[50%] flex-1 flex-col justify-between overflow-hidden rounded-md bg-muted/40 px-4 py-3"
onClick={() => {
if (labelIndex !== undefined && labels && labels.length > 0) {
setLabelIndex((labelIndex + 1) % labels!.length)
Expand All @@ -262,14 +262,9 @@ function GridItem({
>
{chartProps && chartProps.data.length > 2 && (
<div className="pointer-events-none absolute -left-6 -right-6 top-0 h-full">
<AreaChart
className="h-full w-full opacity-50"
showXAxis={false}
showYAxis={false}
showLegend={false}
showGridLines={false}
<SparkAreaChart
className="h-full w-full opacity-30"
curveType="monotone"
showTooltip={false}
colors={['slate']}
{...chartProps}
/>
Expand Down
1 change: 0 additions & 1 deletion src/components/Map/MeasurementsOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { SpaceIcon } from 'lucide-react'
import { Card, CardContent } from '../ui/card'
import RecordButton from './RecordButton'
import PreviewModal from '../Device/PreviewModal'
import { senseBoxDataRecord } from '@/lib/store/useSenseBoxValuesStore'

export default function MeasurementsOverview({
Expand Down
8 changes: 1 addition & 7 deletions src/components/Wizard/ConnectionSelection.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
'use client'

import { Button } from '../ui/button'
import Logo from '../../../public/bike.png'
import Image from 'next/image'
import Link from 'next/link'
import { ArrowLeft, ArrowRight, CheckCircle, CircleIcon } from 'lucide-react'
import useSenseBox from '@/lib/useSenseBox'
import { cn } from '@/lib/utils'
import PreviewModal from '../Device/PreviewModal'
import { ArrowLeft, CheckCircle } from 'lucide-react'
import WizardSlide from './WizardSlide'
import { useAuthStore } from '@/lib/store/useAuthStore'
import { useSwiper } from 'swiper/react'
Expand Down
Loading

0 comments on commit 7567526

Please sign in to comment.