(Android Studio)
Create a camera app that allows the user to upload a picture from their phone camera gallery, see the picture via summary page, and edit the picture as well. Clicking on "Insert picture here from camera photo gallery" in the add page will allow the user to upload a picture from their existing camera photo gallery on their phone. The user can choose where to save the picture, starting with Picture 1-5. Once they choose where to save the picture from, they can view that picture in the summary page. In the summary page, the user can see the picture that they uploaded. They can also change or edit the picture that they uploaded using the Edit button from the Summary Page. Clicking on the Edit Button will take you to the Edit page, where the user can click and edit on the Image View from Picture 1-5 and change the picture. Once they hit the "done" button in the Edit page, it will update the new photo added in the Summary Page.
Notes:
1. Make the application according to the requirement. .
2. Do not screenshot, do not write this on paper. Please copy and paste source codes on Chegg.
3. Please post all codes from both XML and Java codes. If there are any changes in Manifest or values codes, post those as well.
4. If there are specific instructions like how to get the home icon, please describe it in the solution.
5. Screen shot the output, NOT the codes of the camera app.
MainActivity:
package com.practice.com.cameraHomeworkLib; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.Spinner; import java.io.ByteArrayOutputStream; public class MainActivity extends AppCompatActivity { public static final String[] paths = {"Picture 1", "Picture 2", "Picture 3", "Picture 4", "Picture 5"}; private static final int REQUEST_CODE = 1; private static final String TAG = "galley"; private ImageView imageView; private Spinner mySpinner; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mySpinner = findViewById(R.id.spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, paths); imageView = findViewById(R.id.imageView); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mySpinner.setAdapter(adapter); } public void selectPicture(View view) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_CODE); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { switch (requestCode) { case REQUEST_CODE: if (resultCode == Activity.RESULT_OK) { Uri selectedImage = data.getData(); Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage); imageView.setImageBitmap(bitmap); break; } else if (resultCode == Activity.RESULT_CANCELED) { Log.e(TAG, "Selecting picture cancelled"); } break; } } catch (Exception e) { Log.e(TAG, "Exception in onActivityResult : " + e.getMessage()); } } public void goToSummary(View view) { Intent intent = new Intent(this, SummaryPage.class); String imageName = mySpinner.getSelectedItem().toString(); Bitmap bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); intent.putExtra("picture", byteArray); intent.putExtra("imagePosition", imageName); startActivity(intent); } }
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="84dp" android:layout_marginTop="68dp" android:onClick="selectPicture" android:text="Insert Picture From Here" android:textAllCaps="false" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.practice.com.cameraHomeworkLib.VisibleScrollbarSpinner android:id="@+id/spinner" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="220dp" android:layout_marginStart="116dp" android:layout_marginTop="8dp" android:background="@android:drawable/btn_dropdown" android:spinnerMode="dropdown" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/button" app:layout_constraintVertical_bias="1.0" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="24dp" android:layout_marginEnd="16dp" android:layout_marginStart="8dp" android:text="Add Picture" android:onClick="goToSummary" android:textAllCaps="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="1.0" app:layout_constraintStart_toStartOf="parent" /> <ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone"/> </android.support.constraint.ConstraintLayout>
SummaryPage.java
package com.practice.com.cameraHomeworkLib; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Toast; import static com.practice.com.cameraHomeworkLib.MainActivity.paths; public class SummaryPage extends AppCompatActivity { private static final int REQUEST_CODE = 1; private static final String TAG = "edit_mode"; private static int postion; private LinearLayout linearLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_summary_page); Bundle extras = getIntent().getExtras(); byte[] byteArray = extras.getByteArray("picture"); Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); String imagePosition = extras.getString("imagePosition"); linearLayout = findViewById(R.id.summary_page); assert imagePosition != null; if (imagePosition.equals(paths[0])) { ImageView image = (ImageView) findViewById(R.id.imageView1); image.setImageBitmap(bmp); } else if (imagePosition.equals(paths[1])) { ImageView image = (ImageView) findViewById(R.id.imageView2); image.setImageBitmap(bmp); } else if (imagePosition.equals(paths[2])) { ImageView image = (ImageView) findViewById(R.id.imageView3); image.setImageBitmap(bmp); } else if (imagePosition.equals(paths[3])) { ImageView image = (ImageView) findViewById(R.id.imageView4); image.setImageBitmap(bmp); } else if (imagePosition.equals(paths[4])) { ImageView image = (ImageView) findViewById(R.id.imageView5); image.setImageBitmap(bmp); } } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { switch (requestCode) { case REQUEST_CODE: if (resultCode == Activity.RESULT_OK) { Uri selectedImage = data.getData(); Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage); ImageView imageView = (ImageView) linearLayout.getChildAt(postion); imageView.setImageBitmap(bitmap); break; } else if (resultCode == Activity.RESULT_CANCELED) { Log.e(TAG, "Selecting picture cancelled"); } break; } } catch (Exception e) { Log.e(TAG, "Exception in onActivityResult : " + e.getMessage()); } } public void goToEdit(View view) { Button button = findViewById(R.id.edit_button); button.setVisibility(View.GONE); for (int i = 0; i < linearLayout.getChildCount() - 1; i++) { ImageView imageView = (ImageView) linearLayout.getChildAt(i); final int finalI = i; imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { postion = finalI; Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_CODE); } }); } } public void finish(View view) { Button button = findViewById(R.id.edit_button); button.setVisibility(View.VISIBLE); for (int i = 0; i < linearLayout.getChildCount() - 1; i++) { ImageView imageView = (ImageView) linearLayout.getChildAt(i); imageView.setOnClickListener(null); } } }
acitivity_summary_page.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:id="@+id/summary_page" android:orientation="vertical" tools:context=".SummaryPage"> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@mipmap/ic_launcher" /> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@mipmap/ic_launcher" /> <ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@mipmap/ic_launcher" /> <ImageView android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@mipmap/ic_launcher" /> <ImageView android:id="@+id/imageView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@mipmap/ic_launcher" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left" android:orientation="horizontal"> <Button android:id="@+id/edit_button" android:layout_width="150dp" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_weight="1.5" android:onClick="goToEdit" android:text="Edit" /> <Button android:id="@+id/done" android:layout_width="150dp" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_weight="1.5" android:onClick="finish" android:text="Done" /> </LinearLayout> </LinearLayout>
Custom Spinner
package com.practice.com.cameraHomeworkLib; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.widget.ListPopupWindow; import android.widget.Spinner; import java.lang.reflect.Field; import static android.content.ContentValues.TAG; public class VisibleScrollbarSpinner extends Spinner { @Override public boolean performClick() { final boolean superResult = super.performClick(); try { final Field mPopupField = Spinner.class.getDeclaredField("mPopup"); mPopupField.setAccessible(true); ((ListPopupWindow) mPopupField.get(this)).getListView().setScrollbarFadingEnabled(false); mPopupField.setAccessible(false); } catch (NoSuchFieldException | IllegalAccessException e) { Log.e(TAG, e.toString(), e); } return superResult; } public VisibleScrollbarSpinner(Context context) { super(context); } public VisibleScrollbarSpinner(Context context, int mode) { super(context, mode); } public VisibleScrollbarSpinner(Context context, AttributeSet attrs) { super(context, attrs); } public VisibleScrollbarSpinner(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public VisibleScrollbarSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode) { super(context, attrs, defStyleAttr, mode); } }
i have pasted all the code.i have reused summary page as edit page also.
let me know if you have any questions.
(Android Studio) Create a camera app that allows the user to upload a picture from their...
Android Problem Using JAVA Problem: You need to create an app on Android Studios that allows users to register and login into the system. The focus of this project is for you to create an app with several activities and has data validation. You should have for your app: A welcome screen (splash screen) with your app name and a picture. You should then move to a screen that asks the user for either to log in or to register....
I need help developing this app using java in android studio Assignment: Tic-Tac-Toe app User interface Operation The app allows the user to play a game of Tic-Tac-Toe. The user can click the New Game button at any time to start a new game. The app displays other messages to the user as the game progresses such as (1) whose turn it is, (2) if a player wins, and (3) if the game ends in a tie. Specifications The app...
(Android Studio) (Mobile App Development) Create a spinner that has drop down function on it (NOT tab view). Place a scroll bar inside the dropdown of the spinner. The categories inside the spinner include: vegetable, fruit, meat, drink. Clicking on each section will pop up a fragment section below. Here, I clicked on the vegetable section, which leads me to a page displaying vegetables and their expiration dates. Note: Post XML and Java codes for both the main activity and...
Computer Guesses - Create a page that allows the user to think of a number from 1 to 100. Write a function that will guess the number the user chose. The user will provide clues: higher or lower and correct. It should take no more than 7 guesses to get the correct number. User Guesses - Create a page that generates a random number from 1 to 100. Allow the user only 7 guesses to guess the number. Provide clues:...
Create a webpage (the last picture has three potential offers not just 2). Use html, JavaScript and CSS where needed. All information needed is supplied by the picture. Summary Create a dynamic web page that allows users to compare different financing offers for an automobile loan. Purchasers are often presented with different financing offers, and determining the best offer can be difficult. In particular, dealers often have promotions that offer either a lower interest rate or a cash incentive (sometimes...
PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...
Create a new project in BlueJ and name it LastName-lab8-appstore, e.g., Smith-lab8-appstore. If your App class from Lab 4 is fully functional, copy it into the project. (You can drag a file from File Explorer onto the BlueJ project window.) Otherwise, use the instructor's App class: Create a new class using the "New Class..." button and name it App. Open the App class to edit the source code. Select and delete all the source code so that the file is...
You are the systems manager for Blue City Movies Rentals and you have been asked to create a report on historical sales data. To complete your task you will combine and edit data from multiple sources using Excel’s Power add-ins, XML, and text functions.Instructions:For the purpose of grading the project you are required to perform the following tasks:StepInstructionsPoints Possible1Open e10c2MovieRentals.xlsx and save the workbook with the name e10c2MovieRentals_LastFirst.02Import the movie data from the delimited file e10c2Movies.txt and rename the new worksheet Inventory.Hint: On the Data tab,...
Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...