Statistics
| Branch: | Tag: | Revision:

securesmartcam / app / src / main / java / org / witness / obscuracam / ui / ImagePreview.java @ 41590feb

History | View | Annotate | Download (2.17 KB)

1
/**
2
 * This Activity will be the initial Activity for the application.
3
 * It will load the main Activity (CameraObscuraMainMenu) on click
4
 */
5
package org.witness.obscuracam.ui;
6

    
7
import java.io.IOException;
8

    
9
import org.witness.sscphase1.R;
10

    
11
import android.app.Activity;
12
import android.content.Intent;
13
import android.content.res.Configuration;
14
import android.graphics.Bitmap;
15
import android.graphics.BitmapFactory;
16
import android.net.Uri;
17
import android.os.Bundle;
18
import android.util.Log;
19
import android.view.Display;
20
import android.view.LayoutInflater;
21
import android.view.View;
22
import android.view.View.OnClickListener;
23
import android.widget.ImageView;
24
import android.widget.TextView;
25

    
26
public class ImagePreview extends Activity implements OnClickListener {
27
        
28
        public final static String IMAGEURI = "passedimage";
29
        
30
        ImageView imageView;
31
        Uri imageUri;
32
        Bitmap imageBitmap;
33
                        
34
    @Override
35
    public void onCreate(Bundle savedInstanceState) {
36
        super.onCreate(savedInstanceState);
37
        setContentView(R.layout.imagepreview);
38
        
39
        Bundle passedBundle = getIntent().getExtras();
40
        if (passedBundle.containsKey(IMAGEURI)) {
41
                
42
                imageUri = Uri.parse(passedBundle.getString(IMAGEURI));
43
                
44
            imageView = (ImageView) findViewById(R.id.PreviewImageView);
45
            imageView.setOnClickListener(this);
46
            
47
            try {
48
                                // Load up the image's dimensions not the image itself
49
                                BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
50
                                
51
                                // Parse the image
52
                                imageBitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri), null, bmpFactoryOptions);
53
                
54
                                imageView.setImageBitmap(imageBitmap);
55
                                                                
56
                        } catch (IOException e) {
57
                                e.printStackTrace();
58
                        }            
59
        }
60
        else {
61
                // Not passed in, nothing to display
62
                finish();
63
        }
64
        
65
    }
66
    
67
        public void onClick(View view) {
68
                finish();
69
        }
70

    
71
    /*
72
     * Handling screen configuration changes ourselves, we don't want the activity to restart on rotation
73
     */
74
    @Override
75
    public void onConfigurationChanged(Configuration conf) 
76
    {
77
        super.onConfigurationChanged(conf);
78
    }
79
}