From d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Wed, 15 Mar 2017 14:41:07 -0700 Subject: Update Dialer source from latest green build. * Refactor voicemail component * Add new enriched calling components Test: treehugger, manual aosp testing Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942 --- .../dialer/callcomposer/CallComposerFragment.java | 75 +++------------------- 1 file changed, 8 insertions(+), 67 deletions(-) (limited to 'java/com/android/dialer/callcomposer/CallComposerFragment.java') diff --git a/java/com/android/dialer/callcomposer/CallComposerFragment.java b/java/com/android/dialer/callcomposer/CallComposerFragment.java index d6f944955..ee1eb462a 100644 --- a/java/com/android/dialer/callcomposer/CallComposerFragment.java +++ b/java/com/android/dialer/callcomposer/CallComposerFragment.java @@ -17,13 +17,8 @@ package com.android.dialer.callcomposer; import android.content.Context; -import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; import com.android.dialer.common.Assert; import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; @@ -34,26 +29,10 @@ public abstract class CallComposerFragment extends Fragment { protected static final int CAMERA_PERMISSION = 1; protected static final int STORAGE_PERMISSION = 2; - private static final String LOCATION_KEY = "location_key"; - public static final int CONTENT_TOP_UNSET = Integer.MAX_VALUE; - - private View topView; - private int contentTopPx = CONTENT_TOP_UNSET; - private CallComposerListener testListener; - - @Nullable - @Override - public View onCreateView( - LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { - View view = super.onCreateView(layoutInflater, viewGroup, bundle); - Assert.isNotNull(topView); - return view; - } - @Override public void onAttach(Context context) { super.onAttach(context); - if (!(context instanceof CallComposerListener) && testListener == null) { + if (FragmentUtils.getParent(this, CallComposerListener.class) == null) { LogUtil.e( "CallComposerFragment.onAttach", "Container activity must implement CallComposerListener."); @@ -61,56 +40,15 @@ public abstract class CallComposerFragment extends Fragment { } } - /** Call this method to declare which view is located at the top of the fragment's layout. */ - public void setTopView(View view) { - topView = view; - // For each fragment that extends CallComposerFragment, the heights may vary and since - // ViewPagers cannot have their height set to wrap_content, we have to adjust the top of our - // container to match the top of the fragment. This listener populates {@code contentTopPx} as - // it's available. - topView - .getViewTreeObserver() - .addOnGlobalLayoutListener( - new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - topView.getViewTreeObserver().removeOnGlobalLayoutListener(this); - contentTopPx = topView.getTop(); - } - }); - } - - public int getContentTopPx() { - return contentTopPx; - } - - public void setParentForTesting(CallComposerListener listener) { - testListener = listener; - } - + @Nullable public CallComposerListener getListener() { - if (testListener != null) { - return testListener; - } - return FragmentUtils.getParentUnsafe(this, CallComposerListener.class); - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt(LOCATION_KEY, contentTopPx); - } - - @Override - public void onViewStateRestored(Bundle savedInstanceState) { - super.onViewStateRestored(savedInstanceState); - if (savedInstanceState != null) { - contentTopPx = savedInstanceState.getInt(LOCATION_KEY); - } + return FragmentUtils.getParent(this, CallComposerListener.class); } public abstract boolean shouldHide(); + public abstract void clearComposer(); + /** Interface used to listen to CallComposeFragments */ public interface CallComposerListener { /** Let the listener know when a call is ready to be composed. */ @@ -121,5 +59,8 @@ public abstract class CallComposerFragment extends Fragment { /** True is the listener is in fullscreen. */ boolean isFullscreen(); + + /** True if the layout is in landscape mode. */ + boolean isLandscapeLayout(); } } -- cgit v1.2.3