Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ask location permission (fixes #43, #45, #48, #51) #46

Merged
merged 55 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
48160cd
add permission_handler to pubspec.yaml
ComputerOnFire Oct 30, 2021
17102f7
add sdk version to gradle
ComputerOnFire Oct 30, 2021
be06e89
implement permission_handler
ComputerOnFire Oct 30, 2021
9769afd
move permission check to appStart() within BluetoothCubit
ComputerOnFire Oct 30, 2021
e0c0c7d
add PermissionsNotGranted state
ComputerOnFire Oct 30, 2021
e07184f
remove permission check from landing page
ComputerOnFire Oct 30, 2021
6d2bdcd
remove android sdk settings from wrong build.gradle, update compileSd…
ComputerOnFire Oct 30, 2021
7c1da3e
remove android sdk settings from wrong build.gradle, update compileSd…
ComputerOnFire Oct 30, 2021
8698349
remove fluttertoast for now
ComputerOnFire Oct 30, 2021
ed1efa7
remove dart.html import
ComputerOnFire Oct 30, 2021
c297248
cleanup of imports
ComputerOnFire Oct 30, 2021
65b27d3
downgrade permission_handler to 8.2.0
ComputerOnFire Oct 30, 2021
d375e79
downgrade permission_handler to 8.1.6
ComputerOnFire Oct 30, 2021
d1c1f13
formatting
ComputerOnFire Oct 30, 2021
e1b69d1
formatting
ComputerOnFire Oct 30, 2021
44b74ad
refactor permissions requests, add requests for android 12 permissions
ComputerOnFire Nov 4, 2021
164687f
fix location permission
ComputerOnFire Nov 4, 2021
7f92a19
change permissions back to target SDK 30 / Android 11
ComputerOnFire Nov 4, 2021
fbc4218
change permissions back to target SDK 30 / Android 11
ComputerOnFire Nov 4, 2021
f40e790
upgrade flutter packages
ComputerOnFire Nov 4, 2021
e511751
cleanup
ComputerOnFire Nov 4, 2021
08c2439
Update main.yml
ComputerOnFire Nov 4, 2021
85aa3aa
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 4, 2021
dda8abc
Merge branch 'permissions12' of https://github.com/treehouses/flutter…
ComputerOnFire Nov 4, 2021
623d2c4
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 4, 2021
931a5e3
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 4, 2021
317692e
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
1c0d648
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
fa1f05b
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
6b18372
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
860238a
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
7e96423
set ios version back to 9.0
ComputerOnFire Nov 6, 2021
52553d3
set ios version back to 9.0
ComputerOnFire Nov 6, 2021
f56f89e
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
bebe4d4
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
d7f6e71
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
84c8644
set ios version to minimum allowed by CoreBluetooth (10.0)
ComputerOnFire Nov 6, 2021
1a7c9b2
Update main.yml
ComputerOnFire Nov 6, 2021
ec3924f
Update main.yml
ComputerOnFire Nov 6, 2021
f3c978f
Update Podfile
ComputerOnFire Nov 6, 2021
7361d74
make iOS build process match Android build process
ComputerOnFire Nov 6, 2021
c866122
Merge branch 'permissions12' into permissions (target SDK 31 / Androi…
ComputerOnFire Nov 6, 2021
0782de8
Merge branch 'permissions12' into permissions (target SDK 31 / Androi…
ComputerOnFire Nov 6, 2021
30aedae
refactor
ComputerOnFire Nov 6, 2021
8c504ed
refactor
ComputerOnFire Nov 6, 2021
9ef65ca
update podfile for ios permissions
ComputerOnFire Nov 11, 2021
71d9198
update podfile for ios permissions
ComputerOnFire Nov 11, 2021
9917339
update podfile for ios permissions
ComputerOnFire Nov 11, 2021
26aa68f
update pod
rrijal53 Nov 11, 2021
e804cc9
Merge branch 'permissions' of github.com:treehouses/flutter-ble-termi…
rrijal53 Nov 11, 2021
3baee53
fix pod file
rrijal53 Nov 11, 2021
4f2d481
modified xcodeproj
rrijal53 Nov 11, 2021
525440b
updated pod
rrijal53 Nov 11, 2021
c933c69
updated actions
rrijal53 Nov 11, 2021
0f5f934
fix build issue
rrijal53 Nov 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
flutter-version: '2.2.0'
flutter-version: '2.5.2'

- run: |
flutter clean
Expand All @@ -39,7 +39,13 @@ jobs:
- uses: subosito/flutter-action@v1
with:
channel: 'stable' # 'dev', 'alpha', default to: 'stable'
flutter-version: '2.2.0' # you can also specify exact version of flutter
flutter-version: '2.5.2' # you can also specify exact version of flutter

- run: |
flutter clean
flutter pub get
flutter build ios --release --no-codesign
cd ios
pod install


- run: flutter build ios --release --no-codesign
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -36,7 +36,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.treehouses.remoteii"
minSdkVersion 19
targetSdkVersion 30
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
13 changes: 9 additions & 4 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.treehouses.remoteble.treehousesble">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:label="Treehouses RemoteII"
android:icon="@mipmap/launcher_icon">

<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ subprojects {

task clean(type: Delete) {
delete rootProject.buildDir
}
}
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>10.0</string>
</dict>
</plist>
63 changes: 60 additions & 3 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -37,5 +36,63 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
# Here are some configurations automatically generated by flutter

# You can enable the permissions needed here. For example to enable camera
# permission, just remove the `#` character in front so it looks like this:
#
# ## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=1'
#
# Preprocessor definitions can be found in: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

## dart: PermissionGroup.calendar
# 'PERMISSION_EVENTS=1',

## dart: PermissionGroup.reminders
# 'PERMISSION_REMINDERS=1',

## dart: PermissionGroup.contacts
# 'PERMISSION_CONTACTS=1',

## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=1',

## dart: PermissionGroup.microphone
# 'PERMISSION_MICROPHONE=1',

## dart: PermissionGroup.speech
# 'PERMISSION_SPEECH_RECOGNIZER=1',

## dart: PermissionGroup.photos
# 'PERMISSION_PHOTOS=1',

## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',

## dart: PermissionGroup.notification
# 'PERMISSION_NOTIFICATIONS=1',

## dart: PermissionGroup.mediaLibrary
# 'PERMISSION_MEDIA_LIBRARY=1',

## dart: PermissionGroup.sensors
# 'PERMISSION_SENSORS=1',

## dart: PermissionGroup.bluetooth
# 'PERMISSION_BLUETOOTH=1',

## dart: PermissionGroup.appTrackingTransparency
# 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

## dart: PermissionGroup.criticalAlerts
# 'PERMISSION_CRITICAL_ALERTS=1'
]

end
end
end
end
16 changes: 11 additions & 5 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PODS:
- Flutter
- path_provider (0.0.1):
- Flutter
- "permission_handler (5.1.0+2)":
- Flutter
- Protobuf (3.11.4)
- shared_preferences (0.0.1):
- Flutter
Expand All @@ -21,6 +23,7 @@ DEPENDENCIES:
- flutter_blue (from `.symlinks/plugins/flutter_blue/ios`)
- package_info (from `.symlinks/plugins/package_info/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)

Expand All @@ -37,20 +40,23 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info/ios"
path_provider:
:path: ".symlinks/plugins/path_provider/ios"
permission_handler:
:path: ".symlinks/plugins/permission_handler/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"

SPEC CHECKSUMS:
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
flutter_blue: eeb381dc4727a0954dede73515f683865494b370
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
path_provider: d1e9807085df1f9cc9318206cd649dc0b76be3de
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0
Protobuf: 176220c526ad8bd09ab1fb40a978eac3fef665f7
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
shared_preferences: 5033afbb22d372e15aff8ff766df9021b845f273
url_launcher: b6e016d912f04be9f5bf6e8e82dc599b7ba59649

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: d4807ef77006891d298ba2f893031d4f0cd35075

COCOAPODS: 1.10.2
30 changes: 21 additions & 9 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -121,7 +121,6 @@
0790B6FC0CD83AFFF907B93D /* Pods-Runner.release.xcconfig */,
6CCBBC19E381606D430444C9 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -340,7 +339,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -358,7 +357,11 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = io.treehouses.remoteii;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -414,7 +417,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -463,11 +466,12 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -482,7 +486,11 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = io.treehouses.remoteii;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -501,7 +509,11 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = io.treehouses.remoteii;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down
8 changes: 0 additions & 8 deletions ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

This file was deleted.

This file was deleted.

20 changes: 16 additions & 4 deletions lib/common/bloc/bluetooth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';

import 'package:bloc/bloc.dart';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:treehousesble/app/app.dart';
import 'package:treehousesble/common/bloc/bluetooth_state.dart';
import 'package:treehousesble/common/constants/app_constants.dart';
Expand All @@ -18,10 +19,21 @@ class BluetoothCubit extends Cubit<DataState> {

appStart() async {
final bool firstTimeAppOpen = await SharedPref.getFirstTimeAppOpen();
if (firstTimeAppOpen) {
emit(FirstTimeAppOpen());
} else {
emit(NotFirstTimeAppOpen());
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
Permission.bluetoothScan,
Permission.bluetoothConnect,
].request();
if(statuses[Permission.location] == PermissionStatus.granted
&& statuses[Permission.bluetoothScan] == PermissionStatus.granted
&& statuses[Permission.bluetoothConnect] == PermissionStatus.granted){
if (firstTimeAppOpen) {
emit(FirstTimeAppOpen());
} else {
emit(NotFirstTimeAppOpen());
}
} else{
emit(PermissionsNotGranted());
}
}
List<int> _sendCommand(String command) {
Expand Down
5 changes: 4 additions & 1 deletion lib/common/bloc/bluetooth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ class FirstTimeAppOpen extends DataState {
List<Object> get props => [];
}


class NotFirstTimeAppOpen extends DataState {
@override
List<Object> get props => [];
}

class PermissionsNotGranted extends DataState {
@override
List<Object> get props => [];
}

class StateIniital extends DataState {}

Expand Down
1 change: 0 additions & 1 deletion lib/feature/onboard/ui/screen/landing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:treehousesble/common/bloc/bluetooth_cubit.dart';
import 'package:treehousesble/common/bloc/bluetooth_state.dart';
import 'package:treehousesble/feature/dashboard/screen/dashboard_page.dart';
import 'package:treehousesble/feature/dashboard/screen/search_rpi_screen.dart';

import 'onboard_page.dart';
Expand Down
Loading