Permalink
Browse files

Added TakePhotoActivity base

  • Loading branch information...
frogermcs committed Feb 14, 2015
1 parent adc1898 commit e19395ef14a0a29a558a43d36de050958351f99c
@@ -37,6 +37,10 @@
android:name=".ui.activity.UserProfileActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.TransparentActivity" />
+ <activity
+ android:name=".ui.activity.TakePhotoActivity"
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme.TransparentActivity.FullScreen" />
</application>
</manifest>
@@ -12,6 +12,7 @@
import android.widget.ImageButton;
import butterknife.InjectView;
+import butterknife.OnClick;
import io.github.froger.instamaterial.ui.adapter.FeedAdapter;
import io.github.froger.instamaterial.R;
import io.github.froger.instamaterial.Utils;
@@ -159,4 +160,12 @@ public void onCancelClick(int feedItem) {
FeedContextMenuManager.getInstance().hideContextMenu();
}
+ @OnClick(R.id.btnCreate)
+ public void onTakePhotoClick() {
+ int[] startingLocation = new int[2];
+ btnCreate.getLocationOnScreen(startingLocation);
+ startingLocation[0] += btnCreate.getWidth() / 2;
+ TakePhotoActivity.startCameraFromLocation(startingLocation, this);
+ overridePendingTransition(0, 0);
+ }
}
@@ -0,0 +1,66 @@
+package io.github.froger.instamaterial.ui.activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.ViewTreeObserver;
+
+import butterknife.InjectView;
+import io.github.froger.instamaterial.R;
+import io.github.froger.instamaterial.ui.view.RevealBackgroundView;
+
+/**
+ * Created by Miroslaw Stanek on 08.02.15.
+ */
+public class TakePhotoActivity extends BaseActivity implements RevealBackgroundView.OnStateChangeListener {
+ public static final String ARG_REVEAL_START_LOCATION = "reveal_start_location";
+
+ @InjectView(R.id.vRevealBackground)
+ RevealBackgroundView vRevealBackground;
+
+ public static void startCameraFromLocation(int[] startingLocation, Activity startingActivity) {
+ Intent intent = new Intent(startingActivity, TakePhotoActivity.class);
+ intent.putExtra(ARG_REVEAL_START_LOCATION, startingLocation);
+ startingActivity.startActivity(intent);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_take_photo);
+ setupRevealBackground(savedInstanceState);
+ }
+
+ private void setupRevealBackground(Bundle savedInstanceState) {
+ vRevealBackground.setFillPaintColor(0xFF16181a);
+ vRevealBackground.setOnStateChangeListener(this);
+ if (savedInstanceState == null) {
+ final int[] startingLocation = getIntent().getIntArrayExtra(ARG_REVEAL_START_LOCATION);
+ vRevealBackground.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ vRevealBackground.getViewTreeObserver().removeOnPreDrawListener(this);
+ vRevealBackground.startFromLocation(startingLocation);
+ return true;
+ }
+ });
+ } else {
+ vRevealBackground.setToFinishedFrame();
+ }
+ }
+
+ @Override
+ protected boolean shouldInstallDrawer() {
+ return false;
+ }
+
+ @Override
+ public void onStateChange(int state) {
+ if (RevealBackgroundView.STATE_FINISHED == state) {
+
+ } else {
+
+ }
+ }
+
+}
@@ -64,6 +64,10 @@ private void init() {
fillPaint.setColor(Color.WHITE);
}
+ public void setFillPaintColor(int color) {
+ fillPaint.setColor(color);
+ }
+
public void startFromLocation(int[] tapLocationOnScreen) {
changeState(STATE_FILL_STARTED);
startLocationX = tapLocationOnScreen[0];
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <io.github.froger.instamaterial.ui.view.RevealBackgroundView
+ android:id="@+id/vRevealBackground"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+</FrameLayout>
@@ -13,6 +13,10 @@
<item name="android:windowIsTranslucent">true</item>
</style>
+ <style name="AppTheme.TransparentActivity.FullScreen">
+ <item name="android:windowFullscreen">true</item>
+ </style>
+
<style name="ContextMenuButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>

0 comments on commit e19395e

Please sign in to comment.