Home | History | Annotate | Download | only in testingcamera
      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 
     21     public InfoDialogFragment() {
     22         // Empty constructor required for DialogFragment
     23     }
     24 
     25     @Override
     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
     41     public void onClick(View v) {
     42         this.dismiss();
     43     }
     44 
     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\n");
     57         b.append("getParameters() output:\n  ");
     58         Camera.Parameters p = camera.getParameters();
     59         String[] flatP = p.flatten().split(";");
     60         for (String param : flatP) {
     61             b.append(param);
     62             b.append("\n  ");
     63         }
     64 
     65         mInfoString = b.toString();
     66     }
     67 
     68 }
     69