diff options
author | Fred Ross-Perry <fred.ross-perry@artifex.com> | 2016-09-22 13:58:35 -0700 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-09-23 16:31:29 +0100 |
commit | 9dd552b0d4024a213a40d283e8e5c6c47d4661b1 (patch) | |
tree | db3f020e2ea5b5e482cade949165bc0005dd442f /platform/android/example | |
parent | a5db7f3bba96a1550daab9255f66a63b918df515 (diff) | |
download | mupdf-9dd552b0d4024a213a40d283e8e5c6c47d4661b1.tar.xz |
Android example: tweak Apply button in proofing dialog.
Enable Apply button in proofing only when color checkboxes are changed.
Diffstat (limited to 'platform/android/example')
3 files changed, 33 insertions, 3 deletions
diff --git a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java index 65b79c19..8b994537 100644 --- a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java +++ b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/ProofActivity.java @@ -90,6 +90,7 @@ public class ProofActivity extends Activity implements View.OnClickListener, Doc mApplyButton = (Button) findViewById(R.id.proof_apply_button); mApplyButton.setOnClickListener(this); + mApplyButton.setEnabled(false); // wait for layout to open the document final ProofActivity activity = this; @@ -179,6 +180,7 @@ public class ProofActivity extends Activity implements View.OnClickListener, Doc } else if (v == mApplyButton) { + mApplyButton.setEnabled(false); updateColors(); } } @@ -278,7 +280,12 @@ public class ProofActivity extends Activity implements View.OnClickListener, Doc // set up the list mColorList = (ListView)findViewById(R.id.proof_color_list); - mColorAdapter = new ChooseColorAdapter(getLayoutInflater()); + mColorAdapter = new ChooseColorAdapter(getLayoutInflater(), new ColorChangeListener() { + @Override + public void onColorChange() { + mApplyButton.setEnabled(true); + } + }); mColorList.setAdapter(mColorAdapter); // get each one @@ -377,14 +384,21 @@ public class ProofActivity extends Activity implements View.OnClickListener, Doc //--------------------------------------------------------------------------------------------------------- + public interface ColorChangeListener + { + void onColorChange(); + } + public class ChooseColorAdapter extends BaseAdapter { private final LinkedList<ChooseColorItem> mItems; private final LayoutInflater mInflater; + ColorChangeListener mColorChangeListener = null; - public ChooseColorAdapter(LayoutInflater inflater) + public ChooseColorAdapter(LayoutInflater inflater, ColorChangeListener listener) { mInflater = inflater; + mColorChangeListener = listener; mItems = new LinkedList<>(); } @@ -441,6 +455,8 @@ public class ProofActivity extends Activity implements View.OnClickListener, Doc public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { item.checked = isChecked; + if (mColorChangeListener!=null) + mColorChangeListener.onColorChange(); } }); diff --git a/platform/android/example/mupdf/src/main/res/drawable/apply_button.xml b/platform/android/example/mupdf/src/main/res/drawable/apply_button.xml new file mode 100644 index 00000000..4f5c926c --- /dev/null +++ b/platform/android/example/mupdf/src/main/res/drawable/apply_button.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_enabled="false"> + <shape> + <solid android:color="@color/white" /> + </shape> + </item> + <item android:state_enabled="true"> + <shape> + <solid android:color="#ff535353" /> + </shape> + </item> +</selector> diff --git a/platform/android/example/mupdf/src/main/res/layout/activity_proof_view.xml b/platform/android/example/mupdf/src/main/res/layout/activity_proof_view.xml index 726e783b..222a50b4 100755 --- a/platform/android/example/mupdf/src/main/res/layout/activity_proof_view.xml +++ b/platform/android/example/mupdf/src/main/res/layout/activity_proof_view.xml @@ -45,7 +45,7 @@ android:layout_height="wrap_content" android:id="@+id/proof_apply_button" android:layout_gravity="center_horizontal" - android:background="#535353" + android:background="@drawable/apply_button" android:textColor="@color/white" android:textSize="18sp" android:padding="10dp" |