package com.epson.cameracopy.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.p000v4.app.Fragment;
import android.view.Menu;
import android.view.MenuItem;

import epson.print.ActivityIACommon;
import epson.print.ActivityRequestPermissions;


/* renamed from: com.epson.cameracopy.ui.CameraPreviewActivity */
public class CameraPreviewActivity extends ActivityIACommon {
    public static final String PARAM_APP_INIT = "app_init";
    private static final int RESULT_RUNTIMEPERMMISSION = 1;

    public boolean onCreateOptionsMenu(Menu menu) {
        return true;
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_camera_preview);
        setActionBar(R.string.capture_title, true);
        if (bundle == null) {
            if (ActivityRequestPermissions.isRuntimePermissionSupported()) {
                String[] strArr = {"android.permission.CAMERA"};
                ActivityRequestPermissions.Permission permission = new ActivityRequestPermissions.Permission(strArr[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_camera)), ActivityRequestPermissions.DialogParameter.setMessage3A((Context) this, getString(R.string.permission_dialog_message_camera), getString(R.string.permission_function_camera))});
                if (!ActivityRequestPermissions.checkPermission(this, strArr)) {
                    ActivityRequestPermissions.requestPermission((Activity) this, permission, 1);
                    return;
                }
            }
            prepareCameraPreviewFragment();
        }
    }

    private void prepareCameraPreviewFragment() {
        boolean booleanExtra = getIntent().getBooleanExtra(PARAM_APP_INIT, true);
        CameraPreviewFragment cameraPreviewFragment = new CameraPreviewFragment();
        cameraPreviewFragment.setAppInitFlag(booleanExtra);
        getSupportFragmentManager().beginTransaction().add(R.id.container, (Fragment) cameraPreviewFragment).commit();
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 1) {
            prepareCameraPreviewFragment();
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        menuItem.getItemId();
        return super.onOptionsItemSelected(menuItem);
    }

    public void onBackPressed() {
        if (((CameraPreviewFragment) getSupportFragmentManager().findFragmentById(R.id.container)).onBackPressed()) {
            super.onBackPressed();
        }
    }
}
