Commit 110e8801 by Lee Jaebin

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

parent 9edf332f
......@@ -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.PageObjectJSON;
import jp.agentec.abook.abv.bl.common.Constant;
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.ContentObjectLogDao;
......@@ -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.websocket.MeetingManager;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.adf.util.DateTimeUtil;
import org.json.adf.JSONException;
......@@ -51,8 +53,9 @@ public class ContentLogUtil {
int readingLogId = contentReadingLogLogic.startContentReadLog(contentId);
// 位置情報取得許可、サービスオプション、ビルドオプションチェック
if (permissionAccessLocation && checkUsableReadinglogGps(contentId)) {
// 位置情報取得
ABookPermissionHelper helper = new ABookPermissionHelper(context, Constant.ABookPermissionType.AccessFineLocation, null);
if (checkUsableReadinglogGps(contentId) && helper.checkMultiPermissions(false)) { //20190529 アプリ側の位置情報許可チェックはしない
// 位置情報取得
locationManagerUtil = new LocationManagerUtil(context, new LocationManagerUtil.LocationManagerUtilListener() {
@Override
public void onGetLocationFailed() {
......
......@@ -2,6 +2,7 @@ package jp.agentec.abook.abv.ui.home.helper;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
......@@ -32,19 +33,19 @@ import static org.chromium.base.ContextUtils.getApplicationContext;
* Created by kim jinsung on 2018/09/21.
*/
public class ABookPermissionHelper {
private Activity mActivity;
private Context mContext;
private int mPermitionType;
private AlertDialog mAlertDialog;
private Callback mCallback;
public ABookPermissionHelper(Activity activity, int permissionType, Callback callback) {
mActivity = activity;
public ABookPermissionHelper(Context context, int permissionType, Callback callback) {
mContext = context;
mPermitionType = permissionType;
mCallback = callback;
}
public ABookPermissionHelper(Activity activity) {
mActivity = activity;
mContext = activity;
}
public ArrayList<String> checkMultiPermissions() {
......@@ -55,30 +56,30 @@ public class ABookPermissionHelper {
return reqPermissions;
}
// 位置情報
if (ContextCompat.checkSelfPermission(mActivity,
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
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) {
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) {
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) {
reqPermissions.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
// カメラ
if (ContextCompat.checkSelfPermission(mActivity,
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.CAMERA);
}
// マイク(オーディオ)
if (ContextCompat.checkSelfPermission(mActivity,
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.RECORD_AUDIO);
}
......@@ -95,77 +96,77 @@ public class ABookPermissionHelper {
switch (mPermitionType) {
case Constant.ABookPermissionType.ReadExternalStorage:
// ストレージ
if (ContextCompat.checkSelfPermission(mActivity, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(mActivity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
if (mActivity instanceof HTMLWebViewActivity || mActivity instanceof HTMLXWalkWebViewActivity || mActivity instanceof OperationListActivity) {
if (ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
if (mContext instanceof HTMLWebViewActivity || mContext instanceof HTMLXWalkWebViewActivity || mContext instanceof OperationListActivity) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(getApplicationContext(),
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_storage_album,
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
} else {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(getApplicationContext(),
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_storage_update,
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
}
break;
case Constant.ABookPermissionType.AccessFineLocation:
// 位置情報
if (ContextCompat.checkSelfPermission(mActivity,
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(getApplicationContext(),
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_location,
getUserPref(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) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(getApplicationContext(),
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_location,
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
break;
case Constant.ABookPermissionType.Camera:
// カメラ
if (ContextCompat.checkSelfPermission(mActivity,
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.CAMERA) != PERMISSION_GRANTED) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(getApplicationContext(),
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_camera,
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
break;
case Constant.ABookPermissionType.Audio:
// マイク(オーディオ)
if (ContextCompat.checkSelfPermission(mActivity,
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.RECORD_AUDIO) != PERMISSION_GRANTED) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(getApplicationContext(),
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_mic,
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
break;
}
if (permitionTextResourceId > 0) {
if (showDialogFlg) {
ABookAlertDialog dialog = AlertDialogUtil.createABookAlertDialog(mActivity);
ABookAlertDialog dialog = AlertDialogUtil.createABookAlertDialog(mContext);
// リソースパターンの適用
dialog.setTitle(PatternStringUtil.patternToString(getApplicationContext(),
dialog.setTitle(PatternStringUtil.patternToString(mContext,
R.string.title_permission_dialog,
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
dialog.setMessage(permitionTextResourceId);
dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
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);
mActivity.startActivity(intent);
mContext.startActivity(intent);
if (mCallback != null) {
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