Commit 936a6e52 authored by Ryan Rowe's avatar Ryan Rowe
Browse files

EX1 Doodle stub

parent 717c1a9a
# See https://github.com/github/gitignore/blob/master/Android.gitignore
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
.DS_Store
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Doodle.iml" filepath="$PROJECT_DIR$/Doodle.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "cse340.doodle"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'junit:junit:4.12'
}
# Auto detect text files and perform LF normalization
* text=auto
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cse340.doodle">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name="cse340.doodle.Part1Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
food_0,720,457,100
food_1,764,402,100
food_2,824,359,100
food_3,874,317,100
food_4,936,300,100
food_5,1001,310,100
food_6,1047,320,100
food_7,1089,345,100
food_8,1135,369,100
food_9,1163,402,100
food_10,1198,431,100
food_11,1230,469,100
food_12,1258,512,100
food_13,1284,572,100
food_14,1302,643,100
food_15,1317,713,100
food_16,1302,774,100
food_17,1284,835,100
food_18,1258,906,100
food_19,1230,958,100
food_20,1198,1012,100
food_21,1163,1064,100
food_22,1135,1119,100
food_23,1089,1169,100
food_24,1047,1225,100
food_25,1001,1271,100
food_26,955,1320,100
food_27,910,1362,100
food_28,851,1415,100
food_29,809,1455,100
food_30,759,1493,100
food_31,708,1530,100
food_32,670,1563,100
food_33,632,1530,100
food_34,581,1493,100
food_35,531,1455,100
food_36,489,1415,100
food_37,430,1362,100
food_38,385,1320,100
food_39,339,1271,100
food_40,293,1225,100
food_41,251,1169,100
food_42,205,1119,100
food_43,177,1064,100
food_44,142,1012,100
food_45,110,958,100
food_46,82,906,100
food_47,56,835,100
food_48,38,774,100
food_49,23,713,100
food_50,38,643,100
food_51,56,572,100
food_52,82,512,100
food_53,110,469,100
food_54,142,431,100
food_55,177,402,100
food_56,205,369,100
food_57,251,345,100
food_58,293,320,100
food_59,339,310,100
food_60,404,300,100
food_61,466,317,100
food_62,516,359,100
food_63,576,402,100
food_64,620,457,100
food_65,670,470,100
food_66,645,1199,150
food_67,620,950,200
food_68,570,613,300
\ No newline at end of file
package cse340.doodle;
import android.graphics.Point;
import android.support.v7.app.AppCompatActivity;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
abstract class Doodler extends AppCompatActivity {
/**
* Adds an image to the main canvas with the given position and size.
*
* @param canvas Canvas to put new image in.
* @param imageName Filename for image in 'res/drawable'.
* @param x Horizontal location from top left in dp.
* @param y Vertical location from top left dp.
* @param size Width and height of image on-screen in dp.
* @return ImageView which has been added to canvas.
*/
abstract ImageView addImage(FrameLayout canvas, String imageName, float x, float y, int size);
/**
* Adds text to the main canvas with the given position, size, and color.
*
* @param canvas Canvas to put new image in.
* @param text Text to display on-screen.
* @param x Horizontal location from top left in dp.
* @param y Vertical location from top left dp.
* @param fontSize Scaled pixel size for text.
* @param color Color for text in RGB.
* @return TextView which has been added to canvas.
*/
abstract TextView addText(FrameLayout canvas, String text, float x, float y, int fontSize, int color);
/**
* Adds text to the main canvas with the given position, size, and color.
*
* @param canvas Canvas to put new image in.
* @param start Starting point for line.
* @param end Ending point for line
* @param width Stroke width for line.
* @param color Color for text in RGB.
* @return ImageView which has been added to main canvas.
*/
abstract ImageView addLine(FrameLayout canvas, Point start, Point end, int width, int color);
}
package cse340.doodle;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Part1Activity extends Doodler {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the UI layout to this activity.
setContentView(R.layout.activity_main);
// Find canvas from UI layout to add content onto it.
FrameLayout canvas = findViewById(R.id.canvas);
// Add all images as a heart collage.
addAllImagesFromData(canvas);
// Add "I" and "UW" text.
addText(canvas,"I", 50f, 50f, 70, Color.rgb(145,123,76));
addText(canvas,"UW", 50f, 1650f, 70, Color.rgb(51,0,111));
// Add a line under "UW".
addLine(canvas, new Point(0, 1950), new Point(1440, 1950), 5, Color.rgb(145,123,76));
// Check your app screen with the screenshot in our assignment instruction.
}
private void addAllImagesFromData(FrameLayout canvas) {
try {
Scanner scan = new Scanner(new InputStreamReader(getAssets().open("data.csv")));
scan.useDelimiter("[,\n]");
while (scan.hasNextLine()) {
addImage(canvas, scan.next(), scan.nextFloat(), scan.nextFloat(), scan.nextInt());
}
} catch (IOException e) {
throw new IllegalStateException("data.csv not found in assets");
} catch (InputMismatchException e) {
throw new IllegalStateException("data.csv is malformed");
}
}
@Override
public ImageView addImage(FrameLayout canvas, String imageName, float x, float y, int size) {
// Create ImageView and add it to canvas.
ImageView imageView = new ImageView(this);
canvas.addView(imageView);
// Set image size and location.
// Set image content using filename.
int resID = getResources().getIdentifier(imageName, "drawable", getPackageName());
imageView.setImageResource(resID);
return imageView;
}
@Override
public TextView addText(FrameLayout canvas, String text, float x, float y, int fontSize, int color) {
// Create TextView and add it to canvas.
// Set size, location and color of text.
// Return TextView.
return null;
}
@Override
public ImageView addLine(FrameLayout canvas, Point start, Point end, int width, int color) {
// Create a line and add it to canvas.
// One way to do this is to use an ImageView with a Bitmap using ImageView#setImageBitmap().
// Then, initialize a canvas from the bitmap and paint on it.
// Return line as ImageView.
return null;
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment