summaryrefslogtreecommitdiff
path: root/packages/PrintSpooler/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/PrintSpooler/src')
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java23
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/widget/ClickInterceptSpinner.java56
2 files changed, 65 insertions, 14 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index 601491abfd7e..1b7a1b8b9567 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -70,7 +70,6 @@ import android.util.ArraySet;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
-import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
@@ -101,6 +100,7 @@ import com.android.printspooler.util.ApprovedPrintServices;
import com.android.printspooler.util.MediaSizeUtils;
import com.android.printspooler.util.MediaSizeUtils.MediaSizeComparator;
import com.android.printspooler.util.PageRangeUtils;
+import com.android.printspooler.widget.ClickInterceptSpinner;
import com.android.printspooler.widget.PrintContentView;
import com.android.printspooler.widget.PrintContentView.OptionsStateChangeListener;
import com.android.printspooler.widget.PrintContentView.OptionsStateController;
@@ -200,7 +200,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
private TextView mPageRangeTitle;
private EditText mPageRangeEditText;
- private Spinner mDestinationSpinner;
+ private ClickInterceptSpinner mDestinationSpinner;
private DestinationAdapter mDestinationSpinnerAdapter;
private boolean mShowDestinationPrompt;
@@ -1383,19 +1383,14 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
mSummaryCopies.setEnabled(false);
mSummaryPaperSize.setEnabled(false);
- mDestinationSpinner.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- mShowDestinationPrompt = false;
- mSummaryCopies.setEnabled(true);
- mSummaryPaperSize.setEnabled(true);
- updateOptionsUi();
-
- mDestinationSpinner.setOnTouchListener(null);
- mDestinationSpinnerAdapter.notifyDataSetChanged();
+ mDestinationSpinner.setPerformClickListener((v) -> {
+ mShowDestinationPrompt = false;
+ mSummaryCopies.setEnabled(true);
+ mSummaryPaperSize.setEnabled(true);
+ updateOptionsUi();
- return false;
- }
+ mDestinationSpinner.setPerformClickListener(null);
+ mDestinationSpinnerAdapter.notifyDataSetChanged();
});
}
}
diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/ClickInterceptSpinner.java b/packages/PrintSpooler/src/com/android/printspooler/widget/ClickInterceptSpinner.java
new file mode 100644
index 000000000000..1d3aac9997ff
--- /dev/null
+++ b/packages/PrintSpooler/src/com/android/printspooler/widget/ClickInterceptSpinner.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 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.printspooler.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.Spinner;
+
+/**
+ * Spinner that can intercept {@link Spinner#performClick()}
+ */
+public class ClickInterceptSpinner extends Spinner {
+ private OnClickListener mListener;
+
+ /**
+ * Create a new spinner with the given attributes.
+ *
+ * @param context The context for the spinner
+ * @param attrs Attributes of the spinner
+ */
+ public ClickInterceptSpinner(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ /**
+ * Set a listener invoked on {@link #performClick()}
+ *
+ * @param listener The listener to be invoked
+ */
+ public void setPerformClickListener(OnClickListener listener) {
+ mListener = listener;
+ }
+
+ @Override
+ public boolean performClick() {
+ if (mListener != null) {
+ mListener.onClick(this);
+ }
+
+ return super.performClick();
+ }
+}