diff options
author | Ihab Awad <ihab@google.com> | 2013-11-21 12:06:41 -0800 |
---|---|---|
committer | Ihab Awad <ihab@google.com> | 2013-11-22 12:28:34 -0800 |
commit | df76f716297818cd87b927844b642e1a787e2e90 (patch) | |
tree | f2d8db408cfb1ea5e141ce788484be47168896d8 | |
parent | 4b4bd33d67023d5b4b0a25d638826eced3242051 (diff) |
Initial implementation of UI mocks for Wi-Fi calling option.
Change-Id: Id064a98c675527569e67f700b361b653c906d6eb
-rw-r--r-- | res/drawable/ic_phone_plus_wifi.png | bin | 0 -> 31655 bytes | |||
-rw-r--r-- | res/drawable/ic_wifi_call.png | bin | 0 -> 3468 bytes | |||
-rw-r--r-- | res/layout/wifi_call_enable_completion.xml | 55 | ||||
-rw-r--r-- | res/layout/wifi_call_enable_settings.xml | 135 | ||||
-rw-r--r-- | res/layout/wifi_call_enable_teaser.xml | 41 | ||||
-rw-r--r-- | res/values/colors.xml | 13 | ||||
-rw-r--r-- | res/values/strings.xml | 23 | ||||
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteFragment.java | 23 | ||||
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java | 82 | ||||
-rw-r--r-- | src/com/android/dialer/list/WifiWizardAdapter.java | 136 |
10 files changed, 497 insertions, 11 deletions
diff --git a/res/drawable/ic_phone_plus_wifi.png b/res/drawable/ic_phone_plus_wifi.png Binary files differnew file mode 100644 index 000000000..5cd75ab31 --- /dev/null +++ b/res/drawable/ic_phone_plus_wifi.png diff --git a/res/drawable/ic_wifi_call.png b/res/drawable/ic_wifi_call.png Binary files differnew file mode 100644 index 000000000..886cbd7bb --- /dev/null +++ b/res/drawable/ic_wifi_call.png diff --git a/res/layout/wifi_call_enable_completion.xml b/res/layout/wifi_call_enable_completion.xml new file mode 100644 index 000000000..dd63c3b98 --- /dev/null +++ b/res/layout/wifi_call_enable_completion.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout + android:orientation="vertical" + android:id="@+id/call_log_list_item" + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:layout_width="192dp" + android:layout_height="128dp" + android:paddingTop="32dp" + android:paddingBottom="32dp" + android:layout_gravity="center_horizontal" + android:src="@drawable/ic_phone_plus_wifi"/> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingLeft="64dp" + android:paddingRight="64dp" + android:textSize="12dp" + android:textColor="@color/dialtacts_secondary_text_color" + android:text="@string/wifi_setup_completed"/> + + <LinearLayout + android:orientation="horizontal" + android:paddingTop="32dp" + android:paddingBottom="32dp" + android:layout_gravity="center_horizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingRight="16dp" + android:textSize="12dp" + android:textAllCaps="true" + android:textColor="@color/dialtacts_primary_text_color" + android:text="@string/wifi_setup_ok"/> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingRight="16dp" + android:textSize="12dp" + android:textAllCaps="true" + android:textColor="@color/dialtacts_primary_text_color" + android:text="@string/wifi_setup_settings_shortcut"/> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/wifi_call_enable_settings.xml b/res/layout/wifi_call_enable_settings.xml new file mode 100644 index 000000000..565cb0115 --- /dev/null +++ b/res/layout/wifi_call_enable_settings.xml @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout + android:orientation="vertical" + android:id="@+id/call_log_list_item" + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dp" + android:textSize="16dp" + android:textColor="@color/foreground_wifi_highlight" + android:background="@color/background_wifi_highlight" + android:text="@string/wifi_when_connected_to_a_signal"/> + + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/wifi_dark_wifi_highlight"/> + + <LinearLayout + android:padding="10dp" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <!-- TODO(ihab): Do this layout without using layout_weight --> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textSize="16dp" + android:textColor="@color/dialtacts_primary_text_color" + android:text="@string/wifi_always_use_wifi"/> + + <RadioButton + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/wifi_always_use_wifi"/> + + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:background="@color/wifi_list_separator"/> + + <LinearLayout + android:padding="10dp" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <!-- TODO(ihab): Do this layout without using layout_weight --> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textSize="16dp" + android:textColor="@color/dialtacts_primary_text_color" + android:text="@string/wifi_ask_use_wifi"/> + + <RadioButton + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/wifi_ask_use_wifi"/> + + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:background="@color/wifi_list_separator"/> + + <LinearLayout + android:padding="10dp" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <!-- TODO(ihab): Do this layout without using layout_weight --> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textSize="16dp" + android:textColor="@color/dialtacts_primary_text_color" + android:text="@string/wifi_never_use_wifi"/> + + <RadioButton + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:checked="true" + android:id="@+id/wifi_never_use_wifi"/> + + </LinearLayout> + + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/wifi_list_separator"/> + + <LinearLayout + android:padding="10dp" + android:orientation="horizontal" + android:gravity="end" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="16dp" + android:textColor="@color/dialtacts_primary_text_color" + android:text="@string/wifi_next_setup_screen"/> + + <ImageView + android:layout_width="32dp" + android:layout_height="32dp" + android:paddingStart="8dp" + android:src="@drawable/ic_wifi_call"/> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/wifi_call_enable_teaser.xml b/res/layout/wifi_call_enable_teaser.xml new file mode 100644 index 000000000..fd70619aa --- /dev/null +++ b/res/layout/wifi_call_enable_teaser.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout + android:orientation="horizontal" + android:id="@+id/call_log_list_item" + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <ImageView + android:layout_width="64dp" + android:layout_height="64dp" + android:padding="16dp" + android:src="@drawable/ic_wifi_call" + android:background="@color/background_wifi_highlight"/> + + <LinearLayout + android:orientation="vertical" + android:layout_width="0dp" + android:layout_weight="1" + android:gravity="center_vertical" + android:padding="8dp" + android:layout_height="match_parent"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="16dp" + android:textColor="@color/dialtacts_primary_text_color" + android:text="@string/wifi_no_signal_no_problem"/> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="12dp" + android:textColor="@color/dialtacts_secondary_text_color" + android:text="@string/wifi_enable_google_wifi_calling"/> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml index a8ddf2be7..04e10b138 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -70,4 +70,17 @@ <!-- Text color for no favorites message --> <color name="nofavorite_text_color">#777777</color> + + <!-- Background color of wifi highlight items --> + <color name="background_wifi_highlight">#00ff00</color> + + <!-- Foreground color of wifi highlight items --> + <color name="foreground_wifi_highlight">#ffffff</color> + + <!-- Dark (e.g. border) regions of wifi highlight items --> + <color name="wifi_dark_wifi_highlight">#009900</color> + + <!-- Generic separator color for wifi list items --> + <color name="wifi_list_separator">#909090</color> + </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 55cdea4de..33d552725 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -635,4 +635,27 @@ <!-- Content description for dismiss button on badge. [CHAR LIMIT=NONE] --> <string name="description_dismiss">Dismiss</string> + + <string name="wifi_no_signal_no_problem">No Signal? No Problem.</string> + + <string name="wifi_enable_google_wifi_calling">Enable Google Wi-Fi Calling</string> + + <string name="wifi_when_connected_to_a_signal">When connected to a strong Wi-Fi signal:</string> + + <string name="wifi_always_use_wifi">Always use Wi-Fi to make calls</string> + + <string name="wifi_ask_use_wifi">Always ask</string> + + <string name="wifi_never_use_wifi">Never use Wi-Fi to make calls</string> + + <string name="wifi_next_setup_screen">Next</string> + + <string name="wifi_previous_setup_screen">Back</string> + + <string name="wifi_setup_completed">Boom. Wi-Fi calling is all set up. You can change your preferences or turn it off anytime in settings.</string> + + <string name="wifi_setup_ok">Ok, got it</string> + + <string name="wifi_setup_settings_shortcut">Call settings</string> + </resources> diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java index 34666ee99..19abcd72c 100644 --- a/src/com/android/dialer/list/PhoneFavoriteFragment.java +++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java @@ -183,6 +183,26 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen } } + private final WifiWizardAdapter.WifiWizardModel mWifiWizardModel = + new WifiWizardAdapter.WifiWizardModel() { + @Override + public void setWifiCallState(int state) { + // TODO(ihab): Implement based on real data + } + + @Override + public int getWifiCallState() { + // TODO(ihab): Implement based on real data + return WIFI_CALL_STATE_ALWAYS; + } + + @Override + public boolean shouldDisplayWifiSelection() { + // TODO(ihab): Implement based on real data + return true; + } + }; + private Listener mListener; private OnListFragmentScrolledListener mActivityScrollListener; @@ -305,7 +325,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen R.layout.tile_interactions_teaser_view, mListView, false); mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), this, mContactTileAdapter, - mCallLogAdapter, mShowAllContactsButton, mTileInteractionTeaserView); + mCallLogAdapter, mShowAllContactsButton, mTileInteractionTeaserView, + mWifiWizardModel); mTileInteractionTeaserView.setAdapter(mAdapter); diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java index e7190c52f..53d2ea6aa 100644 --- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java @@ -54,6 +54,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { private static final int ALL_CONTACTS_BUTTON_ITEM_ID = -1; private final PhoneFavoritesTileAdapter mContactTileAdapter; private final CallLogAdapter mCallLogAdapter; + private final WifiWizardAdapter mWifiWizardAdapter; private final View mShowAllContactsButton; private final PhoneFavoriteFragment mFragment; private final TileInteractionTeaserView mTileInteractionTeaserView; @@ -104,14 +105,17 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { PhoneFavoritesTileAdapter contactTileAdapter, CallLogAdapter callLogAdapter, View showAllContactsButton, - TileInteractionTeaserView tileInteractionTeaserView) { + TileInteractionTeaserView tileInteractionTeaserView, + WifiWizardAdapter.WifiWizardModel wifiWizardModel) { final Resources resources = context.getResources(); mContext = context; mFragment = fragment; mCallLogPadding = resources.getDimensionPixelSize(R.dimen.recent_call_log_item_padding); mContactTileAdapter = contactTileAdapter; mCallLogAdapter = callLogAdapter; + mWifiWizardAdapter = new WifiWizardAdapter(context, wifiWizardModel); mObserver = new CustomDataSetObserver(); + mWifiWizardAdapter.registerDataSetObserver(mObserver); mCallLogAdapter.registerDataSetObserver(mObserver); mContactTileAdapter.registerDataSetObserver(mObserver); mShowAllContactsButton = showAllContactsButton; @@ -123,15 +127,23 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { @Override public int getCount() { if (mContactTileAdapter.getCount() > 0) { - return mContactTileAdapter.getCount() + mCallLogAdapter.getCount() + 1 + - getTeaserViewCount(); + return mWifiWizardAdapter.getCount() + mContactTileAdapter.getCount() + + mCallLogAdapter.getCount() + 1 + getTeaserViewCount(); } else { - return mCallLogAdapter.getCount(); + return mWifiWizardAdapter.getCount() + mCallLogAdapter.getCount(); } } @Override public Object getItem(int position) { + if (mWifiWizardAdapter.getCount() > 0) { + if (position < mWifiWizardAdapter.getCount()) { + return mWifiWizardAdapter.getItem(position); + } else { + position -= mWifiWizardAdapter.getCount(); + } + } + final int callLogAdapterCount = mCallLogAdapter.getCount(); if (callLogAdapterCount > 0) { @@ -151,16 +163,26 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { * * These are the ranges of IDs reserved for each item type. * - * -(N + 1) to -3: CallLogAdapterItems, where N is equal to the number of call log items + * -(N + 4): Wi-Fi Wizard item, where N is equal to the number of call log items + * -(N + 3) to -3: CallLogAdapterItems, where N is equal to the number of call log items * -2: Teaser * -1: All contacts button - * 0 to (N -1): Rows of tiled contacts, where N is equal to the max rows of tiled contacts - * N to infinity: Rows of regular contacts. Their item id is calculated by N + contact_id, + * 0 to (M -1): Rows of tiled contacts, where M is equal to the max rows of tiled contacts + * M to infinity: Rows of regular contacts. Their item id is calculated by M + contact_id, * where contact_id is guaranteed to never be negative. */ @Override public long getItemId(int position) { final int callLogAdapterCount = mCallLogAdapter.getCount(); + + if (mWifiWizardAdapter.getCount() > 0) { + if (position < mWifiWizardAdapter.getCount()) { + return - callLogAdapterCount - 4; + } else { + position -= mWifiWizardAdapter.getCount(); + } + } + if (position < callLogAdapterCount) { // Call log items are not animated, so reusing their position for IDs is fine. return ALL_CONTACTS_BUTTON_ITEM_ID - 2 - position; @@ -184,7 +206,8 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { @Override public int getViewTypeCount() { - return (mContactTileAdapter.getViewTypeCount() + /* Favorite and frequent */ + return (mWifiWizardAdapter.getViewTypeCount() + /* Enable Wifi calling */ + mContactTileAdapter.getViewTypeCount() + /* Favorite and frequent */ mCallLogAdapter.getViewTypeCount() + /* Recent call log */ getTeaserViewCount() + /* Teaser */ 1); /* Show all contacts button. */ @@ -192,6 +215,14 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { @Override public int getItemViewType(int position) { + if (mWifiWizardAdapter.getCount() > 0) { + if (position < mWifiWizardAdapter.getCount()) { + return mWifiWizardAdapter.getItemViewType(position); + } else { + position -= mWifiWizardAdapter.getCount(); + } + } + final int callLogAdapterCount = mCallLogAdapter.getCount(); if (position < callLogAdapterCount) { @@ -202,7 +233,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { mTileInteractionTeaserView.getShouldDisplayInList()) { // View type of the teaser row is the last view type of the contact tile adapter + 3 return mContactTileAdapter.getViewTypeCount() + 2; - } else if (position < getCount() - 1) { + } else if (position < getCount() - mWifiWizardAdapter.getCount() - 1) { return mContactTileAdapter.getItemViewType( getAdjustedFavoritePosition(position, callLogAdapterCount)); } else { @@ -214,9 +245,32 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { + if (mWifiWizardAdapter.getCount() > 0) { + if (position < mWifiWizardAdapter.getCount()) { + SwipeableCallLogRow wrapper = new SwipeableCallLogRow(mContext); + wrapper.addView(mWifiWizardAdapter.getView(position, convertView, parent)); + wrapper.setOnItemSwipeListener(new OnItemGestureListener() { + @Override + public void onSwipe(View view) {} + + @Override + public void onTouch() {} + + @Override + public boolean isSwipeEnabled() { + return false; + } + }); + return wrapper; + } else { + position -= mWifiWizardAdapter.getCount(); + } + } + final int callLogAdapterCount = mCallLogAdapter.getCount(); - if ((position == getCount() - 1) && (mContactTileAdapter.getCount() > 0)) { + if ((position == getCount() - mWifiWizardAdapter.getCount() - 1) + && (mContactTileAdapter.getCount() > 0)) { return mShowAllContactsButton; } @@ -276,6 +330,14 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter { @Override public boolean isEnabled(int position) { + if (mWifiWizardAdapter.getCount() > 0) { + if (position < mWifiWizardAdapter.getCount()) { + return mWifiWizardAdapter.isEnabled(position); + } else { + position -= mWifiWizardAdapter.getCount(); + } + } + final int callLogAdapterCount = mCallLogAdapter.getCount(); if (position < callLogAdapterCount) { return mCallLogAdapter.isEnabled(position); diff --git a/src/com/android/dialer/list/WifiWizardAdapter.java b/src/com/android/dialer/list/WifiWizardAdapter.java new file mode 100644 index 000000000..bac8c7abe --- /dev/null +++ b/src/com/android/dialer/list/WifiWizardAdapter.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2013 Google Inc. + * Licensed to 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.list; + +import com.android.dialer.R; +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.Button; + +public class WifiWizardAdapter extends BaseAdapter { + + public interface WifiWizardModel { + public static final int WIFI_CALL_STATE_ALWAYS = 0; + public static final int WIFI_CALL_STATE_NEVER = 1; + public static final int WIFI_CALL_STATE_ASK = 2; + + void setWifiCallState(int state); + + int getWifiCallState(); + + boolean shouldDisplayWifiSelection(); + } + + private abstract class WifiWizardStep { + private final int mResourceId; + private View mView; + protected WifiWizardStep(int resourceId) { + mResourceId = resourceId; + } + public final View getView() { + if (mView == null) { + mView = inflate(mResourceId); + } + if (mView.getParent() != null && (mView.getParent() instanceof ViewGroup)) { + ((ViewGroup) mView.getParent()).removeView(mView); + } + configureView(mView); + return mView; + } + protected abstract void configureView(View view); + } + + private WifiWizardStep mTeaserStep = + new WifiWizardStep(R.layout.wifi_call_enable_teaser) { + @Override + protected void configureView(View view) { + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mStep = mSettingsStep; + notifyDataSetChanged(); + } + }); + } + }; + + private WifiWizardStep mSettingsStep = + new WifiWizardStep(R.layout.wifi_call_enable_settings) { + @Override + protected void configureView(View view) { + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mStep = mCompletionStep; + notifyDataSetChanged(); + } + }); + } + }; + + private WifiWizardStep mCompletionStep = + new WifiWizardStep(R.layout.wifi_call_enable_completion) { + @Override + protected void configureView(View view) { + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mStep = mTeaserStep; + notifyDataSetChanged(); + } + }); + } + }; + + private final WifiWizardModel mModel; + private final Context mContext; + private WifiWizardStep mStep = mTeaserStep; + + public WifiWizardAdapter(Context context, WifiWizardModel model) { + this.mContext = context; + this.mModel = model; + } + + @Override + public int getCount() { + return 1; + } + + @Override + public Object getItem(int position) { + return this; + } + + @Override + public long getItemId(int position) { + return 1L; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + return mStep.getView(); + } + + private View inflate(int resource) { + return ((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) + .inflate(resource, null); + } +} |