diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000000000000000000000000000000000000..2aed390b1a94a8acbbb7e69e8e30eb866bff697e
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,288 @@
+//
+// SPDX-FileCopyrightText: 2023 The LineageOS Project
+// SPDX-License-Identifier: Apache-2.0
+//
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_app {
+ name: "Dialer",
+ aaptflags: [
+ "--auto-add-overlay",
+ "--extra-packages com.android.contacts.common",
+ "--extra-packages com.android.dialer.app",
+ "--extra-packages com.android.dialer.assisteddialing",
+ "--extra-packages com.android.dialer.assisteddialing.ui",
+ "--extra-packages com.android.dialer.blocking",
+ "--extra-packages com.android.dialer.blockreportspam",
+ "--extra-packages com.android.dialer.calldetails",
+ "--extra-packages com.android.dialer.calllog.database",
+ "--extra-packages com.android.dialer.calllog.ui",
+ "--extra-packages com.android.dialer.calllog.ui.menu",
+ "--extra-packages com.android.dialer.calllogutils",
+ "--extra-packages com.android.dialer.clipboard",
+ "--extra-packages com.android.dialer.common",
+ "--extra-packages com.android.dialer.contactphoto",
+ "--extra-packages com.android.dialer.contacts.displaypreference",
+ "--extra-packages com.android.dialer.contacts.resources",
+ "--extra-packages com.android.dialer.contactsfragment",
+ "--extra-packages com.android.dialer.databasepopulator",
+ "--extra-packages com.android.dialer.dialpadview",
+ "--extra-packages com.android.dialer.dialpadview.theme",
+ "--extra-packages com.android.dialer.glidephotomanager.impl",
+ "--extra-packages com.android.dialer.historyitemactions",
+ "--extra-packages com.android.dialer.interactions",
+ "--extra-packages com.android.dialer.lettertile",
+ "--extra-packages com.android.dialer.location",
+ "--extra-packages com.android.dialer.main.impl",
+ "--extra-packages com.android.dialer.main.impl.bottomnav",
+ "--extra-packages com.android.dialer.main.impl.toolbar",
+ "--extra-packages com.android.dialer.notification",
+ "--extra-packages com.android.dialer.oem",
+ "--extra-packages com.android.dialer.phonelookup.database",
+ "--extra-packages com.android.dialer.phonenumberutil",
+ "--extra-packages com.android.dialer.postcall",
+ "--extra-packages com.android.dialer.precall.externalreceiver",
+ "--extra-packages com.android.dialer.precall.impl",
+ "--extra-packages com.android.dialer.preferredsim.impl",
+ "--extra-packages com.android.dialer.preferredsim.suggestion",
+ "--extra-packages com.android.dialer.promotion.impl",
+ "--extra-packages com.android.dialer.rtt",
+ "--extra-packages com.android.dialer.searchfragment.common",
+ "--extra-packages com.android.dialer.searchfragment.cp2",
+ "--extra-packages com.android.dialer.searchfragment.directories",
+ "--extra-packages com.android.dialer.searchfragment.list",
+ "--extra-packages com.android.dialer.searchfragment.nearbyplaces",
+ "--extra-packages com.android.dialer.shortcuts",
+ "--extra-packages com.android.dialer.simulator.impl",
+ "--extra-packages com.android.dialer.simulator.service",
+ "--extra-packages com.android.dialer.spannable",
+ "--extra-packages com.android.dialer.speeddial",
+ "--extra-packages com.android.dialer.theme",
+ "--extra-packages com.android.dialer.theme.base",
+ "--extra-packages com.android.dialer.theme.base.impl",
+ "--extra-packages com.android.dialer.theme.common",
+ "--extra-packages com.android.dialer.theme.hidden",
+ "--extra-packages com.android.dialer.util",
+ "--extra-packages com.android.dialer.voicemail.listui",
+ "--extra-packages com.android.dialer.voicemail.listui.error",
+ "--extra-packages com.android.dialer.voicemail.settings",
+ "--extra-packages com.android.dialer.voicemailstatus",
+ "--extra-packages com.android.dialer.widget",
+ "--extra-packages com.android.incallui",
+ "--extra-packages com.android.incallui.answer.impl",
+ "--extra-packages com.android.incallui.answer.impl.affordance",
+ "--extra-packages com.android.incallui.answer.impl.answermethod",
+ "--extra-packages com.android.incallui.answer.impl.hint",
+ "--extra-packages com.android.incallui.audioroute",
+ "--extra-packages com.android.incallui.autoresizetext",
+ "--extra-packages com.android.incallui.callpending",
+ "--extra-packages com.android.incallui.commontheme",
+ "--extra-packages com.android.incallui.contactgrid",
+ "--extra-packages com.android.incallui.disconnectdialog",
+ "--extra-packages com.android.incallui.hold",
+ "--extra-packages com.android.incallui.incall.impl",
+ "--extra-packages com.android.incallui.rtt.impl",
+ "--extra-packages com.android.incallui.rtt.protocol",
+ "--extra-packages com.android.incallui.sessiondata",
+ "--extra-packages com.android.incallui.spam",
+ "--extra-packages com.android.incallui.speakerbuttonlogic",
+ "--extra-packages com.android.incallui.telecomeventui",
+ "--extra-packages com.android.incallui.video.impl",
+ "--extra-packages com.android.incallui.video.protocol",
+ "--extra-packages com.android.voicemail",
+ "--extra-packages com.android.voicemail.impl",
+ "--extra-packages com.android.voicemail.impl.configui",
+ ],
+ aidl: {
+ local_include_dirs: ["java"],
+ },
+ certificate: "shared",
+ exclude_srcs: ["java/com/android/dialer/rootcomponentgenerator/*.java"],
+ libs: [
+ "auto_value_annotations",
+ "org.apache.http.legacy",
+ ],
+ optimize: {
+ proguard_flags_files: [
+ "java/com/android/dialer/common/proguard.flags",
+ "java/com/android/dialer/proguard/proguard.flags",
+ "java/com/android/dialer/proguard/proguard_base.flags",
+ "java/com/android/dialer/proguard/proguard_release.flags",
+ "java/com/android/incallui/answer/impl/proguard.flags",
+ "java/com/android/voicemail/impl/proguard.flags",
+ "proguard.flags",
+ ],
+ },
+ optional_uses_libs: ["org.apache.http.legacy"],
+ plugins: [
+ "auto_value_plugin",
+ "dagger2-compiler",
+ "dialer-rootcomponentprocessor",
+ "glide-annotation-processor",
+ ],
+ privileged: true,
+ product_specific: true,
+ required: [
+ "privapp_whitelist_com.android.dialer",
+ "privapp_whitelist_com.android.dialer-ext.xml",
+ ],
+ resource_dirs: [
+ "assets/quantum/res",
+ "java/com/android/contacts/common/res",
+ "java/com/android/dialer/app/res",
+ "java/com/android/dialer/assisteddialing/res",
+ "java/com/android/dialer/assisteddialing/ui/res",
+ "java/com/android/dialer/blocking/res",
+ "java/com/android/dialer/blockreportspam/res",
+ "java/com/android/dialer/calldetails/res",
+ "java/com/android/dialer/calllog/ui/menu/res",
+ "java/com/android/dialer/calllogutils/res",
+ "java/com/android/dialer/callrecord/res",
+ "java/com/android/dialer/callstats/res",
+ "java/com/android/dialer/clipboard/res",
+ "java/com/android/dialer/common/res",
+ "java/com/android/dialer/contactphoto/res",
+ "java/com/android/dialer/contacts/displaypreference/res",
+ "java/com/android/dialer/contacts/resources/res",
+ "java/com/android/dialer/contactsfragment/res",
+ "java/com/android/dialer/dialpadview/res",
+ "java/com/android/dialer/dialpadview/theme/res",
+ "java/com/android/dialer/glidephotomanager/impl/res",
+ "java/com/android/dialer/helplines/res",
+ "java/com/android/dialer/historyitemactions/res",
+ "java/com/android/dialer/interactions/res",
+ "java/com/android/dialer/lettertile/res",
+ "java/com/android/dialer/lookup/res",
+ "java/com/android/dialer/main/impl/bottomnav/res",
+ "java/com/android/dialer/main/impl/res",
+ "java/com/android/dialer/main/impl/toolbar/res",
+ "java/com/android/dialer/notification/res",
+ "java/com/android/dialer/oem/res",
+ "java/com/android/dialer/phonenumberutil/res",
+ "java/com/android/dialer/postcall/res",
+ "java/com/android/dialer/precall/impl/res",
+ "java/com/android/dialer/preferredsim/impl/res",
+ "java/com/android/dialer/preferredsim/suggestion/res",
+ "java/com/android/dialer/promotion/impl/res",
+ "java/com/android/dialer/rtt/res",
+ "java/com/android/dialer/searchfragment/common/res",
+ "java/com/android/dialer/searchfragment/cp2/res",
+ "java/com/android/dialer/searchfragment/directories/res",
+ "java/com/android/dialer/searchfragment/list/res",
+ "java/com/android/dialer/searchfragment/nearbyplaces/res",
+ "java/com/android/dialer/searchfragment/remote/res",
+ "java/com/android/dialer/shortcuts/res",
+ "java/com/android/dialer/spannable/res",
+ "java/com/android/dialer/speeddial/res",
+ "java/com/android/dialer/theme/base/res",
+ "java/com/android/dialer/theme/common/res",
+ "java/com/android/dialer/theme/hidden/res",
+ "java/com/android/dialer/theme/res",
+ "java/com/android/dialer/util/res",
+ "java/com/android/dialer/voicemail/listui/error/res",
+ "java/com/android/dialer/voicemail/listui/res",
+ "java/com/android/dialer/voicemail/settings/res",
+ "java/com/android/dialer/widget/res",
+ "java/com/android/incallui/answer/impl/affordance/res",
+ "java/com/android/incallui/answer/impl/answermethod/res",
+ "java/com/android/incallui/answer/impl/res",
+ "java/com/android/incallui/audioroute/res",
+ "java/com/android/incallui/autoresizetext/res",
+ "java/com/android/incallui/callpending/res",
+ "java/com/android/incallui/commontheme/res",
+ "java/com/android/incallui/contactgrid/res",
+ "java/com/android/incallui/disconnectdialog/res",
+ "java/com/android/incallui/hold/res",
+ "java/com/android/incallui/incall/impl/res",
+ "java/com/android/incallui/res",
+ "java/com/android/incallui/rtt/impl/res",
+ "java/com/android/incallui/sessiondata/res",
+ "java/com/android/incallui/spam/res",
+ "java/com/android/incallui/speakerbuttonlogic/res",
+ "java/com/android/incallui/telecomeventui/res",
+ "java/com/android/incallui/theme/res",
+ "java/com/android/incallui/video/impl/res",
+ "java/com/android/incallui/video/protocol/res",
+ "java/com/android/voicemail/impl/configui/res",
+ "java/com/android/voicemail/impl/res",
+ ],
+ sdk_version: "system_current",
+ srcs: [
+ "java/**/I*.aidl",
+ "java/**/*.java",
+ ],
+ static_libs: [
+ "android-common",
+ "androidx.annotation_annotation",
+ "androidx.appcompat_appcompat",
+ "androidx.cardview_cardview",
+ "androidx.collection_collection",
+ "androidx.coordinatorlayout_coordinatorlayout",
+ "androidx.dynamicanimation_dynamicanimation",
+ "androidx.exifinterface_exifinterface",
+ "androidx.fragment_fragment",
+ "androidx.localbroadcastmanager_localbroadcastmanager",
+ "androidx.preference_preference",
+ "androidx.recyclerview_recyclerview",
+ "apache-commons-compress",
+ "com.google.android.material_material",
+ "dagger2",
+ "dialer-apache-mime4j-core",
+ "dialer-apache-mime4j-dom",
+ "dialer-commons-io",
+ "dialer-protos",
+ "error_prone_annotations",
+ "glide-annotation-and-compiler-prebuilt",
+ "glide-disklrucache-prebuilt",
+ "glide-gifdecoder-prebuilt",
+ "glide-prebuilt",
+ "guava",
+ "jsr305",
+ "jsr330",
+ "libphonenumber",
+ "org.lineageos.lib.phone",
+ "volley",
+ "elib",
+ ],
+ use_embedded_native_libs: true,
+}
+
+java_library {
+ name: "dialer-protos",
+ proto: {
+ canonical_path_from_root: false,
+ type: "lite",
+ },
+ sdk_version: "system_current",
+ srcs: ["java/**/*.proto",],
+ static_libs: ["libprotobuf-java-lite"],
+}
+
+java_plugin {
+ name: "dialer-rootcomponentprocessor",
+ processor_class: "com.android.dialer.rootcomponentgenerator.RootComponentProcessor",
+ srcs: [
+ "java/com/android/dialer/rootcomponentgenerator/*.java",
+ "java/com/android/dialer/inject/HasRootComponent.java",
+ "java/com/android/dialer/inject/IncludeInDialerRoot.java",
+ "java/com/android/dialer/inject/RootComponentGeneratorMetadata.java",
+ ],
+ static_libs: [
+ "auto_common",
+ "auto_service_annotations",
+ "dagger2",
+ "guava",
+ "javapoet",
+ "jsr330",
+ ],
+}
+
+prebuilt_etc {
+ name: "privapp_whitelist_com.android.dialer-ext.xml",
+ product_specific: true,
+ src: "privapp_whitelist_com.android.dialer-ext.xml",
+ sub_dir: "permissions",
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 786d5a69b73257e59509ccbe81b85c082af8b8c8..0000000000000000000000000000000000000000
--- a/Android.mk
+++ /dev/null
@@ -1,349 +0,0 @@
-# Local modifications:
-# * removed com.google.android.geo.API_KEY key. This should be added to
-# the manifest files in java/com/android/incallui/calllocation/impl/
-# and /java/com/android/incallui/maps/impl/
-# * b/62417801 modify translation string naming convention:
-# $ find . -type d | grep 262 | rename 's/(values)\-([a-zA-Z\+\-]+)\-(mcc262-mnc01)/$1-$3-$2/'
-# * b/37077388 temporarily disable proguard with javac
-# * b/62875795 include manually generated GRPC service class:
-# $ protoc --plugin=protoc-gen-grpc-java=prebuilts/tools/common/m2/repository/io/grpc/protoc-gen-grpc-java/1.0.3/protoc-gen-grpc-java-1.0.3-linux-x86_64.exe \
-# --grpc-java_out=lite:"packages/apps/Dialer/java/com/android/voicemail/impl/" \
-# --proto_path="packages/apps/Dialer/java/com/android/voicemail/impl/transcribe/grpc/" "packages/apps/Dialer/java/com/android/voicemail/impl/transcribe/grpc/voicemail_transcription.proto"
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# The base directory for Dialer sources.
-BASE_DIR := java/com/android
-
-# Exclude testing only class, not used anywhere here
-EXCLUDE_FILES += \
- $(BASE_DIR)/contacts/common/format/testing/SpannedTestUtils.java
-
-# Exclude rootcomponentgenerator
-EXCLUDE_FILES += \
- $(call all-java-files-under, $(BASE_DIR)/dialer/rootcomponentgenerator) \
-
-# All Dialer resources.
-RES_DIRS := $(call all-subdir-named-dirs,res,.)
-
-# Dialer manifest files to merge.
-DIALER_MANIFEST_FILES := $(call all-named-files-under,AndroidManifest.xml,.)
-
-# Merge all manifest files.
-LOCAL_FULL_LIBS_MANIFEST_FILES := \
- $(addprefix $(LOCAL_PATH)/, $(DIALER_MANIFEST_FILES))
-
-LOCAL_SRC_FILES := $(call all-java-files-under, $(BASE_DIR))
-LOCAL_SRC_FILES += $(call all-proto-files-under, $(BASE_DIR))
-LOCAL_SRC_FILES += $(call all-Iaidl-files-under, $(BASE_DIR))
-LOCAL_SRC_FILES := $(filter-out $(EXCLUDE_FILES),$(LOCAL_SRC_FILES))
-
-LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/java
-
-LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)
-
-LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(RES_DIRS))
-
-# We specify each package explicitly to glob resource files.
-include ${LOCAL_PATH}/packages.mk
-
-LOCAL_AAPT_FLAGS := $(addprefix --extra-packages , $(LOCAL_AAPT_FLAGS))
-LOCAL_AAPT_FLAGS += \
- --auto-add-overlay \
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-common \
- android-support-dynamic-animation \
- dialer-commons-io-target \
- dialer-dagger2-target \
- dialer-disklrucache-target \
- dialer-gifdecoder-target \
- dialer-glide-target \
- dialer-j2objc-annotations-target \
- dialer-javax-annotation-api-target \
- dialer-javax-inject-target \
- dialer-mime4j-core-target \
- dialer-mime4j-dom-target \
- dialer-guava-target \
- dialer-glide-target \
- dialer-glide-annotation-target \
- error_prone_annotations \
- jsr305 \
- libphonenumber \
- volley \
- org.lineageos.lib.phone \
- androidx.annotation_annotation \
-
-LOCAL_STATIC_ANDROID_LIBRARIES := \
- android-support-core-ui \
- $(ANDROID_SUPPORT_DESIGN_TARGETS) \
- android-support-transition \
- android-support-v13 \
- android-support-v4 \
- android-support-v7-appcompat \
- android-support-v7-cardview \
- android-support-v7-recyclerview \
-
-LOCAL_JAVA_LIBRARIES := \
- auto_value_annotations \
- org.apache.http.legacy \
-
-LOCAL_ANNOTATION_PROCESSORS := \
- auto_value_plugin \
- javapoet-prebuilt-jar \
- dialer-dagger2 \
- dialer-dagger2-compiler \
- dialer-dagger2-producers \
- dialer-glide-annotation \
- dialer-glide-compiler \
- dialer-guava \
- dialer-javax-annotation-api \
- dialer-javax-inject \
- dialer-rootcomponentprocessor
-
-LOCAL_ANNOTATION_PROCESSOR_CLASSES := \
- com.google.auto.value.processor.AutoValueProcessor,dagger.internal.codegen.ComponentProcessor,com.bumptech.glide.annotation.compiler.GlideAnnotationProcessor,com.android.dialer.rootcomponentgenerator.RootComponentProcessor
-
-# Proguard includes
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags $(call all-named-files-under,proguard.*flags,$(BASE_DIR))
-LOCAL_PROGUARD_ENABLED := custom
-
-LOCAL_PROGUARD_ENABLED += optimization
-
-LOCAL_SDK_VERSION := system_current
-LOCAL_MODULE_TAGS := optional
-LOCAL_PACKAGE_NAME := Dialer
-LOCAL_CERTIFICATE := shared
-LOCAL_PRIVILEGED_MODULE := true
-LOCAL_PRODUCT_MODULE := true
-LOCAL_USE_AAPT2 := true
-LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.dialer
-LOCAL_REQUIRED_MODULES += privapp_whitelist_com.android.dialer-ext.xml
-LOCAL_USES_LIBRARIES := org.apache.http.legacy
-
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-include $(BUILD_PACKAGE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := privapp_whitelist_com.android.dialer-ext.xml
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_ETC)/permissions
-LOCAL_PRODUCT_MODULE := true
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-include $(BUILD_PREBUILT)
-
-# Cleanup local state
-BASE_DIR :=
-EXCLUDE_FILES :=
-RES_DIRS :=
-DIALER_MANIFEST_FILES :=
-EXCLUDE_MANIFESTS :=
-EXCLUDE_EXTRA_PACKAGES :=
-
-# Create references to prebuilt libraries.
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
- dialer-dagger2-compiler:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger-compiler/2.7/dagger-compiler-2.7.jar \
- dialer-dagger2:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger/2.7/dagger-2.7.jar \
- dialer-dagger2-producers:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger-producers/2.7/dagger-producers-2.7.jar \
- dialer-glide-annotation:../../../prebuilts/maven_repo/bumptech/com/github/bumptech/glide/annotation/SNAPSHOT/annotation-SNAPSHOT.jar \
- dialer-glide-compiler:../../../prebuilts/maven_repo/bumptech/com/github/bumptech/glide/compiler/SNAPSHOT/compiler-SNAPSHOT.jar \
- dialer-guava:../../../prebuilts/tools/common/m2/repository/com/google/guava/guava/23.0/guava-23.0.jar \
- dialer-javax-annotation-api:../../../prebuilts/tools/common/m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar \
- dialer-javax-inject:../../../prebuilts/tools/common/m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar \
-
-include $(BUILD_HOST_PREBUILT)
-
-# Enumerate target prebuilts to avoid linker warnings like
-# Dialer (java:sdk) should not link to dialer-guava (java:platform)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-guava-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/com/google/guava/guava/23.0/guava-23.0.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-dagger2-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger/2.7/dagger-2.7.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-disklrucache-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/maven_repo/bumptech/com/github/bumptech/glide/disklrucache/SNAPSHOT/disklrucache-SNAPSHOT.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-gifdecoder-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/maven_repo/bumptech/com/github/bumptech/glide/gifdecoder/SNAPSHOT/gifdecoder-SNAPSHOT.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-glide-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/maven_repo/bumptech/com/github/bumptech/glide/glide/SNAPSHOT/glide-SNAPSHOT.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-glide-annotation-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/maven_repo/bumptech/com/github/bumptech/glide/annotation/SNAPSHOT/annotation-SNAPSHOT.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-javax-annotation-api-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-javax-inject-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-commons-io-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-mime4j-core-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/org/apache/james/apache-mime4j-core/0.7.2/apache-mime4j-core-0.7.2.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-mime4j-dom-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/org/apache/james/apache-mime4j-dom/0.7.2/apache-mime4j-dom-0.7.2.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE := dialer-j2objc-annotations-target
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar
-LOCAL_UNINSTALLABLE_MODULE := true
-
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := dialer-rootcomponentprocessor
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_IS_HOST_MODULE := true
-BASE_DIR := java/com/android
-
-LOCAL_SRC_FILES := \
- $(call all-java-files-under, $(BASE_DIR)/dialer/rootcomponentgenerator) \
- $(BASE_DIR)/dialer/inject/HasRootComponent.java \
- $(BASE_DIR)/dialer/inject/IncludeInDialerRoot.java \
- $(BASE_DIR)/dialer/inject/RootComponentGeneratorMetadata.java
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- dialer-guava \
- dialer-dagger2 \
- javapoet-prebuilt-jar \
- auto_service_annotations \
- auto_common \
- dialer-javax-annotation-api \
- dialer-javax-inject \
- error_prone_annotations
-
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(CLEAR_VARS)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9dd5dc7e3acd0e880a815673c9fab1e820f5f42c..8bbde4c7262432784a56dc36ecd2654d3c3ff780 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -14,102 +14,739 @@
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ xmlns:tools="http://schemas.android.com/tools"
+ coreApp="true"
+ package="com.android.dialer"
+ android:versionCode="2900000"
+ android:versionName="23.0">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/assets/quantum/AndroidManifest.xml b/assets/quantum/AndroidManifest.xml
deleted file mode 100644
index 28f8eec9708689832b4167c74bb6b71898063d05..0000000000000000000000000000000000000000
--- a/assets/quantum/AndroidManifest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
diff --git a/java/com/android/contacts/common/AndroidManifest.xml b/java/com/android/contacts/common/AndroidManifest.xml
deleted file mode 100644
index cb1777a122104c912edf81ce11a90aa69dd7b690..0000000000000000000000000000000000000000
--- a/java/com/android/contacts/common/AndroidManifest.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/java/com/android/contacts/common/Collapser.java b/java/com/android/contacts/common/Collapser.java
index 0b5c48bf260f8e25e020969787f332cabd789b01..f3d6850f0a8225e738ccf29d71356e61e13dbfd7 100644
--- a/java/com/android/contacts/common/Collapser.java
+++ b/java/com/android/contacts/common/Collapser.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +18,9 @@
package com.android.contacts.common;
import android.content.Context;
-import java.util.Iterator;
+
import java.util.List;
+import java.util.Objects;
/**
* Class used for collapsing data items into groups of similar items. The data items that should be
@@ -74,12 +76,7 @@ public final class Collapser {
}
// Remove the null items
- Iterator itr = list.iterator();
- while (itr.hasNext()) {
- if (itr.next() == null) {
- itr.remove();
- }
- }
+ list.removeIf(Objects::isNull);
}
/*
diff --git a/java/com/android/contacts/common/ContactTileLoaderFactory.java b/java/com/android/contacts/common/ContactTileLoaderFactory.java
index 80eda882bb32fd2b2a31f9306fc08d2d915fa697..c82b670cd0b79e79bcb719b93d9e9c02493fd913 100644
--- a/java/com/android/contacts/common/ContactTileLoaderFactory.java
+++ b/java/com/android/contacts/common/ContactTileLoaderFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +17,13 @@
package com.android.contacts.common;
import android.content.Context;
-import android.content.CursorLoader;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
+import androidx.loader.content.CursorLoader;
+
/**
* Used to create {@link CursorLoader} which finds contacts information from the strequents table.
*
@@ -56,7 +58,6 @@ public final class ContactTileLoaderFactory {
.buildUpon()
.appendQueryParameter(ContactsContract.STREQUENT_PHONE_ONLY, "true")
.build();
-
return new CursorLoader(context, uri, COLUMNS_PHONE_ONLY, null, null, null);
}
}
diff --git a/java/com/android/contacts/common/ContactsUtils.java b/java/com/android/contacts/common/ContactsUtils.java
index 5dac957755d7bd41b7bd605d2fe421517657821a..1a243615722aedf85dfa2b00af5870360f6cea67 100644
--- a/java/com/android/contacts/common/ContactsUtils.java
+++ b/java/com/android/contacts/common/ContactsUtils.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +20,7 @@ package com.android.contacts.common;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Directory;
-import androidx.annotation.IntDef;
+import androidx.annotation.LongDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -80,6 +81,6 @@ public class ContactsUtils {
*/
@Retention(RetentionPolicy.SOURCE)
// TODO: Switch to @LongDef when @LongDef is available in the support library
- @IntDef({(int) USER_TYPE_CURRENT, (int) USER_TYPE_WORK})
+ @LongDef({USER_TYPE_CURRENT, USER_TYPE_WORK})
public @interface UserType {}
}
diff --git a/java/com/android/contacts/common/GroupMetaData.java b/java/com/android/contacts/common/GroupMetaData.java
index 6afb2a44b35c029aff0170b123cd21fcd6426e9e..506fe44e190306f16de7ddf77f00d4c0e0bb8608 100644
--- a/java/com/android/contacts/common/GroupMetaData.java
+++ b/java/com/android/contacts/common/GroupMetaData.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,13 +22,13 @@ package com.android.contacts.common;
*/
public final class GroupMetaData {
- private String mAccountName;
- private String mAccountType;
- private String mDataSet;
- private long mGroupId;
- private String mTitle;
- private boolean mDefaultGroup;
- private boolean mFavorites;
+ private final String mAccountName;
+ private final String mAccountType;
+ private final String mDataSet;
+ private final long mGroupId;
+ private final String mTitle;
+ private final boolean mDefaultGroup;
+ private final boolean mFavorites;
public GroupMetaData(
String accountName,
diff --git a/java/com/android/contacts/common/MoreContactUtils.java b/java/com/android/contacts/common/MoreContactUtils.java
index 9749cabfdf9a822d59e727b6471f1e47403ece84..8fc22706e3c356caf03678b969fd806c9ddd8039 100644
--- a/java/com/android/contacts/common/MoreContactUtils.java
+++ b/java/com/android/contacts/common/MoreContactUtils.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ import android.provider.ContactsContract;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.View;
+
import com.android.contacts.common.model.account.AccountType;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
diff --git a/java/com/android/contacts/common/database/EmptyCursor.java b/java/com/android/contacts/common/database/EmptyCursor.java
index c2b24cdf7eaca3c4b1cf94ba20a6b44accfb5b2b..768302e1b4650b199688d18452136323862b3ae9 100644
--- a/java/com/android/contacts/common/database/EmptyCursor.java
+++ b/java/com/android/contacts/common/database/EmptyCursor.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +28,7 @@ import android.database.CursorIndexOutOfBoundsException;
*/
public final class EmptyCursor extends AbstractCursor {
- private String[] mColumns;
+ private final String[] mColumns;
public EmptyCursor(String[] columns) {
this.mColumns = columns;
diff --git a/java/com/android/contacts/common/dialog/CallSubjectDialog.java b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
index bf0ac14b25881261077f92f8c23d18be4c2ebaa4..610316b956d2cf9a3632d18e6e120ee23f936c84 100644
--- a/java/com/android/contacts/common/dialog/CallSubjectDialog.java
+++ b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +25,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -41,15 +41,20 @@ import android.widget.EditText;
import android.widget.ListView;
import android.widget.QuickContactBadge;
import android.widget.TextView;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.preference.PreferenceManager;
+
+import com.android.dialer.R;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.common.LogUtil;
import com.android.dialer.contactphoto.ContactPhotoManager;
-import com.android.dialer.contacts.resources.R;
import com.android.dialer.lettertile.LetterTileDrawable;
import com.android.dialer.precall.PreCall;
import com.android.dialer.util.ViewUtil;
+
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -58,7 +63,7 @@ import java.util.List;
* Implements a dialog which prompts for a call subject for an outgoing call. The dialog includes a
* pop up list of historical call subjects.
*/
-public class CallSubjectDialog extends Activity {
+public class CallSubjectDialog extends AppCompatActivity {
public static final String PREF_KEY_SUBJECT_HISTORY_COUNT = "subject_history_count";
public static final String PREF_KEY_SUBJECT_HISTORY_ITEM = "subject_history_item";
@@ -83,8 +88,6 @@ public class CallSubjectDialog extends Activity {
private TextView mNumberView;
private EditText mCallSubjectView;
private TextView mCharacterLimitView;
- private View mHistoryButton;
- private View mSendAndCallButton;
private ListView mSubjectList;
private int mLimit = CALL_SUBJECT_LIMIT;
@@ -110,27 +113,19 @@ public class CallSubjectDialog extends Activity {
private SharedPreferences mPrefs;
private List mSubjectHistory;
/** Handles displaying the list of past call subjects. */
- private final View.OnClickListener mHistoryOnClickListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- hideSoftKeyboard(CallSubjectDialog.this, mCallSubjectView);
- showCallHistory(mSubjectList.getVisibility() == View.GONE);
- }
- };
+ private final View.OnClickListener mHistoryOnClickListener = v -> {
+ hideSoftKeyboard(CallSubjectDialog.this, mCallSubjectView);
+ showCallHistory(mSubjectList.getVisibility() == View.GONE);
+ };
/**
* Handles auto-hiding the call history when user clicks in the call subject field to give it
* focus.
*/
- private final View.OnClickListener mCallSubjectClickListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mSubjectList.getVisibility() == View.VISIBLE) {
- showCallHistory(false);
- }
- }
- };
+ private final View.OnClickListener mCallSubjectClickListener = v -> {
+ if (mSubjectList.getVisibility() == View.VISIBLE) {
+ showCallHistory(false);
+ }
+ };
private long mPhotoID;
private Uri mPhotoUri;
@@ -142,43 +137,31 @@ public class CallSubjectDialog extends Activity {
private int mContactType;
private PhoneAccountHandle mPhoneAccountHandle;
/** Handles starting a call with a call subject specified. */
- private final View.OnClickListener mSendAndCallOnClickListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String subject = mCallSubjectView.getText().toString();
- PreCall.start(
- CallSubjectDialog.this,
- new CallIntentBuilder(mNumber, CallInitiationType.Type.CALL_SUBJECT_DIALOG)
- .setPhoneAccountHandle(mPhoneAccountHandle)
- .setCallSubject(subject));
-
- mSubjectHistory.add(subject);
- saveSubjectHistory(mSubjectHistory);
- finish();
- }
- };
+ private final View.OnClickListener mSendAndCallOnClickListener = v -> {
+ String subject = mCallSubjectView.getText().toString();
+ PreCall.start(
+ CallSubjectDialog.this,
+ new CallIntentBuilder(mNumber, CallInitiationType.Type.CALL_SUBJECT_DIALOG)
+ .setPhoneAccountHandle(mPhoneAccountHandle)
+ .setCallSubject(subject));
+
+ mSubjectHistory.add(subject);
+ saveSubjectHistory(mSubjectHistory);
+ finish();
+ };
+
/** Click listener which handles user clicks outside of the dialog. */
- private View.OnClickListener mBackgroundListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- };
+ private final View.OnClickListener mBackgroundListener = v -> finish();
/**
* Item click listener which handles user clicks on the items in the list view. Dismisses the
* activity, returning the subject to the caller and closing the activity with the {@link
* Activity#RESULT_OK} result code.
*/
- private AdapterView.OnItemClickListener mItemClickListener =
- new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> arg0, View view, int position, long arg3) {
- mCallSubjectView.setText(mSubjectHistory.get(position));
- showCallHistory(false);
- }
- };
+ private final AdapterView.OnItemClickListener mItemClickListener =
+ (arg0, view, position, arg3) -> {
+ mCallSubjectView.setText(mSubjectHistory.get(position));
+ showCallHistory(false);
+ };
/**
* Show the call subject dialog given a phone number to dial (e.g. from the dialpad).
@@ -291,22 +274,22 @@ public class CallSubjectDialog extends Activity {
mBackgroundView = findViewById(R.id.call_subject_dialog);
mBackgroundView.setOnClickListener(mBackgroundListener);
mDialogView = findViewById(R.id.dialog_view);
- mContactPhoto = (QuickContactBadge) findViewById(R.id.contact_photo);
- mNameView = (TextView) findViewById(R.id.name);
- mNumberView = (TextView) findViewById(R.id.number);
- mCallSubjectView = (EditText) findViewById(R.id.call_subject);
+ mContactPhoto = findViewById(R.id.contact_photo);
+ mNameView = findViewById(R.id.name);
+ mNumberView = findViewById(R.id.number);
+ mCallSubjectView = findViewById(R.id.call_subject);
mCallSubjectView.addTextChangedListener(mTextWatcher);
mCallSubjectView.setOnClickListener(mCallSubjectClickListener);
InputFilter[] filters = new InputFilter[1];
filters[0] = new InputFilter.LengthFilter(mLimit);
mCallSubjectView.setFilters(filters);
- mCharacterLimitView = (TextView) findViewById(R.id.character_limit);
- mHistoryButton = findViewById(R.id.history_button);
- mHistoryButton.setOnClickListener(mHistoryOnClickListener);
- mHistoryButton.setVisibility(mSubjectHistory.isEmpty() ? View.GONE : View.VISIBLE);
- mSendAndCallButton = findViewById(R.id.send_and_call_button);
- mSendAndCallButton.setOnClickListener(mSendAndCallOnClickListener);
- mSubjectList = (ListView) findViewById(R.id.subject_list);
+ mCharacterLimitView = findViewById(R.id.character_limit);
+ View historyButton = findViewById(R.id.history_button);
+ historyButton.setOnClickListener(mHistoryOnClickListener);
+ historyButton.setVisibility(mSubjectHistory.isEmpty() ? View.GONE : View.VISIBLE);
+ View sendAndCallButton = findViewById(R.id.send_and_call_button);
+ sendAndCallButton.setOnClickListener(mSendAndCallOnClickListener);
+ mSubjectList = findViewById(R.id.subject_list);
mSubjectList.setOnItemClickListener(mItemClickListener);
mSubjectList.setVisibility(View.GONE);
@@ -344,14 +327,15 @@ public class CallSubjectDialog extends Activity {
return;
}
mPhotoID = arguments.getLong(ARG_PHOTO_ID);
- mPhotoUri = arguments.getParcelable(ARG_PHOTO_URI);
- mContactUri = arguments.getParcelable(ARG_CONTACT_URI);
+ mPhotoUri = arguments.getParcelable(ARG_PHOTO_URI, Uri.class);
+ mContactUri = arguments.getParcelable(ARG_CONTACT_URI, Uri.class);
mNameOrNumber = arguments.getString(ARG_NAME_OR_NUMBER);
mNumber = arguments.getString(ARG_NUMBER);
mDisplayNumber = arguments.getString(ARG_DISPLAY_NUMBER);
mNumberLabel = arguments.getString(ARG_NUMBER_LABEL);
mContactType = arguments.getInt(ARG_CONTACT_TYPE, LetterTileDrawable.TYPE_DEFAULT);
- mPhoneAccountHandle = arguments.getParcelable(ARG_PHONE_ACCOUNT_HANDLE);
+ mPhoneAccountHandle = arguments.getParcelable(ARG_PHONE_ACCOUNT_HANDLE,
+ PhoneAccountHandle.class);
}
/**
@@ -370,13 +354,14 @@ public class CallSubjectDialog extends Activity {
length = subjectText.length();
}
- mCharacterLimitView.setText(getString(R.string.call_subject_limit, length, mLimit));
+ mCharacterLimitView.setText(getString(R.string.call_subject_limit,
+ String.valueOf(length), String.valueOf(mLimit)));
if (length >= mLimit) {
mCharacterLimitView.setTextColor(
- getResources().getColor(R.color.call_subject_limit_exceeded));
+ getResources().getColor(R.color.call_subject_limit_exceeded, getTheme()));
} else {
mCharacterLimitView.setTextColor(
- getResources().getColor(R.color.dialer_secondary_text_color));
+ getResources().getColor(R.color.dialer_secondary_text_color, getTheme()));
}
}
@@ -428,9 +413,8 @@ public class CallSubjectDialog extends Activity {
final int dialogStartingBottom = mDialogView.getBottom();
if (show) {
// Showing the subject list; bind the list of history items to the list and show it.
- ArrayAdapter adapter =
- new ArrayAdapter(
- CallSubjectDialog.this, R.layout.call_subject_history_list_item, mSubjectHistory);
+ ArrayAdapter adapter = new ArrayAdapter<>(CallSubjectDialog.this,
+ R.layout.call_subject_history_list_item, mSubjectHistory);
mSubjectList.setAdapter(adapter);
mSubjectList.setVisibility(View.VISIBLE);
} else {
diff --git a/java/com/android/contacts/common/dialog/ClearFrequentsDialog.java b/java/com/android/contacts/common/dialog/ClearFrequentsDialog.java
index cd9511c38b4cee925a710f2a4d661b8ffa1709c5..ecea6ce28bdbfc74469fd6dc869bb6fe9160392c 100644
--- a/java/com/android/contacts/common/dialog/ClearFrequentsDialog.java
+++ b/java/com/android/contacts/common/dialog/ClearFrequentsDialog.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,21 +17,26 @@
package com.android.contacts.common.dialog;
-import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.FragmentManager;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
-import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.provider.ContactsContract;
-import com.android.dialer.contacts.resources.R;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.FragmentManager;
+
+import com.android.dialer.R;
import com.android.dialer.util.PermissionsUtil;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
/** Dialog that clears the frequently contacted list after confirming with the user. */
public class ClearFrequentsDialog extends DialogFragment {
@@ -44,39 +50,27 @@ public class ClearFrequentsDialog extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity().getApplicationContext();
final ContentResolver resolver = getActivity().getContentResolver();
- final OnClickListener okListener =
- new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (!PermissionsUtil.hasContactsReadPermissions(context)) {
- return;
- }
+ final OnClickListener okListener = (dialog, which) -> {
+ if (!PermissionsUtil.hasContactsReadPermissions(context)) {
+ return;
+ }
- final ProgressDialog progressDialog =
- ProgressDialog.show(
- getContext(),
- getString(R.string.clearFrequentsProgress_title),
- null,
- true,
- true);
+ final ProgressDialog progressDialog =
+ ProgressDialog.show(
+ getContext(),
+ getString(R.string.clearFrequentsProgress_title),
+ null,
+ true,
+ true);
- final AsyncTask task =
- new AsyncTask() {
- @Override
- protected Void doInBackground(Void... params) {
- resolver.delete(
- ContactsContract.DataUsageFeedback.DELETE_USAGE_URI, null, null);
- return null;
- }
+ final ExecutorService executorService = Executors.newSingleThreadExecutor();
+ final Handler handler = new Handler(Looper.getMainLooper());
- @Override
- protected void onPostExecute(Void result) {
- progressDialog.dismiss();
- }
- };
- task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- };
+ executorService.execute(() -> {
+ resolver.delete(ContactsContract.DataUsageFeedback.DELETE_USAGE_URI, null, null);
+ handler.post(progressDialog::dismiss);
+ });
+ };
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.clearFrequentsConfirmation_title)
.setMessage(R.string.clearFrequentsConfirmation)
diff --git a/java/com/android/contacts/common/list/ContactEntry.java b/java/com/android/contacts/common/list/ContactEntry.java
index 75e6509e79080a7525ccc0bb75049f965a9e7bfe..31942554ef8ebbc1ddc538cfdfc4459cd11d914c 100644
--- a/java/com/android/contacts/common/list/ContactEntry.java
+++ b/java/com/android/contacts/common/list/ContactEntry.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +20,7 @@ package com.android.contacts.common.list;
import android.content.Context;
import android.net.Uri;
import android.provider.ContactsContract.PinnedPositions;
+
import com.android.dialer.contacts.ContactsComponent;
/** Class to hold contact information */
diff --git a/java/com/android/contacts/common/list/ContactListFilter.java b/java/com/android/contacts/common/list/ContactListFilter.java
index 1a03bb64c445485d1839b7099f48cee421f555b5..39bd4a6f717381a43fea295501de5e15442719c7 100644
--- a/java/com/android/contacts/common/list/ContactListFilter.java
+++ b/java/com/android/contacts/common/list/ContactListFilter.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -136,7 +137,7 @@ public final class ContactListFilter implements Comparable, P
return new ContactListFilter(filterType, accountType, accountName, dataSet, null);
}
- public static final String filterTypeToString(int filterType) {
+ public static String filterTypeToString(int filterType) {
switch (filterType) {
case FILTER_TYPE_DEFAULT:
return "FILTER_TYPE_DEFAULT";
diff --git a/java/com/android/contacts/common/list/ContactListFilterController.java b/java/com/android/contacts/common/list/ContactListFilterController.java
index 60fba0d6d43058b5bed69dd05a2348c271da0351..f9b9710abbeafa017b0d026c90c27595e773de33 100644
--- a/java/com/android/contacts/common/list/ContactListFilterController.java
+++ b/java/com/android/contacts/common/list/ContactListFilterController.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,9 +18,12 @@ package com.android.contacts.common.list;
import android.content.Context;
import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
+
+import androidx.preference.PreferenceManager;
+
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
+
import java.util.ArrayList;
import java.util.List;
@@ -66,8 +70,7 @@ public abstract class ContactListFilterController {
class ContactListFilterControllerImpl extends ContactListFilterController {
private final Context mAppContext;
- private final List mListeners =
- new ArrayList();
+ private final List mListeners = new ArrayList<>();
private ContactListFilter mFilter;
public ContactListFilterControllerImpl(Context context) {
diff --git a/java/com/android/contacts/common/list/ViewPagerTabStrip.java b/java/com/android/contacts/common/list/ViewPagerTabStrip.java
index 667f3ce604bcfd914ad9a29c3a44cd4dfa521466..39252220a96e5ea31104ffa1333519e69fb4c4d7 100644
--- a/java/com/android/contacts/common/list/ViewPagerTabStrip.java
+++ b/java/com/android/contacts/common/list/ViewPagerTabStrip.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,13 +24,14 @@ import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
+
import com.android.dialer.contacts.resources.R;
import com.android.dialer.theme.base.ThemeComponent;
public class ViewPagerTabStrip extends LinearLayout {
private final Paint mSelectedUnderlinePaint;
- private int mSelectedUnderlineThickness;
+ private final int mSelectedUnderlineThickness;
private int mIndexForSelection;
private float mSelectionOffset;
diff --git a/java/com/android/contacts/common/list/ViewPagerTabs.java b/java/com/android/contacts/common/list/ViewPagerTabs.java
index b3242ee2b7d40eed2f8c04cd8408eeb8d72b5a0d..5ab23b867f7bbc7fa4ef3f02636bcd147061f50b 100644
--- a/java/com/android/contacts/common/list/ViewPagerTabs.java
+++ b/java/com/android/contacts/common/list/ViewPagerTabs.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +20,6 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Outline;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
@@ -32,6 +31,10 @@ import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
+
+import androidx.viewpager.widget.PagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+
import com.android.dialer.contacts.resources.R;
/**
@@ -71,7 +74,7 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
ViewPager mPager;
int mPrevSelected = -1;
int mSidePadding;
- private ViewPagerTabStrip mTabStrip;
+ private final ViewPagerTabStrip mTabStrip;
private int[] mTabIcons;
// For displaying the unread count next to the tab icon.
private int[] mUnreadCounts;
@@ -181,13 +184,7 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
tabView = textView;
}
- tabView.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- mPager.setCurrentItem(getRtlPosition(position));
- }
- });
+ tabView.setOnClickListener(v -> mPager.setCurrentItem(getRtlPosition(position)));
tabView.setOnLongClickListener(new OnTabLongClickListener(position));
diff --git a/java/com/android/contacts/common/model/AccountTypeManager.java b/java/com/android/contacts/common/model/AccountTypeManager.java
index 70800aef8da2e360faafb147c653b707557d343e..70009a58b0a1f6834f211d6804f790495b1bcc4d 100644
--- a/java/com/android/contacts/common/model/AccountTypeManager.java
+++ b/java/com/android/contacts/common/model/AccountTypeManager.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +31,6 @@ import android.content.SyncStatusObserver;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -40,6 +40,7 @@ import android.provider.ContactsContract;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
+
import com.android.contacts.common.MoreContactUtils;
import com.android.contacts.common.list.ContactListFilterController;
import com.android.contacts.common.model.account.AccountType;
@@ -52,6 +53,7 @@ import com.android.contacts.common.model.account.GoogleAccountType;
import com.android.contacts.common.model.account.SamsungAccountType;
import com.android.contacts.common.model.dataitem.DataKind;
import com.android.contacts.common.util.Constants;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -63,6 +65,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -160,8 +164,7 @@ class AccountTypeManagerImpl extends AccountTypeManager
implements OnAccountsUpdateListener, SyncStatusObserver {
private static final Map
- EMPTY_UNMODIFIABLE_ACCOUNT_TYPE_MAP =
- Collections.unmodifiableMap(new HashMap());
+ EMPTY_UNMODIFIABLE_ACCOUNT_TYPE_MAP = Collections.unmodifiableMap(new HashMap<>());
/**
* A sample contact URI used to test whether any activities will respond to an invitable intent
@@ -172,37 +175,33 @@ class AccountTypeManagerImpl extends AccountTypeManager
private static final int MESSAGE_LOAD_DATA = 0;
private static final int MESSAGE_PROCESS_BROADCAST_INTENT = 1;
- private static final Comparator ACCOUNT_COMPARATOR =
- new Comparator() {
- @Override
- public int compare(AccountWithDataSet a, AccountWithDataSet b) {
- if (Objects.equals(a.name, b.name)
- && Objects.equals(a.type, b.type)
- && Objects.equals(a.dataSet, b.dataSet)) {
- return 0;
- } else if (b.name == null || b.type == null) {
- return -1;
- } else if (a.name == null || a.type == null) {
- return 1;
- } else {
- int diff = a.name.compareTo(b.name);
- if (diff != 0) {
- return diff;
- }
- diff = a.type.compareTo(b.type);
- if (diff != 0) {
- return diff;
- }
+ private static final Comparator ACCOUNT_COMPARATOR = (a, b) -> {
+ if (Objects.equals(a.name, b.name)
+ && Objects.equals(a.type, b.type)
+ && Objects.equals(a.dataSet, b.dataSet)) {
+ return 0;
+ } else if (b.name == null || b.type == null) {
+ return -1;
+ } else if (a.name == null || a.type == null) {
+ return 1;
+ } else {
+ int diff = a.name.compareTo(b.name);
+ if (diff != 0) {
+ return diff;
+ }
+ diff = a.type.compareTo(b.type);
+ if (diff != 0) {
+ return diff;
+ }
- // Accounts without data sets get sorted before those that have them.
- if (a.dataSet != null) {
- return b.dataSet == null ? 1 : a.dataSet.compareTo(b.dataSet);
- } else {
- return -1;
- }
- }
- }
- };
+ // Accounts without data sets get sorted before those that have them.
+ if (a.dataSet != null) {
+ return b.dataSet == null ? 1 : a.dataSet.compareTo(b.dataSet);
+ } else {
+ return -1;
+ }
+ }
+ };
private final InvitableAccountTypeCache mInvitableAccountTypeCache;
/**
* The boolean value is equal to true if the {@link InvitableAccountTypeCache} has been
@@ -216,7 +215,7 @@ class AccountTypeManagerImpl extends AccountTypeManager
private final AtomicBoolean mInvitablesTaskIsRunning = new AtomicBoolean(false);
private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
- private Context mContext;
+ private final Context mContext;
private final Runnable mCheckFilterValidityRunnable =
new Runnable() {
@Override
@@ -224,17 +223,17 @@ class AccountTypeManagerImpl extends AccountTypeManager
ContactListFilterController.getInstance(mContext).checkFilterValidity(true);
}
};
- private AccountManager mAccountManager;
- private AccountType mFallbackAccountType;
+ private final AccountManager mAccountManager;
+ private final AccountType mFallbackAccountType;
private List mAccounts = new ArrayList<>();
private List mContactWritableAccounts = new ArrayList<>();
private List mGroupWritableAccounts = new ArrayList<>();
private Map mAccountTypesWithDataSets = new ArrayMap<>();
private Map mInvitableAccountTypes =
EMPTY_UNMODIFIABLE_ACCOUNT_TYPE_MAP;
- private HandlerThread mListenerThread;
- private Handler mListenerHandler;
- private BroadcastReceiver mBroadcastReceiver =
+ private final HandlerThread mListenerThread;
+ private final Handler mListenerHandler;
+ private final BroadcastReceiver mBroadcastReceiver =
new BroadcastReceiver() {
@Override
@@ -521,9 +520,9 @@ class AccountTypeManagerImpl extends AccountTypeManager
}
}
- Collections.sort(allAccounts, ACCOUNT_COMPARATOR);
- Collections.sort(contactWritableAccounts, ACCOUNT_COMPARATOR);
- Collections.sort(groupWritableAccounts, ACCOUNT_COMPARATOR);
+ allAccounts.sort(ACCOUNT_COMPARATOR);
+ contactWritableAccounts.sort(ACCOUNT_COMPARATOR);
+ groupWritableAccounts.sort(ACCOUNT_COMPARATOR);
synchronized (this) {
mAccountTypesWithDataSets = accountTypesByTypeAndDataSet;
@@ -698,8 +697,8 @@ class AccountTypeManagerImpl extends AccountTypeManager
result.remove(accountTypeWithDataSet);
continue;
}
- ResolveInfo resolveInfo =
- packageManager.resolveActivity(invitableIntent, PackageManager.MATCH_DEFAULT_ONLY);
+ ResolveInfo resolveInfo = packageManager.resolveActivity(invitableIntent,
+ PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY));
if (resolveInfo == null) {
// If we can't find an activity to start for this intent, then there's no point in
// showing this option to the user.
@@ -775,18 +774,20 @@ class AccountTypeManagerImpl extends AccountTypeManager
* the list of all potential invitable account types. Once the work is completed, the list of
* account types is stored in the {@link AccountTypeManager}'s {@link InvitableAccountTypeCache}.
*/
- private class FindInvitablesTask
- extends AsyncTask> {
-
- @Override
- protected Map doInBackground(Void... params) {
- return findUsableInvitableAccountTypes(mContext);
- }
-
- @Override
- protected void onPostExecute(Map accountTypes) {
- mInvitableAccountTypeCache.setCachedValue(accountTypes);
- mInvitablesTaskIsRunning.set(false);
+ private class FindInvitablesTask {
+
+ private void execute() {
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ Handler handler = new Handler(Looper.getMainLooper());
+
+ executor.execute(() -> {
+ final Map accountTypes =
+ findUsableInvitableAccountTypes(mContext);
+ handler.post(() -> {
+ mInvitableAccountTypeCache.setCachedValue(accountTypes);
+ mInvitablesTaskIsRunning.set(false);
+ });
+ });
}
}
}
diff --git a/java/com/android/contacts/common/model/Contact.java b/java/com/android/contacts/common/model/Contact.java
index 44b94f74f40a05e6336339f60155f39baf4d066b..08c5ce8777cc20f0136ca46eaed732fe9e9fbe93 100644
--- a/java/com/android/contacts/common/model/Contact.java
+++ b/java/com/android/contacts/common/model/Contact.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +23,11 @@ import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Directory;
import android.provider.ContactsContract.DisplayNameSources;
+
import com.android.contacts.common.GroupMetaData;
import com.android.contacts.common.model.account.AccountType;
import com.google.common.collect.ImmutableList;
+
import java.util.ArrayList;
/**
diff --git a/java/com/android/contacts/common/model/ContactLoader.java b/java/com/android/contacts/common/model/ContactLoader.java
index a3a3b9d7f7b1d9399516540ca14cc0f3bd43a1d9..8942bf44eb77427a9784446ac887f353ad50b50e 100644
--- a/java/com/android/contacts/common/model/ContactLoader.java
+++ b/java/com/android/contacts/common/model/ContactLoader.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +17,6 @@
package com.android.contacts.common.model;
-import android.content.AsyncTaskLoader;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
@@ -36,6 +36,9 @@ import android.provider.ContactsContract.Directory;
import android.provider.ContactsContract.Groups;
import android.provider.ContactsContract.RawContacts;
import android.text.TextUtils;
+
+import androidx.loader.content.AsyncTaskLoader;
+
import com.android.contacts.common.GroupMetaData;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountTypeWithDataSet;
@@ -53,6 +56,11 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -64,9 +72,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
/** Loads a single Contact and all it constituent RawContacts. */
public class ContactLoader extends AsyncTaskLoader {
@@ -79,10 +84,10 @@ public class ContactLoader extends AsyncTaskLoader {
private final Uri mRequestedUri;
private final Set mNotifiedRawContactIds = Sets.newHashSet();
private Uri mLookupUri;
- private boolean mLoadGroupMetaData;
- private boolean mLoadInvitableAccountTypes;
- private boolean mPostViewNotification;
- private boolean mComputeFormattedPhoneNumber;
+ private final boolean mLoadGroupMetaData;
+ private final boolean mLoadInvitableAccountTypes;
+ private final boolean mPostViewNotification;
+ private final boolean mComputeFormattedPhoneNumber;
private Contact mContact;
private ForceLoadContentObserver mObserver;
@@ -292,8 +297,7 @@ public class ContactLoader extends AsyncTaskLoader {
// status data. Initially, result has empty entities and statuses.
long currentRawContactId = -1;
RawContact rawContact = null;
- ImmutableList.Builder rawContactsBuilder =
- new ImmutableList.Builder();
+ ImmutableList.Builder rawContactsBuilder = new ImmutableList.Builder<>();
do {
long rawContactId = cursor.getLong(ContactQuery.RAW_CONTACT_ID);
if (rawContactId != currentRawContactId) {
@@ -388,8 +392,7 @@ public class ContactLoader extends AsyncTaskLoader {
/** Sets the "invitable" account types to {@link Contact#mInvitableAccountTypes}. */
private void loadInvitableAccountTypes(Contact contactData) {
- final ImmutableList.Builder resultListBuilder =
- new ImmutableList.Builder();
+ final ImmutableList.Builder resultListBuilder = new ImmutableList.Builder<>();
if (!contactData.isUserProfile()) {
Map invitables =
AccountTypeManager.getInstance(getContext()).getUsableInvitableAccountTypes();
@@ -594,7 +597,7 @@ public class ContactLoader extends AsyncTaskLoader {
*/
private void loadGroupMetaData(Contact result) {
StringBuilder selection = new StringBuilder();
- ArrayList selectionArgs = new ArrayList();
+ ArrayList selectionArgs = new ArrayList<>();
final HashSet accountsSeen = new HashSet<>();
for (RawContact rawContact : result.getRawContacts()) {
final String accountName = rawContact.getAccountName();
@@ -619,8 +622,7 @@ public class ContactLoader extends AsyncTaskLoader {
selection.append(")");
}
}
- final ImmutableList.Builder groupListBuilder =
- new ImmutableList.Builder();
+ final ImmutableList.Builder groupListBuilder = new ImmutableList.Builder<>();
final Cursor cursor =
getContext()
.getContentResolver()
@@ -928,7 +930,7 @@ public class ContactLoader extends AsyncTaskLoader {
static {
List projectionList = Lists.newArrayList(COLUMNS_INTERNAL);
projectionList.add(Data.CARRIER_PRESENCE);
- COLUMNS = projectionList.toArray(new String[projectionList.size()]);
+ COLUMNS = projectionList.toArray(new String[0]);
}
}
diff --git a/java/com/android/contacts/common/model/RawContact.java b/java/com/android/contacts/common/model/RawContact.java
index 9efc8a87859048b0e3922f74e665a34260427031..cdb25718733eae4d9ff155de6d399e8944833372 100644
--- a/java/com/android/contacts/common/model/RawContact.java
+++ b/java/com/android/contacts/common/model/RawContact.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,9 +26,11 @@ import android.os.Parcelable;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.RawContacts;
+
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.model.dataitem.DataItem;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -69,7 +72,7 @@ public final class RawContact implements Parcelable {
public RawContact(ContentValues values) {
mValues = values;
- mDataItems = new ArrayList();
+ mDataItems = new ArrayList<>();
}
/**
@@ -78,7 +81,7 @@ public final class RawContact implements Parcelable {
* @param parcel The parcel to de-serialize from.
*/
private RawContact(Parcel parcel) {
- mValues = parcel.readParcelable(ContentValues.class.getClassLoader());
+ mValues = parcel.readParcelable(ContentValues.class.getClassLoader(), ContentValues.class);
mDataItems = new ArrayList<>();
parcel.readTypedList(mDataItems, NamedDataItem.CREATOR);
}
@@ -314,8 +317,9 @@ public final class RawContact implements Parcelable {
}
public NamedDataItem(Parcel parcel) {
- this.mUri = parcel.readParcelable(Uri.class.getClassLoader());
- this.mContentValues = parcel.readParcelable(ContentValues.class.getClassLoader());
+ this.mUri = parcel.readParcelable(Uri.class.getClassLoader(), Uri.class);
+ this.mContentValues = parcel.readParcelable(ContentValues.class.getClassLoader(),
+ ContentValues.class);
}
@Override
diff --git a/java/com/android/contacts/common/model/account/AccountType.java b/java/com/android/contacts/common/model/account/AccountType.java
index e1fb572b7381b4c73e5be71d1bdc319c949b3021..fd9eb0ebd123fac9a9868de711f87c90c0b8762a 100644
--- a/java/com/android/contacts/common/model/account/AccountType.java
+++ b/java/com/android/contacts/common/model/account/AccountType.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,15 +25,17 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.RawContacts;
-import android.support.v4.content.ContextCompat;
import android.util.ArrayMap;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
+
+import androidx.core.content.ContextCompat;
+
import com.android.contacts.common.model.dataitem.DataKind;
import com.android.dialer.contacts.resources.R;
+
import java.text.Collator;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -48,7 +51,7 @@ public abstract class AccountType {
private static final String TAG = "AccountType";
/** {@link Comparator} to sort by {@link DataKind#weight}. */
- private static Comparator sWeightComparator =
+ private final static Comparator sWeightComparator =
Comparator.comparingInt(object -> object.weight);
/** The {@link RawContacts#ACCOUNT_TYPE} these constraints apply to. */
public String accountType = null;
@@ -203,7 +206,7 @@ public abstract class AccountType {
* the account.
*/
public List getExtensionPackageNames() {
- return new ArrayList();
+ return new ArrayList<>();
}
/**
@@ -234,13 +237,6 @@ public abstract class AccountType {
/** Whether or not groups created under this account type have editable membership lists. */
public abstract boolean isGroupMembershipEditable();
- /** Return list of {@link DataKind} supported, sorted by {@link DataKind#weight}. */
- public ArrayList getSortedDataKinds() {
- // TODO: optimize by marking if already sorted
- Collections.sort(mKinds, sWeightComparator);
- return mKinds;
- }
-
/** Find the {@link DataKind} for a specific MIME-type, if it's handled by this data source. */
public DataKind getKindForMimetype(String mimeType) {
return this.mMimeKinds.get(mimeType);
@@ -289,8 +285,8 @@ public abstract class AccountType {
*/
public static class EditType {
- public int rawValue;
- public int labelRes;
+ public final int rawValue;
+ public final int labelRes;
public boolean secondary;
/**
* The number of entries allowed for the type. -1 if not specified.
@@ -381,8 +377,8 @@ public abstract class AccountType {
*/
public static final class EditField {
- public String column;
- public int titleRes;
+ public final String column;
+ public final int titleRes;
public int inputType;
public int minLines;
public boolean optional;
diff --git a/java/com/android/contacts/common/model/account/AccountTypeWithDataSet.java b/java/com/android/contacts/common/model/account/AccountTypeWithDataSet.java
index a32ebe139bc6aa59b77d2ceb47d5706c84e995b4..24fcac3754920952301fd16708ebe8c99febb513 100644
--- a/java/com/android/contacts/common/model/account/AccountTypeWithDataSet.java
+++ b/java/com/android/contacts/common/model/account/AccountTypeWithDataSet.java
@@ -23,6 +23,7 @@ import android.provider.BaseColumns;
import android.provider.ContactsContract;
import android.provider.ContactsContract.RawContacts;
import android.text.TextUtils;
+
import java.util.Objects;
/** Encapsulates an "account type" string and a "data set" string. */
diff --git a/java/com/android/contacts/common/model/account/AccountWithDataSet.java b/java/com/android/contacts/common/model/account/AccountWithDataSet.java
index 54e9a3cea05f3a1089e3167df55e42ed45e7069b..63399d12b53276edd1717f52c022c3d890caa76b 100644
--- a/java/com/android/contacts/common/model/account/AccountWithDataSet.java
+++ b/java/com/android/contacts/common/model/account/AccountWithDataSet.java
@@ -16,20 +16,11 @@
package com.android.contacts.common.model.account;
-import android.accounts.Account;
-import android.content.Context;
-import android.database.Cursor;
-import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
-import android.provider.BaseColumns;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.RawContacts;
import android.text.TextUtils;
-import java.util.ArrayList;
-import java.util.List;
+
import java.util.Objects;
-import java.util.regex.Pattern;
/** Wrapper for an account that includes a data set (which may be null). */
public class AccountWithDataSet implements Parcelable {
diff --git a/java/com/android/contacts/common/model/account/BaseAccountType.java b/java/com/android/contacts/common/model/account/BaseAccountType.java
index 1cf41514a22522e73c6cbd240c2f6109b0b4798a..0d8b73e744d6a23684ffdf7f8431e826ab5fbea4 100644
--- a/java/com/android/contacts/common/model/account/BaseAccountType.java
+++ b/java/com/android/contacts/common/model/account/BaseAccountType.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,43 +38,40 @@ import android.provider.ContactsContract.CommonDataKinds.Website;
import android.util.ArrayMap;
import android.util.AttributeSet;
import android.view.inputmethod.EditorInfo;
+
import com.android.contacts.common.model.dataitem.DataKind;
import com.android.contacts.common.util.CommonDateUtils;
import com.android.contacts.common.util.ContactDisplayUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.contacts.resources.R;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
public abstract class BaseAccountType extends AccountType {
- public static final StringInflater ORGANIZATION_BODY_INFLATER =
- new StringInflater() {
- @Override
- public CharSequence inflateUsing(Context context, ContentValues values) {
- final CharSequence companyValue =
- values.containsKey(Organization.COMPANY)
- ? values.getAsString(Organization.COMPANY)
- : null;
- final CharSequence titleValue =
- values.containsKey(Organization.TITLE)
- ? values.getAsString(Organization.TITLE)
- : null;
-
- if (companyValue != null && titleValue != null) {
- return companyValue + ": " + titleValue;
- } else if (companyValue == null) {
- return titleValue;
- } else {
- return companyValue;
- }
- }
- };
+ public static final StringInflater ORGANIZATION_BODY_INFLATER = (context, values) -> {
+ final CharSequence companyValue = values.containsKey(Organization.COMPANY)
+ ? values.getAsString(Organization.COMPANY)
+ : null;
+ final CharSequence titleValue = values.containsKey(Organization.TITLE)
+ ? values.getAsString(Organization.TITLE)
+ : null;
+
+ if (companyValue != null && titleValue != null) {
+ return companyValue + ": " + titleValue;
+ } else if (companyValue == null) {
+ return titleValue;
+ } else {
+ return companyValue;
+ }
+ };
protected static final int FLAGS_PHONE = EditorInfo.TYPE_CLASS_PHONE;
protected static final int FLAGS_EMAIL =
EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
@@ -314,28 +312,17 @@ public abstract class BaseAccountType extends AccountType {
kind.actionBody = new SimpleInflater(Phone.NUMBER);
kind.typeColumn = Phone.TYPE;
kind.typeList = new ArrayList<>();
+ kind.typeList = new ArrayList<>();
kind.typeList.add(buildPhoneType(Phone.TYPE_MOBILE));
- kind.typeList.add(buildPhoneType(Phone.TYPE_HOME));
kind.typeList.add(buildPhoneType(Phone.TYPE_WORK));
+ kind.typeList.add(buildPhoneType(Phone.TYPE_HOME));
+ kind.typeList.add(buildPhoneType(Phone.TYPE_MAIN));
kind.typeList.add(buildPhoneType(Phone.TYPE_FAX_WORK).setSecondary(true));
kind.typeList.add(buildPhoneType(Phone.TYPE_FAX_HOME).setSecondary(true));
kind.typeList.add(buildPhoneType(Phone.TYPE_PAGER).setSecondary(true));
kind.typeList.add(buildPhoneType(Phone.TYPE_OTHER));
kind.typeList.add(
- buildPhoneType(Phone.TYPE_CUSTOM).setSecondary(true).setCustomColumn(Phone.LABEL));
- kind.typeList.add(buildPhoneType(Phone.TYPE_CALLBACK).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_CAR).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_COMPANY_MAIN).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_ISDN).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_MAIN).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_OTHER_FAX).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_RADIO).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_TELEX).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_TTY_TDD).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_WORK_MOBILE).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_WORK_PAGER).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_ASSISTANT).setSecondary(true));
- kind.typeList.add(buildPhoneType(Phone.TYPE_MMS).setSecondary(true));
+ buildPhoneType(Phone.TYPE_CUSTOM).setSecondary(true).setCustomColumn(Phone.LABEL));
kind.fieldList = new ArrayList<>();
kind.fieldList.add(new EditField(Phone.NUMBER, R.string.phoneLabelsGroup, FLAGS_PHONE));
@@ -354,7 +341,6 @@ public abstract class BaseAccountType extends AccountType {
kind.typeList.add(buildEmailType(Email.TYPE_HOME));
kind.typeList.add(buildEmailType(Email.TYPE_WORK));
kind.typeList.add(buildEmailType(Email.TYPE_OTHER));
- kind.typeList.add(buildEmailType(Email.TYPE_MOBILE));
kind.typeList.add(
buildEmailType(Email.TYPE_CUSTOM).setSecondary(true).setCustomColumn(Email.LABEL));
@@ -407,14 +393,6 @@ public abstract class BaseAccountType extends AccountType {
kind.typeColumn = Im.PROTOCOL;
kind.typeList = new ArrayList<>();
- kind.typeList.add(buildImType(Im.PROTOCOL_AIM));
- kind.typeList.add(buildImType(Im.PROTOCOL_MSN));
- kind.typeList.add(buildImType(Im.PROTOCOL_YAHOO));
- kind.typeList.add(buildImType(Im.PROTOCOL_SKYPE));
- kind.typeList.add(buildImType(Im.PROTOCOL_QQ));
- kind.typeList.add(buildImType(Im.PROTOCOL_GOOGLE_TALK));
- kind.typeList.add(buildImType(Im.PROTOCOL_ICQ));
- kind.typeList.add(buildImType(Im.PROTOCOL_JABBER));
kind.typeList.add(
buildImType(Im.PROTOCOL_CUSTOM).setSecondary(true).setCustomColumn(Im.CUSTOM_PROTOCOL));
@@ -771,31 +749,7 @@ public abstract class BaseAccountType extends AccountType {
@Override
protected int getTypeLabelResource(Integer type) {
- if (type == null) {
- return R.string.chat;
- }
- switch (type) {
- case Im.PROTOCOL_AIM:
- return R.string.chat_aim;
- case Im.PROTOCOL_MSN:
- return R.string.chat_msn;
- case Im.PROTOCOL_YAHOO:
- return R.string.chat_yahoo;
- case Im.PROTOCOL_SKYPE:
- return R.string.chat_skype;
- case Im.PROTOCOL_QQ:
- return R.string.chat_qq;
- case Im.PROTOCOL_GOOGLE_TALK:
- return R.string.chat_gtalk;
- case Im.PROTOCOL_ICQ:
- return R.string.chat_icq;
- case Im.PROTOCOL_JABBER:
- return R.string.chat_jabber;
- case Im.PROTOCOL_NETMEETING:
- return R.string.chat;
- default:
- return R.string.chat;
- }
+ return R.string.chat;
}
}
@@ -1481,30 +1435,6 @@ public abstract class BaseAccountType extends AccountType {
@Override
protected EditType buildEditTypeForTypeTag(AttributeSet attrs, String type) {
- if ("aim".equals(type)) {
- return buildImType(Im.PROTOCOL_AIM);
- }
- if ("msn".equals(type)) {
- return buildImType(Im.PROTOCOL_MSN);
- }
- if ("yahoo".equals(type)) {
- return buildImType(Im.PROTOCOL_YAHOO);
- }
- if ("skype".equals(type)) {
- return buildImType(Im.PROTOCOL_SKYPE);
- }
- if ("qq".equals(type)) {
- return buildImType(Im.PROTOCOL_QQ);
- }
- if ("google_talk".equals(type)) {
- return buildImType(Im.PROTOCOL_GOOGLE_TALK);
- }
- if ("icq".equals(type)) {
- return buildImType(Im.PROTOCOL_ICQ);
- }
- if ("jabber".equals(type)) {
- return buildImType(Im.PROTOCOL_JABBER);
- }
if ("custom".equals(type)) {
return buildImType(Im.PROTOCOL_CUSTOM)
.setSecondary(true)
diff --git a/java/com/android/contacts/common/model/account/ExchangeAccountType.java b/java/com/android/contacts/common/model/account/ExchangeAccountType.java
index 0a95e7ecbf01be349304539739e726c166a69c45..20f3c09fb58fbd0c436aa0baada8d0d4a85ba5d8 100644
--- a/java/com/android/contacts/common/model/account/ExchangeAccountType.java
+++ b/java/com/android/contacts/common/model/account/ExchangeAccountType.java
@@ -29,10 +29,12 @@ import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
+
import com.android.contacts.common.model.dataitem.DataKind;
import com.android.contacts.common.util.CommonDateUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.contacts.resources.R;
+
import java.util.ArrayList;
import java.util.Locale;
diff --git a/java/com/android/contacts/common/model/account/ExternalAccountType.java b/java/com/android/contacts/common/model/account/ExternalAccountType.java
index a38f8f2f84d2654684f4fd13a735318e1c1290e4..d93195b8c3541003b45628a02f9eef6b3ac2eb31 100644
--- a/java/com/android/contacts/common/model/account/ExternalAccountType.java
+++ b/java/com/android/contacts/common/model/account/ExternalAccountType.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,14 +31,17 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Xml;
+
import com.android.contacts.common.model.dataitem.DataKind;
+import com.android.dialer.R;
import com.android.dialer.common.LogUtil;
-import com.android.dialer.contacts.resources.R;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
/** A general contacts account type descriptor. */
public class ExternalAccountType extends BaseAccountType {
@@ -151,7 +155,7 @@ public class ExternalAccountType extends BaseAccountType {
}
}
- mExtensionPackageNames = new ArrayList();
+ mExtensionPackageNames = new ArrayList<>();
mInviteActionLabelResId =
resolveExternalResId(
context,
@@ -189,25 +193,23 @@ public class ExternalAccountType extends BaseAccountType {
public static XmlResourceParser loadContactsXml(Context context, String resPackageName) {
final PackageManager pm = context.getPackageManager();
final Intent intent = new Intent(SYNC_META_DATA).setPackage(resPackageName);
- final List intentServices =
- pm.queryIntentServices(intent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
-
- if (intentServices != null) {
- for (final ResolveInfo resolveInfo : intentServices) {
- final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
- if (serviceInfo == null) {
- continue;
- }
- for (String metadataName : METADATA_CONTACTS_NAMES) {
- final XmlResourceParser parser = serviceInfo.loadXmlMetaData(pm, metadataName);
- if (parser != null) {
- LogUtil.d(
- TAG,
- String.format(
- "Metadata loaded from: %s, %s, %s",
- serviceInfo.packageName, serviceInfo.name, metadataName));
- return parser;
- }
+ final List intentServices = pm.queryIntentServices(intent,
+ PackageManager.ResolveInfoFlags.of(PackageManager.GET_META_DATA));
+
+ for (final ResolveInfo resolveInfo : intentServices) {
+ final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
+ if (serviceInfo == null) {
+ continue;
+ }
+ for (String metadataName : METADATA_CONTACTS_NAMES) {
+ final XmlResourceParser parser = serviceInfo.loadXmlMetaData(pm, metadataName);
+ if (parser != null) {
+ LogUtil.d(
+ TAG,
+ String.format(
+ "Metadata loaded from: %s, %s, %s",
+ serviceInfo.packageName, serviceInfo.name, metadataName));
+ return parser;
}
}
}
@@ -401,9 +403,7 @@ public class ExternalAccountType extends BaseAccountType {
addKind(kind);
}
}
- } catch (XmlPullParserException e) {
- throw new DefinitionException("Problem reading XML", e);
- } catch (IOException e) {
+ } catch (XmlPullParserException | IOException e) {
throw new DefinitionException("Problem reading XML", e);
}
}
diff --git a/java/com/android/contacts/common/model/account/FallbackAccountType.java b/java/com/android/contacts/common/model/account/FallbackAccountType.java
index 9e8af628f2f61caccd54cccd0efadb73a22cb36d..6fc02f14c37d0a0a714fd844b725d9ccb3cca96f 100644
--- a/java/com/android/contacts/common/model/account/FallbackAccountType.java
+++ b/java/com/android/contacts/common/model/account/FallbackAccountType.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +18,7 @@
package com.android.contacts.common.model.account;
import android.content.Context;
-import com.android.contacts.common.model.dataitem.DataKind;
+
import com.android.dialer.common.LogUtil;
import com.android.dialer.contacts.resources.R;
diff --git a/java/com/android/contacts/common/model/account/GoogleAccountType.java b/java/com/android/contacts/common/model/account/GoogleAccountType.java
index e10ade4790bbe8d247a7282c79fb43c4a2c8f301..55ab9450d1ce9f458264d3abee7f351423d39fdc 100644
--- a/java/com/android/contacts/common/model/account/GoogleAccountType.java
+++ b/java/com/android/contacts/common/model/account/GoogleAccountType.java
@@ -24,10 +24,12 @@ import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.Relation;
+
import com.android.contacts.common.model.dataitem.DataKind;
import com.android.contacts.common.util.CommonDateUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.contacts.resources.R;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
diff --git a/java/com/android/contacts/common/model/account/SamsungAccountType.java b/java/com/android/contacts/common/model/account/SamsungAccountType.java
index 77c0575eac25dcd8546d8171cce08e770c3eda64..a550c3f056c167bcfbb7203cb0f92d422bff5bad 100644
--- a/java/com/android/contacts/common/model/account/SamsungAccountType.java
+++ b/java/com/android/contacts/common/model/account/SamsungAccountType.java
@@ -23,10 +23,12 @@ import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.Relation;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
+
import com.android.contacts.common.model.dataitem.DataKind;
import com.android.contacts.common.util.CommonDateUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.contacts.resources.R;
+
import java.util.ArrayList;
import java.util.Locale;
diff --git a/java/com/android/contacts/common/model/dataitem/DataItem.java b/java/com/android/contacts/common/model/dataitem/DataItem.java
index 43a472bde8c220f408485faf390a1f22fdc54725..ebfe85e48c6b17fad46c09b25158b6989ab90beb 100644
--- a/java/com/android/contacts/common/model/dataitem/DataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/DataItem.java
@@ -35,6 +35,7 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
import android.provider.ContactsContract.Contacts.Data;
import android.provider.ContactsContract.Contacts.Entity;
+
import com.android.contacts.common.Collapser;
import com.android.contacts.common.MoreContactUtils;
import com.android.contacts.common.model.account.AccountType.EditType;
diff --git a/java/com/android/contacts/common/model/dataitem/DataKind.java b/java/com/android/contacts/common/model/dataitem/DataKind.java
index 3b470a2ae647f687632cfb26978908b4833f7ebb..194aa8436ea5dca412fc1df2e658981bcdcb11b5 100644
--- a/java/com/android/contacts/common/model/dataitem/DataKind.java
+++ b/java/com/android/contacts/common/model/dataitem/DataKind.java
@@ -19,10 +19,12 @@ package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
import android.content.Context;
import android.provider.ContactsContract.Data;
+
import com.android.contacts.common.model.account.AccountType.EditField;
import com.android.contacts.common.model.account.AccountType.EditType;
import com.android.contacts.common.model.account.AccountType.StringInflater;
import com.google.common.collect.Iterators;
+
import java.text.SimpleDateFormat;
import java.util.List;
diff --git a/java/com/android/contacts/common/model/dataitem/EmailDataItem.java b/java/com/android/contacts/common/model/dataitem/EmailDataItem.java
index 2fe297816f7a2b846a55e368a0873c198296cd79..aed419de03f18a050c174fc1d90d50fd385a908f 100644
--- a/java/com/android/contacts/common/model/dataitem/EmailDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/EmailDataItem.java
@@ -17,6 +17,7 @@
package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
/**
diff --git a/java/com/android/contacts/common/model/dataitem/EventDataItem.java b/java/com/android/contacts/common/model/dataitem/EventDataItem.java
index 15d9880b1439eea6882eb92e59b7cfe1bb7ef8cd..4060e67fee909a210a63b368a84d612dca62d624 100644
--- a/java/com/android/contacts/common/model/dataitem/EventDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/EventDataItem.java
@@ -18,6 +18,7 @@ package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
import android.content.Context;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.text.TextUtils;
diff --git a/java/com/android/contacts/common/model/dataitem/GroupMembershipDataItem.java b/java/com/android/contacts/common/model/dataitem/GroupMembershipDataItem.java
index 42a0dcddfb771d7be7ff4f9138175e1b71357225..7b5115db50fa89cd6aa23e7eff17423435c68d70 100644
--- a/java/com/android/contacts/common/model/dataitem/GroupMembershipDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/GroupMembershipDataItem.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +19,6 @@ package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
import android.provider.ContactsContract;
-import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
/**
* Represents a group memebership data item, wrapping the columns in {@link
diff --git a/java/com/android/contacts/common/model/dataitem/IdentityDataItem.java b/java/com/android/contacts/common/model/dataitem/IdentityDataItem.java
index 81e6934f632165c0d5f5bbae50d01d7e4e498ab8..09cca100dbb8b879d3b3f45b729da96119bcdc75 100644
--- a/java/com/android/contacts/common/model/dataitem/IdentityDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/IdentityDataItem.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +18,7 @@
package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
-import android.provider.ContactsContract.CommonDataKinds.Identity;
+import android.provider.ContactsContract;
/**
* Represents an identity data item, wrapping the columns in {@link
diff --git a/java/com/android/contacts/common/model/dataitem/ImDataItem.java b/java/com/android/contacts/common/model/dataitem/ImDataItem.java
index 20a7a9a72e9954061b6a312038017db209a3b745..ed2b0c4aa875dfa6800e2dc04811c0db6519bba6 100644
--- a/java/com/android/contacts/common/model/dataitem/ImDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/ImDataItem.java
@@ -18,6 +18,7 @@ package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
import android.content.Context;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Im;
import android.text.TextUtils;
diff --git a/java/com/android/contacts/common/model/dataitem/NicknameDataItem.java b/java/com/android/contacts/common/model/dataitem/NicknameDataItem.java
index a448be78624477e1ed7c83829db2a097dc5dd52a..0eabb40bf6a23dc28e3b2267c20009093b053f46 100644
--- a/java/com/android/contacts/common/model/dataitem/NicknameDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/NicknameDataItem.java
@@ -17,6 +17,7 @@
package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Nickname;
/**
diff --git a/java/com/android/contacts/common/model/dataitem/NoteDataItem.java b/java/com/android/contacts/common/model/dataitem/NoteDataItem.java
index b55ecc3e5daf29ada6b322e15797b66e197e9bed..ec9a862a14a837252aaf6757d70b7180491ad8df 100644
--- a/java/com/android/contacts/common/model/dataitem/NoteDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/NoteDataItem.java
@@ -17,6 +17,7 @@
package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Note;
/**
diff --git a/java/com/android/contacts/common/model/dataitem/PhoneDataItem.java b/java/com/android/contacts/common/model/dataitem/PhoneDataItem.java
index a314f7ab3f4875d33f8766c9523265c05376ee9e..e25328fdb591871660f8374001335379abfb397b 100644
--- a/java/com/android/contacts/common/model/dataitem/PhoneDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/PhoneDataItem.java
@@ -19,6 +19,7 @@ package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
import android.content.Context;
import android.provider.ContactsContract.CommonDataKinds.Phone;
+
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
/**
diff --git a/java/com/android/contacts/common/model/dataitem/RelationDataItem.java b/java/com/android/contacts/common/model/dataitem/RelationDataItem.java
index fdbcbb31335d8102749c3b47ae898d68eef32a5a..517b7a2f3dbd4ba496e160f88d1170df077b4c97 100644
--- a/java/com/android/contacts/common/model/dataitem/RelationDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/RelationDataItem.java
@@ -18,6 +18,7 @@ package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
import android.content.Context;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Relation;
import android.text.TextUtils;
diff --git a/java/com/android/contacts/common/model/dataitem/StructuredNameDataItem.java b/java/com/android/contacts/common/model/dataitem/StructuredNameDataItem.java
index a2ddf4365356ca9b629b250c314ba88087d1441b..2b5b48064ca66cae8b50d9b11f8406c8958e3650 100644
--- a/java/com/android/contacts/common/model/dataitem/StructuredNameDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/StructuredNameDataItem.java
@@ -17,6 +17,7 @@
package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Contacts.Data;
diff --git a/java/com/android/contacts/common/model/dataitem/WebsiteDataItem.java b/java/com/android/contacts/common/model/dataitem/WebsiteDataItem.java
index b8400ecd1b3d8d398e02138092fbba80c028fb33..53b103904a24546a75eb2ecde17cd75601072fb1 100644
--- a/java/com/android/contacts/common/model/dataitem/WebsiteDataItem.java
+++ b/java/com/android/contacts/common/model/dataitem/WebsiteDataItem.java
@@ -17,6 +17,7 @@
package com.android.contacts.common.model.dataitem;
import android.content.ContentValues;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Website;
/**
diff --git a/java/com/android/contacts/common/util/ContactDisplayUtils.java b/java/com/android/contacts/common/util/ContactDisplayUtils.java
index 22da7196aa722066e111c0feffa98d68e5832da9..74123f77acfb804b456c314458f953ad0e062cb4 100644
--- a/java/com/android/contacts/common/util/ContactDisplayUtils.java
+++ b/java/com/android/contacts/common/util/ContactDisplayUtils.java
@@ -31,6 +31,7 @@ import androidx.annotation.Nullable;
import com.android.dialer.common.LogUtil;
import com.android.dialer.contacts.resources.R;
+
import java.util.Objects;
/** Methods for handling various contact data labels. */
diff --git a/java/com/android/contacts/common/util/ContactListViewUtils.java b/java/com/android/contacts/common/util/ContactListViewUtils.java
index ba240792bc264c300c0dfed5893bb69d87f51ebf..5bdb96d194177e79f4e293be4c94e8404429a975 100644
--- a/java/com/android/contacts/common/util/ContactListViewUtils.java
+++ b/java/com/android/contacts/common/util/ContactListViewUtils.java
@@ -16,11 +16,8 @@
package com.android.contacts.common.util;
-import android.content.res.Resources;
import android.view.View;
import android.widget.ListView;
-import com.android.dialer.contacts.resources.R;
-import com.android.dialer.util.ViewUtil;
/** Utilities for configuring ListViews with a card background. */
public class ContactListViewUtils {
diff --git a/java/com/android/contacts/common/util/ContactLoaderUtils.java b/java/com/android/contacts/common/util/ContactLoaderUtils.java
index 371bb4eef32b304e47eac01e94af3adb9201e572..df081b127a3318ace947dd449abb01fd67759301 100644
--- a/java/com/android/contacts/common/util/ContactLoaderUtils.java
+++ b/java/com/android/contacts/common/util/ContactLoaderUtils.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +20,11 @@ package com.android.contacts.common.util;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.net.Uri;
-import android.provider.Contacts;
import android.provider.ContactsContract;
import android.provider.ContactsContract.RawContacts;
+import com.android.contacts.common.model.ContactLoader;
+
/** Utility methods for the {@link ContactLoader}. */
public final class ContactLoaderUtils {
@@ -36,7 +38,6 @@ public final class ContactLoaderUtils {
*
*
Do not call from the UI thread.
*/
- @SuppressWarnings("deprecation")
public static Uri ensureIsContactUri(final ContentResolver resolver, final Uri uri)
throws IllegalArgumentException {
if (uri == null) {
diff --git a/java/com/android/contacts/common/util/DateUtils.java b/java/com/android/contacts/common/util/DateUtils.java
index 09d52bce8cd24c71d65e00d771dfcaf20786f419..d5147eb9beba24437db46fa0ce5f52b994880642 100644
--- a/java/com/android/contacts/common/util/DateUtils.java
+++ b/java/com/android/contacts/common/util/DateUtils.java
@@ -16,7 +16,11 @@
package com.android.contacts.common.util;
-import android.text.format.Time;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+
/** Utility methods for processing dates. */
public class DateUtils {
@@ -30,13 +34,9 @@ public class DateUtils {
* @param date2 Second date to check.
* @return The absolute difference in days between the two dates.
*/
- public static int getDayDifference(Time time, long date1, long date2) {
- time.set(date1);
- int startDay = Time.getJulianDay(date1, time.gmtoff);
-
- time.set(date2);
- int currentDay = Time.getJulianDay(date2, time.gmtoff);
-
- return Math.abs(currentDay - startDay);
+ public static int getDayDifference(ZoneId timeZone, long date1, long date2) {
+ LocalDate localDate1 = Instant.ofEpochMilli(date1).atZone(timeZone).toLocalDate();
+ LocalDate localDate2 = Instant.ofEpochMilli(date2).atZone(timeZone).toLocalDate();
+ return Math.abs((int) ChronoUnit.DAYS.between(localDate2, localDate1));
}
}
diff --git a/java/com/android/contacts/common/util/TelephonyManagerUtils.java b/java/com/android/contacts/common/util/TelephonyManagerUtils.java
index e4c2c63732e6df44957ec2dac09b0608d254883d..10af0f5a7b3dc7d79f64af4cf1d98192c85c7e29 100644
--- a/java/com/android/contacts/common/util/TelephonyManagerUtils.java
+++ b/java/com/android/contacts/common/util/TelephonyManagerUtils.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +16,7 @@
*/
package com.android.contacts.common.util;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.telephony.TelephonyManager;
@@ -27,6 +29,7 @@ public class TelephonyManagerUtils {
* @param context Current application context
* @return Voicemail tag, the alphabetic identifier associated with the voice mail number.
*/
+ @SuppressLint("MissingPermission")
public static String getVoiceMailAlphaTag(Context context) {
final TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
diff --git a/java/com/android/contacts/common/widget/ActivityTouchLinearLayout.java b/java/com/android/contacts/common/widget/ActivityTouchLinearLayout.java
index 2988a5a58d2ff725b6df5530a4354a3635a13869..7df82c0b3745d8d9701bee07731d5ddd78d7a1b7 100644
--- a/java/com/android/contacts/common/widget/ActivityTouchLinearLayout.java
+++ b/java/com/android/contacts/common/widget/ActivityTouchLinearLayout.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;
+
import com.android.dialer.util.TouchPointManager;
/**
diff --git a/java/com/android/contacts/common/widget/LayoutSuppressingImageView.java b/java/com/android/contacts/common/widget/LayoutSuppressingImageView.java
index d84d8f75736b239d657fe614ed43f51767d6e831..423881541b94c258cbe891844473f960380f9ba3 100644
--- a/java/com/android/contacts/common/widget/LayoutSuppressingImageView.java
+++ b/java/com/android/contacts/common/widget/LayoutSuppressingImageView.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,22 +17,25 @@
package com.android.contacts.common.widget;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
-import android.widget.ImageView;
+
+import androidx.appcompat.widget.AppCompatImageView;
/**
- * Custom {@link ImageView} that improves layouting performance.
+ * Custom {@link AppCompatImageView} that improves layouting performance.
*
*
This improves the performance by not passing requestLayout() to its parent, taking advantage
* of knowing that image size won't change once set.
*/
-public class LayoutSuppressingImageView extends ImageView {
+public class LayoutSuppressingImageView extends AppCompatImageView {
public LayoutSuppressingImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
+ @SuppressLint("MissingSuperCall")
@Override
public void requestLayout() {
forceLayout();
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
index 43027811c1badaedbe518e3d9b9747531a8df2c9..4a465a24bd3fc5b6a498f00bc29fdfa8d3c4a8cc 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,13 +18,12 @@
package com.android.contacts.common.widget;
import android.annotation.SuppressLint;
-import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
import android.os.ResultReceiver;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -43,6 +43,8 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
import com.android.contacts.common.compat.PhoneAccountCompat;
import com.android.dialer.contacts.resources.R;
@@ -50,7 +52,8 @@ import com.android.dialer.location.GeoUtil;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.protos.ProtoParsers;
import com.android.dialer.telecom.TelecomUtil;
-import com.google.common.base.Optional;
+
+import java.util.Optional;
/**
* Dialog that allows the user to select a phone accounts for a given action. Optionally provides
@@ -101,31 +104,23 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
isSelected = false;
final DialogInterface.OnClickListener selectionListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- isSelected = true;
- PhoneAccountHandle selectedAccountHandle =
- SelectPhoneAccountDialogOptionsUtil.getPhoneAccountHandle(
- options.getEntriesList().get(which));
- Bundle result = new Bundle();
- result.putParcelable(
- SelectPhoneAccountListener.EXTRA_SELECTED_ACCOUNT_HANDLE, selectedAccountHandle);
- result.putBoolean(SelectPhoneAccountListener.EXTRA_SET_DEFAULT, isDefaultChecked);
- result.putString(SelectPhoneAccountListener.EXTRA_CALL_ID, getCallId());
- if (listener != null) {
- listener.onReceiveResult(SelectPhoneAccountListener.RESULT_SELECTED, result);
- }
- }
- };
+ (dialog, which) -> {
+ isSelected = true;
+ PhoneAccountHandle selectedAccountHandle =
+ SelectPhoneAccountDialogOptionsUtil.getPhoneAccountHandle(
+ options.getEntriesList().get(which));
+ Bundle result = new Bundle();
+ result.putParcelable(
+ SelectPhoneAccountListener.EXTRA_SELECTED_ACCOUNT_HANDLE, selectedAccountHandle);
+ result.putBoolean(SelectPhoneAccountListener.EXTRA_SET_DEFAULT, isDefaultChecked);
+ result.putString(SelectPhoneAccountListener.EXTRA_CALL_ID, getCallId());
+ if (listener != null) {
+ listener.onReceiveResult(SelectPhoneAccountListener.RESULT_SELECTED, result);
+ }
+ };
final CompoundButton.OnCheckedChangeListener checkListener =
- new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton check, boolean isChecked) {
- isDefaultChecked = isChecked;
- }
- };
+ (check, isChecked) -> isDefaultChecked = isChecked;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
ListAdapter selectAccountListAdapter =
@@ -191,14 +186,14 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
static final String EXTRA_CALL_ID = "extra_call_id";
protected SelectPhoneAccountListener() {
- super(new Handler());
+ super(new Handler(Looper.getMainLooper()));
}
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
if (resultCode == RESULT_SELECTED) {
onPhoneAccountSelected(
- resultData.getParcelable(EXTRA_SELECTED_ACCOUNT_HANDLE),
+ resultData.getParcelable(EXTRA_SELECTED_ACCOUNT_HANDLE, PhoneAccountHandle.class),
resultData.getBoolean(EXTRA_SET_DEFAULT),
resultData.getString(EXTRA_CALL_ID));
} else if (resultCode == RESULT_DISMISSED) {
@@ -215,7 +210,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
static class SelectAccountListAdapter
extends ArrayAdapter {
- private int mResId;
+ private final int mResId;
private final SelectPhoneAccountDialogOptions options;
SelectAccountListAdapter(
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
index 1880d653877503636d8a6049ddd899e4d513b1f9..18b0055742ace7151bbcbb482eca900fb549c46a 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogOptionsUtil.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,11 +19,10 @@ package com.android.contacts.common.widget;
import android.os.Parcel;
import android.os.UserHandle;
-import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
+
import com.android.dialer.common.Assert;
import com.android.dialer.telecom.TelecomUtil;
-
import com.google.protobuf.ByteString;
import java.util.Collection;
@@ -39,7 +39,7 @@ public final class SelectPhoneAccountDialogOptionsUtil {
byte[] marshalledUserHandle = entry.getUserHandle().toByteArray();
parcel.unmarshall(marshalledUserHandle, 0, marshalledUserHandle.length);
parcel.setDataPosition(0);
- userHandle = parcel.readParcelable(UserHandle.class.getClassLoader());
+ userHandle = parcel.readParcelable(UserHandle.class.getClassLoader(), UserHandle.class);
} catch (NullPointerException e) {
userHandle = null;
}
diff --git a/java/com/android/dialer/activecalls/ActiveCallInfo.java b/java/com/android/dialer/activecalls/ActiveCallInfo.java
index ccf35014189ee997862c037fbcdf19237dca0fca..7c93ceb9f2e1e5f8b393aadffffb10777582b09a 100644
--- a/java/com/android/dialer/activecalls/ActiveCallInfo.java
+++ b/java/com/android/dialer/activecalls/ActiveCallInfo.java
@@ -21,11 +21,11 @@ import android.telecom.PhoneAccountHandle;
import androidx.annotation.Nullable;
import com.google.auto.value.AutoValue;
-import com.google.common.base.Optional;
+
+import java.util.Optional;
/** Info of an active call */
@AutoValue
-@SuppressWarnings("Guava")
public abstract class ActiveCallInfo {
/** The {@link PhoneAccountHandle} the call is made with */
@@ -40,7 +40,7 @@ public abstract class ActiveCallInfo {
public abstract static class Builder {
public Builder setPhoneAccountHandle(@Nullable PhoneAccountHandle phoneAccountHandle) {
- return setPhoneAccountHandle(Optional.fromNullable(phoneAccountHandle));
+ return setPhoneAccountHandle(Optional.ofNullable(phoneAccountHandle));
}
public abstract Builder setPhoneAccountHandle(Optional phoneAccountHandle);
diff --git a/java/com/android/dialer/activecalls/ActiveCallsComponent.java b/java/com/android/dialer/activecalls/ActiveCallsComponent.java
index 99e0e94930dfaf523073efb478910d3320758c2a..f583b8350dde310013f2607a9eba7498ec9ebd3e 100644
--- a/java/com/android/dialer/activecalls/ActiveCallsComponent.java
+++ b/java/com/android/dialer/activecalls/ActiveCallsComponent.java
@@ -17,8 +17,10 @@
package com.android.dialer.activecalls;
import android.content.Context;
+
import com.android.dialer.inject.HasRootComponent;
import com.android.dialer.inject.IncludeInDialerRoot;
+
import dagger.Subcomponent;
/** Component for {@link ActiveCalls} */
diff --git a/java/com/android/dialer/activecalls/ActiveCallsModule.java b/java/com/android/dialer/activecalls/ActiveCallsModule.java
index 9c02ba65755ea1e28b49a78bb5fdb18432dc5804..8ebb6ffb3724b7ddb655f6357db80b36a08a4dca 100644
--- a/java/com/android/dialer/activecalls/ActiveCallsModule.java
+++ b/java/com/android/dialer/activecalls/ActiveCallsModule.java
@@ -17,9 +17,11 @@
package com.android.dialer.activecalls;
import com.android.dialer.activecalls.impl.ActiveCallsImpl;
+
+import javax.inject.Singleton;
+
import dagger.Binds;
import dagger.Module;
-import javax.inject.Singleton;
/** Module for {@link ActiveCallsComponent} */
@Module
diff --git a/java/com/android/dialer/activecalls/impl/ActiveCallsImpl.java b/java/com/android/dialer/activecalls/impl/ActiveCallsImpl.java
index 10e6ffa9dc9e16019d1892224dfa19a861949264..8995962e9761f16232faf4f4cd7f4636ba5dfcf9 100644
--- a/java/com/android/dialer/activecalls/impl/ActiveCallsImpl.java
+++ b/java/com/android/dialer/activecalls/impl/ActiveCallsImpl.java
@@ -22,6 +22,7 @@ import com.android.dialer.activecalls.ActiveCallInfo;
import com.android.dialer.activecalls.ActiveCalls;
import com.android.dialer.common.Assert;
import com.google.common.collect.ImmutableList;
+
import javax.inject.Inject;
/** Implementation of {@link ActiveCalls} */
diff --git a/java/com/android/dialer/app/AccountSelectionActivity.java b/java/com/android/dialer/app/AccountSelectionActivity.java
index de84a36b987f6c329df91a490497607d4bee971e..b6ab6b7942ffe7784091b11acc2f3dd381a872fe 100644
--- a/java/com/android/dialer/app/AccountSelectionActivity.java
+++ b/java/com/android/dialer/app/AccountSelectionActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The LineageOS Project
+ * Copyright (C) 2018-2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,14 +19,16 @@ package com.android.dialer.app;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.text.TextUtils;
+import androidx.appcompat.app.AppCompatActivity;
+
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
import com.android.contacts.common.widget.SelectPhoneAccountDialogOptions;
import com.android.contacts.common.widget.SelectPhoneAccountDialogOptionsUtil;
+import com.android.dialer.R;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.util.CallUtil;
@@ -60,7 +62,7 @@ public class AccountSelectionActivity extends AppCompatActivity {
private String number;
private CallInitiationType.Type initiationType;
- private SelectPhoneAccountDialogFragment.SelectPhoneAccountListener listener =
+ private final SelectPhoneAccountDialogFragment.SelectPhoneAccountListener listener =
new SelectPhoneAccountDialogFragment.SelectPhoneAccountListener() {
@Override
public void onPhoneAccountSelected(PhoneAccountHandle selectedAccountHandle,
@@ -85,8 +87,9 @@ public class AccountSelectionActivity extends AppCompatActivity {
number = getIntent().getStringExtra("number");
initiationType = CallInitiationType.Type.values()[getIntent().getIntExtra("type", 0)];
- if (getFragmentManager().findFragmentByTag("dialog") == null) {
- List handles = getIntent().getParcelableArrayListExtra("accountHandles");
+ if (getSupportFragmentManager().findFragmentByTag("dialog") == null) {
+ List handles = getIntent().getParcelableArrayListExtra("accountHandles",
+ PhoneAccountHandle.class);
SelectPhoneAccountDialogOptions options = SelectPhoneAccountDialogOptionsUtil
.builderWithAccounts(handles)
.setTitle(R.string.call_via_dialog_title)
@@ -95,7 +98,7 @@ public class AccountSelectionActivity extends AppCompatActivity {
SelectPhoneAccountDialogFragment dialog =
SelectPhoneAccountDialogFragment.newInstance(options, listener);
- dialog.show(getFragmentManager(), "dialog");
+ dialog.show(getSupportFragmentManager(), "dialog");
}
}
}
diff --git a/java/com/android/dialer/app/AndroidManifest.xml b/java/com/android/dialer/app/AndroidManifest.xml
deleted file mode 100644
index 15fd14c0d36ec319253f6119fe9e8fc105aafc30..0000000000000000000000000000000000000000
--- a/java/com/android/dialer/app/AndroidManifest.xml
+++ /dev/null
@@ -1,153 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java
index 6efdc6286c4c1372a58b9d20a71885769cc5a53d..b91d164df73a63162341b37dc5a9470729b5a46a 100644
--- a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java
+++ b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,11 +19,11 @@ package com.android.dialer.app.calllog;
import android.content.Context;
import android.provider.BlockedNumberContract;
-import android.support.v4.app.FragmentManager;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import androidx.annotation.NonNull;
+import androidx.fragment.app.FragmentManager;
+import androidx.recyclerview.widget.RecyclerView;
import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler;
import com.android.dialer.blockreportspam.BlockReportSpamDialogs;
diff --git a/java/com/android/dialer/app/calllog/CallLogActivity.java b/java/com/android/dialer/app/calllog/CallLogActivity.java
index 1a07daa1d4bd6b119dfb125e67f0cea6e10c296e..5df7fdd999f72bb138c976b0d90ccb8de868e428 100644
--- a/java/com/android/dialer/app/calllog/CallLogActivity.java
+++ b/java/com/android/dialer/app/calllog/CallLogActivity.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,27 +16,26 @@
*/
package com.android.dialer.app.calllog;
-import android.app.Fragment;
-import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
-import android.support.design.widget.Snackbar;
-import android.support.v13.app.FragmentPagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.ViewGroup;
+
+import androidx.appcompat.app.ActionBar;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentPagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+
import com.android.contacts.common.list.ViewPagerTabs;
-import com.android.dialer.app.R;
-import com.android.dialer.calldetails.OldCallDetailsActivity;
+import com.android.dialer.R;
import com.android.dialer.callstats.CallStatsFragment;
import com.android.dialer.callstats.DoubleDatePickerDialog;
import com.android.dialer.common.Assert;
-import com.android.dialer.constants.ActivityRequestCodes;
import com.android.dialer.database.CallLogQueryHandler;
import com.android.dialer.util.TransactionSafeActivity;
import com.android.dialer.util.ViewUtil;
@@ -86,14 +86,14 @@ public class CallLogActivity extends TransactionSafeActivity implements
tabTitles[1] = getString(R.string.call_log_missed_title);
tabTitles[2] = getString(R.string.call_log_stats_title);
- viewPager = (ViewPager) findViewById(R.id.call_log_pager);
+ viewPager = findViewById(R.id.call_log_pager);
- viewPagerAdapter = new ViewPagerAdapter(getFragmentManager());
+ viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(viewPagerAdapter);
viewPager.setOffscreenPageLimit(1);
viewPager.setOnPageChangeListener(this);
- viewPagerTabs = (ViewPagerTabs) findViewById(R.id.viewpager_header);
+ viewPagerTabs = findViewById(R.id.viewpager_header);
viewPagerTabs.setViewPager(viewPager);
viewPager.setCurrentItem(startingTab);
@@ -151,7 +151,7 @@ public class CallLogActivity extends TransactionSafeActivity implements
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.delete_all) {
- ClearCallLogDialog.show(getFragmentManager());
+ ClearCallLogDialog.show(getSupportFragmentManager());
return true;
}
return super.onOptionsItemSelected(item);
@@ -212,11 +212,6 @@ public class CallLogActivity extends TransactionSafeActivity implements
}
}
- @Override
- public void onBackPressed() {
- super.onBackPressed();
- }
-
/** Adapter for the view pager. */
public class ViewPagerAdapter extends FragmentPagerAdapter {
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index 866f4d725bfb2ae9cb9f0b070d0bf49abfa24cc8..869f90bd87c687fc6e6e9f303f754628e845217d 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,21 +19,16 @@ package com.android.dialer.app.calllog;
import android.app.Activity;
import android.content.ContentUris;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.os.Trace;
import android.provider.BlockedNumberContract;
import android.provider.CallLog;
import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.RecyclerView.ViewHolder;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
@@ -51,9 +47,13 @@ import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import com.android.contacts.common.ContactsUtils;
-import com.android.dialer.app.R;
+import com.android.dialer.R;
import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener;
import com.android.dialer.app.calllog.CallLogGroupBuilder.GroupCreator;
import com.android.dialer.app.calllog.calllogcache.CallLogCache;
@@ -68,8 +68,6 @@ import com.android.dialer.calllogutils.PhoneCallDetails;
import com.android.dialer.common.Assert;
import com.android.dialer.common.FragmentUtils.FragmentUtilListener;
import com.android.dialer.common.LogUtil;
-import com.android.dialer.common.concurrent.AsyncTaskExecutor;
-import com.android.dialer.common.concurrent.AsyncTaskExecutors;
import com.android.dialer.contacts.ContactsComponent;
import com.android.dialer.logging.ContactSource;
import com.android.dialer.logging.ContactSource.Type;
@@ -80,9 +78,12 @@ import com.android.dialer.phonenumbercache.ContactInfoHelper;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.PermissionsUtil;
+
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
/** Adapter class to fill in data for the Call Log. */
public class CallLogAdapter extends GroupingListAdapter
@@ -119,8 +120,7 @@ public class CallLogAdapter extends GroupingListAdapter
/** Helper to group call log entries. */
private final CallLogGroupBuilder callLogGroupBuilder;
- private final AsyncTaskExecutor asyncTaskExecutor = AsyncTaskExecutors.createAsyncTaskExecutor();
- private ContactInfoCache contactInfoCache;
+ private final ContactInfoCache contactInfoCache;
// Tracks the position of the currently expanded list item.
private int currentlyExpandedPosition = RecyclerView.NO_POSITION;
// Tracks the rowId of the currently expanded list item, so the position can be updated if there
@@ -201,34 +201,17 @@ public class CallLogAdapter extends GroupingListAdapter
.getResources()
.getQuantityString(
R.plurals.delete_voicemails_confirmation_dialog_title, selectedItems.size()))
- .setPositiveButton(
- R.string.voicemailMultiSelectDeleteConfirm,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(final DialogInterface dialog, final int button) {
- LogUtil.i(
- "CallLogAdapter.showDeleteSelectedItemsDialog",
- "onClick, these items to delete " + voicemailsToDeleteOnConfirmation);
- deleteSelectedItems(voicemailsToDeleteOnConfirmation);
- actionMode.finish();
- dialog.cancel();
- }
- })
- .setOnCancelListener(
- new OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialogInterface) {
- dialogInterface.cancel();
- }
- })
- .setNegativeButton(
- R.string.voicemailMultiSelectDeleteCancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(final DialogInterface dialog, final int button) {
- dialog.cancel();
- }
- })
+ .setPositiveButton(R.string.voicemailMultiSelectDeleteConfirm, (dialog, button) -> {
+ LogUtil.i(
+ "CallLogAdapter.showDeleteSelectedItemsDialog",
+ "onClick, these items to delete " + voicemailsToDeleteOnConfirmation);
+ deleteSelectedItems(voicemailsToDeleteOnConfirmation);
+ actionMode.finish();
+ dialog.cancel();
+ })
+ .setOnCancelListener(dialogInterface -> dialogInterface.cancel())
+ .setNegativeButton(R.string.voicemailMultiSelectDeleteCancel,
+ (dialog, button) -> dialog.cancel())
.show();
}
@@ -380,7 +363,7 @@ public class CallLogAdapter extends GroupingListAdapter
* if removing an item, it will be shown as an invisible view. This simplifies the calculation of
* item position.
*/
- @NonNull private Set hiddenRowIds = new ArraySet<>();
+ @NonNull private final Set hiddenRowIds = new ArraySet<>();
/**
* Holds a list of URIs that are pending deletion or undo. If the activity ends before the undo
* timeout, all of the pending URIs will be deleted.
@@ -391,7 +374,7 @@ public class CallLogAdapter extends GroupingListAdapter
*/
@NonNull private final Set hiddenItemUris = new ArraySet<>();
- private CallLogListItemViewHolder.OnClickListener blockReportSpamListener;
+ private final CallLogListItemViewHolder.OnClickListener blockReportSpamListener;
/**
* Map, keyed by call ID, used to track the callback action for a call. Calls associated with the
@@ -611,7 +594,7 @@ public class CallLogAdapter extends GroupingListAdapter
* @param parent the parent view.
* @return The {@link ViewHolder}.
*/
- private ViewHolder createCallLogEntryViewHolder(ViewGroup parent) {
+ private RecyclerView.ViewHolder createCallLogEntryViewHolder(ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(activity);
View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
CallLogListItemViewHolder viewHolder =
@@ -643,7 +626,7 @@ public class CallLogAdapter extends GroupingListAdapter
* @param position The position of the entry.
*/
@Override
- public void onBindViewHolder(ViewHolder viewHolder, int position) {
+ public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
Trace.beginSection("onBindViewHolder: " + position);
switch (getItemViewType(position)) {
case VIEW_TYPE_ALERT:
@@ -663,7 +646,7 @@ public class CallLogAdapter extends GroupingListAdapter
updateCheckMarkedStatusOfEntry(views);
if (views.asyncTask != null) {
- views.asyncTask.cancel(true);
+ views.asyncTask.cancel();
}
}
}
@@ -726,10 +709,7 @@ public class CallLogAdapter extends GroupingListAdapter
}
private boolean isHiddenRow(@Nullable String number, long rowId) {
- if (hiddenRowIds.contains(rowId)) {
- return true;
- }
- return false;
+ return hiddenRowIds.contains(rowId);
}
private void loadAndRender(
@@ -744,38 +724,68 @@ public class CallLogAdapter extends GroupingListAdapter
viewHolder.isBlocked = false;
viewHolder.setDetailedPhoneDetails(callDetailsEntries);
- final AsyncTask loadDataTask =
- new AsyncTask() {
- @Override
- protected Boolean doInBackground(Void... params) {
- viewHolder.isBlocked = BlockedNumberContract.canCurrentUserBlockNumbers(activity) &&
- BlockedNumberContract.isBlocked(activity, viewHolder.number);
- details.isBlocked = viewHolder.isBlocked;
- if (isCancelled()) {
- return false;
- }
- return !isCancelled() && loadData(viewHolder, rowId, details);
- }
+ final LoadDataTask loadDataTask = new LoadDataTask(viewHolder, details, rowId);
- @Override
- protected void onPostExecute(Boolean success) {
- viewHolder.isLoaded = true;
- if (success) {
- viewHolder.callbackAction = getCallbackAction(viewHolder.rowId);
- int currentDayGroup = getDayGroup(viewHolder.rowId);
- if (currentDayGroup != details.previousGroup) {
- viewHolder.dayGroupHeaderVisibility = View.VISIBLE;
- viewHolder.dayGroupHeaderText = getGroupDescription(currentDayGroup);
- } else {
- viewHolder.dayGroupHeaderVisibility = View.GONE;
- }
- render(viewHolder, details, rowId);
+ viewHolder.asyncTask = loadDataTask;
+ loadDataTask.execute();
+ }
+
+ public interface LoadDataTaskInterface {
+ void execute();
+ void cancel();
+ }
+
+ private class LoadDataTask implements LoadDataTaskInterface {
+
+ private boolean mIsCancelled = false;
+ private final CallLogListItemViewHolder mViewHolder;
+ private final PhoneCallDetails mDetails;
+ private final long mRowId;
+
+ private final ExecutorService mExecutor;
+ private final Handler mHandler;
+
+ public LoadDataTask(CallLogListItemViewHolder viewHolder, PhoneCallDetails details,
+ long rowId) {
+ mExecutor = Executors.newSingleThreadExecutor();
+ mHandler = new Handler(Looper.getMainLooper());
+ mViewHolder = viewHolder;
+ mDetails = details;
+ mRowId = rowId;
+ }
+
+ public void execute() {
+ mExecutor.execute(() -> {
+ final boolean success;
+ mViewHolder.isBlocked = BlockedNumberContract.canCurrentUserBlockNumbers(activity) &&
+ BlockedNumberContract.isBlocked(activity, mViewHolder.number);
+ mDetails.isBlocked = mViewHolder.isBlocked;
+ if (mIsCancelled) {
+ success = false;
+ } else {
+ success = !mIsCancelled && loadData(mViewHolder, mRowId, mDetails);
+ }
+
+ mHandler.post(() -> {
+ mViewHolder.isLoaded = true;
+ if (success) {
+ mViewHolder.callbackAction = getCallbackAction(mViewHolder.rowId);
+ int currentDayGroup = getDayGroup(mViewHolder.rowId);
+ if (currentDayGroup != mDetails.previousGroup) {
+ mViewHolder.dayGroupHeaderVisibility = View.VISIBLE;
+ mViewHolder.dayGroupHeaderText = getGroupDescription(currentDayGroup);
+ } else {
+ mViewHolder.dayGroupHeaderVisibility = View.GONE;
}
+ render(mViewHolder, mDetails, mRowId);
}
- };
+ });
+ });
+ }
- viewHolder.asyncTask = loadDataTask;
- asyncTaskExecutor.submit(LOAD_DATA_TASK_IDENTIFIER, loadDataTask);
+ public void cancel() {
+ mIsCancelled = true;
+ }
}
/**
diff --git a/java/com/android/dialer/app/calllog/CallLogAlertManager.java b/java/com/android/dialer/app/calllog/CallLogAlertManager.java
index 40b30f001edd7d0a9e660cc459d36aeaf4014a3c..1440c70030a2b7ac7e33cc044736cabb0872dec1 100644
--- a/java/com/android/dialer/app/calllog/CallLogAlertManager.java
+++ b/java/com/android/dialer/app/calllog/CallLogAlertManager.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +17,13 @@
package com.android.dialer.app.calllog;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import com.android.dialer.app.R;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.dialer.R;
import com.android.dialer.app.alert.AlertManager;
import com.android.dialer.common.Assert;
diff --git a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java
index d285848af106849bb52921445458a198f6b4dade..3aebbe9cf88433353526fe6e6e0d59ef56b306d9 100644
--- a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java
+++ b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +21,6 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
-import android.os.AsyncTask;
import android.provider.CallLog;
import android.provider.VoicemailContract.Voicemails;
import android.text.TextUtils;
@@ -52,23 +52,18 @@ public class CallLogAsyncTaskUtil {
}
asyncTaskExecutor.submit(
- Tasks.MARK_VOICEMAIL_READ,
- new AsyncTask() {
- @Override
- public Void doInBackground(Void... params) {
- ContentValues values = new ContentValues();
- values.put(Voicemails.IS_READ, true);
- // "External" changes to the database will be automatically marked as dirty, but this
- // voicemail might be from dialer so it need to be marked manually.
- values.put(Voicemails.DIRTY, 1);
- if (context
- .getContentResolver()
- .update(voicemailUri, values, Voicemails.IS_READ + " = 0", null)
- > 0) {
- uploadVoicemailLocalChangesToServer(context);
- CallLogNotificationsService.markAllNewVoicemailsAsOld(context);
- }
- return null;
+ Tasks.MARK_VOICEMAIL_READ, () -> {
+ ContentValues values = new ContentValues();
+ values.put(Voicemails.IS_READ, true);
+ // "External" changes to the database will be automatically marked as dirty, but this
+ // voicemail might be from dialer so it need to be marked manually.
+ values.put(Voicemails.DIRTY, 1);
+ if (context
+ .getContentResolver()
+ .update(voicemailUri, values, Voicemails.IS_READ + " = 0", null)
+ > 0) {
+ uploadVoicemailLocalChangesToServer(context);
+ CallLogNotificationsService.markAllNewVoicemailsAsOld(context);
}
});
}
@@ -81,22 +76,13 @@ public class CallLogAsyncTaskUtil {
initTaskExecutor();
}
- asyncTaskExecutor.submit(
- Tasks.DELETE_VOICEMAIL,
- new AsyncTask() {
- @Override
- public Void doInBackground(Void... params) {
- deleteVoicemailSynchronous(context, voicemailUri);
- return null;
- }
-
- @Override
- public void onPostExecute(Void result) {
- if (callLogAsyncTaskListener != null) {
- callLogAsyncTaskListener.onDeleteVoicemail();
- }
- }
- });
+ asyncTaskExecutor.submit(Tasks.DELETE_VOICEMAIL,
+ () -> deleteVoicemailSynchronous(context, voicemailUri),
+ () -> {
+ if (callLogAsyncTaskListener != null) {
+ callLogAsyncTaskListener.onDeleteVoicemail();
+ }
+ });
}
public static void deleteVoicemailSynchronous(Context context, Uri voicemailUri) {
@@ -117,35 +103,28 @@ public class CallLogAsyncTaskUtil {
initTaskExecutor();
}
- asyncTaskExecutor.submit(
- Tasks.MARK_CALL_READ,
- new AsyncTask() {
- @Override
- public Void doInBackground(Void... params) {
-
- StringBuilder where = new StringBuilder();
- where.append(CallLog.Calls.TYPE).append(" = ").append(CallLog.Calls.MISSED_TYPE);
- where.append(" AND ");
-
- Long[] callIdLongs = new Long[callIds.length];
- for (int i = 0; i < callIds.length; i++) {
- callIdLongs[i] = callIds[i];
- }
- where
- .append(CallLog.Calls._ID)
- .append(" IN (" + TextUtils.join(",", callIdLongs) + ")");
-
- ContentValues values = new ContentValues(1);
- values.put(CallLog.Calls.IS_READ, "1");
- context
- .getContentResolver()
- .update(CallLog.Calls.CONTENT_URI, values, where.toString(), null);
- return null;
- }
- });
+ asyncTaskExecutor.submit(Tasks.MARK_CALL_READ, () -> {
+ StringBuilder where = new StringBuilder();
+ where.append(CallLog.Calls.TYPE).append(" = ").append(CallLog.Calls.MISSED_TYPE);
+ where.append(" AND ");
+
+ Long[] callIdLongs = new Long[callIds.length];
+ for (int i = 0; i < callIds.length; i++) {
+ callIdLongs[i] = callIds[i];
+ }
+ where
+ .append(CallLog.Calls._ID)
+ .append(" IN (" + TextUtils.join(",", callIdLongs) + ")");
+
+ ContentValues values = new ContentValues(1);
+ values.put(CallLog.Calls.IS_READ, "1");
+ context
+ .getContentResolver()
+ .update(CallLog.Calls.CONTENT_URI, values, where.toString(), null);
+ });
}
- /** The enumeration of {@link AsyncTask} objects used in this class. */
+ /** The enumeration of objects used in this class. */
public enum Tasks {
DELETE_VOICEMAIL,
MARK_VOICEMAIL_READ,
diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java
index 058dba8f7d33522ab3773ed956b9af0b937c67f2..cd2371f838df05c56ffc693d2a15d9ce0d009011 100644
--- a/java/com/android/dialer/app/calllog/CallLogFragment.java
+++ b/java/com/android/dialer/app/calllog/CallLogFragment.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,24 +20,18 @@ package com.android.dialer.app.calllog;
import static android.Manifest.permission.READ_CALL_LOG;
import android.app.Activity;
-import android.app.Fragment;
import android.app.KeyguardManager;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.database.ContentObserver;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
-import android.support.v13.app.FragmentCompat;
-import android.support.v13.app.FragmentCompat.OnRequestPermissionsResultCallback;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -44,10 +39,17 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.CallSuper;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.content.res.AppCompatResources;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
-import com.android.dialer.app.R;
+import com.android.dialer.R;
import com.android.dialer.app.calllog.CallLogAdapter.CallFetcher;
import com.android.dialer.app.calllog.CallLogAdapter.MultiSelectRemoveView;
import com.android.dialer.app.calllog.calllogcache.CallLogCache;
@@ -67,6 +69,7 @@ import com.android.dialer.phonenumbercache.ContactInfoHelper;
import com.android.dialer.util.PermissionsUtil;
import com.android.dialer.widget.EmptyContentView;
import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener;
+
import java.util.Arrays;
/**
@@ -78,7 +81,6 @@ public class CallLogFragment extends Fragment
CallFetcher,
MultiSelectRemoveView,
OnEmptyViewActionButtonClickedListener,
- OnRequestPermissionsResultCallback,
CallLogModalAlertManager.Listener,
OnClickListener {
private static final String KEY_FILTER_TYPE = "filter_type";
@@ -94,12 +96,10 @@ public class CallLogFragment extends Fragment
// No date-based filtering.
private static final int NO_DATE_LIMIT = 0;
- private static final int PHONE_PERMISSIONS_REQUEST_CODE = 1;
-
private static final int EVENT_UPDATE_DISPLAY = 1;
private static final long MILLIS_IN_MINUTE = 60 * 1000;
- private final Handler handler = new Handler();
+ private final Handler handler = new Handler(Looper.getMainLooper());
// See issue 6363009
private final ContentObserver callLogObserver = new CustomContentObserver();
private final ContentObserver contactsObserver = new CustomContentObserver();
@@ -140,7 +140,7 @@ public class CallLogFragment extends Fragment
private boolean isCallLogActivity = false;
private boolean selectAllMode;
private final Handler displayUpdateHandler =
- new Handler() {
+ new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -156,6 +156,15 @@ public class CallLogFragment extends Fragment
protected CallLogModalAlertManager modalAlertManager;
private ViewGroup modalAlertView;
+ private final ActivityResultLauncher permissionLauncher = registerForActivityResult(
+ new ActivityResultContracts.RequestMultiplePermissions(),
+ grantResults -> {
+ if (grantResults.size() >= 1 && grantResults.values().iterator().next()) {
+ // Force a refresh of the data since we were missing the permission before this.
+ refreshDataRequired = true;
+ }
+ });
+
public CallLogFragment() {
this(CallLogQueryHandler.CALL_TYPE_ALL, NO_LOG_LIMIT);
}
@@ -213,7 +222,7 @@ public class CallLogFragment extends Fragment
selectAllMode = state.getBoolean(KEY_SELECT_ALL_MODE, false);
}
- final Activity activity = getActivity();
+ final Activity activity = requireActivity();
final ContentResolver resolver = activity.getContentResolver();
callLogQueryHandler = new CallLogQueryHandler(activity, resolver, this, logLimit);
setHasOptionsMenu(true);
@@ -257,16 +266,12 @@ public class CallLogFragment extends Fragment
}
// Workaround for framework issue: the smooth-scroll doesn't
// occur if setSelection() is called immediately before.
- handler.post(
- new Runnable() {
- @Override
- public void run() {
- if (getActivity() == null || getActivity().isFinishing()) {
- return;
- }
- recyclerView.smoothScrollToPosition(0);
- }
- });
+ handler.post(() -> {
+ if (getActivity() == null || getActivity().isFinishing()) {
+ return;
+ }
+ recyclerView.smoothScrollToPosition(0);
+ });
scrollToTop = false;
}
@@ -318,7 +323,7 @@ public class CallLogFragment extends Fragment
contactInfoCache =
new ContactInfoCache(
- ExpirableCacheHeadlessFragment.attach((AppCompatActivity) getActivity())
+ ExpirableCacheHeadlessFragment.attach(getChildFragmentManager())
.getRetainedCache(),
new ContactInfoHelper(getActivity(), currentCountryIso),
onContactInfoChangedListener);
@@ -334,7 +339,7 @@ public class CallLogFragment extends Fragment
new CallLogCache(getActivity()),
contactInfoCache,
getVoicemailPlaybackPresenter(),
- new FilteredNumberAsyncQueryHandler(getActivity()),
+ new FilteredNumberAsyncQueryHandler(requireActivity()),
activityType);
recyclerView.setAdapter(adapter);
if (adapter.getOnScrollListener() != null) {
@@ -348,15 +353,6 @@ public class CallLogFragment extends Fragment
return null;
}
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- LogUtil.enterBlock("CallLogFragment.onActivityCreated");
- super.onActivityCreated(savedInstanceState);
- setupData();
- updateSelectAllState(savedInstanceState);
- adapter.onRestoreInstanceState(savedInstanceState);
- }
-
private void updateSelectAllState(Bundle savedInstanceState) {
if (savedInstanceState != null) {
if (savedInstanceState.getBoolean(KEY_SELECT_ALL_MODE, false)) {
@@ -366,9 +362,19 @@ public class CallLogFragment extends Fragment
}
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
+ public void onAttach(@NonNull Context context) {
+ LogUtil.enterBlock("CallLogFragment.onAttach");
+ super.onAttach(context);
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
+ LogUtil.enterBlock("CallLogFragment.onViewCreated");
super.onViewCreated(view, savedInstanceState);
updateEmptyMessage(callTypeFilter);
+ setupData();
+ updateSelectAllState(savedInstanceState);
+ adapter.onRestoreInstanceState(savedInstanceState);
}
@Override
@@ -385,7 +391,7 @@ public class CallLogFragment extends Fragment
updateEmptyMessage(callTypeFilter);
}
- ContentResolver resolver = getActivity().getContentResolver();
+ ContentResolver resolver = requireActivity().getContentResolver();
if (PermissionsUtil.hasCallLogReadPermissions(getContext())) {
resolver.registerContentObserver(CallLog.CONTENT_URI, true, callLogObserver);
} else {
@@ -406,7 +412,10 @@ public class CallLogFragment extends Fragment
rescheduleDisplayUpdate();
// onResume() may also be called as a "side" page on the ViewPager, which is not visible.
if (getUserVisibleHint()) {
+ LogUtil.w("CallLogFragment.onResume", "on visible hint");
onVisible();
+ } else {
+ LogUtil.w("CallLogFragment.onResume", "not visible hint");
}
}
@@ -426,7 +435,7 @@ public class CallLogFragment extends Fragment
LogUtil.enterBlock("CallLogFragment.onStart");
super.onStart();
CequintCallerIdManager cequintCallerIdManager = null;
- if (CequintCallerIdManager.isCequintCallerIdEnabled(getContext())) {
+ if (CequintCallerIdManager.isCequintCallerIdEnabled(requireContext())) {
cequintCallerIdManager = new CequintCallerIdManager();
}
contactInfoCache.setCequintCallerIdManager(cequintCallerIdManager);
@@ -443,8 +452,8 @@ public class CallLogFragment extends Fragment
@Override
public void onDestroy() {
LogUtil.enterBlock("CallLogFragment.onDestroy");
- getActivity().getContentResolver().unregisterContentObserver(callLogObserver);
- getActivity().getContentResolver().unregisterContentObserver(contactsObserver);
+ requireActivity().getContentResolver().unregisterContentObserver(callLogObserver);
+ requireActivity().getContentResolver().unregisterContentObserver(contactsObserver);
if (adapter != null) {
adapter.changeCursor(null);
}
@@ -452,7 +461,7 @@ public class CallLogFragment extends Fragment
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(KEY_FILTER_TYPE, callTypeFilter);
outState.putInt(KEY_LOG_LIMIT, logLimit);
@@ -562,7 +571,7 @@ public class CallLogFragment extends Fragment
LogUtil.i(
"CallLogFragment.onEmptyViewActionButtonClicked",
"Requesting permissions: " + Arrays.toString(deniedPermissions));
- FragmentCompat.requestPermissions(this, deniedPermissions, PHONE_PERMISSIONS_REQUEST_CODE);
+ permissionLauncher.launch(deniedPermissions);
} else if (!isCallLogActivity) {
LogUtil.i("CallLogFragment.onEmptyViewActionButtonClicked", "showing dialpad");
// Show dialpad if we are not in the call log activity.
@@ -570,17 +579,6 @@ public class CallLogFragment extends Fragment
}
}
- @Override
- public void onRequestPermissionsResult(
- int requestCode, String[] permissions, int[] grantResults) {
- if (requestCode == PHONE_PERMISSIONS_REQUEST_CODE) {
- if (grantResults.length >= 1 && PackageManager.PERMISSION_GRANTED == grantResults[0]) {
- // Force a refresh of the data since we were missing the permission before this.
- refreshDataRequired = true;
- }
- }
- }
-
/** Schedules an update to the relative call times (X mins ago). */
private void rescheduleDisplayUpdate() {
if (!displayUpdateHandler.hasMessages(EVENT_UPDATE_DISPLAY)) {
@@ -672,8 +670,8 @@ public class CallLogFragment extends Fragment
@Override
public void setSelectAllModeToFalse() {
selectAllMode = false;
- selectUnselectAllIcon.setImageDrawable(
- getContext().getDrawable(R.drawable.ic_empty_check_mark_white_24dp));
+ selectUnselectAllIcon.setImageDrawable(AppCompatResources.getDrawable(requireContext(),
+ R.drawable.ic_empty_check_mark_white_24dp));
}
@Override
@@ -691,12 +689,12 @@ public class CallLogFragment extends Fragment
private void updateSelectAllIcon() {
if (selectAllMode) {
- selectUnselectAllIcon.setImageDrawable(
- getContext().getDrawable(R.drawable.ic_check_mark_blue_24dp));
+ selectUnselectAllIcon.setImageDrawable(AppCompatResources.getDrawable(requireContext(),
+ R.drawable.ic_check_mark_blue_24dp));
getAdapter().onAllSelected();
} else {
- selectUnselectAllIcon.setImageDrawable(
- getContext().getDrawable(R.drawable.ic_empty_check_mark_white_24dp));
+ selectUnselectAllIcon.setImageDrawable(AppCompatResources.getDrawable(requireContext(),
+ R.drawable.ic_empty_check_mark_white_24dp));
getAdapter().onAllDeselected();
}
}
diff --git a/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java b/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java
index db3f284001b8f55c92e832dd54a139583ccc93f9..e4d27a4b0b03de0242d6d96cde3b3dfb451ba36a 100644
--- a/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java
+++ b/java/com/android/dialer/app/calllog/CallLogGroupBuilder.java
@@ -20,7 +20,6 @@ import android.database.Cursor;
import android.provider.CallLog.Calls;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
-import android.text.format.Time;
import androidx.annotation.Nullable;
@@ -30,7 +29,8 @@ import com.android.dialer.calllogutils.CallbackActionHelper.CallbackAction;
import com.android.dialer.compat.telephony.TelephonyManagerCompat;
import com.android.dialer.phonenumbercache.CallLogQuery;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
-import java.util.Objects;
+
+import java.time.ZoneId;
/**
* Groups together calls in the call log. The primary grouping attempts to group together calls to
@@ -55,7 +55,7 @@ public class CallLogGroupBuilder {
/** Day grouping for calls which occurred before last week. */
public static final int DAY_GROUP_OTHER = 2;
/** Instance of the time object used for time calculations. */
- private static final Time TIME = new Time();
+ private static final ZoneId TIME_ZONE = ZoneId.systemDefault();
/** The object on which the groups are created. */
private final GroupCreator groupCreator;
@@ -189,7 +189,7 @@ public class CallLogGroupBuilder {
*/
private boolean equalNumbers(@Nullable String number1, @Nullable String number2) {
if (PhoneNumberHelper.isUriNumber(number1) || PhoneNumberHelper.isUriNumber(number2)) {
- return compareSipAddresses(number1, number2);
+ return PhoneNumberHelper.compareSipAddresses(number1, number2);
}
// PhoneNumberUtils.compare(String, String) ignores special characters such as '#'. For example,
@@ -208,36 +208,6 @@ public class CallLogGroupBuilder {
return TextUtils.equals(name1, name2) && TextUtils.equals(id1, id2);
}
- private boolean compareSipAddresses(@Nullable String number1, @Nullable String number2) {
- if (number1 == null || number2 == null) {
- return Objects.equals(number1, number2);
- }
-
- int index1 = number1.indexOf('@');
- final String userinfo1;
- final String rest1;
- if (index1 != -1) {
- userinfo1 = number1.substring(0, index1);
- rest1 = number1.substring(index1);
- } else {
- userinfo1 = number1;
- rest1 = "";
- }
-
- int index2 = number2.indexOf('@');
- final String userinfo2;
- final String rest2;
- if (index2 != -1) {
- userinfo2 = number2.substring(0, index2);
- rest2 = number2.substring(index2);
- } else {
- userinfo2 = number2;
- rest2 = "";
- }
-
- return userinfo1.equals(userinfo2) && rest1.equalsIgnoreCase(rest2);
- }
-
/**
* Given a call date and the current date, determine which date group the call belongs in.
*
@@ -246,7 +216,7 @@ public class CallLogGroupBuilder {
* @return The date group the call belongs in.
*/
private int getDayGroup(long date, long now) {
- int days = DateUtils.getDayDifference(TIME, date, now);
+ int days = DateUtils.getDayDifference(TIME_ZONE, date, now);
if (days == 0) {
return DAY_GROUP_TODAY;
diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
index 53cc4b70677bcda444f7ccc7c2d86daf4d41a246..1dd4e5360e5f1b8059c74f099661b48702925156 100644
--- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
+++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,13 +30,10 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
-import android.os.AsyncTask;
import android.provider.BlockedNumberContract;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.support.v7.widget.CardView;
-import android.support.v7.widget.RecyclerView;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -45,23 +43,24 @@ import android.telephony.TelephonyManager;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
-import android.view.ContextMenu;
import android.transition.TransitionManager;
-import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.DecelerateInterpolator;
+import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
+import android.view.animation.AccelerateDecelerateInterpolator;
+import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
-import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
+import androidx.cardview.widget.CardView;
+import androidx.recyclerview.widget.RecyclerView;
import com.android.contacts.common.dialog.CallSubjectDialog;
-import com.android.dialer.app.R;
+import com.android.dialer.R;
import com.android.dialer.app.calllog.CallLogAdapter.OnActionModeStateChangedListener;
import com.android.dialer.app.calllog.calllogcache.CallLogCache;
import com.android.dialer.app.voicemail.VoicemailPlaybackLayout;
@@ -72,7 +71,6 @@ import com.android.dialer.calllogutils.CallbackActionHelper.CallbackAction;
import com.android.dialer.clipboard.ClipboardUtils;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.AsyncTaskExecutors;
-import com.android.dialer.constants.ActivityRequestCodes;
import com.android.dialer.contactphoto.ContactPhotoManager;
import com.android.dialer.dialercontact.DialerContact;
import com.android.dialer.dialercontact.SimDetails;
@@ -88,8 +86,7 @@ import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.CallUtil;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.UriUtils;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
+
import java.lang.ref.WeakReference;
/**
@@ -130,7 +127,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
private final CachedNumberLookupService cachedNumberLookupService;
private final VoicemailPlaybackPresenter voicemailPlaybackPresenter;
private final OnClickListener blockReportListener;
- @HostUi private final int hostUi;
/** Whether the data fields are populated by the worker thread, ready to be shown. */
public boolean isLoaded;
/** The view containing call log item actions. Null until the ViewStub is inflated. */
@@ -150,8 +146,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
public View detailsButtonView;
public View callWithNoteButtonView;
public View sendVoicemailButtonView;
- public ImageView workIconView;
- public ImageView checkBoxView;
+ public final ImageView workIconView;
+ public final ImageView checkBoxView;
/**
* The row Id for the first call associated with the call log entry. Used as a key for the map
* used to track which call log entries have the action button section expanded.
@@ -217,7 +213,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
/** Whether the current log entry is a spam number or not. */
public boolean isSpam;
- private View.OnClickListener expandCollapseListener;
+ private final View.OnClickListener expandCollapseListener;
private final OnActionModeStateChangedListener onActionModeStateChangedListener;
private final View.OnLongClickListener longPressListener;
private boolean voicemailPrimaryActionButtonClicked;
@@ -227,7 +223,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
public CharSequence dayGroupHeaderText;
public boolean isAttachedToWindow;
- public AsyncTask asyncTask;
+ public CallLogAdapter.LoadDataTaskInterface asyncTask;
private CallDetailsEntries callDetailsEntries;
private CallLogListItemViewHolder(
@@ -269,21 +265,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
this.callLogEntryView = callLogEntryView;
this.dayGroupHeader = dayGroupHeader;
this.primaryActionButtonView = primaryActionButtonView;
- this.workIconView = (ImageView) rootView.findViewById(R.id.work_profile_icon);
- this.checkBoxView = (ImageView) rootView.findViewById(R.id.quick_contact_checkbox);
+ this.workIconView = rootView.findViewById(R.id.work_profile_icon);
+ this.checkBoxView = rootView.findViewById(R.id.quick_contact_checkbox);
// Set text height to false on the TextViews so they don't have extra padding.
phoneCallDetailsViews.nameView.setElegantTextHeight(false);
phoneCallDetailsViews.callLocationAndDate.setElegantTextHeight(false);
- if (this.context instanceof CallLogActivity) {
- hostUi = HostUi.CALL_HISTORY;
- } else if (this.voicemailPlaybackPresenter == null) {
- hostUi = HostUi.CALL_LOG;
- } else {
- hostUi = HostUi.VOICEMAIL;
- }
-
quickContactView.setOverlay(null);
quickContactView.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
primaryActionButtonView.setOnClickListener(this);
@@ -493,7 +481,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
videoCallButtonView.setVisibility(View.GONE);
// For an emergency number, show "Call details" only.
- if (PhoneNumberHelper.isLocalEmergencyNumber(context, number)) {
+ if (PhoneNumberHelper.isEmergencyNumber(context, number)) {
createNewContactButtonView.setVisibility(View.GONE);
addToExistingContactButtonView.setVisibility(View.GONE);
sendMessageView.setVisibility(View.GONE);
@@ -897,14 +885,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
return;
}
if (OldCallDetailsActivity.isLaunchIntent(intent)) {
- ((Activity) context)
- .startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_CALL_DETAILS);
+ ((Activity) context).startActivity(intent);
} else {
- if (Intent.ACTION_CALL.equals(intent.getAction())
- && intent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, -1)
- == VideoProfile.STATE_BIDIRECTIONAL) {
- }
-
DialerUtils.startActivityWithErrorToast(context, intent);
}
}
@@ -965,11 +947,11 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
blockView.setVisibility(View.GONE);
unblockView.setVisibility(View.GONE);
reportNotSpamView.setVisibility(View.GONE);
- String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso);
+
if (!canPlaceCallToNumber
|| isVoicemailNumber
|| !BlockedNumberContract.canCurrentUserBlockNumbers(context)
- || PhoneNumberUtils.isEmergencyNumber(e164Number)) {
+ || PhoneNumberHelper.isEmergencyNumber(context, number, countryIso)) {
return;
}
@@ -1022,13 +1004,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
.setOnMenuItemClickListener(this);
}
- String e164Number = PhoneNumberUtils.formatNumberToE164(number, countryIso);
boolean isVoicemailNumber = callLogCache.isVoicemailNumber(accountHandle, number);
boolean canPlaceCallToNumber = PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation);
if (canPlaceCallToNumber
&& !isVoicemailNumber
&& BlockedNumberContract.canCurrentUserBlockNumbers(context)
- && !PhoneNumberUtils.isEmergencyNumber(e164Number)) {
+ && !PhoneNumberHelper.isEmergencyNumber(context, number, countryIso)) {
if (isBlocked) {
menu.add(
ContextMenu.NONE,
@@ -1052,15 +1033,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
}
}
- /** Specifies where the view holder belongs. */
- @IntDef({HostUi.CALL_LOG, HostUi.CALL_HISTORY, HostUi.VOICEMAIL})
- @Retention(RetentionPolicy.SOURCE)
- private @interface HostUi {
- int CALL_LOG = 0;
- int CALL_HISTORY = 1;
- int VOICEMAIL = 2;
- }
-
public interface OnClickListener {
void onBlockReportSpam(
@@ -1093,7 +1065,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
ContactSource.Type contactSourceType);
}
- private static class DeleteCallTask extends AsyncTask {
+ private static class DeleteCallTask implements Runnable {
// Using a weak reference to hold the Context so that there is no memory leak.
private final WeakReference contextWeakReference;
@@ -1104,15 +1076,15 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
this.callIdsStr = concatCallIds(callIdsArray);
}
- @Override
// Suppress the lint check here as the user will not be able to see call log entries if
// permission.WRITE_CALL_LOG is not granted.
@SuppressLint("MissingPermission")
@RequiresPermission(value = permission.WRITE_CALL_LOG)
- protected Void doInBackground(Void... params) {
+ @Override
+ public void run() {
Context context = contextWeakReference.get();
if (context == null) {
- return null;
+ return;
}
if (callIdsStr != null) {
@@ -1126,13 +1098,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
.getContentResolver()
.notifyChange(Calls.CONTENT_URI, null);
}
-
- return null;
}
- @Override
- public void onPostExecute(Void result) {}
-
private String concatCallIds(long[] callIds) {
if (callIds == null || callIds.length == 0) {
return null;
diff --git a/java/com/android/dialer/app/calllog/CallLogModalAlertManager.java b/java/com/android/dialer/app/calllog/CallLogModalAlertManager.java
index 9de260a0ae1ca636e0ba514b1977fcc1c821b180..7d8ed4b3b6d7698d78f97ecde222a3ed9d1575cf 100644
--- a/java/com/android/dialer/app/calllog/CallLogModalAlertManager.java
+++ b/java/com/android/dialer/app/calllog/CallLogModalAlertManager.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +20,8 @@ package com.android.dialer.app.calllog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import com.android.dialer.app.R;
+
+import com.android.dialer.R;
import com.android.dialer.app.alert.AlertManager;
/**
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsActivity.java b/java/com/android/dialer/app/calllog/CallLogNotificationsActivity.java
index c08d2c02b47b648e62bca21f462a74ab710dbfe3..b8488c537b9cc5241c6ef7dda751b2128352adc0 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsActivity.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsActivity.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +19,9 @@ package com.android.dialer.app.calllog;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
+
+import androidx.appcompat.app.AppCompatActivity;
+
import com.android.dialer.common.LogUtil;
import com.android.dialer.util.PermissionsUtil;
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
index 60d82f69bc3572bbaa6df8555d81fd9bbd0eaf7f..00d08de0ae81cd99a6f6b4eebf994250ba70d551 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,15 +26,15 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.provider.VoicemailContract.Voicemails;
-import android.support.v4.os.UserManagerCompat;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
+import androidx.core.os.UserManagerCompat;
-import com.android.dialer.app.R;
+import com.android.dialer.R;
import com.android.dialer.calllogutils.PhoneNumberDisplayUtil;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.database.Selection;
@@ -42,6 +43,7 @@ import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.phonenumbercache.ContactInfoHelper;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.util.PermissionsUtil;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
index 947dd0213a881450645a340d4339edc1ab110d0e..d2d31a3c11e0138dea2beab0f319fba0d51b77ae 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
@@ -99,7 +99,7 @@ public class CallLogNotificationsService extends IntentService {
public static PendingIntent createMarkAllNewVoicemailsAsOldIntent(@NonNull Context context) {
Intent intent = new Intent(context, CallLogNotificationsService.class);
intent.setAction(CallLogNotificationsService.ACTION_MARK_ALL_NEW_VOICEMAILS_AS_OLD);
- return PendingIntent.getService(context, 0, intent, 0);
+ return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
}
public static PendingIntent createMarkSingleNewVoicemailAsOldIntent(
@@ -107,13 +107,13 @@ public class CallLogNotificationsService extends IntentService {
Intent intent = new Intent(context, CallLogNotificationsService.class);
intent.setAction(CallLogNotificationsService.ACTION_MARK_SINGLE_NEW_VOICEMAIL_AS_OLD);
intent.setData(voicemailUri);
- return PendingIntent.getService(context, 0, intent, 0);
+ return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
}
public static PendingIntent createCancelAllMissedCallsPendingIntent(@NonNull Context context) {
Intent intent = new Intent(context, CallLogNotificationsService.class);
intent.setAction(ACTION_CANCEL_ALL_MISSED_CALLS);
- return PendingIntent.getService(context, 0, intent, 0);
+ return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
}
public static PendingIntent createCancelSingleMissedCallPendingIntent(
@@ -121,7 +121,7 @@ public class CallLogNotificationsService extends IntentService {
Intent intent = new Intent(context, CallLogNotificationsService.class);
intent.setAction(ACTION_CANCEL_SINGLE_MISSED_CALL);
intent.setData(callUri);
- return PendingIntent.getService(context, 0, intent, 0);
+ return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
}
public static PendingIntent createLegacyVoicemailDismissedPendingIntent(
@@ -129,7 +129,7 @@ public class CallLogNotificationsService extends IntentService {
Intent intent = new Intent(context, CallLogNotificationsService.class);
intent.setAction(ACTION_LEGACY_VOICEMAIL_DISMISSED);
intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
- return PendingIntent.getService(context, 0, intent, 0);
+ return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
}
@Override
@@ -159,7 +159,9 @@ public class CallLogNotificationsService extends IntentService {
break;
case ACTION_LEGACY_VOICEMAIL_DISMISSED:
LegacyVoicemailNotificationReceiver.setDismissed(
- this, intent.getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE), true);
+ this,
+ intent.getParcelableExtra(EXTRA_PHONE_ACCOUNT_HANDLE, PhoneAccountHandle.class),
+ true);
break;
case ACTION_CANCEL_ALL_MISSED_CALLS:
cancelAllMissedCalls(this);
diff --git a/java/com/android/dialer/app/calllog/CallLogReceiver.java b/java/com/android/dialer/app/calllog/CallLogReceiver.java
index 5d8d13039e711643e74b2cd8c8c7c2fceb93e3c0..e28a0819e26a32ea0a40ca0ec3222da40aeb5a0e 100644
--- a/java/com/android/dialer/app/calllog/CallLogReceiver.java
+++ b/java/com/android/dialer/app/calllog/CallLogReceiver.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.provider.VoicemailContract;
+
import com.android.dialer.common.LogUtil;
import com.android.dialer.database.CallLogQueryHandler;
diff --git a/java/com/android/dialer/app/calllog/ClearCallLogDialog.java b/java/com/android/dialer/app/calllog/ClearCallLogDialog.java
index faece65b6d0d970d7f48097d36455610ba200f1d..0b4e5dbb97995f312c2691ec699ef4d289e25069 100644
--- a/java/com/android/dialer/app/calllog/ClearCallLogDialog.java
+++ b/java/com/android/dialer/app/calllog/ClearCallLogDialog.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,20 +18,19 @@
package com.android.dialer.app.calllog;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.FragmentManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.provider.CallLog.Calls;
-import android.support.design.widget.Snackbar;
import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.FragmentManager;
-import com.android.dialer.app.R;
+import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.concurrent.DialerExecutor;
import com.android.dialer.common.concurrent.DialerExecutor.Worker;
@@ -58,7 +58,7 @@ public class ClearCallLogDialog extends DialogFragment {
DialerExecutorComponent.get(getContext())
.dialerExecutorFactory()
.createUiTaskBuilder(
- getFragmentManager(),
+ getChildFragmentManager(),
"clearCallLogTask",
new ClearCallLogWorker(getActivity().getApplicationContext()))
.onSuccess(this::onSuccess)
diff --git a/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java b/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java
index ef61aac9d49e3469ce800e94c91f1ae3b6ef34f5..5a4dd0afeec0e85f6d1776af118fda1ea7fbaa84 100644
--- a/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java
+++ b/java/com/android/dialer/app/calllog/DialerQuickContactBadge.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.QuickContactBadge;
+
import com.android.dialer.app.calllog.CallLogAdapter.OnActionModeStateChangedListener;
/** Allows us to click the contact badge for non multi select mode. */
diff --git a/java/com/android/dialer/app/calllog/GroupingListAdapter.java b/java/com/android/dialer/app/calllog/GroupingListAdapter.java
index 29a4d4e4a321f8e35c0ee8ea9ea39fbcfdc6c086..01250abdf967fbcc547a79f21bac77f72ebcc407 100644
--- a/java/com/android/dialer/app/calllog/GroupingListAdapter.java
+++ b/java/com/android/dialer/app/calllog/GroupingListAdapter.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +21,11 @@ import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.os.Handler;
-import android.support.v7.widget.RecyclerView;
+import android.os.Looper;
import android.util.SparseIntArray;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Maintains a list that groups items into groups of consecutive elements which are disjoint, that
* is, an item can only belong to one group. This is leveraged for grouping calls in the call log
@@ -32,8 +35,8 @@ import android.util.SparseIntArray;
*/
abstract class GroupingListAdapter extends RecyclerView.Adapter {
- protected ContentObserver changeObserver =
- new ContentObserver(new Handler()) {
+ protected final ContentObserver changeObserver =
+ new ContentObserver(new Handler(Looper.getMainLooper())) {
@Override
public boolean deliverSelfNotifications() {
return true;
@@ -44,7 +47,7 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter {
onContentChanged();
}
};
- protected DataSetObserver dataSetObserver =
+ protected final DataSetObserver dataSetObserver =
new DataSetObserver() {
@Override
public void onChanged() {
diff --git a/java/com/android/dialer/app/calllog/IntentProvider.java b/java/com/android/dialer/app/calllog/IntentProvider.java
index f80e0d8692efc53b8e5d2ae1050ad182e9143acc..10d6a891ec0dcebe72c2f31e95a6ac623e43a06b 100644
--- a/java/com/android/dialer/app/calllog/IntentProvider.java
+++ b/java/com/android/dialer/app/calllog/IntentProvider.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ import android.net.Uri;
import android.provider.ContactsContract;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
+
import com.android.contacts.common.model.Contact;
import com.android.contacts.common.model.ContactLoader;
import com.android.dialer.app.AccountSelectionActivity;
@@ -33,6 +35,7 @@ import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.dialercontact.DialerContact;
import com.android.dialer.precall.PreCall;
import com.android.dialer.util.IntentUtil;
+
import java.util.ArrayList;
/**
diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
index dba69808b9110de22fbc7f2cc7b5d4638b173d33..301265d99a28c59e464250910d5ab1fa3cfde7a9 100644
--- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
@@ -16,6 +16,7 @@
package com.android.dialer.app.calllog;
+import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
@@ -96,6 +97,7 @@ public final class LegacyVoicemailNotifier {
context
.getResources()
.getQuantityString(R.plurals.notification_voicemail_title, count, count);
+ @SuppressLint("MissingPermission")
PersistableBundle config = pinnedTelephonyManager.getCarrierConfig();
boolean isOngoing;
if (config == null) {
@@ -174,7 +176,7 @@ public final class LegacyVoicemailNotifier {
@NonNull
private static String getNotificationTag(
@NonNull Context context, @NonNull PhoneAccountHandle phoneAccountHandle) {
- if (context.getSystemService(TelephonyManager.class).getPhoneCount() <= 1) {
+ if (context.getSystemService(TelephonyManager.class).getActiveModemCount() <= 1) {
return NOTIFICATION_TAG;
}
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java b/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java
index 2ec1a533077524f82b8950968eb813cb5abce963..6bf9203e867cc6e18855a26596a8bcb722619d88 100644
--- a/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java
+++ b/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +20,9 @@ package com.android.dialer.app.calllog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.support.v4.util.Pair;
+
+import androidx.core.util.Pair;
+
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.DialerExecutorComponent;
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
index cc9c62ea54781996eb51c99e59970702cb2d9c30..987336d3e9c6d0a33770679df4742dc7fbd2a484 100644
--- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java
+++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +18,8 @@ package com.android.dialer.app.calllog;
import static com.android.dialer.app.DevicePolicyResources.NOTIFICATION_MISSED_WORK_CALL_TITLE;
+import android.annotation.SuppressLint;
import android.app.Notification;
-import android.app.Notification.Builder;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -29,8 +30,6 @@ import android.graphics.drawable.Icon;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.service.notification.StatusBarNotification;
-import android.support.v4.os.UserManagerCompat;
-import android.support.v4.util.Pair;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -43,10 +42,12 @@ import android.util.ArraySet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
+import androidx.core.os.UserManagerCompat;
+import androidx.core.util.Pair;
import com.android.contacts.common.ContactsUtils;
+import com.android.dialer.R;
import com.android.dialer.app.MainComponent;
-import com.android.dialer.app.R;
import com.android.dialer.app.calllog.CallLogNotificationsQueryHelper.NewCall;
import com.android.dialer.app.contactinfo.ContactPhotoLoader;
import com.android.dialer.callintent.CallInitiationType;
@@ -64,6 +65,7 @@ import com.android.dialer.precall.PreCall;
import com.android.dialer.theme.base.ThemeComponent;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.IntentUtil;
+
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -364,7 +366,7 @@ public class MissedCallNotifier implements Worker, Void> {
}
private Notification.Builder createNotificationBuilder() {
- return new Notification.Builder(context)
+ return new Notification.Builder(context, NotificationChannelId.MISSED_CALL)
.setGroup(MissedCallConstants.GROUP_KEY)
.setSmallIcon(android.R.drawable.stat_notify_missed_call)
.setColor(context.getResources().getColor(R.color.dialer_primary_color))
@@ -375,7 +377,7 @@ public class MissedCallNotifier implements Worker, Void> {
}
private Notification.Builder createNotificationBuilder(@NonNull NewCall call) {
- Builder builder =
+ Notification.Builder builder =
createNotificationBuilder()
.setWhen(call.dateMs)
.setDeleteIntent(
@@ -430,7 +432,8 @@ public class MissedCallNotifier implements Worker, Void> {
// TODO (a bug): scroll to call
contentIntent.setData(callUri);
- return PendingIntent.getActivity(context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ return PendingIntent.getActivity(context, 0, contentIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
private PendingIntent createCallBackPendingIntent(String number, @NonNull Uri callUri) {
@@ -440,7 +443,8 @@ public class MissedCallNotifier implements Worker, Void> {
intent.setData(callUri);
// Use FLAG_UPDATE_CURRENT to make sure any previous pending intent is updated with the new
// extra.
- return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ return PendingIntent.getService(context, 0, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
private PendingIntent createSendSmsFromNotificationPendingIntent(
@@ -451,7 +455,8 @@ public class MissedCallNotifier implements Worker, Void> {
intent.setData(callUri);
// Use FLAG_UPDATE_CURRENT to make sure any previous pending intent is updated with the new
// extra.
- return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ return PendingIntent.getActivity(context, 0, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
/** Configures a notification to emit the blinky notification light. */
@@ -461,6 +466,7 @@ public class MissedCallNotifier implements Worker, Void> {
}
/** Closes open system dialogs and the notification shade. */
+ @SuppressLint("MissingPermission")
private void closeSystemDialogs(Context context) {
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
index 0ecdf061f51903992ccdaf0b34711b91486f9303..4bd74fdfa6cd15aeeb2d6f0aa0aab171378a91e4 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +22,8 @@ import android.content.res.Resources;
import android.graphics.Typeface;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.support.v4.content.ContextCompat;
import android.telecom.PhoneAccount;
-import android.telephony.PhoneNumberUtils;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.View;
@@ -39,6 +39,7 @@ import com.android.dialer.phonenumbercache.PhoneNumberCache;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.theme.base.ThemeComponent;
import com.android.dialer.util.DialerUtils;
+
import java.util.ArrayList;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
@@ -57,7 +58,7 @@ public class PhoneCallDetailsHelper {
private final CachedNumberLookupService cachedNumberLookupService;
/** List of items to be concatenated together for accessibility descriptions */
- private ArrayList descriptionItems = new ArrayList<>();
+ private final ArrayList descriptionItems = new ArrayList<>();
/**
* Creates a new instance of the helper.
@@ -150,7 +151,8 @@ public class PhoneCallDetailsHelper {
int color = callLogCache.getAccountColor(details.accountHandle);
if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) {
int defaultColor = R.color.dialer_secondary_text_color;
- views.callAccountLabel.setTextColor(context.getResources().getColor(defaultColor));
+ views.callAccountLabel.setTextColor(context.getResources().getColor(defaultColor,
+ context.getTheme()));
} else {
views.callAccountLabel.setTextColor(color);
}
@@ -179,7 +181,8 @@ public class PhoneCallDetailsHelper {
return;
}
- if (PhoneNumberUtils.isEmergencyNumber(details.displayNumber)) {
+ TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
+ if (telephonyManager.isEmergencyNumber(details.displayNumber)) {
views.nameView.setText(R.string.emergency_number);
views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT);
return;
@@ -198,24 +201,27 @@ public class PhoneCallDetailsHelper {
* @return The call location and date string.
*/
public CharSequence getCallLocationAndDate(PhoneCallDetails details) {
- descriptionItems.clear();
-
- if (details.callTypes[0] != Calls.VOICEMAIL_TYPE) {
- // Get type of call (ie mobile, home, etc) if known, or the caller's location.
- CharSequence callTypeOrLocation = getCallTypeOrLocation(details);
-
- // Only add the call type or location if its not empty. It will be empty for unknown
- // callers.
- if (!TextUtils.isEmpty(callTypeOrLocation)) {
- descriptionItems.add(callTypeOrLocation);
+ synchronized (this) {
+ descriptionItems.clear();
+
+ if (details.callTypes[0] != Calls.VOICEMAIL_TYPE) {
+ // Get type of call (ie mobile, home, etc) if known, or the caller's location.
+ CharSequence callTypeOrLocation = getCallTypeOrLocation(details);
+
+ // Only add the call type or location if its not empty. It will be empty for unknown
+ // callers.
+ if (!TextUtils.isEmpty(callTypeOrLocation)) {
+ descriptionItems.add(callTypeOrLocation);
+ }
}
- }
- // The date of this call
- descriptionItems.add(getCallDate(details));
+ // The date of this call
+ descriptionItems.add(getCallDate(details));
+
+ // Create a comma separated list from the call type or location, and call date.
- // Create a comma separated list from the call type or location, and call date.
- return DialerUtils.join(descriptionItems);
+ return DialerUtils.join(descriptionItems);
+ }
}
/**
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java
index 8ba34938d57dc92ac8f3a76754b4af859604b4e2..88d05fb6265d188005f50edc98688efdd3235e55 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +19,7 @@ package com.android.dialer.app.calllog;
import android.view.View;
import android.widget.TextView;
+
import com.android.dialer.app.R;
import com.android.dialer.calllogutils.CallTypeIconsView;
import com.android.dialer.widget.BidiTextView;
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java
index 1a21b79b49f59ea3b64ada5b8c0fd00009c463be..e5927fe16f3daf7cb60d6be42d891a193c706a54 100644
--- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java
+++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023-2024 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +28,11 @@ import android.provider.VoicemailContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import com.android.dialer.app.R;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.android.dialer.R;
import com.android.dialer.app.voicemail.VoicemailAudioManager;
import com.android.dialer.app.voicemail.VoicemailErrorManager;
import com.android.dialer.app.voicemail.VoicemailPlaybackPresenter;
@@ -40,6 +45,7 @@ import com.android.dialer.voicemail.listui.error.VoicemailErrorMessageCreator;
import com.android.dialer.voicemail.listui.error.VoicemailStatus;
import com.android.dialer.voicemail.listui.error.VoicemailStatusWorker;
import com.android.dialer.widget.EmptyContentView;
+
import java.util.List;
public class VisualVoicemailCallLogFragment extends CallLogFragment {
@@ -60,9 +66,9 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment {
}
@Override
- public void onActivityCreated(Bundle savedInstanceState) {
- voicemailPlaybackPresenter =
- VoicemailPlaybackPresenter.getInstance(getActivity(), savedInstanceState);
+ public void onCreate(Bundle savedInstanceState) {
+ voicemailPlaybackPresenter = VoicemailPlaybackPresenter.getInstance(
+ (AppCompatActivity) getActivity(), savedInstanceState);
if (PermissionsUtil.hasReadVoicemailPermissions(getContext())
&& PermissionsUtil.hasAddVoicemailPermissions(getContext())) {
getActivity()
@@ -71,16 +77,21 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment {
VoicemailContract.Status.CONTENT_URI, true, voicemailStatusObserver);
} else {
LogUtil.w(
- "VisualVoicemailCallLogFragment.onActivityCreated",
+ "VisualVoicemailCallLogFragment.onCreate",
"read voicemail permission unavailable.");
}
- super.onActivityCreated(savedInstanceState);
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
preSyncVoicemailStatusCheckExecutor =
DialerExecutorComponent.get(getContext())
.dialerExecutorFactory()
.createUiTaskBuilder(
- getActivity().getFragmentManager(),
+ getActivity().getSupportFragmentManager(),
"fetchVoicemailStatus",
new VoicemailStatusWorker())
.onSuccess(this::onPreSyncVoicemailStatusChecked)
@@ -99,7 +110,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment {
voicemailErrorManager.getContentObserver());
} else {
LogUtil.w(
- "VisualVoicemailCallLogFragment.onActivityCreated",
+ "VisualVoicemailCallLogFragment.onViewCreated",
"read voicemail permission unavailable.");
}
}
@@ -147,7 +158,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment {
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
if (voicemailPlaybackPresenter != null) {
voicemailPlaybackPresenter.onSaveInstanceState(outState);
@@ -204,7 +215,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment {
if (getActivity() != null) {
getActivity().setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
// onNotVisible will be called in the lock screen when the call ends
- if (!getActivity().getSystemService(KeyguardManager.class).inKeyguardRestrictedInputMode()) {
+ if (!getActivity().getSystemService(KeyguardManager.class).isKeyguardLocked()) {
LogUtil.i("VisualVoicemailCallLogFragment.onNotVisible", "clearing all new voicemails");
CallLogNotificationsService.markAllNewVoicemailsAsOld(getActivity());
}
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
index dd3ce34c742388baa2cae123530b3b97edcf85e7..5ddbf4f75be7c8174bb5e12fc81afe18b973e572 100644
--- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,13 +24,13 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
-import android.support.v4.app.NotificationCompat;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.app.NotificationCompat;
import com.android.contacts.common.util.ContactDisplayUtils;
import com.android.dialer.app.MainComponent;
@@ -43,6 +44,7 @@ import com.android.dialer.notification.NotificationManagerUtils;
import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.theme.base.ThemeComponent;
+
import java.util.List;
import java.util.Map;
@@ -89,11 +91,11 @@ final class VisualVoicemailNotifier {
if (shouldAlert) {
groupSummary.setOnlyAlertOnce(false);
// Group summary will alert when posted/updated
- groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_ALL);
+ groupSummary.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL);
} else {
// Only children will alert. but since all children are set to "only alert summary" it is
// effectively silenced.
- groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN);
+ groupSummary.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
}
PhoneAccountHandle handle = getAccountForCall(context, newCalls.get(0));
groupSummary.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
@@ -169,7 +171,7 @@ final class VisualVoicemailNotifier {
}
builder.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
- builder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);
+ builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
ContactPhotoLoader loader = new ContactPhotoLoader(context, contactInfo);
Bitmap photoIcon = loader.loadPhotoIcon();
@@ -223,7 +225,8 @@ final class VisualVoicemailNotifier {
if (voicemail != null) {
intent.setData(voicemail.voicemailUri);
}
- return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ return PendingIntent.getActivity(context, 0, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
/**
diff --git a/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java b/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java
index 754ab2727aa0a72329079da59950e79cbf687c05..4801f962125c55b6669a9e235c3cd754ae995354 100644
--- a/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java
+++ b/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ import android.app.job.JobService;
import android.content.ComponentName;
import android.content.Context;
import android.provider.VoicemailContract;
+
import com.android.dialer.common.LogUtil;
import com.android.dialer.constants.ScheduledJobIds;
@@ -52,11 +54,7 @@ public class VoicemailNotificationJobService extends JobService {
@Override
public boolean onStartJob(JobParameters params) {
LogUtil.i("VoicemailNotificationJobService.onStartJob", "updating notification");
- VisualVoicemailUpdateTask.scheduleTask(
- this,
- () -> {
- jobFinished(params, false);
- });
+ VisualVoicemailUpdateTask.scheduleTask(this, () -> jobFinished(params, false));
return true; // Running in background
}
diff --git a/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java b/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java
index cad838a553e0a6933ec8d95c57145878ad17057d..c2729bc423d1b6820eef67e4f35919db2e5714a6 100644
--- a/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java
+++ b/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,10 +47,8 @@ public class VoicemailQueryHandler extends AsyncQueryHandler {
@WorkerThread
public static void markAllNewVoicemailsAsOld(final @NonNull Context context) {
ThreadUtil.postOnUiThread(
- () -> {
- new VoicemailQueryHandler(context.getContentResolver())
- .markNewVoicemailsAsOld(context, null);
- });
+ () -> new VoicemailQueryHandler(context.getContentResolver())
+ .markNewVoicemailsAsOld(context, null));
}
@WorkerThread
@@ -60,10 +59,8 @@ public class VoicemailQueryHandler extends AsyncQueryHandler {
return;
}
ThreadUtil.postOnUiThread(
- () -> {
- new VoicemailQueryHandler(context.getContentResolver())
- .markNewVoicemailsAsOld(context, voicemailUri);
- });
+ () -> new VoicemailQueryHandler(context.getContentResolver())
+ .markNewVoicemailsAsOld(context, voicemailUri));
}
/** Updates all new voicemails to mark them as old. */
diff --git a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java
index ca759af06f20c2a9dc11233233b48dd4202c6c09..8e2b4c6d79fd6c22cf3d3e39847ef29b26bd1fc1 100644
--- a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java
+++ b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +28,9 @@ import com.android.dialer.app.calllog.CallLogAdapter;
import com.android.dialer.calllogutils.PhoneAccountUtils;
import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.CallUtil;
+
import java.util.Map;
+
import javax.annotation.concurrent.ThreadSafe;
/**
@@ -104,7 +107,7 @@ public class CallLogCache {
if (phoneAccountColorCache.containsKey(accountHandle)) {
return phoneAccountColorCache.get(accountHandle);
} else {
- Integer color = PhoneAccountUtils.getAccountColor(context, accountHandle);
+ int color = PhoneAccountUtils.getAccountColor(context, accountHandle);
phoneAccountColorCache.put(accountHandle, color);
return color;
}
@@ -121,7 +124,7 @@ public class CallLogCache {
if (phoneAccountCallWithNoteCache.containsKey(accountHandle)) {
return phoneAccountCallWithNoteCache.get(accountHandle);
} else {
- Boolean supportsCallWithNote =
+ boolean supportsCallWithNote =
PhoneAccountUtils.getAccountSupportsCallSubject(context, accountHandle);
phoneAccountCallWithNoteCache.put(accountHandle, supportsCallWithNote);
return supportsCallWithNote;
diff --git a/java/com/android/dialer/app/contactinfo/ContactInfoCache.java b/java/com/android/dialer/app/contactinfo/ContactInfoCache.java
index 702bacb5097cca1d02fd22ee1ae648b6e1c2a62d..f53bd5e801b4a1b7c131af7967b5574e086a24e4 100644
--- a/java/com/android/dialer/app/contactinfo/ContactInfoCache.java
+++ b/java/com/android/dialer/app/contactinfo/ContactInfoCache.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +18,7 @@
package com.android.dialer.app.contactinfo;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
@@ -29,6 +31,7 @@ import com.android.dialer.oem.CequintCallerIdManager;
import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.phonenumbercache.ContactInfoHelper;
import com.android.dialer.util.ExpirableCache;
+
import java.lang.ref.WeakReference;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;
@@ -66,6 +69,7 @@ public class ContactInfoCache {
private final WeakReference contactInfoCacheWeakReference;
public InnerHandler(WeakReference contactInfoCacheWeakReference) {
+ super(Looper.getMainLooper());
this.contactInfoCacheWeakReference = contactInfoCacheWeakReference;
}
diff --git a/java/com/android/dialer/app/contactinfo/ContactInfoRequest.java b/java/com/android/dialer/app/contactinfo/ContactInfoRequest.java
index 256c9c06c4345965277c5ca90a6793c34ef627f0..f575e87065bd39bbcbf097cc2e9fca6325cd307f 100644
--- a/java/com/android/dialer/app/contactinfo/ContactInfoRequest.java
+++ b/java/com/android/dialer/app/contactinfo/ContactInfoRequest.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@ import android.text.TextUtils;
import androidx.annotation.IntDef;
import com.android.dialer.phonenumbercache.ContactInfo;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
diff --git a/java/com/android/dialer/app/contactinfo/ContactPhotoLoader.java b/java/com/android/dialer/app/contactinfo/ContactPhotoLoader.java
index 68e42b261b50e42ad54c511e20a403714c16e3e6..82cdb7308e079fd803addd9e4479a70285bf8ea4 100644
--- a/java/com/android/dialer/app/contactinfo/ContactPhotoLoader.java
+++ b/java/com/android/dialer/app/contactinfo/ContactPhotoLoader.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +22,10 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
-import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import androidx.annotation.Nullable;
+import androidx.core.graphics.drawable.RoundedBitmapDrawable;
+import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import com.android.dialer.app.R;
import com.android.dialer.common.Assert;
@@ -33,6 +34,7 @@ import com.android.dialer.lettertile.LetterTileDrawable;
import com.android.dialer.location.GeoUtil;
import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.phonenumbercache.ContactInfoHelper;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
diff --git a/java/com/android/dialer/app/contactinfo/ExpirableCacheHeadlessFragment.java b/java/com/android/dialer/app/contactinfo/ExpirableCacheHeadlessFragment.java
index 72b68ffd6d0078f1df0be3077fdd0a3da5d43cc6..dc059d8b1d760d79c349bcecc7934cd0d89262bf 100644
--- a/java/com/android/dialer/app/contactinfo/ExpirableCacheHeadlessFragment.java
+++ b/java/com/android/dialer/app/contactinfo/ExpirableCacheHeadlessFragment.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,11 +18,10 @@
package com.android.dialer.app.contactinfo;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v7.app.AppCompatActivity;
import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.util.ExpirableCache;
@@ -36,16 +36,11 @@ public class ExpirableCacheHeadlessFragment extends Fragment {
private static final String FRAGMENT_TAG = "ExpirableCacheHeadlessFragment";
private static final int CONTACT_INFO_CACHE_SIZE = 100;
- private ExpirableCache retainedCache =
+ private final ExpirableCache retainedCache =
ExpirableCache.create(CONTACT_INFO_CACHE_SIZE);
@NonNull
- public static ExpirableCacheHeadlessFragment attach(@NonNull AppCompatActivity parentActivity) {
- return attach(parentActivity.getSupportFragmentManager());
- }
-
- @NonNull
- private static ExpirableCacheHeadlessFragment attach(FragmentManager fragmentManager) {
+ public static ExpirableCacheHeadlessFragment attach(FragmentManager fragmentManager) {
ExpirableCacheHeadlessFragment fragment =
(ExpirableCacheHeadlessFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (fragment == null) {
diff --git a/java/com/android/dialer/app/list/RemoveView.java b/java/com/android/dialer/app/list/RemoveView.java
index bb547351108d991194e95b1e032b12c1f02f0038..1420ead285668f6b19d346d1d6f3447d8ff3f657 100644
--- a/java/com/android/dialer/app/list/RemoveView.java
+++ b/java/com/android/dialer/app/list/RemoveView.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +26,10 @@ import android.view.accessibility.AccessibilityEvent;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
-import com.android.dialer.app.R;
+
+import androidx.core.content.res.ResourcesCompat;
+
+import com.android.dialer.R;
public class RemoveView extends FrameLayout {
@@ -49,12 +53,13 @@ public class RemoveView extends FrameLayout {
@Override
protected void onFinishInflate() {
- removeText = (TextView) findViewById(R.id.remove_view_text);
- removeIcon = (ImageView) findViewById(R.id.remove_view_icon);
+ super.onFinishInflate();
+ removeText = findViewById(R.id.remove_view_text);
+ removeIcon = findViewById(R.id.remove_view_icon);
final Resources r = getResources();
- unhighlightedColor = r.getColor(android.R.color.white);
- highlightedColor = r.getColor(R.color.remove_highlighted_text_color);
- removeDrawable = r.getDrawable(R.drawable.quantum_ic_clear_vd_theme_24,
+ unhighlightedColor = r.getColor(android.R.color.white, getContext().getTheme());
+ highlightedColor = r.getColor(R.color.remove_highlighted_text_color, getContext().getTheme());
+ removeDrawable = ResourcesCompat.getDrawable(r, R.drawable.quantum_ic_clear_vd_theme_24,
getContext().getTheme());
}
diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml b/java/com/android/dialer/app/res/color/switch_thumb_color.xml
similarity index 54%
rename from java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml
rename to java/com/android/dialer/app/res/color/switch_thumb_color.xml
index 583ad20d579d19942bb3600d95b714d71a4153bb..6391563b004980df0421eaa5b00c26cb1680e4ef 100644
--- a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml
+++ b/java/com/android/dialer/app/res/color/switch_thumb_color.xml
@@ -1,5 +1,6 @@
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
diff --git a/java/com/android/dialer/app/res/color/switch_track_color.xml b/java/com/android/dialer/app/res/color/switch_track_color.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9a645d908f0d1e6a841966715083c5a27de39bf2
--- /dev/null
+++ b/java/com/android/dialer/app/res/color/switch_track_color.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/com/android/dialer/app/res/drawable/popup_background.xml b/java/com/android/dialer/app/res/drawable/popup_background.xml
new file mode 100644
index 0000000000000000000000000000000000000000..fe5e4656aa5c85a221fe49260e6d7333981b0fe9
--- /dev/null
+++ b/java/com/android/dialer/app/res/drawable/popup_background.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
diff --git a/java/com/android/voicemail/impl/configui/AndroidManifest.xml b/java/com/android/dialer/app/res/drawable/switch_thumb.xml
similarity index 57%
rename from java/com/android/voicemail/impl/configui/AndroidManifest.xml
rename to java/com/android/dialer/app/res/drawable/switch_thumb.xml
index 95796f978e44a6be5f4c89081ff22d3ca1b6eab0..4ff649cd91d3cd793664a405c98d3f9f1eb70461 100644
--- a/java/com/android/voicemail/impl/configui/AndroidManifest.xml
+++ b/java/com/android/dialer/app/res/drawable/switch_thumb.xml
@@ -1,5 +1,6 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/java/com/android/dialer/contacts/resources/res/drawable/dialog_background_material.xml b/java/com/android/dialer/app/res/drawable/switch_track.xml
similarity index 66%
rename from java/com/android/dialer/contacts/resources/res/drawable/dialog_background_material.xml
rename to java/com/android/dialer/app/res/drawable/switch_track.xml
index c93d43ea6a68e13af2ef7bdc2d5c4cb67f3e76ca..f54a350a6bc6efd64c8c2827360ab8d6aeffcc80 100644
--- a/java/com/android/dialer/contacts/resources/res/drawable/dialog_background_material.xml
+++ b/java/com/android/dialer/app/res/drawable/switch_track.xml
@@ -1,5 +1,6 @@
-
+
-
-
-
-
-
-
+
+
+
diff --git a/java/com/android/dialer/app/res/layout/activity_settings.xml b/java/com/android/dialer/app/res/layout/activity_settings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e53ce2122847e9cdfe032a6dce7210c7004f25ac
--- /dev/null
+++ b/java/com/android/dialer/app/res/layout/activity_settings.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/java/com/android/dialer/app/res/layout/call_log_activity.xml b/java/com/android/dialer/app/res/layout/call_log_activity.xml
index f42fe56e72883dc4c79f03bf3d33b914ca0f51f7..cbbec105c39eb8a5104d31e37f551a6445fba925 100644
--- a/java/com/android/dialer/app/res/layout/call_log_activity.xml
+++ b/java/com/android/dialer/app/res/layout/call_log_activity.xml
@@ -1,5 +1,6 @@
-
@@ -148,8 +150,8 @@
android:layout_gravity="center_vertical"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:scaleType="center"
- android:tint="?colorIcon"
- android:visibility="gone"/>
+ android:visibility="gone"
+ app:tint="?colorIcon" />
@@ -164,6 +166,6 @@
-
+
diff --git a/java/com/android/dialer/app/res/layout/voicemail_playback_layout.xml b/java/com/android/dialer/app/res/layout/voicemail_playback_layout.xml
index 4f10d111c8704840b6fbd45c2d075eff8372286d..92c0544a5e1f36823348ea5992879cc4c13a22c1 100644
--- a/java/com/android/dialer/app/res/layout/voicemail_playback_layout.xml
+++ b/java/com/android/dialer/app/res/layout/voicemail_playback_layout.xml
@@ -1,5 +1,6 @@
-
\ No newline at end of file
+
+
diff --git a/java/com/android/dialer/app/res/menu/call_log_options.xml b/java/com/android/dialer/app/res/menu/call_log_options.xml
index e78b72e3c975cab0bac738e712450ed648819976..abe869b2bb9a4fad13f223f8a2252d06fe77c18e 100644
--- a/java/com/android/dialer/app/res/menu/call_log_options.xml
+++ b/java/com/android/dialer/app/res/menu/call_log_options.xml
@@ -1,5 +1,7 @@
-
-