Skip to content

Commit

Permalink
Add AlertDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Feb 3, 2023
1 parent 8667a5a commit d538dbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/xtr/keymapper/EditorService.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package xtr.keymapper;

import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.view.ContextThemeWrapper;

Expand All @@ -30,7 +33,16 @@ public int onStartCommand(Intent intent, int flags, int startId) {
mService.registerOnKeyEventListener(editor);
} catch (RemoteException ignored) {
}
else {
AlertDialog.Builder builder = new AlertDialog.Builder(context);

builder.setMessage(R.string.dialog_alert_editor)
.setPositiveButton("Ok", (dialog, which) -> {})
.setTitle(R.string.dialog_alert_editor_title);
AlertDialog dialog = builder.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
dialog.show();
}
return super.onStartCommand(intent, flags, startId);
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@
<string name="drag_mouse">Ctrl + Drag Mouse</string>
<string name="mouse_wheel">Ctrl + Mouse Wheel</string>
<string name="pinch_to_zoom_gesture_info">Two finger gesture with:</string>
<string name="dialog_alert_editor">
Service is not running. \n
You might not be able to map all key events. \n
Run Activation and try again.</string>
<string name="dialog_alert_editor_title" >Not Activated</string>
</resources>

0 comments on commit d538dbf

Please sign in to comment.