123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620 |
- package epson.print;
- import android.app.Activity;
- import android.app.AlertDialog;
- 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.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 androidx.annotation.MainThread;
- import androidx.annotation.NonNull;
- import androidx.annotation.Nullable;
- import androidx.fragment.app.DialogFragment;
- import androidx.fragment.app.FragmentActivity;
- import androidx.lifecycle.Observer;
- import androidx.lifecycle.ViewModelProviders;
- 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.ReviewInvitationDialog;
- import com.epson.mobilephone.common.ReviewInvitationViewModel;
- 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 {
- mEpsonService.unregisterCallback(mCallback);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- IEpsonService unused = mEpsonService = null;
- }
- public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
- IEpsonService unused = mEpsonService = IEpsonService.Stub.asInterface(iBinder);
- if (mEpsonService != null) {
- try {
- mEpsonService.registerCallback(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 (isFinishing()) {
- return true;
- }
- int i = message.what;
- if (i != 100) {
- switch (i) {
- case 0:
- mModelDialog.doShow(DIALOG_LOAD);
- break;
- case 1:
- mModelDialog.doDismiss(DIALOG_LOAD);
- break;
- case 2:
- break;
- case 3:
- ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
- AllReloadTask unused = reloadTask = new AllReloadTask(context);
- if (reloadTask != null) {
- reloadTask.executeOnExecutor(new Void[0]);
- }
- mHandler.sendEmptyMessageDelayed(1, 300);
- break;
- default:
- switch (i) {
- case 5:
- startPrint();
- break;
- case 6:
- papersizeTextView.setText(getString(new MediaInfo.PaperSize().getStringId(currentPaperSize)));
- break;
- case 7:
- if (imageList.size() <= 0) {
- deleteButton.setEnabled(false);
- printButton.setEnabled(false);
- int unused2 = imageNo = 0;
- }
- TextView access$1900 = pageTextView;
- access$1900.setText(imageNo + CommonDefine.SLASH + imageList.size());
- updateGallery();
- previewImageView.invalidate();
- Toast.makeText(context, context.getString(R.string.file_size_notsupport), 1).show();
- break;
- case 8:
- showSimpleDialog(R.string.str_err_msg_out_of_memory_title);
- return true;
- }
- }
- } else {
- ArrayList unused3 = aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
- if (aPaperSourceSetting != null) {
- papersizeTextView.setBackgroundColor(getResources().getColor(R.color.epson_blue));
- papersizeTextView.setTextColor(getResources().getColor(R.color.all_white));
- PrintSetting printSetting = new PrintSetting(ActivityViewImageSelect.this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- if (paperSourceInfo.checkPaperMissmatch(printSetting, aPaperSourceSetting)) {
- paperMissmath.setVisibility(View.VISIBLE);
- } else {
- paperMissmath.setVisibility(View.GONE);
- }
- } else {
- papersizeTextView.setBackgroundColor(getResources().getColor(R.color.all_white));
- papersizeTextView.setTextColor(getResources().getColor(R.color.epson_blue));
- 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()) {
- 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) {
- 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(currentLayout, currentLayoutMulti);
- previewImageView.setPaper(currentPaperSize);
- previewImageView.setColor(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 (imageNo != i) {
- int unused = imageNo = i;
- gallery.setSelection(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 = mModelDialog.checkQueue();
- if (checkQueue != null) {
- String str = checkQueue[0];
- String str2 = checkQueue[1];
- if (str2.equals("do_show")) {
- showDialog(str);
- }
- if (str2.equals("do_dismiss")) {
- 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) {
- clearListToastAndFinish();
- } else if (!setPhotoImageList(result.epImageWrappers)) {
- clearListToastAndFinish();
- } else {
- updateImageListDisplay();
- boolean unused = mFileCheckEnd = true;
- loadImage();
- }
- }
- });
- photoImageConvertViewModel.setOriginalImageList(mImageFilenameListFromIntent);
- }
- private void updateGallery() {
- galleryAdapter.setImageList(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 (imageList.size() <= 0) {
- return false;
- }
- return true;
- }
- private void updateImageListDisplay() {
- previewImageView.setImageList(imageList);
- TextView textView = pageTextView;
- textView.setText("1/" + imageList.size());
- if (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(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(galleryAdapter);
- gallery.setSelection(imageNo);
- galleryAdapter.setAlignLeft(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.d(TAG, "Actual URI: " + uri.toString());
- uri = Uri.parse(uri.toString().replace("com.android.gallery3d", "com.google.android.gallery3d"));
- EPLog.d(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.d(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.d(TAG, "addImageByIntent by isPhotoFile()");
- return;
- }
- } else {
- mImageFilenameListFromIntent.add(contentFromCR);
- return;
- }
- }
- clearListToastAndFinish();
- }
- private String getContentFromCR(Uri uri, String str) {
- String str2;
- File file;
- EPLog.d(TAG, "getContentFromCR uri = " + uri + " fType = " + str);
- try {
- str2 = Utils.makeTempFileName(str);
- } catch (FileNotFoundException unused) {
- EPLog.w(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.d(TAG, "getContentFromCR success");
- return file.getAbsolutePath();
- }
- }
- file = file2;
- EPLog.d(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(currentPrinterName)) {
- currentPrinterName = string;
- printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
- updateEpsonColorStatus();
- bAutoStartPrint = true;
- mHandler.sendEmptyMessage(3);
- return;
- }
- onClick(printButton);
- EPLog.d(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 (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 (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.i("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 (!currentPrinterName.equalsIgnoreCase(string)) {
- currentPrinterName = string;
- z2 = true;
- } else {
- z2 = false;
- }
- if (currentLayout != i8) {
- currentLayout = i8;
- previewImageView.setLayout(currentLayout, currentLayoutMulti);
- z2 = true;
- }
- if (currentLayoutMulti != i6) {
- currentLayoutMulti = i6;
- previewImageView.setLayout(currentLayout, currentLayoutMulti);
- z2 = true;
- }
- if (currentPaperSize != i7) {
- currentPaperSize = i7;
- previewImageView.setPaper(i7);
- papersizeTextView.setText(getString(new MediaInfo.PaperSize().getStringId(i7)));
- z2 = true;
- }
- if (currentColor != i5) {
- currentColor = i5;
- previewImageView.setColor(currentColor);
- z2 = true;
- }
- if (imageList.size() == 0) {
- printButton.setEnabled(false);
- }
- if (isRemotePrinter != z) {
- isRemotePrinter = z;
- z2 = true;
- }
- if (!z) {
- if (previewImageView.getApfMode() != i4) {
- z2 = true;
- }
- if (previewImageView.getSharpnessValue() != i3) {
- z2 = true;
- }
- if (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.d("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 (reloadTask != null) {
- switch (C211111.$SwitchMap$android$os$AsyncTask$Status[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.C211111.<clinit>():void");
- }
- }
- protected void onDestroy() {
- EPLog.d("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.d("ActivityImageViewSelect", "onPause");
- super.onPause();
- NfcTagUtils.disableForegroundDispatch(this);
- paperSourceInfo.stop();
- if (isFinishing()) {
- localUnbindService();
- ApfPreviewView.deleteWorkingDirectory(this);
- PhotoImageConvertViewModel.clearTempDirectory(this);
- }
- }
- protected void onRestart() {
- EPLog.d("ActivityImageViewSelect", "onRestart");
- super.onRestart();
- }
- public void onBackPressed() {
- if (mStartActivityFromPhoto == 0) {
- Intent intent = new Intent();
- intent.putStringArrayListExtra("imageList", imageList.getArgumentFileList());
- setResult(18, intent);
- } else if (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 (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 (isPaperLandscape) {
- isPaperLandscape = false;
- } else {
- isPaperLandscape = true;
- }
- if (currentLayout != 4) {
- new PaperDirectionRotateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
- return;
- }
- return;
- case R.id.btn_add_photo /*2131230867*/:
- if (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 (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 (isRemotePrinter && enableShowWarning) {
- AlertDialog.Builder cancelable = new AlertDialog.Builder(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) {
- check3GAndStartPrint();
- }
- }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- }).show();
- return;
- } else if (currentPrinterName.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
- new AlertDialog.Builder(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 (imageNo >= imageList.size()) {
- imageNo = imageList.size() - 1;
- }
- if (imageNo < 0) {
- imageNo = 0;
- }
- }
- protected void removeCurrentImage() {
- previewImageView.invalidateImageNo();
- int i = imageNo;
- if (i >= 0 && i < imageList.size()) {
- imageList.remove(imageNo);
- imageNo--;
- }
- updateGallery();
- adjustImageNo();
- new PreviewImageSelectTask().executeOnExecutor(new Void[0]);
- }
- protected void updateScreen() {
- if (imageList.size() < 30) {
- addButton.setEnabled(true);
- addButton.setImageResource(R.drawable.plus);
- }
- if (imageList.size() > 0) {
- TextView textView = pageTextView;
- textView.setText((imageNo + 1) + CommonDefine.SLASH + imageList.size());
- gallery.setSelection(imageNo);
- } else {
- deleteButton.setEnabled(false);
- printButton.setEnabled(false);
- pageTextView.setText("0/0");
- }
- if (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.e("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 (!isRemotePrinter) {
- return printSetting.photoApfValueForLocalPrinter;
- }
- return 0;
- }
- protected int getSharpnessValue(PrintSetting printSetting) {
- if (!isRemotePrinter) {
- return printSetting.sharpnessForPhoto;
- }
- return 0;
- }
- protected int getClearlyVividValue(PrintSetting printSetting) {
- if (!isRemotePrinter) {
- int i = printSetting.paperTypeValue;
- int code = Constants.MediaName.EPS_MTID_PLAIN.getCode();
- EPLog.i("setteing = " + i + "plain = " + code);
- return (i == code && printSetting.getKind() == PrintSetting.Kind.photo) ? 1 : 0;
- }
- }
- public void onViewSizeChanged() {
- EPLog.d(TAG, "onViewSizeChanged()");
- if (isFinishing()) {
- EPLog.d(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;
- }
- }
- private void showDialog(String r4) {
- throw new UnsupportedOperationException("Method not decompiled: epson.print.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.i(TAG, "handleMessage(): msg.arg1 = " + message.arg1 + ", index = " + AllReloadTask.index);
- if (AllReloadTask.firstDraw) {
- boolean unused = AllReloadTask.firstDraw = false;
- }
- boolean unused2 = AllReloadTask.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 (executeAllReloadTaskAgain()) {
- return null;
- }
- mIsAllReloadTaskRetryAcceptable = true;
- return super.executeOnExecutor(voidArr);
- }
- protected void onPreExecute() {
- mModelDialog.doShow(DIALOG_ALL_UPDATE);
- imageList.clearExceptSrcFileName();
- previewImageView.setDrawEndHandler(handler);
- }
- protected Boolean doInBackground(Void... voidArr) {
- System.gc();
- int i = 0;
- do {
- try {
- if (mEpsonService != null) {
- break;
- }
- Thread.sleep(100);
- i++;
- } catch (RemoteException e) {
- e.printStackTrace();
- } catch (InterruptedException e2) {
- e2.printStackTrace();
- }
- } while (i < 100);
- if (mEpsonService != null) {
- if (isRemotePrinter) {
- mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.photo.name());
- } else {
- mEpsonService.updatePrinterSettings(PrintSetting.Kind.photo.name());
- }
- }
- PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
- printSetting.loadSettings();
- int unused = currentPaperSize = printSetting.paperSizeValue;
- int unused2 = currentLayout = printSetting.layoutValue;
- int unused3 = currentLayoutMulti = printSetting.layoutMultiPageValue;
- int unused4 = currentColor = printSetting.colorValue;
- previewImageView.setLayout(currentLayout, currentLayoutMulti);
- previewImageView.setPaper(currentPaperSize);
- previewImageView.setColor(currentColor);
- previewImageView.setApfLibParams(getApfValue(printSetting), getSharpnessValue(printSetting), getClearlyVividValue(printSetting));
- mHandler.sendEmptyMessage(6);
- do {
- boolean unused5 = mAllReloadTaskRetryRequested = false;
- previewImageView.setPaper(currentPaperSize);
- updatePreviewImage();
- } while (lastCheckAllReloadTaskRetryRequest());
- boolean unused6 = mAllReloadTaskDone = true;
- return true;
- }
- private void updatePreviewImage() {
- previewImageView.invalidateImageNo();
- previewImageView.invalidatePreview();
- index = 0;
- while (index < imageList.size()) {
- EPLog.i(TAG, "doInBack Start -> " + index);
- while (!mAllReloadTaskRetryRequested) {
- try {
- if (previewImageView.setImage(index, 2, this)) {
- endRedraw = false;
- publishProgress(new Integer[]{Integer.valueOf(index + 1)});
- int i = 0;
- while (true) {
- if (endRedraw) {
- break;
- }
- Thread.sleep(100, 0);
- i++;
- if (i >= 50) {
- break;
- }
- }
- EPLog.i(TAG, "doInBack End -> " + index);
- index++;
- } else {
- Thread.sleep(300);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (OutOfMemoryError unused) {
- imageList.remove(index);
- index--;
- mDeletePreview = true;
- if (mAllReloadTaskDone) {
- mHandler.sendEmptyMessage(8);
- int unused2 = imageNo = 0;
- } else {
- mHandler.sendEmptyMessage(7);
- }
- }
- }
- return;
- }
- if (imageList.size() > 0) {
- showCurrentImage();
- return;
- }
- try {
- previewImageView.setImage(0, 2, this);
- } catch (OutOfMemoryError unused3) {
- }
- }
- private void showCurrentImage() {
- boolean z = false;
- while (true) {
- try {
- previewImageView.setImage(imageNo, 0, this);
- return;
- } catch (OutOfMemoryError unused) {
- if (!z) {
- mHandler.sendEmptyMessage(8);
- }
- z = true;
- if (imageList.size() > 0) {
- if (imageNo >= 0 && imageNo < imageList.size()) {
- imageList.remove(imageNo);
- }
- int unused2 = imageNo = 0;
- } else {
- return;
- }
- }
- }
- }
- private boolean testCheckStatus() {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return mAllReloadTaskRetryRequested;
- }
- protected void onProgressUpdate(Integer... numArr) {
- previewImageView.invalidate();
- TextView access$1900 = pageTextView;
- access$1900.setText(numArr[0] + CommonDefine.SLASH + imageList.size());
- if (previewImageView.getIsPaperLandscape()) {
- boolean unused = isPaperLandscape = true;
- } else {
- boolean unused2 = isPaperLandscape = false;
- }
- }
- protected void onPostExecute(Boolean bool) {
- if (!isFinishing()) {
- if (mDeletePreview) {
- updateGallery();
- }
- previewImageView.invalidate();
- updateScreen();
- previewImageView.setDrawEndHandler((Handler) null);
- mModelDialog.doDismiss(DIALOG_ALL_UPDATE);
- if (bAutoStartPrint) {
- ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
- onClick(printButton);
- EPLog.d(TAG, "onClick(printButton)");
- 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 {
- previewImageView.setImage(imageNo, 0, ActivityViewImageSelect.this);
- return null;
- } catch (OutOfMemoryError unused) {
- mError = true;
- if (!z) {
- mHandler.sendEmptyMessage(8);
- }
- if (imageList.size() <= 0) {
- return null;
- }
- if (imageNo >= 0 && imageNo < imageList.size()) {
- imageList.remove(imageNo);
- }
- int unused2 = imageNo = 0;
- z = true;
- }
- }
- }
- protected void onPreExecute() {
- mModelDialog.doShow(DIALOG_PROGRESS);
- }
- protected void onPostExecute(Void voidR) {
- if (!isFinishing()) {
- if (mError) {
- updateGallery();
- }
- previewImageView.invalidate();
- updateScreen();
- mModelDialog.doDismiss(DIALOG_PROGRESS);
- }
- }
- }
- private class PaperDirectionRotateTask extends AsyncTask<Void, Void, Void> {
- private PaperDirectionRotateTask() {
- }
- protected void onPreExecute() {
- mModelDialog.doShow(DIALOG_PROGRESS);
- }
- protected void onPostExecute(Void voidR) {
- if (!isFinishing()) {
- mModelDialog.doDismiss(DIALOG_PROGRESS);
- }
- }
- protected Void doInBackground(Void... voidArr) {
- previewImageView.setIsPaperLandscape(isPaperLandscape, ActivityViewImageSelect.this);
- return null;
- }
- }
- }
|