Home | History | Annotate | Download | only in module
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.camera.module;
     18 
     19 import com.android.camera.CameraActivity;
     20 import com.android.camera.ShutterButton;
     21 import com.android.camera.app.CameraAppUI.BottomBarUISpec;
     22 import com.android.camera.hardware.HardwareSpec;
     23 import com.android.camera.settings.SettingsManager;
     24 import com.android.ex.camera2.portability.CameraAgent;
     25 
     26 /**
     27  * The controller at app level.
     28  */
     29 public interface ModuleController extends ShutterButton.OnShutterButtonListener {
     30     /** Preview is fully visible. */
     31     public static final int VISIBILITY_VISIBLE = 0;
     32     /** Preview is covered by e.g. the transparent mode drawer. */
     33     public static final int VISIBILITY_COVERED = 1;
     34     /** Preview is fully hidden, e.g. by the filmstrip. */
     35     public static final int VISIBILITY_HIDDEN = 2;
     36 
     37     /**
     38      * Returns a unique string which identifies this module.
     39      * This string is used by the SettingsManager to scope settings
     40      * specific to each module.
     41      */
     42     public String getModuleStringIdentifier();
     43 
     44     /********************** Life cycle management **********************/
     45 
     46     /**
     47      * Initializes the module.
     48      *
     49      * @param activity The camera activity.
     50      * @param isSecureCamera Whether the app is in secure camera mode.
     51      * @param isCaptureIntent Whether the app is in capture intent mode.
     52      */
     53     public void init(CameraActivity activity, boolean isSecureCamera, boolean isCaptureIntent);
     54 
     55     /**
     56      * Resumes the module. Always call this method whenever it's being put in
     57      * the foreground.
     58      */
     59     public void resume();
     60 
     61     /**
     62      * Pauses the module. Always call this method whenever it's being put in the
     63      * background.
     64      */
     65     public void pause();
     66 
     67     /**
     68      * Destroys the module. Always call this method to release the resources used
     69      * by this module.
     70      */
     71     public void destroy();
     72 
     73     /********************** UI / Camera preview **********************/
     74 
     75     /**
     76      * Called when the preview becomes visible/invisible.
     77      *
     78      * @param visible Whether the preview is visible, one of
     79      *            {@link #VISIBILITY_VISIBLE}, {@link #VISIBILITY_COVERED},
     80      *            {@link #VISIBILITY_HIDDEN}
     81      */
     82     public void onPreviewVisibilityChanged(int visibility);
     83 
     84     /**
     85      * Called when the framework layout orientation changed.
     86      *
     87      * @param isLandscape Whether the new orientation is landscape or portrait.
     88      */
     89     public void onLayoutOrientationChanged(boolean isLandscape);
     90 
     91     /**
     92      * Called when the UI orientation is changed.
     93      *
     94      * @param orientation The new orientation, valid values are 0, 90, 180 and
     95      *                    270.
     96      */
     97     public void onOrientationChanged(int orientation);
     98 
     99     /**
    100      * Called when back key is pressed.
    101      *
    102      * @return Whether the back key event is processed.
    103      */
    104     public abstract boolean onBackPressed();
    105 
    106     /********************** App-level resources **********************/
    107 
    108     /**
    109      * Called by the app when the camera is available. The module should use
    110      * {@link com.android.camera.app.AppController#}
    111      *
    112      * @param cameraProxy The camera device proxy.
    113      */
    114     public void onCameraAvailable(CameraAgent.CameraProxy cameraProxy);
    115 
    116     /**
    117      * Called by the app on startup or module switches, this allows the module
    118      * to perform a hard reset on specific settings.
    119      */
    120     public void hardResetSettings(SettingsManager settingsManager);
    121 
    122     /**
    123      * Returns a {@link com.android.camera.hardware.HardwareSpec}
    124      * based on the module's open camera device.
    125      */
    126     public HardwareSpec getHardwareSpec();
    127 
    128     /**
    129      * Returns a {@link com.android.camera.app.CameraAppUI.BottomBarUISpec}
    130      * which represents the module's ideal bottom bar layout of the
    131      * mode options.  The app edits the final layout based on the
    132      * {@link com.android.camera.hardware.HardwareSpec}.
    133      */
    134     public BottomBarUISpec getBottomBarSpec();
    135 
    136     /**
    137      * Used by the app on configuring the bottom bar color and visibility.
    138      */
    139     // Necessary because not all modules have a bottom bar.
    140     // TODO: once all modules use the generic module UI, move this
    141     // logic into the app.
    142     public boolean isUsingBottomBar();
    143 }
    144