添加日历读取联系人信息提示框

这篇博客讲述了在CTA认证过程中遇到的日历应用读取联系人信息无提示的问题。为解决此问题,对源代码进行了修改,包括在strings.xml文件中新增安全提醒的中文和英文描述,以及在AllInOneActivity.java中添加了关于对话框显示的代码,以确保用户在日历应用试图访问联系人信息时能够收到明确的许可请求。
摘要由CSDN通过智能技术生成

过CTA认证时,实验室报日历读取联系人无提示。修改:

+++ b//vendor/mediatek/proprietary/packages/apps/Calendar/res/values-zh-rCN/strings.xml
@@ -280,4 +280,10 @@
“每天”
“每周(每周的<xliff:g id=“DAYS_OF_WEEK”>%s</xliff:g>)”
“每月(每月的<xliff:g id=“ORDINAL_NUMBER”>%1 s &lt; / x l i f f : g &gt; &lt; x l i f f : g i d = &quot; D A Y O F W E E K &quot; &gt; s&lt;/xliff:g&gt;&lt;xliff:g id=&quot;DAY_OF_WEEK&quot;&gt;%2 s</xliff:g><xliff:gid="DAYOFWEEK">s</xliff:g>)”

  • “安全提醒”
  • “日历会尝试取得您的联系人信息以供功能正常运行”
  • “允许”
  • “拒绝”
  • “日历被拒绝取用联系人资讯”

+++ b//vendor/mediatek/proprietary/packages/apps/Calendar/res/values/strings.xml
@@ -762,4 +762,10 @@

 <!-- Do Not Translate.  Sender identity for global notification synchronization. -->
 <string name="notification_sender_id" translatable="false"></string>
  • Security warning
  • Calendar is trying to access your contacts.
  • Allow
  • Deny
  • Calendar is denied to access contacts.

+++ b/vendor/mediatek/proprietary/packages/apps/Calendar/src/com/android/calendar/AllInOneActivity.java
@@ -100,6 +100,10 @@ import static android.provider.CalendarContract.EXTRA_EVENT_ALL_DAY;
import static android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;
import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME;

+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+
public class AllInOneActivity extends AbstractCalendarActivity implements EventHandler,
OnSharedPreferenceChangeListener, SearchView.OnQueryTextListener, ActionBar.TabListener,
ActionBar.OnNavigationListener, OnSuggestionListener {
@@ -634,6 +638,8 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
“AllInOneActivity.onCreate.restoreState”);

     mBundleIcicleOncreate = icicle;
  •    buildAndShowConfirmDialog();
    
       if (!checkAndRequestPermission(CALENDAR_ONCREATE_PERMISSIONS_REQUEST_CODE))
       {
    

@@ -646,6 +652,52 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
continueonCreateCalendar();
}

  • ///add 日历读取联系人信息gu 20190619{{{&&&
  • private final String CALENDAR_CONFIRM_PREF_NAME = “ConfirmPrefFile”;
  • private final String CONFIRM_VALUE_KEY = “mtk_calendar_confirmed”;
  • private void setConfirmed() {
  •    SharedPreferences settings = getSharedPreferences(CALENDAR_CONFIRM_PREF_NAME, 0);
    
  •    SharedPreferences.Editor editor = settings.edit();
    
  •    editor.putBoolean(CONFIRM_VALUE_KEY, true);
    
  •    editor.commit();
    
  • }
  • private boolean getConfirmed() {
  •    SharedPreferences settings = getSharedPreferences(CALENDAR_CONFIRM_PREF_NAME, 0);
    
  •    return settings.getBoolean(CONFIRM_VALUE_KEY, false);
    
  • }
  • private void buildAndShowConfirmDialog() {
  •    if (!getConfirmed()) {
    
  •        Log.d(TAG, "buildAndShowConfirmDialog()");
    
  •        Dialog dialog = new AlertDialog.Builder(this)
    
  •            //.setTitle(R.string.confirm_dialog_title)
    
  •            .setMessage(R.string.confirm_dialog_msg)
    
  •            .setPositiveButton(R.string.confirm_dialog_allow_button,
    
  •                    new DialogInterface.OnClickListener() {
    
  •                    public void onClick(DialogInterface dialog, int whichButton) {
    
  •                    setConfirmed();
    
  •                    }
    
  •                    })
    
  •        .setNegativeButton(R.string.confirm_dialog_deny_button,
    
  •                new DialogInterface.OnClickListener() {
    
  •                public void onClick(DialogInterface dialog, int whichButton) {
    
  •                Toast toast = Toast.makeText(getApplicationContext(), R.string.deny_toast_msg,
    
  •                    Toast.LENGTH_LONG);
    
  •                toast.show();
    
  •                finish();
    
  •                }
    
  •                })
    
  •        .create();
    
  •        dialog.setCanceledOnTouchOutside(false);
    
  •        dialog.setCancelable(false);
    
  •        dialog.show();
    
  •    }
    
  •   }
    
  •    ///&&&}}}
    
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值