Code Monkey home page Code Monkey logo

squarecamera's Introduction

SquareCamera

Android Arsenal

Description

Android module that takes a square photo using the native Android Camera APIs. The new Camera2 APIs from the L release is not used because support has to go back to SDK version 14 for my own requirement.

Features

  • Tap to focus
  • Two fingers zooming
  • Front & Back camera
  • Flash mode (Saved when the user exits)
  • Supports both portrait & landscape
  • Runtime permission is supported for saving/viewing photos

SDK Support

Support from SDK version 14 onwards

Download

jCenter:

repositories {
    jcenter()
}

dependencies {
    compile 'com.github.boxme:squarecamera:1.1.0'
}

Example

private static final int REQUEST_CAMERA = 0;

// Check for camera permission in MashMallow
public void requestForCameraPermission(View view) {
    final String permission = Manifest.permission.CAMERA;
    if (ContextCompat.checkSelfPermission(MainActivity.this, permission)
            != PackageManager.PERMISSION_GRANTED) {
        if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, permission)) {
            // Show permission rationale
        } else {
            // Handle the result in Activity#onRequestPermissionResult(int, String[], int[])
            ActivityCompat.requestPermissions(YourActivity.this, new String[]{permission}, REQUEST_CAMERA_PERMISSION);
        }
    } else {
        // Start CameraActivity
    }
}

// Start CameraActivity
Intent startCustomCameraIntent = new Intent(this, CameraActivity.class);
startActivityForResult(startCustomCameraIntent, REQUEST_CAMERA);

// Receive Uri of saved square photo
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_OK) return;

    if (requestCode == REQUEST_CAMERA) {
        Uri photoUri = data.getData();
    }
    super.onActivityResult(requestCode, resultCode, data);
}

Video Demo

Link: https://youtu.be/cSGFiP-gZYU

squarecamera's People

Contributors

boxme avatar abdyer avatar pavlospt avatar

Watchers

James Cloos avatar Koustuv Ganguly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.