From a1d40f89e1314aee446826297602566b26a84b5c Mon Sep 17 00:00:00 2001 From: Fred Ross-Perry Date: Thu, 22 Sep 2016 13:47:37 -0700 Subject: Android example: add embedded profile to print profiles list In the proof dialog, when the document has an embedded print profile, add it to the top of the list of choices. If it's selected, send into gs instead of a file name. --- .../com/artifex/mupdf/android/DocActivityView.java | 45 +++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'platform') diff --git a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocActivityView.java b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocActivityView.java index 03739349..15ec6f01 100644 --- a/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocActivityView.java +++ b/platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocActivityView.java @@ -17,6 +17,7 @@ import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; +import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageButton; @@ -38,6 +39,8 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; import java.util.UUID; public class DocActivityView extends FrameLayout implements TabHost.OnTabChangeListener, View.OnClickListener, DocView.SelectionChangeListener @@ -81,6 +84,8 @@ public class DocActivityView extends FrameLayout implements TabHost.OnTabChangeL private ImageButton mProofButton; + private String mEmbeddedProfile = null; + public DocActivityView(Context context) { super(context); @@ -810,10 +815,6 @@ public class DocActivityView extends FrameLayout implements TabHost.OnTabChangeL return; } - - - - // show a dialog to collect the resolution and profiles final Activity activity = (Activity)getContext(); @@ -821,12 +822,22 @@ public class DocActivityView extends FrameLayout implements TabHost.OnTabChangeL dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.proof_dialog); - final String embeddedProfile = getEmbeddedProfileName(); - final Spinner sp1 = (Spinner)(dialog.findViewById(R.id.print_profile_spinner)); final Spinner sp2 = (Spinner)(dialog.findViewById(R.id.display_profile_spinner)); final Spinner sp3 = (Spinner)(dialog.findViewById(R.id.resolution_spinner)); + mEmbeddedProfile = getEmbeddedProfileName(); + if (mEmbeddedProfile!=null && !mEmbeddedProfile.isEmpty()) + { + // if the doc has an embedded profile, add it to the beginning of the list of print profiles. + String[] baseList = getResources().getStringArray(R.array.proof_print_profiles); + ArrayList list = new ArrayList(Arrays.asList(baseList)); + list.add(0, "Output Intent: " + mEmbeddedProfile); + ArrayAdapter spinnerAdapter = new ArrayAdapter(activity, android.R.layout.simple_spinner_item, list); + spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + sp1.setAdapter(spinnerAdapter); + } + dialog.findViewById(R.id.cancel_button).setOnClickListener(new OnClickListener() { @Override @@ -889,12 +900,26 @@ public class DocActivityView extends FrameLayout implements TabHost.OnTabChangeL String resolutionString = resolutions[resolutionIndex]; int resolution = Integer.parseInt(resolutionString); - // get the print profile as a temp file + // get the print profile + String printProfilePath; String[] printProfiles = getResources().getStringArray(R.array.proof_print_profile_files); - String printProfileFile = printProfiles[printProfileIndex]; - String printProfilePath = extractProfileAsset("profiles/CMYK/" + printProfileFile); + if (mEmbeddedProfile!=null && !mEmbeddedProfile.isEmpty()) + { + if (printProfileIndex==0) + { + printProfilePath = ""; + } + else + { + printProfilePath = extractProfileAsset("profiles/CMYK/" + printProfiles[printProfileIndex-1]); + } + } + else + { + printProfilePath = extractProfileAsset("profiles/CMYK/" + printProfiles[printProfileIndex]); + } - // get the display profile as a temp file + // get the display profile String[] displayProfiles = getResources().getStringArray(R.array.proof_display_profile_files); String displayProfileFile = displayProfiles[displayProfileIndex]; String displayProfilePath = extractProfileAsset("profiles/RGB/" + displayProfileFile); -- cgit v1.2.3