summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/widget
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-03-15 14:41:07 -0700
committerEric Erfanian <erfanian@google.com>2017-03-15 16:24:23 -0700
commitd5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 (patch)
treeb54abbb51fb7d66e7755a1fbb5db023ff601090b /java/com/android/dialer/widget
parent30436e7e6d3f2c8755a91b2b6222b74d465a9e87 (diff)
Update Dialer source from latest green build.
* Refactor voicemail component * Add new enriched calling components Test: treehugger, manual aosp testing Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942
Diffstat (limited to 'java/com/android/dialer/widget')
-rw-r--r--java/com/android/dialer/widget/MessageFragment.java172
-rw-r--r--java/com/android/dialer/widget/res/color/dialer_tint_state.xml23
-rw-r--r--java/com/android/dialer/widget/res/layout/fragment_message.xml81
-rw-r--r--java/com/android/dialer/widget/res/layout/selectable_text_view.xml25
-rw-r--r--java/com/android/dialer/widget/res/values/dimens.xml23
-rw-r--r--java/com/android/dialer/widget/res/values/strings.xml5
6 files changed, 329 insertions, 0 deletions
diff --git a/java/com/android/dialer/widget/MessageFragment.java b/java/com/android/dialer/widget/MessageFragment.java
new file mode 100644
index 000000000..ab47f2463
--- /dev/null
+++ b/java/com/android/dialer/widget/MessageFragment.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2017 The Android Open Source 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.widget;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.text.Editable;
+import android.text.InputFilter;
+import android.text.TextWatcher;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.android.dialer.common.Assert;
+import com.android.dialer.common.FragmentUtils;
+
+/** Fragment used to compose call with message fragment. */
+public class MessageFragment extends Fragment implements OnClickListener, TextWatcher {
+ private static final String CHAR_LIMIT_KEY = "char_limit";
+ private static final String SHOW_SEND_ICON_KEY = "show_send_icon";
+ private static final String MESSAGE_LIST_KEY = "message_list";
+
+ public static final int NO_CHAR_LIMIT = -1;
+
+ private EditText customMessage;
+ private ImageView sendMessage;
+ private TextView remainingChar;
+ private int charLimit;
+
+ private static MessageFragment newInstance(Builder builder) {
+ MessageFragment fragment = new MessageFragment();
+ Bundle args = new Bundle();
+ args.putInt(CHAR_LIMIT_KEY, builder.charLimit);
+ args.putBoolean(SHOW_SEND_ICON_KEY, builder.showSendIcon);
+ args.putStringArray(MESSAGE_LIST_KEY, builder.messages);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Nullable
+ public String getMessage() {
+ return customMessage == null ? null : customMessage.getText().toString();
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_message, container, false);
+
+ sendMessage = (ImageView) view.findViewById(R.id.send_message);
+ if (getArguments().getBoolean(SHOW_SEND_ICON_KEY, false)) {
+ sendMessage.setVisibility(View.VISIBLE);
+ sendMessage.setEnabled(false);
+ sendMessage.setOnClickListener(this);
+ }
+
+ customMessage = (EditText) view.findViewById(R.id.custom_message);
+ customMessage.addTextChangedListener(this);
+ charLimit = getArguments().getInt(CHAR_LIMIT_KEY, NO_CHAR_LIMIT);
+ if (charLimit != NO_CHAR_LIMIT) {
+ remainingChar = (TextView) view.findViewById(R.id.remaining_characters);
+ remainingChar.setVisibility(View.VISIBLE);
+ remainingChar = (TextView) view.findViewById(R.id.remaining_characters);
+ remainingChar.setText("" + charLimit);
+ customMessage.setFilters(new InputFilter[] {new InputFilter.LengthFilter(charLimit)});
+ }
+
+ LinearLayout messageContainer = (LinearLayout) view.findViewById(R.id.message_container);
+ for (String message : getArguments().getStringArray(MESSAGE_LIST_KEY)) {
+ TextView textView = (TextView) inflater.inflate(R.layout.selectable_text_view, null);
+ textView.setOnClickListener(this);
+ textView.setText(message);
+ messageContainer.addView(textView);
+ }
+ return view;
+ }
+
+ @Override
+ public void onClick(View view) {
+ if (view == sendMessage) {
+ getListener().onMessageFragmentSendMessage(customMessage.getText().toString());
+ } else if (view.getId() == R.id.selectable_text_view) {
+ customMessage.setText(((TextView) view).getText());
+ customMessage.setSelection(customMessage.getText().length());
+ } else {
+ Assert.fail("Unknown view clicked");
+ }
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ sendMessage.setEnabled(s.length() > 0);
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (charLimit != NO_CHAR_LIMIT) {
+ remainingChar.setText("" + (charLimit - s.length()));
+ }
+ getListener().onMessageFragmentAfterTextChange(s.toString());
+ }
+
+ private Listener getListener() {
+ return FragmentUtils.getParentUnsafe(this, Listener.class);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** Builder for {@link MessageFragment}. */
+ public static class Builder {
+ private String[] messages;
+ private boolean showSendIcon;
+ private int charLimit = NO_CHAR_LIMIT;
+
+ /**
+ * @throws NullPointerException if message is null
+ * @throws IllegalArgumentException if messages.length is outside the range [1,3].
+ */
+ public Builder setMessages(String... messages) {
+ // Since we only allow up to 3 messages, crash if more are set.
+ Assert.checkArgument(messages.length > 0 && messages.length <= 3);
+ this.messages = messages;
+ return this;
+ }
+
+ public Builder showSendIcon() {
+ showSendIcon = true;
+ return this;
+ }
+
+ public Builder setCharLimit(int charLimit) {
+ this.charLimit = charLimit;
+ return this;
+ }
+
+ public MessageFragment build() {
+ return MessageFragment.newInstance(this);
+ }
+ }
+
+ /** Interface for parent activity to implement to listen for important events. */
+ public interface Listener {
+ void onMessageFragmentSendMessage(String message);
+
+ void onMessageFragmentAfterTextChange(String message);
+ }
+}
diff --git a/java/com/android/dialer/widget/res/color/dialer_tint_state.xml b/java/com/android/dialer/widget/res/color/dialer_tint_state.xml
new file mode 100644
index 000000000..c29f334ac
--- /dev/null
+++ b/java/com/android/dialer/widget/res/color/dialer_tint_state.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2015 The Android Open Source 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.
+ */
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@color/dialer_edit_text_hint_color" android:state_enabled="false"/>
+ <item android:color="@color/dialer_theme_color"/>
+</selector> \ No newline at end of file
diff --git a/java/com/android/dialer/widget/res/layout/fragment_message.xml b/java/com/android/dialer/widget/res/layout/fragment_message.xml
new file mode 100644
index 000000000..f09c54f57
--- /dev/null
+++ b/java/com/android/dialer/widget/res/layout/fragment_message.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2016 The Android Open Source 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
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:gravity="bottom"
+ android:background="@color/background_dialer_white">
+
+ <LinearLayout
+ android:id="@+id/message_container"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/message_divider_height"
+ android:background="#12000000"/>
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <EditText
+ android:id="@+id/custom_message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/textview_item_padding"
+ android:textSize="@dimen/message_item_text_size"
+ android:hint="@string/custom_message_hint"
+ android:textColor="@color/dialer_primary_text_color"
+ android:textColorHint="@color/dialer_edit_text_hint_color"
+ android:background="@color/background_dialer_white"
+ android:textCursorDrawable="@drawable/searchedittext_custom_cursor"
+ android:layout_toStartOf="@+id/count_and_send_container"/>
+
+ <LinearLayout
+ android:id="@+id/count_and_send_container"
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:layout_marginEnd="@dimen/textview_item_padding"
+ android:gravity="center">
+
+ <ImageView
+ android:id="@+id/send_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:src="@drawable/quantum_ic_send_white_24"
+ android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:tint="@color/dialer_tint_state"/>
+
+ <TextView
+ android:id="@+id/remaining_characters"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:textSize="@dimen/message_remaining_char_text_size"
+ android:textColor="@color/dialer_edit_text_hint_color"/>
+ </LinearLayout>
+ </RelativeLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/java/com/android/dialer/widget/res/layout/selectable_text_view.xml b/java/com/android/dialer/widget/res/layout/selectable_text_view.xml
new file mode 100644
index 000000000..3d120d13d
--- /dev/null
+++ b/java/com/android/dialer/widget/res/layout/selectable_text_view.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2016 The Android Open Source 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
+ -->
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/selectable_text_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textSize="16sp"
+ android:textColor="@color/dialer_primary_text_color"
+ android:padding="16dp"
+ android:background="@drawable/item_background_material_light"/> \ No newline at end of file
diff --git a/java/com/android/dialer/widget/res/values/dimens.xml b/java/com/android/dialer/widget/res/values/dimens.xml
new file mode 100644
index 000000000..6c4ea604f
--- /dev/null
+++ b/java/com/android/dialer/widget/res/values/dimens.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2016 The Android Open Source 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>
+ <!-- Message Fragment -->
+ <dimen name="message_item_text_size">16sp</dimen>
+ <dimen name="textview_item_padding">16dp</dimen>
+ <dimen name="message_remaining_char_text_size">12sp</dimen>
+ <dimen name="message_divider_height">1dp</dimen>
+</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/widget/res/values/strings.xml b/java/com/android/dialer/widget/res/values/strings.xml
new file mode 100644
index 000000000..6904c2de1
--- /dev/null
+++ b/java/com/android/dialer/widget/res/values/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <!-- Hint in a text field to compose a custom message to send with a phone call [CHAR LIMIT=27] -->
+ <string name="custom_message_hint">Write a custom message</string>
+</resources> \ No newline at end of file