Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -10,7 +10,6 @@ import 'logical_key_data.dart';
|
||||
import 'physical_key_data.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
|
||||
/// Generates the key mapping for Android, based on the information in the key
|
||||
/// data structure given to it.
|
||||
class AndroidCodeGenerator extends PlatformCodeGenerator {
|
||||
@@ -21,7 +20,9 @@ class AndroidCodeGenerator extends PlatformCodeGenerator {
|
||||
final StringBuffer androidKeyCodeMap = StringBuffer();
|
||||
for (final LogicalKeyEntry entry in logicalData.entries) {
|
||||
for (final int code in entry.androidValues) {
|
||||
androidKeyCodeMap.writeln(' put(${toHex(code, digits: 10)}L, ${toHex(entry.value, digits: 10)}L); // ${entry.constantName}');
|
||||
androidKeyCodeMap.writeln(
|
||||
' put(${toHex(code, digits: 10)}L, ${toHex(entry.value, digits: 10)}L); // ${entry.constantName}',
|
||||
);
|
||||
}
|
||||
}
|
||||
return androidKeyCodeMap.toString().trimRight();
|
||||
@@ -32,7 +33,9 @@ class AndroidCodeGenerator extends PlatformCodeGenerator {
|
||||
final StringBuffer androidScanCodeMap = StringBuffer();
|
||||
for (final PhysicalKeyEntry entry in keyData.entries) {
|
||||
for (final int code in entry.androidScanCodes.cast<int>()) {
|
||||
androidScanCodeMap.writeln(' put(${toHex(code, digits: 10)}L, ${toHex(entry.usbHidCode, digits: 10)}L); // ${entry.constantName}');
|
||||
androidScanCodeMap.writeln(
|
||||
' put(${toHex(code, digits: 10)}L, ${toHex(entry.usbHidCode, digits: 10)}L); // ${entry.constantName}',
|
||||
);
|
||||
}
|
||||
}
|
||||
return androidScanCodeMap.toString().trimRight();
|
||||
@@ -47,35 +50,38 @@ class AndroidCodeGenerator extends PlatformCodeGenerator {
|
||||
};
|
||||
goalsSource.forEach((String flagName, List<String> keys) {
|
||||
int? lineId;
|
||||
final List<String> keysString = keys.map((String keyName) {
|
||||
final PhysicalKeyEntry physicalKey = keyData.entryByName(keyName);
|
||||
final LogicalKeyEntry logicalKey = logicalData.entryByName(keyName);
|
||||
lineId ??= physicalKey.usbHidCode;
|
||||
return ' new KeyPair(${toHex(physicalKey.usbHidCode)}L, '
|
||||
'${toHex(logicalKey.value, digits: 10)}L), // ${physicalKey.name}';
|
||||
}).toList();
|
||||
lines.add(lineId!,
|
||||
' new PressingGoal(\n'
|
||||
' KeyEvent.META_${flagName}_ON,\n'
|
||||
' new KeyPair[] {\n'
|
||||
'${keysString.join('\n')}\n'
|
||||
' }),');
|
||||
final List<String> keysString =
|
||||
keys.map((String keyName) {
|
||||
final PhysicalKeyEntry physicalKey = keyData.entryByName(keyName);
|
||||
final LogicalKeyEntry logicalKey = logicalData.entryByName(keyName);
|
||||
lineId ??= physicalKey.usbHidCode;
|
||||
return ' new KeyPair(${toHex(physicalKey.usbHidCode)}L, '
|
||||
'${toHex(logicalKey.value, digits: 10)}L), // ${physicalKey.name}';
|
||||
}).toList();
|
||||
lines.add(
|
||||
lineId!,
|
||||
' new PressingGoal(\n'
|
||||
' KeyEvent.META_${flagName}_ON,\n'
|
||||
' new KeyPair[] {\n'
|
||||
'${keysString.join('\n')}\n'
|
||||
' }),',
|
||||
);
|
||||
});
|
||||
return lines.sortedJoin().trimRight();
|
||||
}
|
||||
|
||||
String get _togglingGoals {
|
||||
final OutputLines<int> lines = OutputLines<int>('Android toggling goals');
|
||||
const Map<String, String> goalsSource = <String, String>{
|
||||
'CAPS_LOCK': 'CapsLock',
|
||||
};
|
||||
const Map<String, String> goalsSource = <String, String>{'CAPS_LOCK': 'CapsLock'};
|
||||
goalsSource.forEach((String flagName, String keyName) {
|
||||
final PhysicalKeyEntry physicalKey = keyData.entryByName(keyName);
|
||||
final LogicalKeyEntry logicalKey = logicalData.entryByName(keyName);
|
||||
lines.add(physicalKey.usbHidCode,
|
||||
' new TogglingGoal(KeyEvent.META_${flagName}_ON, '
|
||||
'${toHex(physicalKey.usbHidCode)}L, '
|
||||
'${toHex(logicalKey.value, digits: 10)}L),');
|
||||
lines.add(
|
||||
physicalKey.usbHidCode,
|
||||
' new TogglingGoal(KeyEvent.META_${flagName}_ON, '
|
||||
'${toHex(physicalKey.usbHidCode)}L, '
|
||||
'${toHex(logicalKey.value, digits: 10)}L),',
|
||||
);
|
||||
});
|
||||
return lines.sortedJoin().trimRight();
|
||||
}
|
||||
@@ -89,7 +95,9 @@ class AndroidCodeGenerator extends PlatformCodeGenerator {
|
||||
kAndroidPlane,
|
||||
];
|
||||
for (final MaskConstant constant in maskConstants) {
|
||||
buffer.writeln(' public static final long k${constant.upperCamelName} = ${toHex(constant.value, digits: 11)}L;');
|
||||
buffer.writeln(
|
||||
' public static final long k${constant.upperCamelName} = ${toHex(constant.value, digits: 11)}L;',
|
||||
);
|
||||
}
|
||||
return buffer.toString().trimRight();
|
||||
}
|
||||
@@ -98,8 +106,12 @@ class AndroidCodeGenerator extends PlatformCodeGenerator {
|
||||
String get templatePath => path.join(dataRoot, 'android_keyboard_map_java.tmpl');
|
||||
|
||||
@override
|
||||
String outputPath(String platform) => path.join(PlatformCodeGenerator.engineRoot, 'shell', 'platform',
|
||||
path.join('android', 'io', 'flutter', 'embedding', 'android', 'KeyboardMap.java'));
|
||||
String outputPath(String platform) => path.join(
|
||||
PlatformCodeGenerator.engineRoot,
|
||||
'shell',
|
||||
'platform',
|
||||
path.join('android', 'io', 'flutter', 'embedding', 'android', 'KeyboardMap.java'),
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> mappings() {
|
||||
|
||||
Reference in New Issue
Block a user