Skip to content

Commit

Permalink
Version 1.0:
Browse files Browse the repository at this point in the history
*  !!! Play Store Launch Version !!!
*  Minor Bug-Fixes and Feature Additions
*  Created JavaDoc Documentation!
  • Loading branch information
paulpall committed Mar 31, 2021
1 parent 051b828 commit e02c6ba
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 48 deletions.
15 changes: 7 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
}
buildTypes.each {
// INSERT THE GOOGLE CLOUD API KEY BELOW (Instead of "AIza..."):
it.buildConfigField 'String', 'API_KEY', '"AIzaSyD-VCuixZVo-YP0_m0T09VDxBjA0Ab-xnI"'
it.buildConfigField 'String', 'API_KEY', '"AIzaSyDwR3SH15gXIXK7_7d3fZbTbzCyEZ7GnxI"'
}
}
compileOptions {
Expand All @@ -41,22 +41,21 @@ android {

dependencies {

// Default Dependencies:
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

// Additional Dependencies:
implementation 'com.google.apis:google-api-services-vision:v1-rev9-1.21.0'
implementation 'com.android.support:support-annotations:28.0.0'

implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.core:core-ktx:1.3.2'
//implementation 'com.android.support:design:28.0.0' //Turns out we don't use this!
implementation 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
implementation 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
implementation 'com.opencsv:opencsv:5.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'


testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
11 changes: 9 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!--for Google's 2021 Solution Challenge-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="google.sc21.sortify">
<!-- This Ensures that Only Devices with a Camera can Download our App -->
<uses-feature
Expand All @@ -19,8 +20,14 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Sortify">
<activity android:name=".ExploreActivity" />
<activity android:name=".MainActivity">
<activity
android:name=".ExploreActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity"/>
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
51 changes: 43 additions & 8 deletions app/src/main/java/google/sc21/sortify/ExploreActivity.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,74 @@
/*
* --------------------------------------------------
* Sortify App, Created 13/03/2021
* Made by Paul & Abdul
* for Google's 2021 Solution Challenge
* https://github.com/paulpall/Sortify/
* --------------------------------------------------
* ExploreActivity.java is the class for our List Activity.
* This activity contains a list of items that was requested,
* along with the option of an image that was taken.
*/
package google.sc21.sortify;


// REQUIRED PACKAGES:
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

import static google.sc21.sortify.MainActivity.DATASET_FILENAME;

public class ExploreActivity extends AppCompatActivity implements MyRecyclerViewAdapter.ItemClickListener {


/** Explore Activity Object...
*
* Object that represents our Explore view.
* @author Paul
*
*/
public class ExploreActivity extends AppCompatActivity implements MyRecyclerViewAdapter.ItemClickListener {
//GUI Objects
private static MyRecyclerViewAdapter adapter;
private static RecyclerView exploreList;
private static ImageView junkPhoto;
private static Context context;



/** <p>Loads A List to RecyclerView</p>
* A Method that takes a List of Junk and Displays it in our RecyclerView.
* @param data A List of Junk objects.
* @since 0.7
*/
public static void loadData(List<Junk> data) {
exploreList.setLayoutManager(new LinearLayoutManager(ExploreActivity.context));
adapter = new MyRecyclerViewAdapter(ExploreActivity.context, data);
exploreList.setAdapter(adapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(exploreList.getContext(), LinearLayoutManager.VERTICAL);
exploreList.addItemDecoration(dividerItemDecoration);
}


/** <p>Sets the Image (Displayed over the List)</p>
* A Method that takes a Bitmap image and sets it to display over the list.
* @param image An image that will be displayed over the list.
* @since 0.7
*/
public static void setImage(Bitmap image) {
junkPhoto.setImageBitmap(image);
}
Expand All @@ -51,7 +80,7 @@ public void onItemClick(View view, int position) {
}


//region PLEASE DO NOT LOOK IN HERE (terrible practise, I know)
//region PLEASE DO NOT LOOK IN HERE (terrible practise, I know :()
private List<Junk> importDataset() {
List<Junk> referenceData = new ArrayList<>();

Expand All @@ -74,25 +103,31 @@ private List<Junk> importDataset() {



/** <p>Main Method</p>
* Handles Tasks on Activity Launch.
* @since 0.7
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
//Tie the GUI with Code
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_explore);
junkPhoto = findViewById(R.id.junkView);
exploreList = findViewById(R.id.junkListView);
ExploreActivity.context = getApplicationContext();

//Empty Item to Display While Waiting for Results to Arrive
List<Junk> template = new ArrayList<>();
List<String> empty = new LinkedList<String>();
template.add(new Junk("Please Wait...",empty,"",""));

//RecyclerView Configurations
exploreList.setLayoutManager(new LinearLayoutManager(this));
adapter = new MyRecyclerViewAdapter(this, template);
adapter.setClickListener(this);
exploreList.setAdapter(adapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(exploreList.getContext(), LinearLayoutManager.VERTICAL);
exploreList.addItemDecoration(dividerItemDecoration);

//Checks whether the User started the Discover mode or Camera mode
Intent intent = getIntent();
String mode = intent.getStringExtra("mode");
if (mode.equals("discover")) {
Expand Down
50 changes: 47 additions & 3 deletions app/src/main/java/google/sc21/sortify/Junk.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
/*
* --------------------------------------------------
* Sortify App, Created 13/03/2021
* Made by Paul & Abdul
* for Google's 2021 Solution Challenge
* https://github.com/paulpall/Sortify/
* --------------------------------------------------
* Junk.java is the class for our object.
* This object contains all the necessary information
* that we store for a single item of trash.
*/
package google.sc21.sortify;


// REQUIRED PACKAGES:
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;



/** Junk Data Object...
*
* Object that represents a single item of Junk for our app.
* @author Paul
*
*/
public class Junk {
//Junk Item Parameters:
private String name;
private List<String> aliases = new LinkedList<>();
private String guidance;
private String link;
private float accuracy;



//Constructors:
public Junk(String junkName, List<String> junkAliases, String junkGuidance, String junkURL) {
name = junkName;
aliases = junkAliases;
Expand All @@ -19,6 +44,15 @@ public Junk(String junkName, List<String> junkAliases, String junkGuidance, Stri
}
private Junk() {}



//region ITEM CONSTRUCTION FUNCTION
/** <p>Constructs an Item from a CSV line</p>
* A Method for Constructing a new Item from a CSV line.
* @param scanner A line/row of CSV data
* @return A new Junk object Item.
* @since 0.6
*/
public static Junk newItemFromCSV(Scanner scanner) {
Junk item = new Junk();
item.name = scanner.next();
Expand Down Expand Up @@ -46,8 +80,16 @@ public static Junk newItemFromCSV(Scanner scanner) {
item.accuracy = 0;
return item;
}
//endregion


// Returns how accurate the match is
//region MATCH COMPARISON FUNCTION
/** <p>Checks Whether & How Much a Label Matches to an Item</p>
* A Method for Checking Whether and How Much a String Matches to a Junk Item's Name and Alias.
* @param label A string that will be compared against the item.
* @return How much the given label matches. (0 = Not a Match & 1 = 100% Match)
* @since 0.6
*/
public float matches(String label) {
String input = label.toLowerCase();
float accuracy = 0;
Expand Down Expand Up @@ -95,12 +137,14 @@ public float matches(String label) {
}
return accuracy;
}
//endregion



//Methods for Accessing Information Outside of Class:
public String returnName() {return name;}
public List<String> returnAliases() {return aliases;}
public String returnInfo() {return guidance;}
public void setAccuracy(float value) {accuracy = value;}
public float returnAccurcay() {return accuracy;}


}
Loading

0 comments on commit e02c6ba

Please sign in to comment.