Browse Source

[flutter_example_packages] Add path_provider, update android icon, splash

merge-requests/21/head
Vitaliy Zarubin 2 years ago
parent
commit
bbc67eb2d2
  1. 3
      example/android/app/src/main/AndroidManifest.xml
  2. 11
      example/android/app/src/main/res/drawable/splash.xml
  3. BIN
      example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
  4. BIN
      example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
  5. BIN
      example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
  6. BIN
      example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  7. BIN
      example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  8. 4
      example/android/app/src/main/res/values-night/colors.xml
  9. 2
      example/android/app/src/main/res/values-night/styles.xml
  10. 4
      example/android/app/src/main/res/values/colors.xml
  11. 2
      example/android/app/src/main/res/values/styles.xml
  12. 60
      example/lib/l10n/app_en.arb
  13. 60
      example/lib/l10n/app_ru.arb
  14. 91
      example/lib/packages/path_provider/model.dart
  15. 36
      example/lib/packages/path_provider/page.dart
  16. 8
      packages/path_provider/path_provider_aurora/README.md

3
example/android/app/src/main/AndroidManifest.xml

@ -3,7 +3,8 @@
<application
android:label="flutter_example_packages"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
android:name=".MainActivity"
android:exported="true"

11
example/android/app/src/main/res/drawable/splash.xml

@ -0,0 +1,11 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@color/bg_splash" />
<item
android:width="150dp"
android:height="150dp"
android:drawable="@drawable/icon_splash"
android:gravity="center" />
</layer-list>

BIN
example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

4
example/android/app/src/main/res/values-night/colors.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="bg_splash">#000000</color>
</resources>

2
example/android/app/src/main/res/values-night/styles.xml

@ -4,7 +4,7 @@
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowBackground">@drawable/splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your

4
example/android/app/src/main/res/values/colors.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="bg_splash">#ffffff</color>
</resources>

2
example/android/app/src/main/res/values/styles.xml

@ -4,7 +4,7 @@
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowBackground">@drawable/splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your

60
example/lib/l10n/app_en.arb

@ -1,13 +1,13 @@
{
"@_BATTERY_PLUS": {},
"batteryPlusTitleBatteryLevel": "Battery Level",
"batteryPlusDescBatteryLevel": "Battery level in percent 0 - 100",
"batteryPlusDescBatteryLevel": "Battery level in percent 0 - 100.",
"batteryPlusTitleBatteryState": "Battery State",
"batteryPlusDescBatteryState": "Battery state: full, charging, discharging, unknown",
"batteryPlusDescBatteryState": "Battery state: full, charging, discharging, unknown.",
"batteryPlusTitleBatterySaveMode": "Save Mode",
"batteryPlusDescBatterySaveMode": "Check is enable 'Save Mode'",
"batteryPlusDescBatterySaveMode": "Check is enable 'Save Mode'.",
"batteryPlusTitleBatteryStateLive": "Battery State 'Live'",
"batteryPlusDescBatteryStateLive": "Battery change state stream",
"batteryPlusDescBatteryStateLive": "Battery change state stream.",
"@_CACHED_NETWORK_IMAGE": {},
"cachedNetworkImageTitle": "Title",
@ -15,41 +15,41 @@
"@_DEVICE_INFO_PLUS": {},
"deviceInfoPlusTitleID": "ID",
"deviceInfoPlusDescID": "Device ID",
"deviceInfoPlusDescID": "Device ID.",
"deviceInfoPlusTitleName": "Name",
"deviceInfoPlusDescName": "Device name",
"deviceInfoPlusDescName": "Device name.",
"deviceInfoPlusTitleVersion": "Version OS",
"deviceInfoPlusDescVersion": "Short OS version",
"deviceInfoPlusDescVersion": "Short OS version.",
"deviceInfoPlusTitlePrettyName": "Full Name",
"deviceInfoPlusDescPrettyName": "Pretty name OS",
"deviceInfoPlusDescPrettyName": "Pretty name OS.",
"deviceInfoPlusTitleGNSS": "GNSS",
"deviceInfoPlusDescGNSS": "Check is has GNSS",
"deviceInfoPlusDescGNSS": "Check is has GNSS.",
"deviceInfoPlusTitleNFC": "NFC",
"deviceInfoPlusDescNFC": "Check is has NFC",
"deviceInfoPlusDescNFC": "Check is has NFC.",
"deviceInfoPlusTitleBluetooth": "Bluetooth",
"deviceInfoPlusDescBluetooth": "Check is has bluetooth",
"deviceInfoPlusDescBluetooth": "Check is has bluetooth.",
"deviceInfoPlusTitleWlan": "WLAN",
"deviceInfoPlusDescWlan": "Check is has Wireless LAN",
"deviceInfoPlusDescWlan": "Check is has Wireless LAN.",
"deviceInfoPlusTitleMaxCpuClockSpeed": "CPU speed",
"deviceInfoPlusDescMaxCpuClockSpeed": "Max CPU clock speed",
"deviceInfoPlusDescMaxCpuClockSpeed": "Max CPU clock speed.",
"deviceInfoPlusTitleNumberCpuCores": "CPU cores",
"deviceInfoPlusDescNumberCpuCores": "Number CPU cores",
"deviceInfoPlusDescNumberCpuCores": "Number CPU cores.",
"deviceInfoPlusTitleBatteryCharge": "Battery charge",
"deviceInfoPlusDescBatteryCharge": "Battery level in percent 0-100",
"deviceInfoPlusDescBatteryCharge": "Battery level in percent 0-100.",
"deviceInfoPlusTitleMainCameraResolution": "Main camera",
"deviceInfoPlusDescMainCameraResolution": "Main camera resolution",
"deviceInfoPlusDescMainCameraResolution": "Main camera resolution.",
"deviceInfoPlusTitleFrontalCameraResolution": "Frontal camera",
"deviceInfoPlusDescFrontalCameraResolution": "Frontal camera resolution",
"deviceInfoPlusDescFrontalCameraResolution": "Frontal camera resolution.",
"deviceInfoPlusTitleRamTotalSize": "RAM total",
"deviceInfoPlusDescRamTotalSize": "RAM total size",
"deviceInfoPlusDescRamTotalSize": "RAM total size.",
"deviceInfoPlusTitleRamFreeSize": "RAM free",
"deviceInfoPlusDescRamFreeSize": "RAM free size",
"deviceInfoPlusDescRamFreeSize": "RAM free size.",
"deviceInfoPlusTitleScreenResolution": "Screen",
"deviceInfoPlusDescScreenResolution": "Screen resolution",
"deviceInfoPlusDescScreenResolution": "Screen resolution.",
"deviceInfoPlusTitleOsVersion": "Version OS",
"deviceInfoPlusDescOsVersion": "Full OS version",
"deviceInfoPlusDescOsVersion": "Full OS version.",
"deviceInfoPlusTitleDeviceModel": "Device",
"deviceInfoPlusDescDeviceModel": "Device name model",
"deviceInfoPlusDescDeviceModel": "Device name model.",
"@_FLUTTER_CACHE_MANAGER": {},
"flutterCacheManagerTitle": "Title",
@ -68,8 +68,20 @@
"packageInfoPlusDesc": "Desc",
"@_PATH_PROVIDER": {},
"pathProviderTitle": "Title",
"pathProviderDesc": "Desc",
"pathProviderTitleApplicationSupport": "Application Support",
"pathProviderDescApplicationSupport": "Directory where the application may place application support files.",
"pathProviderTitleTemporary": "Temporary",
"pathProviderDescTemporary": "Directory location where user-specific non-essential (cached) data should be written.",
"pathProviderTitleApplicationDocuments": "Documents",
"pathProviderDescApplicationDocuments": "Directory containing user document files.",
"pathProviderTitleDownloads": "Download",
"pathProviderDescDownloads": "Directory for user's downloaded files.",
"pathProviderTitlePictures": "Pictures",
"pathProviderDescPictures": "There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.pictures directory.",
"pathProviderTitleMusic": "Music",
"pathProviderDescMusic": "There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.music directory.",
"pathProviderTitleMovies": "Movies",
"pathProviderDescMovies": "There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.movies directory.",
"@_SHARED_PREFERENCES": {},
"sharedPreferencesTitle": "Title",

60
example/lib/l10n/app_ru.arb

@ -1,51 +1,51 @@
{
"@_BATTERY_PLUS": {},
"batteryPlusTitleBatteryLevel": "Уровень заряда батареи",
"batteryPlusDescBatteryLevel": "Уровень заряда батареи в процентах от 0 до 100",
"batteryPlusDescBatteryLevel": "Уровень заряда батареи в процентах от 0 до 100.",
"batteryPlusTitleBatteryState": "Состояние батареи",
"batteryPlusDescBatteryState": "Состояния: full, charging, discharging, unknown",
"batteryPlusDescBatteryState": "Состояния: full, charging, discharging, unknown.",
"batteryPlusTitleBatterySaveMode": "Save Mode",
"batteryPlusDescBatterySaveMode": "Проверка включен ли режим 'Save Mode'",
"batteryPlusDescBatterySaveMode": "Проверка включен ли режим 'Save Mode'.",
"batteryPlusTitleBatteryStateLive": "Состояние батареи 'Live'",
"batteryPlusDescBatteryStateLive": "Изменение состояния батареи",
"batteryPlusDescBatteryStateLive": "Изменение состояния батареи.",
"@_CACHED_NETWORK_IMAGE": {},
"deviceInfoPlusTitleID": "ID",
"deviceInfoPlusDescID": "Идентификатор устройства",
"deviceInfoPlusDescID": "Идентификатор устройства.",
"deviceInfoPlusTitleName": "Имя",
"deviceInfoPlusDescName": "Имя устройства",
"deviceInfoPlusDescName": "Имя устройства.",
"deviceInfoPlusTitleVersion": "Версия ОС",
"deviceInfoPlusDescVersion": "Короткое название версии ОС",
"deviceInfoPlusDescVersion": "Короткое название версии ОС.",
"deviceInfoPlusTitlePrettyName": "Полное имя",
"deviceInfoPlusDescPrettyName": "Красивое имя ОС",
"deviceInfoPlusDescPrettyName": "Красивое имя ОС.",
"deviceInfoPlusTitleGNSS": "GNSS",
"deviceInfoPlusDescGNSS": "Проверить наличие GNSS",
"deviceInfoPlusDescGNSS": "Проверить наличие GNSS.",
"deviceInfoPlusTitleNFC": "NFC",
"deviceInfoPlusDescNFC": "Проверить, есть ли NFC",
"deviceInfoPlusDescNFC": "Проверить, есть ли NFC.",
"deviceInfoPlusTitleBluetooth": "Bluetooth",
"deviceInfoPlusDescBluetooth": "Проверьте, есть ли Bluetooth",
"deviceInfoPlusDescBluetooth": "Проверьте, есть ли Bluetooth.",
"deviceInfoPlusTitleWlan": "WLAN",
"deviceInfoPlusDescWlan": "Проверьте, есть ли Wireless LAN",
"deviceInfoPlusDescWlan": "Проверьте, есть ли Wireless LAN.",
"deviceInfoPlusTitleMaxCpuClockSpeed": "Частота процессора",
"deviceInfoPlusDescMaxCpuClockSpeed": "Максимальная тактовая частота процессора",
"deviceInfoPlusDescMaxCpuClockSpeed": "Максимальная тактовая частота процессора.",
"deviceInfoPlusTitleNumberCpuCores": "Ядра ЦП",
"deviceInfoPlusDescNumberCpuCores": "Количество ядер ЦП",
"deviceInfoPlusDescNumberCpuCores": "Количество ядер ЦП.",
"deviceInfoPlusTitleBatteryCharge": "Заряд батареи",
"deviceInfoPlusDescBatteryCharge": "Уровень заряда батареи в процентах от 0 до 100",
"deviceInfoPlusDescBatteryCharge": "Уровень заряда батареи в процентах от 0 до 100.",
"deviceInfoPlusTitleMainCameraResolution": "Основная камера",
"deviceInfoPlusDescMainCameraResolution": "Разрешение основной камеры",
"deviceInfoPlusDescMainCameraResolution": "Разрешение основной камеры.",
"deviceInfoPlusTitleFrontalCameraResolution": "Фронтальная камера",
"deviceInfoPlusDescFrontalCameraResolution": "Разрешение фронтальной камеры",
"deviceInfoPlusDescFrontalCameraResolution": "Разрешение фронтальной камеры.",
"deviceInfoPlusTitleRamTotalSize": "Всего ОЗУ",
"deviceInfoPlusDescRamTotalSize": "Общий размер ОЗУ",
"deviceInfoPlusDescRamTotalSize": "Общий размер ОЗУ.",
"deviceInfoPlusTitleRamFreeSize": "Свободно ОЗУ",
"deviceInfoPlusDescRamFreeSize": "Свободный размер ОЗУ",
"deviceInfoPlusDescRamFreeSize": "Свободный размер ОЗУ.",
"deviceInfoPlusTitleScreenResolution": "Экран",
"deviceInfoPlusDescScreenResolution": "Разрешение экрана",
"deviceInfoPlusDescScreenResolution": "Разрешение экрана.",
"deviceInfoPlusTitleOsVersion": "Версия ОС",
"deviceInfoPlusDescOsVersion": "Полное название версия ОС",
"deviceInfoPlusDescOsVersion": "Полное название версия ОС.",
"deviceInfoPlusTitleDeviceModel": "Устройство",
"deviceInfoPlusDescDeviceModel": "Имя модели устройства",
"deviceInfoPlusDescDeviceModel": "Имя модели устройства.",
"@_DEVICE_INFO_PLUS": {},
"deviceInfoPlusTitle": "Заголовок",
@ -68,8 +68,20 @@
"packageInfoPlusDesc": "Описание",
"@_PATH_PROVIDER": {},
"pathProviderTitle": "Заголовок",
"pathProviderDesc": "Описание",
"pathProviderTitleApplicationSupport": "Поддержка приложений",
"pathProviderDescApplicationSupport": "Каталог, в котором приложение может размещать файлы поддержки приложений.",
"pathProviderTitleTemporary": "Временный",
"pathProviderDescTemporary": "Расположение каталога, куда должны быть записаны второстепенные (кешированные) данные пользователя.",
"pathProviderTitleApplicationDocuments": "Документы",
"pathProviderDescApplicationDocuments": "Каталог, содержащий файлы пользовательских документов.",
"pathProviderTitleDownloads": "Скачать",
"pathProviderDescDownloads": "Каталог для загруженных пользователем файлов.",
"pathProviderTitlePictures": "Изображения",
"pathProviderDescPictures": "В Aurora OS нет концепции External, но этот интерфейс позволяет получить каталог StorageDirectory.pictures.",
"pathProviderTitleMusic": "Музыка",
"pathProviderDescMusic": "В Aurora OS нет концепции External, но этот интерфейс позволяет получить каталог StorageDirectory.music.",
"pathProviderTitleMovies": "Фильмы",
"pathProviderDescMovies": "В Aurora OS нет концепции External, но этот интерфейс позволяет получить каталог StorageDirectory.movies.",
"@_SHARED_PREFERENCES": {},
"sharedPreferencesTitle": "Заголовок",

91
example/lib/packages/path_provider/model.dart

@ -1,10 +1,14 @@
import 'package:flutter/widgets.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path_provider/path_provider.dart' as provider;
import 'package:scoped_model/scoped_model.dart';
import 'package:universal_io/io.dart';
/// Model for [PathProviderPage]
class PathProviderModel extends Model {
/// Get [ScopedModel]
static PathProviderModel of(BuildContext context) => ScopedModel.of<PathProviderModel>(context);
static PathProviderModel of(BuildContext context) =>
ScopedModel.of<PathProviderModel>(context);
/// Error
String? _error;
@ -14,4 +18,87 @@ class PathProviderModel extends Model {
/// Public is error
bool get isError => _error != null;
}
/// Directory where the application may place application support files.
Future<Directory?> getApplicationSupportDirectory() async {
try {
return await provider.getApplicationSupportDirectory();
} catch (e) {
_error = e.toString();
}
notifyListeners();
return null;
}
/// Directory location where user-specific non-essential (cached) data should be written.
Future<Directory?> getTemporaryDirectory() async {
try {
return await provider.getTemporaryDirectory();
} catch (e) {
_error = e.toString();
}
notifyListeners();
return null;
}
/// Directory containing user document files.
Future<Directory?> getApplicationDocumentsDirectory() async {
try {
return await provider.getApplicationDocumentsDirectory();
} catch (e) {
_error = e.toString();
}
notifyListeners();
return null;
}
/// Directory for user's downloaded files.
Future<Directory?> getDownloadsDirectory() async {
try {
return await provider.getDownloadsDirectory();
} catch (e) {
_error = e.toString();
}
notifyListeners();
return null;
}
/// There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.pictures directory.
Future<List<Directory>?> getExternalStorageDirectoriesPictures() async {
try {
return await provider.getExternalStorageDirectories(
type: StorageDirectory.pictures,
);
} catch (e) {
_error = e.toString();
}
notifyListeners();
return null;
}
/// There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.music directory.
Future<List<Directory>?> getExternalStorageDirectoriesMusic() async {
try {
return await provider.getExternalStorageDirectories(
type: StorageDirectory.music,
);
} catch (e) {
_error = e.toString();
}
notifyListeners();
return null;
}
/// There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.movies directory.
Future<List<Directory>?> getExternalStorageDirectoriesMovies() async {
try {
return await provider.getExternalStorageDirectories(
type: StorageDirectory.movies,
);
} catch (e) {
_error = e.toString();
}
notifyListeners();
return null;
}
}

36
example/lib/packages/path_provider/page.dart

@ -41,9 +41,39 @@ class _PathProviderPageState extends AppState<PathProviderPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BlockItem(
title: l10n.pathProviderTitle,
desc: l10n.pathProviderDesc,
value: null,
title: l10n.pathProviderTitleApplicationSupport,
desc: l10n.pathProviderDescApplicationSupport,
future: model.getApplicationSupportDirectory(),
),
BlockItem(
title: l10n.pathProviderTitleTemporary,
desc: l10n.pathProviderDescTemporary,
future: model.getTemporaryDirectory(),
),
BlockItem(
title: l10n.pathProviderTitleApplicationDocuments,
desc: l10n.pathProviderDescApplicationDocuments,
future: model.getApplicationDocumentsDirectory(),
),
BlockItem(
title: l10n.pathProviderTitleDownloads,
desc: l10n.pathProviderDescDownloads,
future: model.getDownloadsDirectory(),
),
BlockItem(
title: l10n.pathProviderTitlePictures,
desc: l10n.pathProviderDescPictures,
future: model.getExternalStorageDirectoriesPictures(),
),
BlockItem(
title: l10n.pathProviderTitleMusic,
desc: l10n.pathProviderDescMusic,
future: model.getExternalStorageDirectoriesMusic(),
),
BlockItem(
title: l10n.pathProviderTitleMovies,
desc: l10n.pathProviderDescMovies,
future: model.getExternalStorageDirectoriesMovies(),
),
],
),

8
packages/path_provider/path_provider_aurora/README.md

@ -31,11 +31,11 @@ final Directory? downloadsDir = await getDownloadsDirectory();
## Supported APIs
- [x] `getTemporaryDirectory` - Returns a directory location where user-specific non-essential (cached) data should be written
- [ ] `getApplicationSupportDirectory`
- [x] `getTemporaryDirectory` - Directory location where user-specific non-essential (cached) data should be written
- [x] `getApplicationSupportDirectory` - Directory where the application may place application support files.
- [ ] `getLibraryDirectory`
- [x] `getApplicationDocumentsDirectory` - Returns the directory containing user document files.
- [x] `getApplicationDocumentsDirectory` - Directory containing user document files.
- [ ] `getExternalStorageDirectory`
- [ ] `getExternalCacheDirectories`
- [x] `getExternalStorageDirectories` - There is no concept of External in Aurora OS, but this interface allows you to get the pictures/music/movies directory
- [x] `getDownloadsDirectory`- Returns a directory for user's downloaded files.
- [x] `getDownloadsDirectory`- Directory for user's downloaded files.

Loading…
Cancel
Save