1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678 |
- package epson.print;
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.arch.lifecycle.Observer;
- import android.arch.lifecycle.ViewModelProviders;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.ServiceConnection;
- import android.content.SharedPreferences;
- import android.content.res.Configuration;
- import android.database.Cursor;
- import android.net.Uri;
- import android.os.AsyncTask;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.IBinder;
- import android.os.Message;
- import android.os.RemoteException;
- import android.support.annotation.MainThread;
- import android.view.KeyEvent;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.Button;
- import android.widget.Gallery;
- import android.widget.ImageButton;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.TextView;
- import android.widget.Toast;
- import android.widget.ZoomControls;
- import com.epson.iprint.apf.ApfAdapter;
- import com.epson.iprint.apf.ApfPreviewView;
- import com.epson.iprint.prtlogger.NewLoggerController;
- import com.epson.iprint.prtlogger.PrintLog;
- import com.epson.iprint.shared.EpsoniPrintSharedActivity;
- import com.epson.iprint.shared.SharedParamPhoto;
- import com.epson.mobilephone.common.escpr.MediaInfo;
- import com.epson.mobilephone.common.license.LicenseTopActivity;
- import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.ArrayList;
- import java.util.Deque;
- import java.util.Iterator;
- import epson.common.Constants;
- import epson.common.DialogProgressViewModel;
- import epson.common.ExternalFileUtils;
- import epson.common.IprintLicenseInfo;
- import epson.common.IprintUserSurveyInfo;
- import epson.common.OsAssistant;
- import epson.common.Utils;
- import epson.print.Util.AsyncTaskExecutor;
- import epson.print.Util.EPLog;
- import epson.print.imgsel.PhotoImageSelectActivity;
- import epson.print.phlayout.PhotoPreview;
- import epson.print.phlayout.PhotoPreviewImageList;
- import epson.print.screen.PaperSourceInfo;
- import epson.print.screen.PaperSourceSetting;
- import epson.print.screen.PaperSourceSettingScr;
- import epson.print.screen.PrintProgress;
- import epson.print.screen.PrintSetting;
- import epson.print.screen.SettingScr;
- import epson.print.service.EpsonService;
- import epson.print.service.IEpsonService;
- import epson.print.service.IEpsonServiceCallback;
- public class ActivityViewImageSelect extends ActivityIACommon implements View.OnClickListener, PhotoPreview.ViewSizeChangeListener, ReviewInvitationDialog.OnClickListener {
- private static final int ALL_REFRESH_DRAW_END = 4;
- private static final String DIALOG_ALL_UPDATE = "dialog_all_update";
- private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog";
- private static final String DIALOG_LOAD = "dialog_load";
- private static final String DIALOG_PROGRESS = "dialog_progress";
- private static final int FROM_EPSON_PHOTO = 0;
- private static final int FROM_NOT_PHOTO = 1;
- public static final String LIST_ALBUM = "listAlbum";
- private static final int LOAD_ALL_IMAGE = 3;
- static final int MAX_IMAGE_NUMBER = 30;
- private static final int MESSAGE_OUT_OF_MEMORY_ERROR_NOTIFY = 8;
- private static final int OUT_OF_MEMORY_ERROR = 7;
- public static final String PARAMS_KEY_EPSON_COLOR_MODE = "epson_color_mode";
- public static final String PARAMS_KEY_FROM_EPSON = "FROM_EPSON";
- public static final String PARAMS_KEY_IMAGE_LIST = "imageList";
- public static final String PARAMS_KEY_PRINT_LOG = "print_log";
- private static final int PREVIEW_LOAD_DIALOG_DISMISS = 1;
- private static final int PREVIEW_LOAD_DIALOG_SHOW = 0;
- private static final int REQUEST_CODE_LICENSE_CHECK = 10;
- private static final int RESULT_RUNTIMEPERMMISSION = 9;
- private static final int START_PRINT = 5;
- private static final String TAG = "ActivityViewImageSelect";
- private static final int UPDATE_PAPERSIZE_TEXT = 6;
- private static final int ZOOM_CONTROL = 2;
- private ArrayList<PaperSourceSetting> aPaperSourceSetting;
- private ImageButton addButton = null;
- boolean bAutoStartPrint = false;
- boolean bRequestPermission = false;
- private Context context = null;
- private int currentColor = 0;
- private int currentLayout = 2;
- private int currentLayoutMulti = 0;
- private int currentPaperSize = 0;
- private String currentPrinterName = "";
- private Button deleteButton = null;
- private boolean enableShowWarning = true;
- private Gallery gallery = null;
- private GalleryAdapter galleryAdapter = null;
- private final PhotoPreviewImageList imageList = new PhotoPreviewImageList();
- private int imageNo = 0;
- private boolean isCustomAction = false;
- private boolean isPaperLandscape = false;
- private boolean isPrintedOK = false;
- private boolean isRemotePrinter = false;
- private boolean mAllReloadTaskDone;
- protected final Object mAllReloadTaskLock = new Object();
- private volatile boolean mAllReloadTaskRetryRequested;
- private IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
- public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
- }
- public void onGetInkState() throws RemoteException {
- }
- public void onGetStatusState() throws RemoteException {
- }
- public void onNotifyContinueable(int i) throws RemoteException {
- }
- public void onNotifyEndJob(int i) throws RemoteException {
- }
- public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
- }
- public void onNotifyProgress(int i, int i2) throws RemoteException {
- }
- };
- private boolean mEnableEpsonColorDisplay;
- private ImageView mEpsonColorImageView;
- private ServiceConnection mEpsonConnection = new ServiceConnection() {
- public void onServiceDisconnected(ComponentName componentName) {
- try {
- ActivityViewImageSelect.mEpsonService.unregisterCallback(ActivityViewImageSelect.mCallback);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- IEpsonService unused = ActivityViewImageSelect.mEpsonService = null;
- }
- public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
- IEpsonService unused = ActivityViewImageSelect.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
- if (ActivityViewImageSelect.mEpsonService != null) {
- try {
- ActivityViewImageSelect.mEpsonService.registerCallback(ActivityViewImageSelect.mCallback);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- }
- };
- private IEpsonService mEpsonService = null;
- private boolean mFileCheckEnd;
- Handler mHandler = new Handler(new Handler.Callback() {
- public boolean handleMessage(Message message) {
- if (ActivityViewImageSelect.this.isFinishing()) {
- return true;
- }
- int i = message.what;
- if (i != 100) {
- switch (i) {
- case 0:
- ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_LOAD);
- break;
- case 1:
- ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_LOAD);
- break;
- case 2:
- break;
- case 3:
- ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
- AllReloadTask unused = activityViewImageSelect.reloadTask = new AllReloadTask(activityViewImageSelect.context);
- if (ActivityViewImageSelect.this.reloadTask != null) {
- ActivityViewImageSelect.this.reloadTask.executeOnExecutor(new Void[0]);
- }
- ActivityViewImageSelect.mHandler.sendEmptyMessageDelayed(1, 300);
- break;
- default:
- switch (i) {
- case 5:
- ActivityViewImageSelect.this.startPrint();
- break;
- case 6:
- ActivityViewImageSelect.this.papersizeTextView.setText(ActivityViewImageSelect.this.getString(new MediaInfo.PaperSize().getStringId(ActivityViewImageSelect.this.currentPaperSize)));
- break;
- case 7:
- if (ActivityViewImageSelect.this.imageList.size() <= 0) {
- ActivityViewImageSelect.this.deleteButton.setEnabled(false);
- ActivityViewImageSelect.this.printButton.setEnabled(false);
- int unused2 = ActivityViewImageSelect.this.imageNo = 0;
- }
- TextView access$1900 = ActivityViewImageSelect.this.pageTextView;
- access$1900.setText(ActivityViewImageSelect.this.imageNo + CommonDefine.SLASH + ActivityViewImageSelect.this.imageList.size());
- ActivityViewImageSelect.this.updateGallery();
- ActivityViewImageSelect.this.previewImageView.invalidate();
- Toast.makeText(ActivityViewImageSelect.this.context, ActivityViewImageSelect.this.context.getString(R.string.file_size_notsupport), 1).show();
- break;
- case 8:
- ActivityViewImageSelect.this.showSimpleDialog(R.string.str_err_msg_out_of_memory_title);
- return true;
- }
- }
- } else {
- ArrayList unused3 = ActivityViewImageSelect.this.aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
- if (ActivityViewImageSelect.this.aPaperSourceSetting != null) {
- ActivityViewImageSelect.this.papersizeTextView.setBackgroundColor(ActivityViewImageSelect.this.getResources().getColor(R.color.epson_blue));
- ActivityViewImageSelect.this.papersizeTextView.setTextColor(ActivityViewImageSelect.this.getResources().getColor(R.color.all_white));
- PrintSetting printSetting = new PrintSetting(ActivityViewImageSelect.this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- if (ActivityViewImageSelect.this.paperSourceInfo.checkPaperMissmatch(printSetting, ActivityViewImageSelect.this.aPaperSourceSetting)) {
- ActivityViewImageSelect.this.paperMissmath.setVisibility(View.VISIBLE);
- } else {
- ActivityViewImageSelect.this.paperMissmath.setVisibility(View.GONE);
- }
- } else {
- ActivityViewImageSelect.this.papersizeTextView.setBackgroundColor(ActivityViewImageSelect.this.getResources().getColor(R.color.all_white));
- ActivityViewImageSelect.this.papersizeTextView.setTextColor(ActivityViewImageSelect.this.getResources().getColor(R.color.epson_blue));
- ActivityViewImageSelect.this.paperMissmath.setVisibility(View.GONE);
- }
- }
- return true;
- }
- });
- private final ArrayList<String> mImageFilenameListFromIntent = new ArrayList<>();
- private int mIntentFileType = 0;
- protected volatile boolean mIsAllReloadTaskRetryAcceptable;
- private boolean mLicenseCheckDone;
- private DialogProgressViewModel mModelDialog;
- private boolean mOnSizeChangeReceived;
- private PrintLog mPrintLog;
- private ReviewInvitationViewModel mReviewInvitationViewModel;
- private int mStartActivityFromPhoto = 0;
- private TextView pageTextView = null;
- private ImageView paperMissmath = null;
- PaperSourceInfo paperSourceInfo = null;
- private TextView papersizeTextView = null;
- protected ApfPreviewView previewImageView;
- private Button printButton = null;
- private String printerId = "";
- private AllReloadTask reloadTask = null;
- private Button rotateButton = null;
- private ZoomControls zoomControls = null;
- public void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- setContentView(R.layout.photo_preview);
- context = this;
- mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
- mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer<Boolean>() {
- public void onChanged(@Nullable Boolean bool) {
- if (bool.booleanValue()) {
- ActivityViewImageSelect.this.showStoreDialog();
- }
- }
- });
- mOnSizeChangeReceived = false;
- mLicenseCheckDone = false;
- mFileCheckEnd = false;
- mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
- mModelDialog.getDialogJob().observe(this, new Observer() {
- public final void onChanged(Object obj) {
- ActivityViewImageSelect.lambda$onCreate$0(ActivityViewImageSelect.this, (Deque) obj);
- }
- });
- NewLoggerController.stopLoggerIfNotAgreed(this);
- setActionBar(R.string.photo_btn_label, true);
- ExternalFileUtils.getInstance(this).initTempViewDir();
- ExternalFileUtils.getInstance(this).initTempCRDir();
- ExternalFileUtils.getInstance(this).initPrintDir();
- Intent intent = getIntent();
- if (intent == null) {
- Toast.makeText(this, getString(R.string.no_image), 0).show();
- finish();
- }
- setFieldFromStartIntent(intent);
- if (mImageFilenameListFromIntent.size() == 0) {
- clearListToastAndFinish();
- return;
- }
- mEnableEpsonColorDisplay = getEpsonColorModeFromIntent(intent);
- PhotoPreview photoPreview = (PhotoPreview) findViewById(R.id.previewImageView);
- photoPreview.setViewSizeChangeListener(this);
- previewImageView = new ApfPreviewView();
- previewImageView.init(this, photoPreview);
- SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
- if (sharedPreferences != null) {
- currentPrinterName = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
- printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
- PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- currentPaperSize = printSetting.paperSizeValue;
- currentLayout = printSetting.layoutValue;
- currentLayoutMulti = printSetting.layoutMultiPageValue;
- currentColor = printSetting.colorValue;
- previewImageView.setLayout(this.currentLayout, currentLayoutMulti);
- previewImageView.setPaper(this.currentPaperSize);
- previewImageView.setColor(this.currentColor);
- }
- previewImageView.setApfLibParams(0, 0, 0);
- papersizeTextView = (TextView) findViewById(R.id.btn_paper_size);
- papersizeTextView.setText(getPaperSizeName());
- papersizeTextView.setOnClickListener(this);
- pageTextView = (TextView) findViewById(R.id.btn_photo_count);
- Handler handler = mHandler;
- if (handler != null) {
- handler.sendEmptyMessage(2);
- }
- rotateButton = (Button) findViewById(R.id.bt_rotate);
- rotateButton.setOnClickListener(this);
- gallery = (Gallery) findViewById(R.id.gallery);
- if (mImageFilenameListFromIntent.size() != 0) {
- gallery.setCallbackDuringFling(false);
- gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- public void onNothingSelected(AdapterView<?> adapterView) {
- }
- public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
- if (ActivityViewImageSelect.this.imageNo != i) {
- int unused = ActivityViewImageSelect.this.imageNo = i;
- ActivityViewImageSelect.this.gallery.setSelection(ActivityViewImageSelect.this.imageNo);
- new PreviewImageSelectTask().executeOnExecutor(new Void[0]);
- }
- }
- });
- }
- addButton = (ImageButton) findViewById(R.id.btn_add_photo);
- addButton.setOnClickListener(this);
- deleteButton = (Button) findViewById(R.id.btn_deselect);
- deleteButton.setOnClickListener(this);
- if (mImageFilenameListFromIntent.size() == 0) {
- deleteButton.setEnabled(false);
- }
- if (mStartActivityFromPhoto != 0) {
- addButton.setVisibility(View.GONE);
- deleteButton.setVisibility(View.GONE);
- }
- printButton = (Button) findViewById(R.id.btn_print);
- printButton.setOnClickListener(this);
- previewImageView.setZoomControlHandler(mHandler);
- paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch);
- mModelDialog.doShow(DIALOG_LOAD);
- enableShowWarning = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true);
- isRemotePrinter = MyPrinter.isRemotePrinter(this);
- switch (intent.getIntExtra("from", 0)) {
- case 3:
- setTitle(getString(R.string.document_btn_label));
- ((LinearLayout) findViewById(R.id.linearLayout3)).setVisibility(View.GONE);
- break;
- case 4:
- setTitle(getString(R.string.network_storage_title));
- ((LinearLayout) findViewById(R.id.linearLayout3)).setVisibility(View.GONE);
- break;
- default:
- setTitle(getString(R.string.photo_btn_label));
- break;
- }
- mEpsonColorImageView = (ImageView) findViewById(R.id.epsonColorImageView);
- updateEpsonColorStatus();
- paperSourceInfo = PaperSourceInfo.getInstance(this);
- if (mEpsonService == null) {
- bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
- }
- if (bundle == null) {
- startLicenseCheckActivity();
- } else if (!permissionCheck()) {
- finish();
- }
- }
- public static /* synthetic */ void lambda$onCreate$0(ActivityViewImageSelect activityViewImageSelect, Deque deque) {
- String[] checkQueue = activityViewImageSelect.mModelDialog.checkQueue();
- if (checkQueue != null) {
- String str = checkQueue[0];
- String str2 = checkQueue[1];
- if (str2.equals("do_show")) {
- activityViewImageSelect.showDialog(str);
- }
- if (str2.equals("do_dismiss")) {
- activityViewImageSelect.dismissDialog(str);
- }
- }
- }
- private void showStoreDialog() {
- ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG);
- }
- private void observeImageList(PhotoPreviewImageList photoPreviewImageList) {
- PhotoImageConvertViewModel photoImageConvertViewModel = (PhotoImageConvertViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(PhotoImageConvertViewModel.class);
- photoImageConvertViewModel.getData().observe(this, new Observer<PhotoImageConvertViewModel.Result>() {
- public void onChanged(@Nullable PhotoImageConvertViewModel.Result result) {
- if (result.epImageWrappers == null) {
- ActivityViewImageSelect.this.clearListToastAndFinish();
- } else if (!ActivityViewImageSelect.this.setPhotoImageList(result.epImageWrappers)) {
- ActivityViewImageSelect.this.clearListToastAndFinish();
- } else {
- ActivityViewImageSelect.this.updateImageListDisplay();
- boolean unused = ActivityViewImageSelect.mFileCheckEnd = true;
- ActivityViewImageSelect.this.loadImage();
- }
- }
- });
- photoImageConvertViewModel.setOriginalImageList(mImageFilenameListFromIntent);
- }
- private void updateGallery() {
- galleryAdapter.setImageList(this.imageList.getGalleryFileList());
- }
- private boolean checkExternalStorageReadPermission() {
- return ActivityRequestPermissions.checkPermission(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"});
- }
- private void requestReadExternalStoragePermission() {
- ActivityRequestPermissions.requestPermission((Activity) this, new ActivityRequestPermissions.Permission(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}[0], new String[]{getString(R.string.permission_dialog_title), getString(R.string.permission_dialog_title)}, new String[]{ActivityRequestPermissions.DialogParameter.setMessage2((Context) this, getString(R.string.permission_dialog_message_storage)), ActivityRequestPermissions.DialogParameter.setMessage3A((Context) this, getString(R.string.permission_dialog_message_storage), getString(R.string.permission_function_storage))}), 9);
- bRequestPermission = true;
- }
- private boolean setPhotoImageList(@Nullable ArrayList<PhotoPreviewImageList.EpImageWrapper> arrayList) {
- imageList.clear();
- if (arrayList == null) {
- return false;
- }
- Iterator<PhotoPreviewImageList.EpImageWrapper> it = arrayList.iterator();
- while (it.hasNext()) {
- imageList.add(it.next());
- }
- if (this.imageList.size() <= 0) {
- return false;
- }
- return true;
- }
- private void updateImageListDisplay() {
- previewImageView.setImageList(this.imageList);
- TextView textView = pageTextView;
- textView.setText("1/" + imageList.size());
- if (this.imageList.size() == 0) {
- deleteButton.setEnabled(false);
- }
- }
- private void startLicenseCheckActivity() {
- IprintLicenseInfo.beforeLicenseCheck(getApplicationContext());
- startActivityForResult(LicenseTopActivity.getStartIntent(getApplicationContext(), new IprintLicenseInfo(), new IprintUserSurveyInfo()), 10);
- }
- private void setFieldFromStartIntent(@NonNull Intent intent) {
- ArrayList<String> arrayFileFullPath;
- int i = 0;
- isCustomAction = false;
- mImageFilenameListFromIntent.clear();
- mIntentFileType = 0;
- mStartActivityFromPhoto = 1;
- try {
- mPrintLog = (PrintLog) intent.getSerializableExtra("print_log");
- } catch (ClassCastException unused) {
- }
- if (EpsoniPrintSharedActivity.ACTION_PHOTO_PRINT.equals(intent.getAction())) {
- isCustomAction = true;
- SharedParamPhoto sharedParamPhoto = (SharedParamPhoto) intent.getSerializableExtra("extParam");
- if (sharedParamPhoto != null && (arrayFileFullPath = sharedParamPhoto.getArrayFileFullPath()) != null) {
- int i2 = 0;
- while (i < arrayFileFullPath.size()) {
- if (i2 < 30) {
- mImageFilenameListFromIntent.add(arrayFileFullPath.get(i));
- i2++;
- }
- i++;
- }
- if (sharedParamPhoto.isFileTypeValid()) {
- mIntentFileType = sharedParamPhoto.getFile_type();
- }
- mStartActivityFromPhoto = 1;
- } else {
- return;
- }
- } else {
- if (intent.getStringArrayListExtra(LIST_ALBUM) == null && intent.getStringArrayListExtra("imageList") == null && -1 == intent.getIntExtra("from", -1)) {
- new PrintSetting(this, (PrintSetting.Kind) null).resetPrintSettings();
- }
- if (intent.getStringArrayListExtra(LIST_ALBUM) != null) {
- if (intent.getBooleanExtra(CommonDefine.STYPE, false)) {
- mStartActivityFromPhoto = 1;
- intent.removeExtra(CommonDefine.STYPE);
- }
- ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra(LIST_ALBUM);
- if (stringArrayListExtra != null) {
- while (i < stringArrayListExtra.size()) {
- mImageFilenameListFromIntent.add(stringArrayListExtra.get(i));
- i++;
- }
- intent.removeExtra(LIST_ALBUM);
- } else {
- return;
- }
- } else if (intent.getBooleanExtra(PARAMS_KEY_FROM_EPSON, false)) {
- mStartActivityFromPhoto = 1;
- Uri uri = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
- if (uri != null) {
- String decode = Uri.decode(uri.getPath());
- if (decode != null) {
- mImageFilenameListFromIntent.add(decode);
- } else {
- return;
- }
- } else {
- ArrayList<String> stringArrayListExtra2 = intent.getStringArrayListExtra("android.intent.extra.STREAM");
- if (stringArrayListExtra2 != null) {
- while (i < stringArrayListExtra2.size()) {
- mImageFilenameListFromIntent.add(stringArrayListExtra2.get(i));
- i++;
- }
- } else {
- return;
- }
- }
- } else if ("android.intent.action.SEND".equals(intent.getAction())) {
- mStartActivityFromPhoto = 1;
- setPrintLogForExternalApp();
- try {
- Uri uri2 = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
- if (uri2 != null) {
- addImageByIntent(intent, uri2);
- } else {
- return;
- }
- } catch (Exception unused2) {
- return;
- }
- } else if ("android.intent.action.VIEW".equals(intent.getAction())) {
- mStartActivityFromPhoto = 1;
- setPrintLogForExternalApp();
- try {
- addImageByIntent(intent, intent.getData());
- } catch (Exception unused3) {
- }
- } else if ("android.intent.action.SEND_MULTIPLE".equals(intent.getAction())) {
- mStartActivityFromPhoto = 1;
- setPrintLogForExternalApp();
- Bundle extras = intent.getExtras();
- if (extras != null) {
- if (extras.get("android.intent.extra.STREAM") instanceof ArrayList) {
- try {
- ArrayList parcelableArrayListExtra = intent.getParcelableArrayListExtra("android.intent.extra.STREAM");
- if (parcelableArrayListExtra != null) {
- while (i < parcelableArrayListExtra.size() && i < 30) {
- try {
- addImageByIntent(intent, (Uri) parcelableArrayListExtra.get(i));
- i++;
- } catch (Exception unused4) {
- return;
- }
- }
- }
- } catch (Exception unused5) {
- return;
- }
- } else {
- try {
- addImageByIntent(intent, (Uri) intent.getExtras().getParcelable("android.intent.extra.STREAM"));
- } catch (Exception unused6) {
- return;
- }
- }
- } else {
- return;
- }
- } else {
- mStartActivityFromPhoto = 0;
- ArrayList<String> stringArrayListExtra3 = intent.getStringArrayListExtra("imageList");
- if (stringArrayListExtra3 != null) {
- while (i < stringArrayListExtra3.size()) {
- mImageFilenameListFromIntent.add(stringArrayListExtra3.get(i));
- i++;
- }
- } else {
- return;
- }
- }
- }
- if (mPrintLog == null) {
- mPrintLog = new PrintLog();
- }
- }
- private void setPrintLogForExternalApp() {
- if (mPrintLog == null) {
- mPrintLog = new PrintLog();
- }
- if (mPrintLog.callerPackage == null) {
- mPrintLog.callerPackage = getCallingPackage();
- }
- if (mPrintLog.uiRoute <= 0) {
- mPrintLog.uiRoute = 4097;
- }
- }
- private void requestPermissionOrObserveImageList() {
- if (!requestExternalStoragePermissionIfNeeded()) {
- observeImageList(this.imageList);
- }
- }
- private boolean requestExternalStoragePermissionIfNeeded() {
- if (!isPermissionRequestRequired(mImageFilenameListFromIntent)) {
- return false;
- }
- requestReadExternalStoragePermission();
- return true;
- }
- private boolean isPermissionRequestRequired(@NonNull ArrayList<String> arrayList) {
- if (!ActivityRequestPermissions.isRuntimePermissionSupported() || checkExternalStorageReadPermission()) {
- return false;
- }
- String lowerCase = ExternalFileUtils.getInstance(this).getWorkingDir().toLowerCase();
- Iterator<String> it = arrayList.iterator();
- while (it.hasNext()) {
- if (!it.next().toLowerCase().startsWith(lowerCase)) {
- return true;
- }
- }
- return false;
- }
- private void loadImage() {
- if (mFileCheckEnd && mOnSizeChangeReceived && mLicenseCheckDone) {
- galleryAdapter = new GalleryAdapter(getApplicationContext(), imageList.getGalleryFileList());
- gallery.setAdapter(this.galleryAdapter);
- gallery.setSelection(this.imageNo);
- galleryAdapter.setAlignLeft(this.gallery);
- mHandler.sendEmptyMessage(3);
- }
- }
- private void clearListToastAndFinish() {
- Toast.makeText(this, getString(R.string.file_size_notsupport), 1).show();
- imageList.clear();
- onBackPressed();
- }
- public static boolean checkBmpNot24Bit(@NonNull EPImage ePImage) {
- return Utils.checkMimeType(ePImage.loadImageFileName, CommonDefine.IMAGE_TYPE_BMP) && new EPImageUtil().getBitCount(ePImage.loadImageFileName) != 24;
- }
- private void addImageByIntent(Intent intent, Uri uri) {
- String contentFromCR;
- String type = intent.getType();
- String uri2 = uri.toString();
- if (uri2.startsWith("content://")) {
- Cursor cursor = null;
- try {
- cursor = getContentResolver().query(uri, new String[]{"_data"}, (String) null, (String[]) null, (String) null);
- } catch (IllegalArgumentException unused) {
- }
- if (cursor != null) {
- cursor.close();
- } else if (uri.toString().startsWith("content://com.android.gallery3d.provider")) {
- EPLog.m305d(TAG, "Actual URI: " + uri.toString());
- uri = Uri.parse(uri.toString().replace("com.android.gallery3d", "com.google.android.gallery3d"));
- EPLog.m305d(TAG, "Effective URI: " + uri.toString());
- }
- String contentFromCR2 = getContentFromCR(uri, type);
- if (contentFromCR2 != null) {
- mImageFilenameListFromIntent.add(contentFromCR2);
- return;
- }
- String realPathFromURI = getRealPathFromURI(uri);
- if (realPathFromURI != null) {
- mImageFilenameListFromIntent.add(realPathFromURI);
- EPLog.m305d(TAG, "addImageByIntent by getRealPathFromURI");
- return;
- }
- } else if (uri2.startsWith("file://")) {
- if (type == null || type.length() <= 0 || (contentFromCR = getContentFromCR(uri, type)) == null) {
- String path = uri.getPath();
- if (path.startsWith("/file:")) {
- path = path.substring(6);
- }
- if (Utils.isPhotoFile(path)) {
- mImageFilenameListFromIntent.add(path);
- EPLog.m305d(TAG, "addImageByIntent by isPhotoFile()");
- return;
- }
- } else {
- mImageFilenameListFromIntent.add(contentFromCR);
- return;
- }
- }
- clearListToastAndFinish();
- }
- private String getContentFromCR(Uri uri, String str) {
- String str2;
- File file;
- EPLog.m305d(TAG, "getContentFromCR uri = " + uri + " fType = " + str);
- try {
- str2 = Utils.makeTempFileName(str);
- } catch (FileNotFoundException unused) {
- EPLog.m318w(TAG, "getContentFromCR Unknown fType = " + str);
- str2 = String.valueOf(System.currentTimeMillis());
- }
- try {
- InputStream openInputStream = getContentResolver().openInputStream(uri);
- File file2 = new File(ExternalFileUtils.getInstance(this).getTempCRDir(), str2);
- FileOutputStream fileOutputStream = new FileOutputStream(file2);
- byte[] bArr = new byte[1024];
- while (true) {
- int read = openInputStream.read(bArr);
- if (read <= 0) {
- break;
- }
- fileOutputStream.write(bArr, 0, read);
- }
- fileOutputStream.close();
- if (Utils.getExtention(file2.getName()) == null) {
- String realMimeType = Utils.getRealMimeType(file2.getAbsolutePath());
- String mimeExt = realMimeType != null ? Utils.getMimeExt(realMimeType) : null;
- if (mimeExt != null) {
- file = new File(file2.getAbsolutePath() + mimeExt);
- file2.renameTo(file);
- EPLog.m305d(TAG, "getContentFromCR success");
- return file.getAbsolutePath();
- }
- }
- file = file2;
- EPLog.m305d(TAG, "getContentFromCR success");
- return file.getAbsolutePath();
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
- public String getRealPathFromURI(Uri uri) {
- Cursor query = getContentResolver().query(uri, new String[]{"_data"}, (String) null, (String[]) null, (String) null);
- String str = null;
- if (query == null) {
- return null;
- }
- try {
- int columnIndexOrThrow = query.getColumnIndexOrThrow("_data");
- query.moveToFirst();
- str = query.getString(columnIndexOrThrow);
- } catch (Exception e) {
- e.printStackTrace();
- } catch (Throwable th) {
- query.close();
- throw th;
- }
- query.close();
- return str;
- }
- public static boolean checkEPImage(EPImage ePImage) {
- return ePImage != null && ePImage.srcWidth > 0 && ePImage.srcHeight > 0;
- }
- protected boolean getEpsonColorModeFromIntent(Intent intent) {
- return intent.getBooleanExtra(PARAMS_KEY_EPSON_COLOR_MODE, false);
- }
- private String getPaperSizeName() {
- MediaInfo.PaperSize paperSize = new MediaInfo.PaperSize();
- PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- return getString(paperSize.getStringId(printSetting.paperSizeValue));
- }
- private boolean permissionCheck() {
- if (!IprintLicenseInfo.isAgreedCurrentVersion(getApplicationContext())) {
- return false;
- }
- mLicenseCheckDone = true;
- requestPermissionOrObserveImageList();
- return true;
- }
- protected void onActivityResult(int i, int i2, Intent intent) {
- super.onActivityResult(i, i2, intent);
- switch (i) {
- case 5:
- if (i2 == -1) {
- SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
- String string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
- if (!string.equals(this.currentPrinterName)) {
- currentPrinterName = string;
- printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
- updateEpsonColorStatus();
- bAutoStartPrint = true;
- mHandler.sendEmptyMessage(3);
- return;
- }
- onClick(this.printButton);
- EPLog.m305d(TAG, "onClick(printButton)");
- return;
- }
- return;
- case 9:
- if (i2 != -1) {
- clearListToastAndFinish();
- return;
- } else {
- requestPermissionOrObserveImageList();
- return;
- }
- case 10:
- if (!permissionCheck()) {
- mModelDialog.doDismiss(DIALOG_LOAD);
- finish();
- return;
- }
- return;
- case CommonDefine.REQUEST_SETTING /*254*/:
- onPrintSettingEnd(i2);
- return;
- case 255:
- unlockScreenRotation();
- if (i2 == 0) {
- setResult(i2);
- if (this.isCustomAction) {
- setResult(0);
- finish();
- return;
- }
- } else if (i2 != 4) {
- if (i2 == 1000) {
- printButton.setEnabled(true);
- ExternalFileUtils.getInstance(this).initPrintDir();
- return;
- }
- return;
- }
- mReviewInvitationViewModel.onPrintEnd(PrintProgress.isPrintSuccess(i2));
- if (this.isCustomAction) {
- setResult(-1);
- finish();
- return;
- }
- printButton.setEnabled(true);
- ExternalFileUtils.getInstance(this).initPrintDir();
- return;
- default:
- return;
- }
- }
- private void onPrintSettingEnd(int i) {
- int i2;
- boolean z;
- int i3;
- int i4;
- int i5;
- int i6;
- int i7;
- boolean z2;
- if (i == 3) {
- printButton.setEnabled(true);
- SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
- String string = getString(R.string.str_lbl_title_scan);
- printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
- int i8 = 2;
- if (sharedPreferences != null) {
- string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
- PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- i7 = printSetting.paperSizeValue;
- i8 = printSetting.layoutValue;
- i6 = printSetting.layoutMultiPageValue;
- i5 = printSetting.colorValue;
- i4 = printSetting.photoApfValueForLocalPrinter;
- i3 = printSetting.sharpnessForPhoto;
- int i9 = printSetting.paperTypeValue;
- int code = Constants.MediaName.EPS_MTID_PLAIN.getCode();
- EpLog.m77i("KIND = " + printSetting.getKind() + " NEW setteing = " + i9 + " plain = " + code);
- i2 = (i9 == code && printSetting.getKind() == PrintSetting.Kind.photo) ? 1 : 0;
- z = MyPrinter.isRemotePrinter(this);
- } else {
- i2 = 0;
- i7 = 0;
- i6 = 0;
- i5 = 0;
- i4 = 0;
- i3 = 0;
- z = false;
- }
- if (!this.currentPrinterName.equalsIgnoreCase(string)) {
- currentPrinterName = string;
- z2 = true;
- } else {
- z2 = false;
- }
- if (this.currentLayout != i8) {
- currentLayout = i8;
- previewImageView.setLayout(this.currentLayout, currentLayoutMulti);
- z2 = true;
- }
- if (this.currentLayoutMulti != i6) {
- currentLayoutMulti = i6;
- previewImageView.setLayout(this.currentLayout, currentLayoutMulti);
- z2 = true;
- }
- if (this.currentPaperSize != i7) {
- currentPaperSize = i7;
- previewImageView.setPaper(i7);
- papersizeTextView.setText(getString(new MediaInfo.PaperSize().getStringId(i7)));
- z2 = true;
- }
- if (this.currentColor != i5) {
- currentColor = i5;
- previewImageView.setColor(this.currentColor);
- z2 = true;
- }
- if (this.imageList.size() == 0) {
- printButton.setEnabled(false);
- }
- if (this.isRemotePrinter != z) {
- isRemotePrinter = z;
- z2 = true;
- }
- if (!z) {
- if (this.previewImageView.getApfMode() != i4) {
- z2 = true;
- }
- if (this.previewImageView.getSharpnessValue() != i3) {
- z2 = true;
- }
- if (this.previewImageView.getClearlyVividMode() != i2) {
- z2 = true;
- }
- }
- updateEpsonColorStatus();
- if (z2) {
- mHandler.sendEmptyMessage(3);
- }
- }
- }
- private boolean isEpsonColorMode() {
- boolean z = false;
- if (!mEnableEpsonColorDisplay) {
- return false;
- }
- PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- int apfValue = getApfValue(printSetting);
- int i = printSetting.paperTypeValue;
- int i2 = printSetting.colorValue;
- if (apfValue == 1) {
- z = true;
- }
- return ApfAdapter.isEpsonColor(this, i, i2, z);
- }
- private void updateEpsonColorStatus() {
- mEpsonColorImageView.setVisibility(isEpsonColorMode() ? 0 : 8);
- }
- protected void onResume() {
- EPLog.m305d("ActivityImageViewSelect", "onResume");
- super.onResume();
- NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
- paperMissmath.setVisibility(View.GONE);
- paperSourceInfo.start(this, mHandler);
- }
- protected void onNewIntent(Intent intent) {
- NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
- super.onNewIntent(intent);
- String action = intent.getAction();
- if (this.reloadTask != null) {
- switch (C211111.$SwitchMap$android$os$AsyncTask$Status[this.reloadTask.getStatus().ordinal()]) {
- case 1:
- case 2:
- if ("android.nfc.action.NDEF_DISCOVERED".equals(action) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
- Intent intent2 = new Intent();
- intent2.setClass(this, ActivityNfcPrinter.class);
- intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
- intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 1);
- startActivityForResult(intent2, 5);
- return;
- }
- return;
- default:
- return;
- }
- }
- }
- /* renamed from: epson.print.ActivityViewImageSelect$11 */
- static /* synthetic */ class C211111 {
- static final /* synthetic */ int[] $SwitchMap$android$os$AsyncTask$Status = new int[AsyncTask.Status.values().length];
- /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|6) */
- /* JADX WARNING: Code restructure failed: missing block: B:7:?, code lost:
- return;
- */
- /* JADX WARNING: Failed to process nested try/catch */
- /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
- static {
- /*
- android.os.AsyncTask$Status[] r0 = android.os.AsyncTask.Status.values()
- int r0 = r0.length
- int[] r0 = new int[r0]
- $SwitchMap$android$os$AsyncTask$Status = r0
- int[] r0 = $SwitchMap$android$os$AsyncTask$Status // Catch:{ NoSuchFieldError -> 0x0014 }
- android.os.AsyncTask$Status r1 = android.os.AsyncTask.Status.PENDING // Catch:{ NoSuchFieldError -> 0x0014 }
- int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x0014 }
- r2 = 1
- r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x0014 }
- L_0x0014:
- int[] r0 = $SwitchMap$android$os$AsyncTask$Status // Catch:{ NoSuchFieldError -> 0x001f }
- android.os.AsyncTask$Status r1 = android.os.AsyncTask.Status.FINISHED // Catch:{ NoSuchFieldError -> 0x001f }
- int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x001f }
- r2 = 2
- r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x001f }
- L_0x001f:
- return
- */
- throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityViewImageSelect.C211111.<clinit>():void");
- }
- }
- protected void onDestroy() {
- EPLog.m305d("ActivityImageViewSelect", "onDestroy");
- super.onDestroy();
- }
- @MainThread
- private void localUnbindService() {
- IEpsonService iEpsonService = mEpsonService;
- if (iEpsonService != null) {
- try {
- iEpsonService.cancelSearchPrinter();
- mEpsonService.unregisterCallback(mCallback);
- unbindService(mEpsonConnection);
- } catch (RemoteException unused) {
- }
- }
- }
- protected void onPause() {
- EPLog.m305d("ActivityImageViewSelect", "onPause");
- super.onPause();
- NfcTagUtils.disableForegroundDispatch(this);
- paperSourceInfo.stop();
- if (isFinishing()) {
- localUnbindService();
- ApfPreviewView.deleteWorkingDirectory(this);
- PhotoImageConvertViewModel.clearTempDirectory(this);
- }
- }
- protected void onRestart() {
- EPLog.m305d("ActivityImageViewSelect", "onRestart");
- super.onRestart();
- }
- public void onBackPressed() {
- if (mStartActivityFromPhoto == 0) {
- Intent intent = new Intent();
- intent.putStringArrayListExtra("imageList", imageList.getArgumentFileList());
- setResult(18, intent);
- } else if (this.isPrintedOK) {
- setResult(-1);
- } else {
- setResult(0);
- }
- finish();
- }
- private void check3GAndStartPrint() {
- mHandler.sendEmptyMessage(5);
- }
- private void showSimpleDialog(int i) {
- SimpleMessageDialogFragment.newInstance(i).show(getSupportFragmentManager(), "simple-dialog");
- }
- private void unlockScreenRotation() {
- setRequestedOrientation(-1);
- }
- private void startPrint() {
- printButton.setEnabled(false);
- OsAssistant.lockScreenRotation(this);
- ExternalFileUtils.getInstance(this).initPrintDir();
- if (this.isRemotePrinter) {
- SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
- edit.putInt(epson.common.Constants.SOURCE_TYPE, 2);
- edit.commit();
- }
- PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- EPImageList imageList2 = previewImageView.getImageList();
- imageList2.apfModeInPrinting = getApfValue(printSetting);
- imageList2.setSharpness(getSharpnessValue(printSetting));
- imageList2.setClearlyVivid(getClearlyVividValue(printSetting));
- imageList2.setMultifileMode(true);
- if (mPrintLog == null) {
- mPrintLog = new PrintLog();
- }
- mPrintLog.previewType = 1;
- startActivityForResult(PrintProgress.getPrintIntent(this, imageList2, false, isEpsonColorMode(), mPrintLog), 255);
- }
- private void addPhotos() {
- PhotoImageSelectActivity.startAddImageSelect(this, imageList.getArgumentFileList());
- }
- public void onClick(View view) {
- switch (view.getId()) {
- case R.id.bt_rotate /*2131230858*/:
- if (this.isPaperLandscape) {
- isPaperLandscape = false;
- } else {
- isPaperLandscape = true;
- }
- if (this.currentLayout != 4) {
- new PaperDirectionRotateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
- return;
- }
- return;
- case R.id.btn_add_photo /*2131230867*/:
- if (this.imageList.size() == 30) {
- new AlertDialog.Builder(this).setMessage(getString(R.string.max_image)).setNegativeButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- }).create().show();
- return;
- }
- addPhotos();
- finish();
- return;
- case R.id.btn_deselect /*2131230869*/:
- removeCurrentImage();
- return;
- case R.id.btn_paper_size /*2131230874*/:
- if (this.aPaperSourceSetting != null) {
- Intent intent = new Intent();
- intent.setClass(this, PaperSourceSettingScr.class);
- intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, aPaperSourceSetting);
- intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.photo.name());
- startActivityForResult(intent, CommonDefine.REQUEST_SETTING);
- return;
- }
- callPrintSetting();
- return;
- case R.id.btn_print /*2131230877*/:
- isRemotePrinter = MyPrinter.isRemotePrinter(this);
- if (this.isRemotePrinter && enableShowWarning) {
- AlertDialog.Builder cancelable = new AlertDialog.Builder(this.context).setCancelable(false);
- cancelable.setMessage(getString(R.string.epsonconnect_str_remote_print_warning) + "\n\n" + getString(R.string.epsonconnect_str_remote_print_warning2)).setPositiveButton(getString(R.string.str_yes), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- ActivityViewImageSelect.this.check3GAndStartPrint();
- }
- }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- }).show();
- return;
- } else if (this.currentPrinterName.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
- new AlertDialog.Builder(this.context).setCancelable(false).setTitle(R.string.printer_not_select).setMessage(getString(R.string.printer_notselect_warning)).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- }).show();
- return;
- } else {
- check3GAndStartPrint();
- return;
- }
- default:
- return;
- }
- }
- protected void adjustImageNo() {
- if (this.imageNo >= imageList.size()) {
- imageNo = imageList.size() - 1;
- }
- if (this.imageNo < 0) {
- imageNo = 0;
- }
- }
- protected void removeCurrentImage() {
- previewImageView.invalidateImageNo();
- int i = imageNo;
- if (i >= 0 && i < imageList.size()) {
- imageList.remove(this.imageNo);
- imageNo--;
- }
- updateGallery();
- adjustImageNo();
- new PreviewImageSelectTask().executeOnExecutor(new Void[0]);
- }
- protected void updateScreen() {
- if (this.imageList.size() < 30) {
- addButton.setEnabled(true);
- addButton.setImageResource(R.drawable.plus);
- }
- if (this.imageList.size() > 0) {
- TextView textView = pageTextView;
- textView.setText((this.imageNo + 1) + CommonDefine.SLASH + imageList.size());
- gallery.setSelection(this.imageNo);
- } else {
- deleteButton.setEnabled(false);
- printButton.setEnabled(false);
- pageTextView.setText("0/0");
- }
- if (this.previewImageView.getIsPaperLandscape()) {
- isPaperLandscape = true;
- } else {
- isPaperLandscape = false;
- }
- Handler handler = mHandler;
- if (handler != null) {
- handler.sendEmptyMessage(2);
- }
- }
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- if (menuItem.getItemId() == R.id.Menu_Show_PrintSettings) {
- callPrintSetting();
- }
- return super.onOptionsItemSelected(menuItem);
- }
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- getMenuInflater().inflate(R.menu.print_menu, menu);
- return true;
- }
- public void callPrintSetting() {
- System.gc();
- SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
- edit.putInt(epson.common.Constants.SOURCE_TYPE, 2);
- edit.commit();
- startActivityForResult(new Intent(this, SettingScr.class), CommonDefine.REQUEST_SETTING);
- }
- public boolean onKeyDown(int i, KeyEvent keyEvent) {
- if (keyEvent.getAction() == 0 && i == 84) {
- EPLog.m307e("key search", "diable");
- return true;
- } else if (keyEvent.getAction() != 0 || i != 4) {
- return false;
- } else {
- onBackPressed();
- return true;
- }
- }
- public void onConfigurationChanged(Configuration configuration) {
- super.onConfigurationChanged(configuration);
- }
- protected int getApfValue(PrintSetting printSetting) {
- if (!this.isRemotePrinter) {
- return printSetting.photoApfValueForLocalPrinter;
- }
- return 0;
- }
- protected int getSharpnessValue(PrintSetting printSetting) {
- if (!this.isRemotePrinter) {
- return printSetting.sharpnessForPhoto;
- }
- return 0;
- }
- protected int getClearlyVividValue(PrintSetting printSetting) {
- if (!this.isRemotePrinter) {
- int i = printSetting.paperTypeValue;
- int code = Constants.MediaName.EPS_MTID_PLAIN.getCode();
- EpLog.m77i("setteing = " + i + "plain = " + code);
- return (i == code && printSetting.getKind() == PrintSetting.Kind.photo) ? 1 : 0;
- }
- }
- public void onViewSizeChanged() {
- EPLog.m305d(TAG, "onViewSizeChanged()");
- if (isFinishing()) {
- EPLog.m305d(TAG, "onViewSizeChanged() isFinishing == true");
- return;
- }
- mOnSizeChangeReceived = true;
- loadImage();
- }
- public void invitationDialogClicked(boolean z) {
- mReviewInvitationViewModel.setStartStoreEnd();
- }
- protected boolean executeAllReloadTaskAgain() {
- synchronized (mAllReloadTaskLock) {
- if (!mIsAllReloadTaskRetryAcceptable) {
- return false;
- }
- mAllReloadTaskRetryRequested = true;
- return true;
- }
- }
- protected boolean lastCheckAllReloadTaskRetryRequest() {
- synchronized (mAllReloadTaskLock) {
- if (mAllReloadTaskRetryRequested) {
- return true;
- }
- mIsAllReloadTaskRetryAcceptable = false;
- return false;
- }
- }
- /* JADX WARNING: Removed duplicated region for block: B:18:0x003a */
- /* JADX WARNING: Removed duplicated region for block: B:19:0x003c */
- /* JADX WARNING: Removed duplicated region for block: B:20:0x0045 */
- /* JADX WARNING: Removed duplicated region for block: B:21:0x004e */
- /* JADX WARNING: Removed duplicated region for block: B:23:0x0058 */
- /* JADX WARNING: Removed duplicated region for block: B:25:? A[RETURN, SYNTHETIC] */
- /* Code decompiled incorrectly, please refer to instructions dump. */
- private void showDialog(String r4) {
- /*
- r3 = this;
- int r0 = r4.hashCode()
- r1 = -2144563074(0xffffffff802c907e, float:-4.092596E-39)
- r2 = 0
- if (r0 == r1) goto L_0x0029
- r1 = -21731516(0xfffffffffeb46744, float:-1.1989861E38)
- if (r0 == r1) goto L_0x001f
- r1 = 23498109(0x1668d7d, float:4.234584E-38)
- if (r0 == r1) goto L_0x0015
- goto L_0x0033
- L_0x0015:
- java.lang.String r0 = "dialog_load"
- boolean r0 = r4.equals(r0)
- if (r0 == 0) goto L_0x0033
- r0 = 1
- goto L_0x0034
- L_0x001f:
- java.lang.String r0 = "dialog_progress"
- boolean r0 = r4.equals(r0)
- if (r0 == 0) goto L_0x0033
- r0 = 0
- goto L_0x0034
- L_0x0029:
- java.lang.String r0 = "dialog_all_update"
- boolean r0 = r4.equals(r0)
- if (r0 == 0) goto L_0x0033
- r0 = 2
- goto L_0x0034
- L_0x0033:
- r0 = -1
- L_0x0034:
- r1 = 2131625177(0x7f0e04d9, float:1.8877555E38)
- switch(r0) {
- case 0: goto L_0x004e;
- case 1: goto L_0x0045;
- case 2: goto L_0x003c;
- default: goto L_0x003a;
- }
- L_0x003a:
- r0 = 0
- goto L_0x0056
- L_0x003c:
- java.lang.String r0 = r3.getString(r1)
- epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r2, r0)
- goto L_0x0056
- L_0x0045:
- java.lang.String r0 = r3.getString(r1)
- epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r2, r0)
- goto L_0x0056
- L_0x004e:
- java.lang.String r0 = r3.getString(r1)
- epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r2, r0)
- L_0x0056:
- if (r0 == 0) goto L_0x0062
- r0.setCancelable(r2)
- android.support.v4.app.FragmentManager r1 = r3.getSupportFragmentManager()
- r0.show(r1, r4)
- L_0x0062:
- return
- */
- throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityViewImageSelect.showDialog(java.lang.String):void");
- }
- private void dismissDialog(String str) {
- DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
- if (dialogFragment != null) {
- dialogFragment.dismiss();
- }
- }
- private class AllReloadTask extends AsyncTaskExecutor<Void, Integer, Boolean> {
- private Context context = null;
- private volatile boolean endRedraw = false;
- private boolean firstDraw = true;
- Handler handler = new Handler(new Handler.Callback() {
- public boolean handleMessage(Message message) {
- if (message.what == 4) {
- EPLog.m313i(ActivityViewImageSelect.TAG, "handleMessage(): msg.arg1 = " + message.arg1 + ", index = " + AllReloadTask.this.index);
- if (AllReloadTask.this.firstDraw) {
- boolean unused = AllReloadTask.this.firstDraw = false;
- }
- boolean unused2 = AllReloadTask.this.endRedraw = true;
- }
- return true;
- }
- });
- private int index = 0;
- private boolean mDeletePreview;
- public AllReloadTask(Context context2) {
- context = context2;
- }
- public AsyncTask<Void, Integer, Boolean> executeOnExecutor(Void... voidArr) {
- if (ActivityViewImageSelect.this.executeAllReloadTaskAgain()) {
- return null;
- }
- ActivityViewImageSelect.mIsAllReloadTaskRetryAcceptable = true;
- return super.executeOnExecutor(voidArr);
- }
- protected void onPreExecute() {
- ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_ALL_UPDATE);
- ActivityViewImageSelect.this.imageList.clearExceptSrcFileName();
- ActivityViewImageSelect.this.previewImageView.setDrawEndHandler(this.handler);
- }
- protected Boolean doInBackground(Void... voidArr) {
- System.gc();
- int i = 0;
- do {
- try {
- if (ActivityViewImageSelect.mEpsonService != null) {
- break;
- }
- Thread.sleep(100);
- i++;
- } catch (RemoteException e) {
- e.printStackTrace();
- } catch (InterruptedException e2) {
- e2.printStackTrace();
- }
- } while (i < 100);
- if (ActivityViewImageSelect.mEpsonService != null) {
- if (ActivityViewImageSelect.this.isRemotePrinter) {
- ActivityViewImageSelect.mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.photo.name());
- } else {
- ActivityViewImageSelect.mEpsonService.updatePrinterSettings(PrintSetting.Kind.photo.name());
- }
- }
- PrintSetting printSetting = new PrintSetting(ActivityViewImageSelect.this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- int unused = ActivityViewImageSelect.this.currentPaperSize = printSetting.paperSizeValue;
- int unused2 = ActivityViewImageSelect.this.currentLayout = printSetting.layoutValue;
- int unused3 = ActivityViewImageSelect.this.currentLayoutMulti = printSetting.layoutMultiPageValue;
- int unused4 = ActivityViewImageSelect.this.currentColor = printSetting.colorValue;
- ActivityViewImageSelect.this.previewImageView.setLayout(ActivityViewImageSelect.this.currentLayout, ActivityViewImageSelect.this.currentLayoutMulti);
- ActivityViewImageSelect.this.previewImageView.setPaper(ActivityViewImageSelect.this.currentPaperSize);
- ActivityViewImageSelect.this.previewImageView.setColor(ActivityViewImageSelect.this.currentColor);
- ActivityViewImageSelect.this.previewImageView.setApfLibParams(ActivityViewImageSelect.this.getApfValue(printSetting), ActivityViewImageSelect.this.getSharpnessValue(printSetting), ActivityViewImageSelect.this.getClearlyVividValue(printSetting));
- ActivityViewImageSelect.mHandler.sendEmptyMessage(6);
- do {
- boolean unused5 = ActivityViewImageSelect.mAllReloadTaskRetryRequested = false;
- ActivityViewImageSelect.this.previewImageView.setPaper(ActivityViewImageSelect.this.currentPaperSize);
- updatePreviewImage();
- } while (ActivityViewImageSelect.this.lastCheckAllReloadTaskRetryRequest());
- boolean unused6 = ActivityViewImageSelect.mAllReloadTaskDone = true;
- return true;
- }
- private void updatePreviewImage() {
- ActivityViewImageSelect.this.previewImageView.invalidateImageNo();
- ActivityViewImageSelect.this.previewImageView.invalidatePreview();
- index = 0;
- while (this.index < ActivityViewImageSelect.this.imageList.size()) {
- EPLog.m313i(ActivityViewImageSelect.TAG, "doInBack Start -> " + index);
- while (!ActivityViewImageSelect.mAllReloadTaskRetryRequested) {
- try {
- if (ActivityViewImageSelect.this.previewImageView.setImage(this.index, 2, ActivityViewImageSelect.this)) {
- endRedraw = false;
- publishProgress(new Integer[]{Integer.valueOf(this.index + 1)});
- int i = 0;
- while (true) {
- if (this.endRedraw) {
- break;
- }
- Thread.sleep(100, 0);
- i++;
- if (i >= 50) {
- break;
- }
- }
- EPLog.m313i(ActivityViewImageSelect.TAG, "doInBack End -> " + index);
- index++;
- } else {
- Thread.sleep(300);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (OutOfMemoryError unused) {
- ActivityViewImageSelect.this.imageList.remove(this.index);
- index--;
- mDeletePreview = true;
- if (ActivityViewImageSelect.mAllReloadTaskDone) {
- ActivityViewImageSelect.mHandler.sendEmptyMessage(8);
- int unused2 = ActivityViewImageSelect.this.imageNo = 0;
- } else {
- ActivityViewImageSelect.mHandler.sendEmptyMessage(7);
- }
- }
- }
- return;
- }
- if (ActivityViewImageSelect.this.imageList.size() > 0) {
- showCurrentImage();
- return;
- }
- try {
- ActivityViewImageSelect.this.previewImageView.setImage(0, 2, ActivityViewImageSelect.this);
- } catch (OutOfMemoryError unused3) {
- }
- }
- private void showCurrentImage() {
- boolean z = false;
- while (true) {
- try {
- ActivityViewImageSelect.this.previewImageView.setImage(ActivityViewImageSelect.this.imageNo, 0, ActivityViewImageSelect.this);
- return;
- } catch (OutOfMemoryError unused) {
- if (!z) {
- ActivityViewImageSelect.mHandler.sendEmptyMessage(8);
- }
- z = true;
- if (ActivityViewImageSelect.this.imageList.size() > 0) {
- if (ActivityViewImageSelect.this.imageNo >= 0 && ActivityViewImageSelect.this.imageNo < ActivityViewImageSelect.this.imageList.size()) {
- ActivityViewImageSelect.this.imageList.remove(ActivityViewImageSelect.this.imageNo);
- }
- int unused2 = ActivityViewImageSelect.this.imageNo = 0;
- } else {
- return;
- }
- }
- }
- }
- private boolean testCheckStatus() {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return ActivityViewImageSelect.mAllReloadTaskRetryRequested;
- }
- protected void onProgressUpdate(Integer... numArr) {
- ActivityViewImageSelect.this.previewImageView.invalidate();
- TextView access$1900 = ActivityViewImageSelect.this.pageTextView;
- access$1900.setText(numArr[0] + CommonDefine.SLASH + ActivityViewImageSelect.this.imageList.size());
- if (ActivityViewImageSelect.this.previewImageView.getIsPaperLandscape()) {
- boolean unused = ActivityViewImageSelect.this.isPaperLandscape = true;
- } else {
- boolean unused2 = ActivityViewImageSelect.this.isPaperLandscape = false;
- }
- }
- protected void onPostExecute(Boolean bool) {
- if (!ActivityViewImageSelect.this.isFinishing()) {
- if (mDeletePreview) {
- ActivityViewImageSelect.this.updateGallery();
- }
- ActivityViewImageSelect.this.previewImageView.invalidate();
- ActivityViewImageSelect.this.updateScreen();
- ActivityViewImageSelect.this.previewImageView.setDrawEndHandler((Handler) null);
- ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_ALL_UPDATE);
- if (ActivityViewImageSelect.this.bAutoStartPrint) {
- ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
- activityViewImageSelect.onClick(activityViewImageSelect.printButton);
- EPLog.m305d(ActivityViewImageSelect.TAG, "onClick(printButton)");
- ActivityViewImageSelect.this.bAutoStartPrint = false;
- }
- }
- }
- }
- private class PreviewImageSelectTask extends AsyncTaskExecutor<Void, Void, Void> {
- private boolean mError;
- private PreviewImageSelectTask() {
- }
- protected Void doInBackground(Void... voidArr) {
- boolean z = false;
- while (true) {
- try {
- ActivityViewImageSelect.this.previewImageView.setImage(ActivityViewImageSelect.this.imageNo, 0, ActivityViewImageSelect.this);
- return null;
- } catch (OutOfMemoryError unused) {
- mError = true;
- if (!z) {
- ActivityViewImageSelect.mHandler.sendEmptyMessage(8);
- }
- if (ActivityViewImageSelect.this.imageList.size() <= 0) {
- return null;
- }
- if (ActivityViewImageSelect.this.imageNo >= 0 && ActivityViewImageSelect.this.imageNo < ActivityViewImageSelect.this.imageList.size()) {
- ActivityViewImageSelect.this.imageList.remove(ActivityViewImageSelect.this.imageNo);
- }
- int unused2 = ActivityViewImageSelect.this.imageNo = 0;
- z = true;
- }
- }
- }
- protected void onPreExecute() {
- ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_PROGRESS);
- }
- protected void onPostExecute(Void voidR) {
- if (!ActivityViewImageSelect.this.isFinishing()) {
- if (mError) {
- ActivityViewImageSelect.this.updateGallery();
- }
- ActivityViewImageSelect.this.previewImageView.invalidate();
- ActivityViewImageSelect.this.updateScreen();
- ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_PROGRESS);
- }
- }
- }
- private class PaperDirectionRotateTask extends AsyncTask<Void, Void, Void> {
- private PaperDirectionRotateTask() {
- }
- protected void onPreExecute() {
- ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_PROGRESS);
- }
- protected void onPostExecute(Void voidR) {
- if (!ActivityViewImageSelect.this.isFinishing()) {
- ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_PROGRESS);
- }
- }
- protected Void doInBackground(Void... voidArr) {
- ActivityViewImageSelect.this.previewImageView.setIsPaperLandscape(ActivityViewImageSelect.this.isPaperLandscape, ActivityViewImageSelect.this);
- return null;
- }
- }
- }
|