diff options
author | Fred Ross-Perry <fred.ross-perry@artifex.com> | 2016-09-22 13:47:37 -0700 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-09-23 16:31:30 +0100 |
commit | a1d40f89e1314aee446826297602566b26a84b5c (patch) | |
tree | eab8f9742821d778c531d47df4d634a9794257bc | |
parent | 9dd552b0d4024a213a40d283e8e5c6c47d4661b1 (diff) | |
download | mupdf-a1d40f89e1314aee446826297602566b26a84b5c.tar.xz |
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 <EMBEDDED> into gs instead of a file name.
-rw-r--r-- | platform/android/example/mupdf/src/main/java/com/artifex/mupdf/android/DocActivityView.java | 45 |
1 files changed, 35 insertions, 10 deletions
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<String> list = new ArrayList<String>(Arrays.asList(baseList)); + list.add(0, "Output Intent: " + mEmbeddedProfile); + ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(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 = "<EMBEDDED>"; + } + 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); |