diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-07-24 11:05:12 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-08-06 10:23:00 +0100 |
commit | 612a2064986643ba69de4b59d2baab9068987ba3 (patch) | |
tree | 7a704ca8e45cb8cd12437d043d6db53b90e279d3 | |
parent | 22608b731635fdc28ab6b1a490ad65a2d4c2df7d (diff) |
Improved resizing handle, added visual feedback, limits.
Change-Id: I6f1f9168dd53f660b676bf5050848ce509e11ae1
13 files changed, 48 insertions, 37 deletions
diff --git a/android/sdremote/res/drawable-hdpi/handle_default.9.png b/android/sdremote/res/drawable-hdpi/handle_default.9.png Binary files differnew file mode 100644 index 000000000000..d978f956854e --- /dev/null +++ b/android/sdremote/res/drawable-hdpi/handle_default.9.png diff --git a/android/sdremote/res/drawable-hdpi/handle_light.9.png b/android/sdremote/res/drawable-hdpi/handle_light.9.png Binary files differnew file mode 100644 index 000000000000..b0d7bef534d6 --- /dev/null +++ b/android/sdremote/res/drawable-hdpi/handle_light.9.png diff --git a/android/sdremote/res/drawable-ldpi/handle_default.9.png b/android/sdremote/res/drawable-ldpi/handle_default.9.png Binary files differnew file mode 100644 index 000000000000..d978f956854e --- /dev/null +++ b/android/sdremote/res/drawable-ldpi/handle_default.9.png diff --git a/android/sdremote/res/drawable-ldpi/handle_light.9.png b/android/sdremote/res/drawable-ldpi/handle_light.9.png Binary files differnew file mode 100644 index 000000000000..b0d7bef534d6 --- /dev/null +++ b/android/sdremote/res/drawable-ldpi/handle_light.9.png diff --git a/android/sdremote/res/drawable-mdpi/handle_default.9.png b/android/sdremote/res/drawable-mdpi/handle_default.9.png Binary files differnew file mode 100644 index 000000000000..d978f956854e --- /dev/null +++ b/android/sdremote/res/drawable-mdpi/handle_default.9.png diff --git a/android/sdremote/res/drawable-mdpi/handle_light.9.png b/android/sdremote/res/drawable-mdpi/handle_light.9.png Binary files differnew file mode 100644 index 000000000000..b0d7bef534d6 --- /dev/null +++ b/android/sdremote/res/drawable-mdpi/handle_light.9.png diff --git a/android/sdremote/res/drawable-xhdpi/handle_default.9.png b/android/sdremote/res/drawable-xhdpi/handle_default.9.png Binary files differnew file mode 100644 index 000000000000..d978f956854e --- /dev/null +++ b/android/sdremote/res/drawable-xhdpi/handle_default.9.png diff --git a/android/sdremote/res/drawable-xhdpi/handle_light.9.png b/android/sdremote/res/drawable-xhdpi/handle_light.9.png Binary files differnew file mode 100644 index 000000000000..b0d7bef534d6 --- /dev/null +++ b/android/sdremote/res/drawable-xhdpi/handle_light.9.png diff --git a/android/sdremote/res/drawable/handle.xml b/android/sdremote/res/drawable/handle.xml new file mode 100644 index 000000000000..9fda3d89bbad --- /dev/null +++ b/android/sdremote/res/drawable/handle.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <item android:drawable="@drawable/handle_light" android:state_activated="true"/> + <item android:drawable="@drawable/handle_light" android:state_pressed="true"/> + <item android:drawable="@drawable/handle_light" android:state_focused="true"/> + <item android:drawable="@drawable/handle_default"/> + +</selector>
\ No newline at end of file diff --git a/android/sdremote/res/drawable/handle_center.png b/android/sdremote/res/drawable/handle_center.png Binary files differdeleted file mode 100644 index b591d3594ad4..000000000000 --- a/android/sdremote/res/drawable/handle_center.png +++ /dev/null diff --git a/android/sdremote/res/drawable/handle_line.png b/android/sdremote/res/drawable/handle_line.png Binary files differdeleted file mode 100644 index ede5d818ace2..000000000000 --- a/android/sdremote/res/drawable/handle_line.png +++ /dev/null diff --git a/android/sdremote/res/layout/fragment_presentation.xml b/android/sdremote/res/layout/fragment_presentation.xml index 9331dc53bae1..3da7e0997cf6 100644 --- a/android/sdremote/res/layout/fragment_presentation.xml +++ b/android/sdremote/res/layout/fragment_presentation.xml @@ -2,7 +2,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" > + android:orientation="vertical" + android:id="@+id/presentation_layout"> <ImageView android:id="@+id/imageView1" @@ -11,40 +12,17 @@ android:contentDescription="TODO" android:src="@drawable/testimage" /> - <LinearLayout - android:layout_width="match_parent" + <ImageView + android:id="@+id/presentation_handle" + android:layout_width="fill_parent" android:layout_height="wrap_content" - android:id="@+id/presentation_handle" > - - <ImageView - android:id="@+id/imageView4" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="0.5" - android:contentDescription="TODO" - android:paddingLeft="6dp" - android:scaleType="fitXY" - android:src="@drawable/handle_line" /> - - <ImageView - android:id="@+id/imageView3" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" - android:contentDescription="TODO" - android:src="@drawable/handle_center" /> - - <ImageView - android:id="@+id/imageView2" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="0.5" - android:maxWidth="500dp" - android:paddingRight="6dp" - android:scaleType="fitXY" - android:src="@drawable/handle_line" - android:contentDescription="TODO"/> - </LinearLayout> + android:layout_marginLeft="6dp" + android:layout_marginRight="6dp" + android:contentDescription="TODO" + android:paddingBottom="5dp" + android:paddingTop="5dp" + android:scaleType="fitXY" + android:src="@drawable/handle" /> <ScrollView android:id="@+id/scrollView1" diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java index 5ae47b306446..c031986d25ee 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java @@ -1,6 +1,7 @@ package org.libreoffice.impressremote; import android.app.Fragment; +import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -9,14 +10,20 @@ import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.webkit.WebView; +import android.widget.ImageView; public class PresentationFragment extends Fragment { private View mTopView; + private ImageView mHandle; + private View mLayout; + + private Context mContext; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Inflate the layout for this fragment + mContext = container.getContext(); + View v = inflater.inflate(R.layout.fragment_presentation, container, false); @@ -26,9 +33,10 @@ public class PresentationFragment extends Fragment { mWebView.loadData(summary, "text/html", null); mTopView = v.findViewById(R.id.imageView1); + mLayout = v.findViewById(R.id.presentation_layout); - v.findViewById(R.id.presentation_handle).setOnTouchListener( - new SizeListener()); + mHandle = (ImageView) v.findViewById(R.id.presentation_handle); + mHandle.setOnTouchListener(new SizeListener()); return v; } @@ -41,9 +49,25 @@ public class PresentationFragment extends Fragment { LayoutParams aParams = mTopView.getLayoutParams(); switch (aEvent.getAction()) { + case MotionEvent.ACTION_DOWN: + mHandle.setImageResource(R.drawable.handle_light); + break; + case MotionEvent.ACTION_UP: + mHandle.setImageResource(R.drawable.handle_default); + break; case MotionEvent.ACTION_MOVE: int aHeight = mTopView.getHeight(); aParams.height = aHeight + (int) (aEvent.getY()); + + final int DRAG_MARGIN = 120; + + int aSize = mLayout.getHeight(); + if (aParams.height < DRAG_MARGIN) { + aParams.height = DRAG_MARGIN; + } else if (aParams.height > aSize - DRAG_MARGIN) { + aParams.height = aSize - DRAG_MARGIN; + } + mTopView.setLayoutParams(aParams); break; } |