diff options
author | Adam Cohen <adamcohen@google.com> | 2012-06-01 17:17:08 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2012-06-04 12:18:04 -0700 |
commit | 06dff35763bc46884b6464a9bf4406d32cdcaea4 (patch) | |
tree | 197f97d8c6e43df01730841136db5bbd9c4f515d /src/com/android/launcher2/LauncherAppWidgetHostView.java | |
parent | 1fa57ee628a135dbbf34af43765ecf9d43c37cbc (diff) | |
download | android_packages_apps_Trebuchet-06dff35763bc46884b6464a9bf4406d32cdcaea4.tar.gz android_packages_apps_Trebuchet-06dff35763bc46884b6464a9bf4406d32cdcaea4.tar.bz2 android_packages_apps_Trebuchet-06dff35763bc46884b6464a9bf4406d32cdcaea4.zip |
Fixing issue where widgets could be inflated in wrong orientation (issue 6584646)
Change-Id: I24ea7f59345e8f62daf36c13cb43e1ab0180e805
Diffstat (limited to 'src/com/android/launcher2/LauncherAppWidgetHostView.java')
-rw-r--r-- | src/com/android/launcher2/LauncherAppWidgetHostView.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/android/launcher2/LauncherAppWidgetHostView.java index e34196ee6..9970c7675 100644 --- a/src/com/android/launcher2/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher2/LauncherAppWidgetHostView.java @@ -18,10 +18,14 @@ package com.android.launcher2; import android.appwidget.AppWidgetHostView; import android.content.Context; +import android.content.res.Configuration; +import android.os.Bundle; +import android.os.Parcel; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.widget.RemoteViews; import com.android.launcher.R; @@ -31,9 +35,12 @@ import com.android.launcher.R; public class LauncherAppWidgetHostView extends AppWidgetHostView { private CheckLongPressHelper mLongPressHelper; private LayoutInflater mInflater; + private Context mContext; + private int mPreviousOrientation; public LauncherAppWidgetHostView(Context context) { super(context); + mContext = context; mLongPressHelper = new CheckLongPressHelper(this); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @@ -43,6 +50,21 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView { return mInflater.inflate(R.layout.appwidget_error, this, false); } + @Override + public void updateAppWidget(RemoteViews remoteViews) { + // Store the orientation in which the widget was inflated + mPreviousOrientation = mContext.getResources().getConfiguration().orientation; + super.updateAppWidget(remoteViews); + } + + public boolean orientationChangedSincedInflation() { + int orientation = mContext.getResources().getConfiguration().orientation; + if (mPreviousOrientation != orientation) { + return true; + } + return false; + } + public boolean onInterceptTouchEvent(MotionEvent ev) { // Consume any touch events for ourselves after longpress is triggered if (mLongPressHelper.hasPerformedLongPress()) { |