• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.testingcamera;
2 
3 import android.hardware.Camera;
4 import android.hardware.Camera.CameraInfo;
5 import android.os.Bundle;
6 import android.app.DialogFragment;
7 import android.view.LayoutInflater;
8 import android.view.View;
9 import android.view.ViewGroup;
10 import android.widget.Button;
11 import android.widget.TextView;
12 
13 public class InfoDialogFragment extends DialogFragment implements View.OnClickListener {
14 
15     Button mOkButton;
16     TextView mInfoText;
17 
18     String mTitleString = "";
19     String mInfoString = "";
20 
InfoDialogFragment()21     public InfoDialogFragment() {
22         // Empty constructor required for DialogFragment
23     }
24 
25     @Override
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)26     public View onCreateView(LayoutInflater inflater, ViewGroup container,
27             Bundle savedInstanceState) {
28         View view = inflater.inflate(R.layout.fragment_info, container);
29 
30         mOkButton = (Button) view.findViewById(R.id.info_ok_button);
31         mOkButton.setOnClickListener(this);
32 
33         mInfoText= (TextView) view.findViewById(R.id.info_text);
34         mInfoText.setText(mInfoString);
35 
36         getDialog().setTitle(mTitleString);
37         return view;
38     }
39 
40     @Override
onClick(View v)41     public void onClick(View v) {
42         this.dismiss();
43     }
44 
updateInfo(int cameraId, Camera camera)45     public void updateInfo(int cameraId, Camera camera) {
46         mTitleString = "Current camera " + cameraId + " state";
47         StringBuilder b = new StringBuilder();
48 
49         CameraInfo cameraInfo = new CameraInfo();
50         Camera.getCameraInfo(cameraId, cameraInfo);
51         b.append("getInfo() output:\n");
52         b.append("  Facing: ");
53         b.append(cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT ? "FRONT\n" : "BACK\n");
54         b.append("  Orientation: ");
55         b.append(cameraInfo.orientation);
56         b.append("\n");
57         b.append("  Can disable shutter sound: ");
58         b.append(cameraInfo.canDisableShutterSound);
59         b.append("\n\n");
60         b.append("getParameters() output:\n  ");
61         Camera.Parameters p = camera.getParameters();
62         String[] flatP = p.flatten().split(";");
63         for (String param : flatP) {
64             b.append(param);
65             b.append("\n  ");
66         }
67 
68         mInfoString = b.toString();
69     }
70 
71 }
72