1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.exoplatform.widget;
20
21 import org.exoplatform.R;
22 import org.exoplatform.controller.social.ComposeMessageController;
23 import org.exoplatform.ui.DocumentActionDialog;
24 import org.exoplatform.utils.PhotoUtils;
25
26 import android.app.Activity;
27 import android.app.Dialog;
28 import android.view.View;
29 import android.view.Window;
30 import android.widget.Button;
31
32 public class AddPhotoDialog extends Dialog implements android.view.View.OnClickListener {
33
34 private Button takePhotoButton;
35
36 private Button libraryButton;
37
38 private Button cancelButton;
39
40 private Activity mActivity;
41
42 private ComposeMessageController messageController;
43
44 private DocumentActionDialog fileActionDialog;
45
46 public AddPhotoDialog(Activity callingActivity, DocumentActionDialog dialog) {
47 super(callingActivity);
48 requestWindowFeature(Window.FEATURE_NO_TITLE);
49 setContentView(R.layout.add_photo_dialog_layout);
50 mActivity = callingActivity;
51 fileActionDialog = dialog;
52
53 init();
54
55 }
56
57 public AddPhotoDialog(Activity callingActivity, ComposeMessageController controller) {
58 super(callingActivity);
59 requestWindowFeature(Window.FEATURE_NO_TITLE);
60 setContentView(R.layout.add_photo_dialog_layout);
61 mActivity = callingActivity;
62 messageController = controller;
63
64 init();
65 }
66
67 private void init() {
68
69 takePhotoButton = (Button) findViewById(R.id.add_photo_take_button);
70 takePhotoButton.setOnClickListener(this);
71 libraryButton = (Button) findViewById(R.id.add_photo_library_button);
72 libraryButton.setOnClickListener(this);
73 cancelButton = (Button) findViewById(R.id.add_photo_cancel_button);
74 cancelButton.setOnClickListener(this);
75
76 }
77
78 public void onClick(View view) {
79 if (view.equals(cancelButton)) {
80 dismiss();
81 } else {
82 if (view.equals(takePhotoButton)) {
83
84 dismiss();
85 startCapture();
86 } else if (view.equals(libraryButton)) {
87
88 dismiss();
89 pickPhoto();
90 }
91 }
92 }
93
94 private void startCapture() {
95 if (messageController == null)
96 fileActionDialog._documentActionAdapter.initCamera();
97 else
98 messageController.initCamera();
99 }
100
101 private void pickPhoto() {
102 PhotoUtils.pickPhotoForActivity(mActivity);
103 }
104 }