Skip to content

Commit

Permalink
Remove unused permissions (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
shareef-dweikat authored Jun 17, 2022
1 parent 9be335e commit e34621a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 80 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.dart_wormhole_gui"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
3 changes: 0 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
package="com.example.dart_wormhole_gui">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.STORAGE_INTERNAL" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

<application
android:label="Destiny"
Expand Down
8 changes: 4 additions & 4 deletions lib/constants/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ const String ANDROID_DOWNLOADS_FOLDER_PATH = '/storage/emulated/0/Download';

const String WINDOW_TITLE = "Destiny";

const String ERR_WRONG_CODE_RECEIVER = """Oops..
If you’re sure this is the right code: Either the sender is no longer connected, or the code was already used.
const String ERR_WRONG_CODE_RECEIVER = """Oops..\n
If you’re sure this is the right code: Either the sender is no longer connected, or the code was already used.\n
Please ask the sender for a new code and for them to stay connected until you get the file.""";

const String ERR_WRONG_CODE_SENDER = """Oops..
The receiver has entered the wrong code.
const String ERR_WRONG_CODE_SENDER = """Oops..\n
The receiver has entered the wrong code.\n
Please try sending the file again""";

const String ERR_INTERRUPTION_CANCELLATION_RECEIVER =
Expand Down
45 changes: 19 additions & 26 deletions lib/views/desktop/send/widgets/DTErrorUI.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:dart_wormhole_gui/config/theme/colors.dart';
import 'package:dart_wormhole_gui/views/desktop/widgets/DTButtonWithBackground.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../shared/util.dart';

void doNothing() {
print("Doing nothing with error UI button");
Expand Down Expand Up @@ -35,31 +36,23 @@ class DTErrorUI extends StatelessWidget {
)
: null,
padding: EdgeInsets.only(left: 8.0.w, right: 8.0.w, top: paddingTop),
child: Column(
children: [
Text(
text,
style: Theme.of(context).textTheme.headline1,
textAlign: TextAlign.center,
),
SizedBox(
height: 10.0.h,
),
Text(
subText,
style: Theme.of(context).textTheme.headline1,
textAlign: TextAlign.center,
),
SizedBox(
height: 100.0.h,
),
DTButtonWithBackground(
onPressed: onPressed,
title: buttonTitle,
width: 150.0,
disabled: false,
)
],
));
child: Column(children: [
...convertErrorMessageIntoParagraphs(text,
Theme.of(context).textTheme.headline1, TextAlign.center, context),
Text(
subText,
style: Theme.of(context).textTheme.headline1,
textAlign: TextAlign.center,
),
SizedBox(
height: 100.0.h,
),
DTButtonWithBackground(
onPressed: onPressed,
title: buttonTitle,
width: 150.0,
disabled: false,
)
]));
}
}
2 changes: 1 addition & 1 deletion lib/views/mobile/receive/receive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ReceiveScreen extends StatelessWidget {
return Consumer<ReceiveSharedState>(builder: (context, state, _) {
return ErrorUI(
errorTitle: state.errorTitle,
errorMessage: state.errorMessage,
errorMessage: state.errorMessage ?? "Unknown error",
error: state.error,
actionText: "Receive a file",
onPressed: () {
Expand Down
3 changes: 2 additions & 1 deletion lib/views/mobile/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class _SettingsState extends SettingsShared<Settings> {
ButtonWithBackground(
fontSize: 20.0.sp,
title: SELECT_A_FOLDER,
handleClicked: handleSelectFile,
// handleClicked: handleSelectFile,
handleClicked: () {},
height: 60.0.h,
width: 200.0.w,
key: Key(SETTINGS_SCREEN_SELECT_A_FOLDER_BUTTON)),
Expand Down
50 changes: 17 additions & 33 deletions lib/views/mobile/widgets/ErrorUI.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../constants/asset_path.dart';
import '../../widgets/Heading.dart';
import '../../shared/util.dart';
import 'buttons/ButtonWithBackground.dart';

class ErrorUI extends StatelessWidget {
Expand All @@ -21,40 +21,24 @@ class ErrorUI extends StatelessWidget {
: super(key: key);
@override
Widget build(BuildContext context) {
return Column(
children: [
Heading(
title: this.errorTitle,
textStyle: TextStyle(
fontSize: 14.0,
fontFamily: MONTSERRAT,
color: Theme.of(context).colorScheme.secondary,
),
textAlign: TextAlign.left,
),
Heading(
title: this.error,
textStyle: Theme.of(context).textTheme.headline6,
textAlign: TextAlign.left,
),
Heading(
marginTop: 44.0,
title: errorMessage ?? "Unknown error",
textStyle: TextStyle(
return Column(children: [
...convertErrorMessageIntoParagraphs(
errorMessage,
TextStyle(
fontSize: Theme.of(context).textTheme.headline6?.fontSize,
fontFamily: MONTSERRAT_LIGHT_ITALIC,
fontFamily: MONTSERRAT_LIGHT,
color: Theme.of(context).colorScheme.secondary,
),
),
ButtonWithBackground(
width: 200.0.w,
height: 60.0.h,
title: actionText,
handleClicked: () {
onPressed();
},
fontSize: 18.0.sp),
],
);
TextAlign.left,
context),
ButtonWithBackground(
width: 200.0.w,
height: 60.0.h,
title: actionText,
handleClicked: () {
onPressed();
},
fontSize: 18.0.sp),
]);
}
}
31 changes: 20 additions & 11 deletions lib/views/shared/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'dart:typed_data';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:cross_file/cross_file.dart';
import 'package:dart_wormhole_william/client/file.dart' as f;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

const int KB = 1000;
Expand Down Expand Up @@ -58,19 +60,26 @@ String nonExistingPathFor(String path) {
}
}

List<Container> convertErrorMessageIntoParagraphs(String? errorMessage,
TextStyle? textStyle, TextAlign textAlign, BuildContext context) {
return errorMessage
?.split("\n")
.map((txt) => Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.zero,
child: Text(
txt,
style: textStyle,
textAlign: textAlign,
),
))
.toList() ??
[];
}

Future<bool> isAndroidStoragePermissionsGranted() async {
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
final androidInfo = await deviceInfoPlugin.androidInfo;
const int API_LEVEL_29 = 29;
bool isGranted;

if (androidInfo.version.sdkInt! <= API_LEVEL_29) {
isGranted = await Permission.storage.request() == PermissionStatus.granted;
} else {
isGranted = await Permission.manageExternalStorage.request() ==
PermissionStatus.granted;
}

isGranted = await Permission.storage.request() == PermissionStatus.granted;
return isGranted;
}

Expand Down

0 comments on commit e34621a

Please sign in to comment.