From df76f716297818cd87b927844b642e1a787e2e90 Mon Sep 17 00:00:00 2001 From: Ihab Awad Date: Thu, 21 Nov 2013 12:06:41 -0800 Subject: Initial implementation of UI mocks for Wi-Fi calling option. Change-Id: Id064a98c675527569e67f700b361b653c906d6eb --- res/drawable/ic_phone_plus_wifi.png | Bin 0 -> 31655 bytes res/drawable/ic_wifi_call.png | Bin 0 -> 3468 bytes res/layout/wifi_call_enable_completion.xml | 55 +++++++++ res/layout/wifi_call_enable_settings.xml | 135 ++++++++++++++++++++ res/layout/wifi_call_enable_teaser.xml | 41 +++++++ res/values/colors.xml | 13 ++ res/values/strings.xml | 23 ++++ .../android/dialer/list/PhoneFavoriteFragment.java | 23 +++- .../dialer/list/PhoneFavoriteMergedAdapter.java | 82 +++++++++++-- src/com/android/dialer/list/WifiWizardAdapter.java | 136 +++++++++++++++++++++ 10 files changed, 497 insertions(+), 11 deletions(-) create mode 100644 res/drawable/ic_phone_plus_wifi.png create mode 100644 res/drawable/ic_wifi_call.png create mode 100644 res/layout/wifi_call_enable_completion.xml create mode 100644 res/layout/wifi_call_enable_settings.xml create mode 100644 res/layout/wifi_call_enable_teaser.xml create mode 100644 src/com/android/dialer/list/WifiWizardAdapter.java diff --git a/res/drawable/ic_phone_plus_wifi.png b/res/drawable/ic_phone_plus_wifi.png new file mode 100644 index 000000000..5cd75ab31 Binary files /dev/null and b/res/drawable/ic_phone_plus_wifi.png differ diff --git a/res/drawable/ic_wifi_call.png b/res/drawable/ic_wifi_call.png new file mode 100644 index 000000000..886cbd7bb Binary files /dev/null and b/res/drawable/ic_wifi_call.png differ 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 @@ + + + + + + + + + + + + + + + + + \ 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 @@ + + + + + + + + + + + + + + + \ 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 @@ #777777 + + + #00ff00 + + + #ffffff + + + #009900 + + + #909090 + 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 @@ Dismiss + + No Signal? No Problem. + + Enable Google Wi-Fi Calling + + When connected to a strong Wi-Fi signal: + + Always use Wi-Fi to make calls + + Always ask + + Never use Wi-Fi to make calls + + Next + + Back + + Boom. Wi-Fi calling is all set up. You can change your preferences or turn it off anytime in settings. + + Ok, got it + + Call settings + 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); + } +} -- cgit v1.2.3