diff options
Diffstat (limited to 'java/com/android/dialer/calllogutils')
7 files changed, 250 insertions, 4 deletions
diff --git a/java/com/android/dialer/calllogutils/CallTypeIconsView.java b/java/com/android/dialer/calllogutils/CallTypeIconsView.java index 19c30c575..79d1e6e58 100644 --- a/java/com/android/dialer/calllogutils/CallTypeIconsView.java +++ b/java/com/android/dialer/calllogutils/CallTypeIconsView.java @@ -290,13 +290,15 @@ public class CallTypeIconsView extends View { int iconId = R.drawable.quantum_ic_call_received_white_24; Drawable drawable = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId); incoming = drawable.mutate(); - incoming.setColorFilter(r.getColor(R.color.dialer_call_green), PorterDuff.Mode.MULTIPLY); + incoming.setColorFilter(r.getColor(R.color.answered_incoming_call), + PorterDuff.Mode.MULTIPLY); // Create a rotated instance of the call arrow for outgoing calls. iconId = R.drawable.quantum_ic_call_made_white_24; drawable = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId); outgoing = drawable.mutate(); - outgoing.setColorFilter(r.getColor(R.color.dialer_call_green), PorterDuff.Mode.MULTIPLY); + outgoing.setColorFilter(r.getColor(R.color.answered_outgoing_call), + PorterDuff.Mode.MULTIPLY); // Need to make a copy of the arrow drawable, otherwise the same instance colored // above will be recolored here. diff --git a/java/com/android/dialer/calllogutils/FilterSpinnerHelper.java b/java/com/android/dialer/calllogutils/FilterSpinnerHelper.java new file mode 100644 index 000000000..a6ae5528b --- /dev/null +++ b/java/com/android/dialer/calllogutils/FilterSpinnerHelper.java @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2014 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package com.android.dialer.calllogutils; + +import android.content.Context; +import android.provider.CallLog; +import android.telecom.PhoneAccountHandle; +import android.telecom.TelecomManager; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Spinner; + +import com.android.dialer.R; +import com.android.dialer.util.PermissionsUtil; +import java.util.ArrayList; +import java.util.List; + +public class FilterSpinnerHelper implements AdapterView.OnItemSelectedListener { + private static String TAG = FilterSpinnerHelper.class.getSimpleName(); + + public interface OnFilterChangedListener { + void onFilterChanged(PhoneAccountHandle account, int callType); + } + + private OnFilterChangedListener mListener; + private Spinner mAccountSpinner; + private ArrayAdapter<AccountItem> mAccountAdapter; + private Spinner mTypeSpinner; + private ArrayAdapter<TypeItem> mTypeAdapter; + + public FilterSpinnerHelper(View rootView, boolean includeVoicemailType, + OnFilterChangedListener listener) { + mListener = listener; + + mAccountAdapter = createAccountAdapter(rootView.getContext()); + mAccountSpinner = initSpinner(rootView, R.id.filter_account_spinner, mAccountAdapter); + + mTypeAdapter = createTypeAdapter(rootView.getContext(), includeVoicemailType); + mTypeSpinner = initSpinner(rootView, R.id.filter_status_spinner, mTypeAdapter); + } + + @Override + public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { + int selectedAccountPos = Math.max(mAccountSpinner.getSelectedItemPosition(), 0); + int selectedTypePos = Math.max(mTypeSpinner.getSelectedItemPosition(), 0); + PhoneAccountHandle selectedAccount = mAccountAdapter.getItem(selectedAccountPos).account; + int selectedType = mTypeAdapter.getItem(selectedTypePos).value; + mListener.onFilterChanged(selectedAccount, selectedType); + } + + @Override + public void onNothingSelected(AdapterView<?> parent) { + } + + private Spinner initSpinner(View rootView, int spinnerResId, ArrayAdapter<?> adapter) { + Spinner spinner = rootView.findViewById(spinnerResId); + if (spinner == null) { + throw new IllegalArgumentException("Could not find spinner " + + rootView.getContext().getResources().getResourceName(spinnerResId)); + } + spinner.setAdapter(adapter); + spinner.setOnItemSelectedListener(this); + if (adapter.getCount() <= 1) { + spinner.setVisibility(View.GONE); + } + return spinner; + } + + private ArrayAdapter<AccountItem> createAccountAdapter(Context context) { + ArrayList<AccountItem> items = new ArrayList<>(); + items.add(new AccountItem(null, context.getString(R.string.call_log_show_all_accounts))); + if (PermissionsUtil.hasPermission(context, android.Manifest.permission.READ_PHONE_STATE)) { + TelecomManager tm = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); + for (PhoneAccountHandle account : tm.getCallCapablePhoneAccounts()) { + String displayName = PhoneAccountUtils.getAccountLabel(context, account); + if (!TextUtils.isEmpty(displayName)) { + items.add(new AccountItem(account, displayName)); + } + } + } + + return new ArrayAdapter<AccountItem>(context, R.layout.call_log_filter_spinner_item, items); + } + + private ArrayAdapter<TypeItem> createTypeAdapter(Context context, boolean includeVoicemail) { + ArrayList<TypeItem> items = new ArrayList<>(); + items.add(new TypeItem(-1, context.getString(R.string.call_log_all_calls_header))); + items.add(new TypeItem(CallLog.Calls.INCOMING_TYPE, + context.getString(R.string.call_log_incoming_header))); + items.add(new TypeItem(CallLog.Calls.OUTGOING_TYPE, + context.getString(R.string.call_log_outgoing_header))); + items.add(new TypeItem(CallLog.Calls.MISSED_TYPE, + context.getString(R.string.call_log_missed_header))); + items.add(new TypeItem(CallLog.Calls.BLOCKED_TYPE, + context.getString(R.string.call_log_blacklist_header))); + if (includeVoicemail) { + items.add(new TypeItem(CallLog.Calls.VOICEMAIL_TYPE, + context.getString(R.string.call_log_voicemail_header))); + } + + return new ArrayAdapter<TypeItem>(context, R.layout.call_log_filter_spinner_item, items); + } + + private final class AccountItem { + public final PhoneAccountHandle account; + public final String label; + + private AccountItem(PhoneAccountHandle account, String label) { + this.account = account; + this.label = label; + } + + @Override + public String toString() { + return label; + } + } + + private final class TypeItem { + public final int value; + public final String label; + + private TypeItem(int value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String toString() { + return label; + } + } +} diff --git a/java/com/android/dialer/calllogutils/PhoneNumberDisplayUtil.java b/java/com/android/dialer/calllogutils/PhoneNumberDisplayUtil.java index 6fe3a82c8..6509af3e1 100644 --- a/java/com/android/dialer/calllogutils/PhoneNumberDisplayUtil.java +++ b/java/com/android/dialer/calllogutils/PhoneNumberDisplayUtil.java @@ -64,7 +64,7 @@ public class PhoneNumberDisplayUtil { * @param number the number to display * @param formattedNumber the formatted number if available, may be null */ - static CharSequence getDisplayNumber( + public static CharSequence getDisplayNumber( Context context, CharSequence number, int presentation, diff --git a/java/com/android/dialer/calllogutils/res/layout/call_log_filter_spinner_item.xml b/java/com/android/dialer/calllogutils/res/layout/call_log_filter_spinner_item.xml new file mode 100644 index 000000000..d7fdb4654 --- /dev/null +++ b/java/com/android/dialer/calllogutils/res/layout/call_log_filter_spinner_item.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of The Linux Foundation, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + style="@style/Dialer.TextAppearance.Primary" + android:layout_width="match_parent" + android:layout_height="40dip" + android:paddingLeft="8dip" + android:paddingRight="8dip" + android:textSize="14sp" + android:textStyle="bold" + android:gravity="center_vertical" + android:singleLine="true" + android:textAllCaps="true" /> diff --git a/java/com/android/dialer/calllogutils/res/layout/call_log_filter_spinners.xml b/java/com/android/dialer/calllogutils/res/layout/call_log_filter_spinners.xml new file mode 100644 index 000000000..ecaf1d10c --- /dev/null +++ b/java/com/android/dialer/calllogutils/res/layout/call_log_filter_spinners.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingStart="@dimen/call_log_outer_margin" + android:paddingEnd="@dimen/call_log_outer_margin"> + <Spinner + android:id="@+id/filter_account_spinner" + android:layout_width="0dip" + android:layout_height="@dimen/list_section_divider_min_height" + android:layout_weight="1.2" + android:layout_marginTop="6dip" + android:layout_marginBottom="6dip" /> + <Spinner + android:id="@+id/filter_status_spinner" + android:layout_width="0dip" + android:layout_height="@dimen/list_section_divider_min_height" + android:layout_weight="1.8" + android:layout_marginTop="6dip" + android:layout_marginBottom="6dip" /> +</LinearLayout> diff --git a/java/com/android/dialer/calllogutils/res/values/cm_strings.xml b/java/com/android/dialer/calllogutils/res/values/cm_strings.xml new file mode 100644 index 000000000..d30aa1774 --- /dev/null +++ b/java/com/android/dialer/calllogutils/res/values/cm_strings.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013-2014 The CyanogenMod Project + Copyright (C) 2018 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="call_log_show_all_accounts">All accounts</string> + <string name="call_log_all_calls_header">All calls</string> + <string name="call_log_incoming_header">Incoming calls only</string> + <string name="call_log_outgoing_header">Outgoing calls only</string> + <string name="call_log_missed_header">Missed calls only</string> + <string name="call_log_voicemail_header">Calls with voicemail only</string> + <string name="call_log_blacklist_header">Blocked calls only</string> +</resources> diff --git a/java/com/android/dialer/calllogutils/res/values/colors.xml b/java/com/android/dialer/calllogutils/res/values/colors.xml index 3a9e3ae8a..40a522b56 100644 --- a/java/com/android/dialer/calllogutils/res/values/colors.xml +++ b/java/com/android/dialer/calllogutils/res/values/colors.xml @@ -15,4 +15,12 @@ ~ limitations under the License --> <resources> -</resources>
\ No newline at end of file + <!-- Color for missed call icons. --> + <color name="missed_call">#C53929</color> + <!-- Color for answered call icons. --> + <color name="answered_incoming_call">#00a8ff</color> + <!-- Color for outgoing call icons. --> + <color name="answered_outgoing_call">#00c853</color> + <!-- Color for blocked call icons. --> + <color name="blocked_call">@color/dialer_secondary_text_color</color> +</resources> |