1/*
2 * Copyright (C) 2012 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 */
16package com.android.gallery3d.app;
17
18import android.graphics.Rect;
19import android.os.Parcel;
20import android.os.Parcelable;
21
22import com.android.gallery3d.ui.ScreenNail;
23
24// This is the bridge to connect a PhotoPage to the external environment.
25public abstract class AppBridge implements Parcelable {
26    public int describeContents() {
27        return 0;
28    }
29
30    public void writeToParcel(Parcel dest, int flags) {
31    }
32
33    //////////////////////////////////////////////////////////////////////////
34    //  These are requests sent from PhotoPage to the app
35    //////////////////////////////////////////////////////////////////////////
36
37    public abstract boolean isPanorama();
38    public abstract ScreenNail attachScreenNail();
39    public abstract void detachScreenNail();
40
41    // Return true if the tap is consumed.
42    public abstract boolean onSingleTapUp(int x, int y);
43
44    // This is used to notify that the screen nail will be drawn in full screen
45    // or not in next draw() call.
46    public abstract void onFullScreenChanged(boolean full);
47
48    //////////////////////////////////////////////////////////////////////////
49    //  These are requests send from app to PhotoPage
50    //////////////////////////////////////////////////////////////////////////
51
52    public interface Server {
53        // Set the camera frame relative to GLRootView.
54        public void setCameraRelativeFrame(Rect frame);
55        // Switch to the previous or next picture using the capture animation.
56        // The offset is -1 to switch to the previous picture, 1 to switch to
57        // the next picture.
58        public boolean switchWithCaptureAnimation(int offset);
59        // Enable or disable the swiping gestures (the default is enabled).
60        public void setSwipingEnabled(boolean enabled);
61        // Notify that the ScreenNail is changed.
62        public void notifyScreenNailChanged();
63    }
64
65    // If server is null, the services are not available.
66    public abstract void setServer(Server server);
67}
68