12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616 |
- 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.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 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;
- }
- }
- }
|