Add cancel button, fix button switching, change icons to vector
This commit is contained in:
@@ -6,6 +6,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
import android.hardware.Camera.PictureCallback;
|
import android.hardware.Camera.PictureCallback;
|
||||||
|
import android.media.Image;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
@@ -17,6 +18,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
||||||
@@ -89,12 +91,8 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
final View view = inflater.inflate(R.layout.fragment_camera, container, false);
|
final View view = inflater.inflate(R.layout.fragment_camera, container, false);
|
||||||
|
|
||||||
mCamera = getCameraInstance(facing);
|
mCamera = getCameraInstance(facing);
|
||||||
Camera.Parameters params = mCamera.getParameters();
|
|
||||||
params.setRotation(0);
|
|
||||||
mCamera.setParameters(params);
|
|
||||||
|
|
||||||
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
||||||
final RelativeLayout pictureButtons = (RelativeLayout) view.findViewById(R.id.picture_taken_buttons);
|
|
||||||
final RelativeLayout filterButtons = (RelativeLayout) view.findViewById(R.id.filter_buttons);
|
final RelativeLayout filterButtons = (RelativeLayout) view.findViewById(R.id.filter_buttons);
|
||||||
final RelativeLayout mCameraLayout = (RelativeLayout) view.findViewById(R.id.camera_preview);
|
final RelativeLayout mCameraLayout = (RelativeLayout) view.findViewById(R.id.camera_preview);
|
||||||
|
|
||||||
@@ -103,7 +101,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
// Draw buttons over preview
|
// Draw buttons over preview
|
||||||
view.findViewById(R.id.picture_button).bringToFront();
|
view.findViewById(R.id.picture_button).bringToFront();
|
||||||
view.findViewById(R.id.switch_camera_button).bringToFront();
|
view.findViewById(R.id.switch_camera_button).bringToFront();
|
||||||
pictureButtons.bringToFront();
|
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
|
|
||||||
(view.findViewById(R.id.switch_camera_button)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.switch_camera_button)).setOnClickListener(new View.OnClickListener() {
|
||||||
@@ -150,6 +147,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
view.findViewById(R.id.comment_box).setClickable(true);
|
view.findViewById(R.id.comment_box).setClickable(true);
|
||||||
view.findViewById(R.id.comment_box).setVisibility(View.VISIBLE);
|
view.findViewById(R.id.comment_box).setVisibility(View.VISIBLE);
|
||||||
view.findViewById(R.id.comment_box).bringToFront();
|
view.findViewById(R.id.comment_box).bringToFront();
|
||||||
|
view.findViewById(R.id.filter_buttons).setVisibility(View.GONE);
|
||||||
((FloatingActionButton)view.findViewById(R.id.upload_button)).hide();
|
((FloatingActionButton)view.findViewById(R.id.upload_button)).hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -173,9 +171,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
mCameraLayout.removeView(mPreview);
|
mCameraLayout.removeView(mPreview);
|
||||||
|
|
||||||
mCamera = getCameraInstance(facing);
|
mCamera = getCameraInstance(facing);
|
||||||
Camera.Parameters params = mCamera.getParameters();
|
|
||||||
params.setRotation(90);
|
|
||||||
mCamera.setParameters(params);
|
|
||||||
|
|
||||||
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
||||||
mCameraLayout.addView(mPreview);
|
mCameraLayout.addView(mPreview);
|
||||||
@@ -184,7 +179,30 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
view.findViewById(R.id.switch_camera_button).bringToFront();
|
view.findViewById(R.id.switch_camera_button).bringToFront();
|
||||||
|
|
||||||
mCameraLayout.removeView(view.findViewById(R.id.pic_preview));
|
mCameraLayout.removeView(view.findViewById(R.id.pic_preview));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
(view.findViewById(R.id.comment_cancel)).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
((EditText) view.findViewById(R.id.comment_text)).setText("");
|
||||||
|
|
||||||
|
mPhoto.recycle();
|
||||||
|
|
||||||
|
filterButtons.setVisibility(View.GONE);
|
||||||
|
switchButtons(view);
|
||||||
|
|
||||||
|
mCameraLayout.removeView(mPreview);
|
||||||
|
|
||||||
|
mCamera = getCameraInstance(facing);
|
||||||
|
|
||||||
|
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
||||||
|
mCameraLayout.addView(mPreview);
|
||||||
|
|
||||||
|
view.findViewById(R.id.picture_button).bringToFront();
|
||||||
|
view.findViewById(R.id.switch_camera_button).bringToFront();
|
||||||
|
|
||||||
|
mCameraLayout.removeView(view.findViewById(R.id.pic_preview));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -200,7 +218,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
|
|
||||||
mCameraLayout.addView(mPicPreview);
|
mCameraLayout.addView(mPicPreview);
|
||||||
|
|
||||||
view.findViewById(R.id.picture_taken_buttons).bringToFront();
|
view.findViewById(R.id.upload_button).bringToFront();
|
||||||
filterButtons.setVisibility(View.VISIBLE);
|
filterButtons.setVisibility(View.VISIBLE);
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
}
|
}
|
||||||
@@ -218,7 +236,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
|
|
||||||
mCameraLayout.addView(mPicPreview);
|
mCameraLayout.addView(mPicPreview);
|
||||||
|
|
||||||
view.findViewById(R.id.picture_taken_buttons).bringToFront();
|
view.findViewById(R.id.upload_button).bringToFront();
|
||||||
filterButtons.setVisibility(View.VISIBLE);
|
filterButtons.setVisibility(View.VISIBLE);
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
}
|
}
|
||||||
@@ -294,20 +312,26 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void switchButtons(View view) {
|
public void switchButtons(View view) {
|
||||||
RelativeLayout pictureButtons = (RelativeLayout) view.findViewById(R.id.picture_taken_buttons);
|
|
||||||
FloatingActionButton upload = (FloatingActionButton) view.findViewById(R.id.upload_button);
|
FloatingActionButton upload = (FloatingActionButton) view.findViewById(R.id.upload_button);
|
||||||
|
ImageButton picButton = (ImageButton) view.findViewById(R.id.picture_button);
|
||||||
|
ImageButton switchButton = (ImageButton) view.findViewById(R.id.switch_camera_button);
|
||||||
|
|
||||||
if (((Integer)upload.getVisibility()).equals(View.VISIBLE)) {
|
if (((Integer)picButton.getVisibility()).equals(View.GONE)) {
|
||||||
|
Log.d(TAG, "switchButtons: GONE");
|
||||||
upload.hide();
|
upload.hide();
|
||||||
|
|
||||||
view.findViewById(R.id.picture_button).setVisibility(View.VISIBLE);
|
picButton.setVisibility(View.VISIBLE);
|
||||||
view.findViewById(R.id.switch_camera_button).setVisibility(View.VISIBLE);
|
switchButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
picButton.bringToFront();
|
||||||
|
switchButton.bringToFront();
|
||||||
} else {
|
} else {
|
||||||
pictureButtons.bringToFront();
|
Log.d(TAG, "switchButtons: VISIBLE");
|
||||||
|
upload.bringToFront();
|
||||||
upload.show();
|
upload.show();
|
||||||
|
|
||||||
view.findViewById(R.id.picture_button).setVisibility(View.GONE);
|
picButton.setVisibility(View.GONE);
|
||||||
view.findViewById(R.id.switch_camera_button).setVisibility(View.GONE);
|
switchButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 199 B |
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||||
|
</vector>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 222 B |
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M9.4,10.5l4.77,-8.26C13.47,2.09 12.75,2 12,2c-2.4,0 -4.6,0.85 -6.32,2.25l3.66,6.35 0.06,-0.1zM21.54,9c-0.92,-2.92 -3.15,-5.26 -6,-6.34L11.88,9h9.66zM21.8,10h-7.49l0.29,0.5 4.76,8.25C21,16.97 22,14.61 22,12c0,-0.69 -0.07,-1.35 -0.2,-2zM8.54,12l-3.9,-6.75C3.01,7.03 2,9.39 2,12c0,0.69 0.07,1.35 0.2,2h7.49l-1.15,-2zM2.46,15c0.92,2.92 3.15,5.26 6,6.34L12.12,15L2.46,15zM13.73,15l-3.9,6.76c0.7,0.15 1.42,0.24 2.17,0.24 2.4,0 4.6,-0.85 6.32,-2.25l-3.66,-6.35 -0.93,1.6z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M20,4h-3.17L15,2L9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM15,15.5L15,13L9,13v2.5L5.5,12 9,8.5L9,11h6L15,8.5l3.5,3.5 -3.5,3.5z"/>
|
||||||
|
</vector>
|
||||||
@@ -18,20 +18,23 @@
|
|||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:padding="10dp"
|
android:padding="15dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:scaleX="2"
|
android:scaleX="2.5"
|
||||||
android:scaleY="2"
|
android:scaleY="2.5"
|
||||||
app:srcCompat="@android:drawable/ic_menu_camera" />
|
android:src="@drawable/ic_camera_black_24dp"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/switch_camera_button"
|
android:id="@+id/switch_camera_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
|
android:padding="10dp"
|
||||||
android:layout_margin="9dp"
|
android:layout_margin="9dp"
|
||||||
|
android:scaleX="1.5"
|
||||||
|
android:scaleY="1.5"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
app:srcCompat="@android:drawable/ic_menu_revert" />
|
android:src="@drawable/ic_switch_camera_black_24dp"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/load_bar"
|
android:id="@+id/load_bar"
|
||||||
@@ -54,8 +57,10 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:scaleX="0.5"
|
android:scaleX="2"
|
||||||
android:scaleY="0.5"
|
android:scaleY="2"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:src="@drawable/ic_arrow_back_black_24dp"/>
|
android:src="@drawable/ic_arrow_back_black_24dp"/>
|
||||||
|
|
||||||
@@ -64,8 +69,10 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:scaleX="0.5"
|
android:scaleX="2"
|
||||||
android:scaleY="0.5"
|
android:scaleY="2"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:src="@drawable/ic_arrow_forward_black_24dp"/>
|
android:src="@drawable/ic_arrow_forward_black_24dp"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
@@ -94,45 +101,40 @@
|
|||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:background="@android:color/darker_gray"/>
|
android:background="@android:color/darker_gray"/>
|
||||||
<Button
|
|
||||||
android:id="@+id/comment_submit"
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/upload"/>
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/comment_submit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/upload"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/comment_cancel"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/cancel"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/picture_taken_buttons"
|
android:id="@+id/upload_button"
|
||||||
android:layout_width="match_parent"
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_marginLeft="30dp"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginRight="30dp"
|
android:scaleType="center"
|
||||||
android:layout_marginBottom="20dp">
|
android:layout_margin="15dp"
|
||||||
|
app:fabSize="normal"
|
||||||
<android.support.design.widget.FloatingActionButton
|
android:src="@android:drawable/ic_menu_upload"/>
|
||||||
android:id="@+id/upload_button"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:scaleType="center"
|
|
||||||
app:fabSize="normal"
|
|
||||||
android:src="@android:drawable/ic_menu_upload"/>
|
|
||||||
|
|
||||||
<!--<android.support.design.widget.FloatingActionButton
|
|
||||||
android:id="@+id/save_button"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:scaleType="center"
|
|
||||||
app:fabSize="normal"
|
|
||||||
android:src="@android:drawable/ic_menu_save"/>-->
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -32,4 +32,5 @@
|
|||||||
<string name="upload_profile_pic">Profielfoto aan het uploaden…</string>
|
<string name="upload_profile_pic">Profielfoto aan het uploaden…</string>
|
||||||
<string name="niet_slecht">"\"Niet slecht.\"s "</string>
|
<string name="niet_slecht">"\"Niet slecht.\"s "</string>
|
||||||
<string name="comment">Bijschrift:</string>
|
<string name="comment">Bijschrift:</string>
|
||||||
|
<string name="cancel">Annuleer</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -31,4 +31,5 @@
|
|||||||
<string name="update_profile_pic_error">Updating the profile picture failed. Please check network connection.</string>
|
<string name="update_profile_pic_error">Updating the profile picture failed. Please check network connection.</string>
|
||||||
<string name="upload_profile_pic">Uploading profile picture...</string>
|
<string name="upload_profile_pic">Uploading profile picture...</string>
|
||||||
<string name="comment">Comment:</string>
|
<string name="comment">Comment:</string>
|
||||||
|
<string name="cancel">Cancel</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user