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 45 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
10 changes: 7 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,11 @@ 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
flutter pub upgrade

- 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>
4 changes: 2 additions & 2 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -35,7 +35,7 @@ target 'Runner' do
end

post_install do |installer|
installer.pods_project.targets.each do |target|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ComputerOnFire we need to add permission here as well , other wise it will not work in IOS
eg:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      ... # 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.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
        'PERMISSION_LOCATION=1',

      ]

    end
  end
end

6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,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 = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -414,7 +414,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 = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -463,7 +463,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 = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
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