remove dup Accessibility-Input solution;fix audio crash
This commit is contained in:
parent
56e195b018
commit
11a1b12fe7
@ -262,7 +262,8 @@ class MainService : Service() {
|
|||||||
_isReady = true
|
_isReady = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onStartCommand(intent, flags, startId)
|
super.onStartCommand(intent, flags, startId)
|
||||||
|
return START_NOT_STICKY // don't use sticky (auto restart),the new service (from auto restart) will lose control
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
@ -464,15 +465,19 @@ class MainService : Service() {
|
|||||||
private fun startAudioRecorder() {
|
private fun startAudioRecorder() {
|
||||||
checkAudioRecorder()
|
checkAudioRecorder()
|
||||||
if (audioReader != null && audioRecorder != null && minBufferSize != 0) {
|
if (audioReader != null && audioRecorder != null && minBufferSize != 0) {
|
||||||
audioRecorder!!.startRecording()
|
try {
|
||||||
audioRecordStat = true
|
audioRecorder!!.startRecording()
|
||||||
thread {
|
audioRecordStat = true
|
||||||
while (audioRecordStat) {
|
thread {
|
||||||
audioReader!!.readSync(audioRecorder!!)?.let {
|
while (audioRecordStat) {
|
||||||
onAudioFrameUpdate(it)
|
audioReader!!.readSync(audioRecorder!!)?.let {
|
||||||
|
onAudioFrameUpdate(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Log.d(logTag, "Exit audio thread")
|
||||||
}
|
}
|
||||||
Log.d(logTag, "Exit audio thread")
|
} catch (e: Exception) {
|
||||||
|
Log.d(logTag, "startAudioRecorder fail:$e")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(logTag, "startAudioRecorder fail")
|
Log.d(logTag, "startAudioRecorder fail")
|
||||||
@ -555,11 +560,7 @@ class MainService : Service() {
|
|||||||
addCategory(Intent.CATEGORY_LAUNCHER)
|
addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
putExtra("type", type)
|
putExtra("type", type)
|
||||||
}
|
}
|
||||||
val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
val pendingIntent = PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT)
|
||||||
PendingIntent.getActivity(this, 0, intent, FLAG_IMMUTABLE)
|
|
||||||
} else {
|
|
||||||
PendingIntent.getActivity(this, 0, intent, FLAG_UPDATE_CURRENT)
|
|
||||||
}
|
|
||||||
val notification = notificationBuilder
|
val notification = notificationBuilder
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setSmallIcon(R.mipmap.ic_launcher)
|
.setSmallIcon(R.mipmap.ic_launcher)
|
||||||
@ -584,7 +585,7 @@ class MainService : Service() {
|
|||||||
) {
|
) {
|
||||||
val notification = notificationBuilder
|
val notification = notificationBuilder
|
||||||
.setOngoing(false)
|
.setOngoing(false)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
.setContentTitle(translate("Do you accept?"))
|
.setContentTitle(translate("Do you accept?"))
|
||||||
.setContentText("$type:$username-$peerId")
|
.setContentText("$type:$username-$peerId")
|
||||||
// .setStyle(MediaStyle().setShowActionsInCompactView(0, 1))
|
// .setStyle(MediaStyle().setShowActionsInCompactView(0, 1))
|
||||||
@ -603,7 +604,7 @@ class MainService : Service() {
|
|||||||
cancelNotification(clientID)
|
cancelNotification(clientID)
|
||||||
val notification = notificationBuilder
|
val notification = notificationBuilder
|
||||||
.setOngoing(false)
|
.setOngoing(false)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||||
.setContentTitle("$type ${translate("Established")}")
|
.setContentTitle("$type ${translate("Established")}")
|
||||||
.setContentText("$username - $peerId")
|
.setContentText("$username - $peerId")
|
||||||
.build()
|
.build()
|
||||||
|
@ -44,8 +44,8 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
void showToast(String text,{Duration? duration}) {
|
void showToast(String text, {Duration? duration}) {
|
||||||
SmartDialog.showToast(text,displayTime: duration);
|
SmartDialog.showToast(text, displayTime: duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showLoading(String text, {bool clickMaskDismiss = false}) {
|
void showLoading(String text, {bool clickMaskDismiss = false}) {
|
||||||
|
@ -192,6 +192,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
_isStart = true;
|
_isStart = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
FFI.setByName("ensure_init_event_queue");
|
FFI.setByName("ensure_init_event_queue");
|
||||||
|
_interval?.cancel();
|
||||||
_interval = Timer.periodic(Duration(milliseconds: 30), (timer) {
|
_interval = Timer.periodic(Duration(milliseconds: 30), (timer) {
|
||||||
FFI.ffiModel.update("");
|
FFI.ffiModel.update("");
|
||||||
});
|
});
|
||||||
|
@ -40,9 +40,6 @@ class ChatPage extends StatelessWidget implements PageShape {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
|
||||||
final scrollController = FFI.chatModel.scroller;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
|
@ -22,9 +22,6 @@ class ConnectionPage extends StatefulWidget implements PageShape {
|
|||||||
@override
|
@override
|
||||||
final appBarActions = !isAndroid ? <Widget>[WebMenu()] : <Widget>[];
|
final appBarActions = !isAndroid ? <Widget>[WebMenu()] : <Widget>[];
|
||||||
|
|
||||||
@override
|
|
||||||
final scrollController = ScrollController();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ConnectionPageState createState() => _ConnectionPageState();
|
_ConnectionPageState createState() => _ConnectionPageState();
|
||||||
}
|
}
|
||||||
@ -50,7 +47,6 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
Provider.of<FfiModel>(context);
|
Provider.of<FfiModel>(context);
|
||||||
if (_idController.text.isEmpty) _idController.text = FFI.getId();
|
if (_idController.text.isEmpty) _idController.text = FFI.getId();
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
controller: widget.scrollController,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
@ -9,7 +9,6 @@ abstract class PageShape extends Widget {
|
|||||||
final String title = "";
|
final String title = "";
|
||||||
final Icon icon = Icon(null);
|
final Icon icon = Icon(null);
|
||||||
final List<Widget> appBarActions = [];
|
final List<Widget> appBarActions = [];
|
||||||
final ScrollController? scrollController = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
@ -72,20 +71,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
_selectedIndex = index;
|
_selectedIndex = index;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
body: Listener(
|
body: _pages.elementAt(_selectedIndex),
|
||||||
onPointerMove: (evt) {
|
|
||||||
final page = _pages.elementAt(_selectedIndex);
|
|
||||||
|
|
||||||
/// Flutter can't not catch PointerMoveEvent when size is 1
|
|
||||||
/// This will happen in Android AccessibilityService Input
|
|
||||||
/// android can't init dispatching size yet ,see: https://stackoverflow.com/questions/59960451/android-accessibility-dispatchgesture-is-it-possible-to-specify-pressure-for-a
|
|
||||||
/// use this temporary solution until flutter or android fixes the bug
|
|
||||||
if (evt.size == 1 && page.scrollController != null) {
|
|
||||||
final offset = page.scrollController!.offset.toDouble();
|
|
||||||
page.scrollController!.jumpTo(offset - evt.delta.dy);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: _pages.elementAt(_selectedIndex)),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,6 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
|
||||||
final scrollController = ScrollController();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
checkService();
|
checkService();
|
||||||
@ -68,7 +65,6 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
value: FFI.serverModel,
|
value: FFI.serverModel,
|
||||||
child: Consumer<ServerModel>(
|
child: Consumer<ServerModel>(
|
||||||
builder: (context, serverModel, child) => SingleChildScrollView(
|
builder: (context, serverModel, child) => SingleChildScrollView(
|
||||||
controller: scrollController,
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
@ -20,9 +20,6 @@ class SettingsPage extends StatefulWidget implements PageShape {
|
|||||||
@override
|
@override
|
||||||
final appBarActions = [ScanButton()];
|
final appBarActions = [ScanButton()];
|
||||||
|
|
||||||
@override
|
|
||||||
final scrollController = null;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SettingsState createState() => _SettingsState();
|
_SettingsState createState() => _SettingsState();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user