Commit ef6115ec by Lee Jaebin

位置情報の権限チェック処理修正(ABookPermissionHelperのActivity→contextに変更)

parent 92c3e67d
...@@ -2,6 +2,7 @@ package jp.agentec.abook.abv.cl.util; ...@@ -2,6 +2,7 @@ package jp.agentec.abook.abv.cl.util;
import jp.agentec.abook.abv.bl.acms.client.json.content.MediaInfoJSON; import jp.agentec.abook.abv.bl.acms.client.json.content.MediaInfoJSON;
import jp.agentec.abook.abv.bl.acms.client.json.content.PageObjectJSON; import jp.agentec.abook.abv.bl.acms.client.json.content.PageObjectJSON;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao; import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.ContentObjectLogDao; import jp.agentec.abook.abv.bl.data.dao.ContentObjectLogDao;
...@@ -13,6 +14,7 @@ import jp.agentec.abook.abv.bl.logic.ContentReadingLogLogic; ...@@ -13,6 +14,7 @@ import jp.agentec.abook.abv.bl.logic.ContentReadingLogLogic;
import jp.agentec.abook.abv.bl.logic.ContractLogic; import jp.agentec.abook.abv.bl.logic.ContractLogic;
import jp.agentec.abook.abv.bl.websocket.MeetingManager; import jp.agentec.abook.abv.bl.websocket.MeetingManager;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
import org.json.adf.JSONException; import org.json.adf.JSONException;
...@@ -51,7 +53,8 @@ public class ContentLogUtil { ...@@ -51,7 +53,8 @@ public class ContentLogUtil {
int readingLogId = contentReadingLogLogic.startContentReadLog(contentId); int readingLogId = contentReadingLogLogic.startContentReadLog(contentId);
// 位置情報取得許可、サービスオプション、ビルドオプションチェック // 位置情報取得許可、サービスオプション、ビルドオプションチェック
if (checkUsableReadinglogGps(contentId)) { //20190529 アプリ側の位置情報許可チェックはしない ABookPermissionHelper helper = new ABookPermissionHelper(context, Constant.ABookPermissionType.AccessFineLocation, null);
if (helper.checkMultiPermissions(false) && checkUsableReadinglogGps(contentId)) { //20190529 アプリ側の位置情報許可チェックはしない
// 位置情報取得 // 位置情報取得
locationManagerUtil = new LocationManagerUtil(context, new LocationManagerUtil.LocationManagerUtilListener() { locationManagerUtil = new LocationManagerUtil(context, new LocationManagerUtil.LocationManagerUtilListener() {
@Override @Override
......
...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.ui.home.helper; ...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.ui.home.helper;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
...@@ -32,19 +33,19 @@ import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref; ...@@ -32,19 +33,19 @@ import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref;
* Created by kim jinsung on 2018/09/21. * Created by kim jinsung on 2018/09/21.
*/ */
public class ABookPermissionHelper { public class ABookPermissionHelper {
private Activity mActivity; private Context mContext;
private int mPermitionType; private int mPermitionType;
private AlertDialog mAlertDialog; private AlertDialog mAlertDialog;
private Callback mCallback; private Callback mCallback;
public ABookPermissionHelper(Activity activity, int permissionType, Callback callback) { public ABookPermissionHelper(Context context, int permissionType, Callback callback) {
mActivity = activity; mContext = context;
mPermitionType = permissionType; mPermitionType = permissionType;
mCallback = callback; mCallback = callback;
} }
public ABookPermissionHelper(Activity activity) { public ABookPermissionHelper(Context context) {
mActivity = activity; mContext = context;
} }
public ArrayList<String> checkMultiPermissions() { public ArrayList<String> checkMultiPermissions() {
...@@ -55,35 +56,35 @@ public class ABookPermissionHelper { ...@@ -55,35 +56,35 @@ public class ABookPermissionHelper {
return reqPermissions; return reqPermissions;
} }
// 位置情報 // 位置情報
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.ACCESS_FINE_LOCATION); reqPermissions.add(android.Manifest.permission.ACCESS_FINE_LOCATION);
} }
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.ACCESS_COARSE_LOCATION); reqPermissions.add(android.Manifest.permission.ACCESS_COARSE_LOCATION);
} }
// ストレージ // ストレージ
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.READ_EXTERNAL_STORAGE); reqPermissions.add(android.Manifest.permission.READ_EXTERNAL_STORAGE);
} }
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE); reqPermissions.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
} }
// カメラ // カメラ
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.CAMERA); reqPermissions.add(android.Manifest.permission.CAMERA);
} }
// マイク(オーディオ) // マイク(オーディオ)
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.RECORD_AUDIO); reqPermissions.add(android.Manifest.permission.RECORD_AUDIO);
} }
// Bluetooth // Bluetooth
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) { android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.BLUETOOTH); reqPermissions.add(android.Manifest.permission.BLUETOOTH);
} }
...@@ -100,77 +101,77 @@ public class ABookPermissionHelper { ...@@ -100,77 +101,77 @@ public class ABookPermissionHelper {
switch (mPermitionType) { switch (mPermitionType) {
case Constant.ABookPermissionType.ReadExternalStorage: case Constant.ABookPermissionType.ReadExternalStorage:
// ストレージ // ストレージ
if (ContextCompat.checkSelfPermission(mActivity, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED || if (ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(mActivity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) { ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
if (mActivity instanceof HTMLWebViewActivity || mActivity instanceof HTMLXWalkWebViewActivity || mActivity instanceof OperationListActivity) { if (mContext instanceof HTMLWebViewActivity || mContext instanceof HTMLXWalkWebViewActivity || mContext instanceof OperationListActivity) {
// リソースパターンの適用 // リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mActivity.getApplicationContext(), permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_storage_album, R.string.msg_permission_dialog_storage_album,
getUserPref(mActivity.getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)); getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
} else { } else {
// リソースパターンの適用 // リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mActivity.getApplicationContext(), permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_storage_update, R.string.msg_permission_dialog_storage_update,
getUserPref(mActivity.getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)); getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
} }
} }
break; break;
case Constant.ABookPermissionType.AccessFineLocation: case Constant.ABookPermissionType.AccessFineLocation:
// 位置情報 // 位置情報
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) { android.Manifest.permission.ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {
// リソースパターンの適用 // リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mActivity.getApplicationContext(), permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_location, R.string.msg_permission_dialog_location,
getUserPref(mActivity.getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)); getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
} }
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.ACCESS_COARSE_LOCATION) != PERMISSION_GRANTED) { android.Manifest.permission.ACCESS_COARSE_LOCATION) != PERMISSION_GRANTED) {
// リソースパターンの適用 // リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mActivity.getApplicationContext(), permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_location, R.string.msg_permission_dialog_location,
getUserPref(mActivity.getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)); getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
} }
break; break;
case Constant.ABookPermissionType.Camera: case Constant.ABookPermissionType.Camera:
// カメラ // カメラ
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.CAMERA) != PERMISSION_GRANTED) { android.Manifest.permission.CAMERA) != PERMISSION_GRANTED) {
// リソースパターンの適用 // リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mActivity.getApplicationContext(), permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_camera, R.string.msg_permission_dialog_camera,
getUserPref(mActivity.getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)); getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
} }
break; break;
case Constant.ABookPermissionType.Audio: case Constant.ABookPermissionType.Audio:
// マイク(オーディオ) // マイク(オーディオ)
if (ContextCompat.checkSelfPermission(mActivity, if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.RECORD_AUDIO) != PERMISSION_GRANTED) { android.Manifest.permission.RECORD_AUDIO) != PERMISSION_GRANTED) {
// リソースパターンの適用 // リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mActivity.getApplicationContext(), permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_mic, R.string.msg_permission_dialog_mic,
getUserPref(mActivity.getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)); getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
} }
break; break;
} }
if (permitionTextResourceId > 0) { if (permitionTextResourceId > 0) {
if (showDialogFlg) { if (showDialogFlg) {
ABookAlertDialog dialog = AlertDialogUtil.createABookAlertDialog(mActivity); ABookAlertDialog dialog = AlertDialogUtil.createABookAlertDialog(mContext);
// リソースパターンの適用 // リソースパターンの適用
dialog.setTitle(PatternStringUtil.patternToString(mActivity.getApplicationContext(), dialog.setTitle(PatternStringUtil.patternToString(mContext,
R.string.title_permission_dialog, R.string.title_permission_dialog,
getUserPref(mActivity.getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
dialog.setMessage(permitionTextResourceId); dialog.setMessage(permitionTextResourceId);
dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", mActivity.getPackageName(), null); Uri uri = Uri.fromParts("package", mContext.getPackageName(), null);
intent.setData(uri); intent.setData(uri);
mActivity.startActivity(intent); mContext.startActivity(intent);
if (mCallback != null) { if (mCallback != null) {
mCallback.callback(true); mCallback.callback(true);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment