[Android] UI: dismiss menu when jumping to time
Sébastien Toque
git at videolan.org
Sat Apr 6 00:17:31 CEST 2013
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sat Apr 6 00:15:12 2013 +0200| [249a99099db82b11f2af1b0ce4ee82a522a24180] | committer: Sébastien Toque
UI: dismiss menu when jumping to time
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=249a99099db82b11f2af1b0ce4ee82a522a24180
---
vlc-android/res/layout/advanced_options.xml | 1 +
.../src/org/videolan/vlc/gui/CommonDialogs.java | 24 ++++++++++++++++-
.../videolan/vlc/gui/expandable/JumpToTime.java | 1 +
.../vlc/interfaces/OnExpandableListener.java | 25 ++++++++++++++++++
.../org/videolan/vlc/widget/ExpandableLayout.java | 27 +++++++++++++-------
5 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/vlc-android/res/layout/advanced_options.xml b/vlc-android/res/layout/advanced_options.xml
index 44a47e7..8101fab 100644
--- a/vlc-android/res/layout/advanced_options.xml
+++ b/vlc-android/res/layout/advanced_options.xml
@@ -5,6 +5,7 @@
android:layout_height="wrap_content" >
<LinearLayout
+ android:id="@+id/advanced_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
diff --git a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
index 02786eb..1e990bc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
+++ b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
@@ -27,6 +27,8 @@ import java.net.URISyntaxException;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.VlcRunnable;
+import org.videolan.vlc.interfaces.OnExpandableListener;
+import org.videolan.vlc.widget.ExpandableLayout;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@@ -37,6 +39,7 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.LayoutParams;
+import android.widget.LinearLayout;
public class CommonDialogs {
public final static String TAG = "VLC/CommonDialogs";
@@ -73,10 +76,29 @@ public class CommonDialogs {
LayoutInflater inflater = LayoutInflater.from(VLCApplication.getAppContext());
View view = inflater.inflate(R.layout.advanced_options, null);
+ // build dialog
Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.Theme_VLC_AlertMenu))
.setView(view);
- AlertDialog dialog = builder.create();
+ final AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(true);
+
+ // register listener on each ExpandableLayout in advanced_layout
+ LinearLayout advanced_layout = (LinearLayout) view.findViewById(R.id.advanced_layout);
+ OnExpandableListener mExpandableListener = new OnExpandableListener() {
+ @Override
+ public void onDismiss() {
+ dialog.dismiss();
+ }
+ };
+ for (int i = 0; i < advanced_layout.getChildCount(); ++i)
+ {
+ View child = advanced_layout.getChildAt(i);
+ if (child instanceof ExpandableLayout) {
+ ((ExpandableLayout) child).setOnExpandableListener(mExpandableListener);
+ }
+ }
+
+ // show dialog
dialog.show();
// force size
diff --git a/vlc-android/src/org/videolan/vlc/gui/expandable/JumpToTime.java b/vlc-android/src/org/videolan/vlc/gui/expandable/JumpToTime.java
index a75bad7..068f906 100644
--- a/vlc-android/src/org/videolan/vlc/gui/expandable/JumpToTime.java
+++ b/vlc-android/src/org/videolan/vlc/gui/expandable/JumpToTime.java
@@ -91,6 +91,7 @@ public class JumpToTime extends ExpandableLayout {
1000 * (mHourWheel.getCurrentItem() * 60 * 60 +
mMinWheel.getCurrentItem() * 60 +
mSecWheel.getCurrentItem()));
+ dismiss();
}
};
}
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/OnExpandableListener.java b/vlc-android/src/org/videolan/vlc/interfaces/OnExpandableListener.java
new file mode 100644
index 0000000..e92bd83
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/interfaces/OnExpandableListener.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * OnExpandableListener.java
+ *****************************************************************************
+ * Copyright © 2013 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+package org.videolan.vlc.interfaces;
+
+public interface OnExpandableListener {
+ public abstract void onDismiss();
+}
diff --git a/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java b/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java
index d2d5c3c..6da20b8 100644
--- a/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java
+++ b/vlc-android/src/org/videolan/vlc/widget/ExpandableLayout.java
@@ -21,6 +21,7 @@
package org.videolan.vlc.widget;
import org.videolan.vlc.R;
+import org.videolan.vlc.interfaces.OnExpandableListener;
import android.content.Context;
import android.util.AttributeSet;
@@ -39,6 +40,7 @@ public class ExpandableLayout extends LinearLayout {
private final ImageView mMore;
private final LinearLayout mContent;
private Boolean mExpanded;
+ private OnExpandableListener listener = null;
public ExpandableLayout(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -55,14 +57,14 @@ public class ExpandableLayout extends LinearLayout {
mHeaderLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- SetState(!mExpanded);
+ setState(!mExpanded);
}
});
- SetState(isInEditMode());
+ setState(isInEditMode());
}
- private void SetState(Boolean expanded) {
+ private void setState(Boolean expanded) {
mExpanded = expanded;
mMore.setImageResource(expanded ? R.drawable.ic_up : R.drawable.ic_down);
mContent.setVisibility(expanded ? View.VISIBLE : View.GONE);
@@ -87,13 +89,20 @@ public class ExpandableLayout extends LinearLayout {
mContent.addView(view);
}
- public void Expand()
- {
- SetState(true);
+ public void expand() {
+ setState(true);
}
- public void Collapse()
- {
- SetState(false);
+ public void collapse() {
+ setState(false);
+ }
+
+ public void dismiss() {
+ if (this.listener != null)
+ this.listener.onDismiss();
+ }
+
+ public void setOnExpandableListener(OnExpandableListener listener) {
+ this.listener = listener;
}
}
More information about the Android
mailing list