[Fix]取消悬浮窗权限

This commit is contained in:
chenfufeng
2022-03-08 16:39:32 +08:00
parent a1d717ad81
commit 9ca2a852d6
9 changed files with 34 additions and 26 deletions

View File

@@ -8,7 +8,6 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<application>

View File

@@ -105,14 +105,14 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
if (CallChatApi.getInstance().getApiProvider() != null) {
CallChatApi.getInstance().getApiProvider().initVehicleTeamContainer("init", R.id.module_main_id_message_history_fragment_container, this);
}
//申请悬浮窗权限
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// 检查是否有悬浮窗权限
if (Settings.canDrawOverlays(this)) {
return;
}
PermissionsDialogUtils.openAppDetails(this, "显示悬浮窗", REQUEST_CODE_DIALOG);
}
// //申请悬浮窗权限
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// // 检查是否有悬浮窗权限
// if (Settings.canDrawOverlays(this)) {
// return;
// }
// PermissionsDialogUtils.openAppDetails(this, "显示悬浮窗", REQUEST_CODE_DIALOG);
// }
}
// 隐藏布局

View File

@@ -48,6 +48,7 @@ android {
protobuf {
protoc {
// Apple Silicon M1 使用artifact = 'com.google.protobuf:protoc:3.6.1:osx-x86_64'
artifact = 'com.google.protobuf:protoc:3.6.1'
}

View File

@@ -33,12 +33,12 @@ public class BaseFloatDialog extends Dialog {
}
private void addFlag() {
// TODO 这里需要申请悬浮床权限
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
} else {
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
// } else {
// getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// }
getWindow().setType(WindowManager.LayoutParams.LAST_SUB_WINDOW);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
| WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE);

View File

@@ -1,5 +1,6 @@
package com.mogo.module.common.dialog;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.TextView;
@@ -74,10 +75,10 @@ public class WMDialog implements DialogInterface {
private Context mContext;
private WMDialogParams mParams;
public Builder( Context context ) {
this.mContext = context;
public Builder( Activity activity ) {
this.mContext = activity;
mParams = new WMDialogParams();
mParams.mContext = context;
mParams.mContext = activity;
}
public Builder setContent( CharSequence content ) {

View File

@@ -8,8 +8,10 @@ import android.view.View;
import android.view.WindowManager;
/**
* 采用windowManager实现接口
* 采用windowManager实现接口(取消系统级弹窗)
* {@link DialogImpl}
*/
@Deprecated
class WindowManagerImpl implements IWindowManagerView {
private WindowManager mWindowManager;

View File

@@ -97,6 +97,7 @@ public class WindowManagerView {
return new WindowManagerView( mParams, new DialogImpl() );
}
@Deprecated
public WindowManagerView showInWindowManager() {
if ( mParams.mContentView == null ) {
throw new NullPointerException( "WMViewParams#mContentView must not be null." );

View File

@@ -1,5 +1,6 @@
package com.mogo.module.service.intent;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
@@ -23,6 +24,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.AppStateManager;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.map.marker.IMogoMarker;
@@ -94,12 +96,15 @@ public class MockIntentHandler implements IntentHandler {
MarkerServiceHandler.getMapUIController().changeBearing(bearing);
break;
case 9:// 测试弹窗
new WMDialog.Builder(context)
.setOkButton("确认", (dlg, which) -> dlg.dismiss())
.setCancelButton("取消", (dlg, which) -> dlg.dismiss())
.setContent("内容内容内容内容内容内容内容内容")
.build()
.show();
Activity activity = AppStateManager.INSTANCE.currentActivity();
if (activity != null) {
new WMDialog.Builder(activity)
.setOkButton("确认", (dlg, which) -> dlg.dismiss())
.setCancelButton("取消", (dlg, which) -> dlg.dismiss())
.setContent("内容内容内容内容内容内容内容内容")
.build()
.show();
}
break;
case 10://测试GEO查询
IMogoGeoSearch geoSearch = MarkerServiceHandler.getMapService().getGeoSearch(context);

View File

@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.service.map">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest>