1
0
mirror of https://github.com/bspeice/itcs4180 synced 2024-12-04 13:18:16 -05:00

Commit initial Homework 4

This commit is contained in:
DjBushido 2014-03-18 20:33:51 -04:00
parent d23208c55f
commit 0e90b852c9
25 changed files with 537 additions and 0 deletions

9
HW4/.classpath Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

33
HW4/.project Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HW4</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

27
HW4/AndroidManifest.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hw4"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.hw4.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hw4"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.hw4.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

BIN
HW4/ic_launcher-web.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

20
HW4/proguard-project.txt Normal file
View File

@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

14
HW4/project.properties Normal file
View File

@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,32 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/btnThread"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnAsync"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/btnAsync"
android:layout_marginTop="100dp"
android:onClick="onClick"
android:text="Generate Image Thread" />
<Button
android:id="@+id/btnAsync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnThread"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:onClick="onClick"
android:text="Generate Image AsyncTask" />
</RelativeLayout>

View File

@ -0,0 +1,28 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_async"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".PhotoActivity" >
<GridView
android:id="@+id/grid_async"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:columnWidth="90dp"
android:numColumns="@integer/column_count" />
<Button
android:id="@+id/btn_exit_async"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="@string/exit_button_text" />
</LinearLayout>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="@dimen/image_width"
android:layout_height="@dimen/image_height"
android:layout_gravity="center"
android:padding="@dimen/image_padding"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:text="@string/download_error" />
</LinearLayout>

9
HW4/res/menu/main.xml Normal file
View File

@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

View File

@ -0,0 +1,8 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw600dp devices (e.g. 7" tablets) here.
-->
</resources>

View File

@ -0,0 +1,9 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-->
<dimen name="activity_horizontal_margin">128dp</dimen>
</resources>

View File

@ -0,0 +1,11 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View File

@ -0,0 +1,12 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

10
HW4/res/values/dimens.xml Normal file
View File

@ -0,0 +1,10 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="image_padding">5dp</dimen>
<dimen name="image_height">140dp</dimen>
<dimen name="image_width">140dp</dimen>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="column_count">2</integer>
</resources>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">In Class 3</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="ifest_main_image">http://farm9.staticflickr.com/8083/8415182658_5402d77eeb_z.jpg</string>
<string name="commencement_main_image">http://farm9.staticflickr.com/8218/8278724118_9a28024cf5_z.jpg</string>
<string name="uncc_main_image">http://farm9.staticflickr.com/8196/8114421135_7c5cbb874b_z.jpg</string>
<string name="football_main_image">http://farm9.staticflickr.com/8441/7882624916_5f62cb318f_z.jpg</string>
<string name="title_activity_photo">UNC Charlotte Photos</string>
<string name="title_activity_photo_thread">UNC Charlotte Photos</string>
<string name="exit_button_text">Exit</string>
<string name="download_error">Error Downloading</string>
<string name="uncc">UNC Charlotte</string>
<string name="sports">Sports</string>
<string name="ifest">Ifest</string>
<string name="commencement">Commencement</string>
</resources>

20
HW4/res/values/styles.xml Normal file
View File

@ -0,0 +1,20 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View File

@ -0,0 +1,39 @@
package com.example.hw4;
/*
* Bradlee Speice, Brandon Rodenmayer
* ITIS 4180
* In Class 3
* MainActivity.java
*/
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onClick(View v) {
// One of our buttons has been clicked, let's start the activity and go!
if (v.getId() == R.id.btnAsync)
startActivity(new Intent(this, PhotoActivity.class));
else
startActivity(new Intent(this, PhotoThread.class));
}
}

View File

@ -0,0 +1,182 @@
package com.example.hw4;
/*
* Bradlee Speice, Brandon Rodenmayer
* ITIS 4180
* In Class 3
* PhotoActivity.java
*/
import java.net.URL;
import java.util.ArrayList;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class PhotoActivity extends Activity {
ProgressDialog progress;
LinearLayout root;
GridView photoGrid;
int[] imageUrlIds = {R.string.uncc_main_image, R.string.football_main_image,
R.string.ifest_main_image, R.string.commencement_main_image
};
int[] imageNames = {R.string.uncc, R.string.sports, R.string.ifest, R.string.commencement};
ArrayList<Bitmap> bitmapList = new ArrayList<Bitmap>();
ArrayList<String> bitmapNames = new ArrayList<String>();
int downloadProgress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo);
root = (LinearLayout)findViewById(R.id.layout_async);
photoGrid = (GridView)findViewById(R.id.grid_async);
downloadProgress = 0;
//set the progress dialog
progress = new ProgressDialog(this);
progress.setMessage("Loading...");
progress.setCancelable(false);
progress.show();
for(int x : imageUrlIds)//download images
{
new DownloadPhoto().execute(getString(x));
}
//create exit button
Button exit = (Button)findViewById(R.id.btn_exit_async);
exit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.photo, menu);
return true;
}
private class DownloadPhoto extends AsyncTask<String, Void, Bitmap>
{
@Override
protected Bitmap doInBackground(String... url)
{
Bitmap image = null;
try
{
URL imageUrl = new URL(url[0]);
image = BitmapFactory.decodeStream(imageUrl.openStream());
}
catch(Exception e)
{
e.printStackTrace();
}
return image;
}
@Override
protected void onPostExecute(Bitmap result)
{
//already a default picture included in grid_schema.xml, so no need to set a blank pic
bitmapList.add(result);
bitmapNames.add(getString(imageNames[downloadProgress]));
downloadProgress++;
if(downloadProgress>=imageUrlIds.length)
{
progress.dismiss();
//all images are loaded, so set them in the grid
photoGrid.setAdapter(new ImageAdapter(photoGrid.getContext()));
}
}
}
public class ImageAdapter extends BaseAdapter
{
private Context context;
public ImageAdapter(Context context)
{
this.context = context;
}
@Override
public int getCount()
{
return imageUrlIds.length;
}
@Override
public Object getItem(int position)//no purpose. only to fill the requirement of needing the method.
{
return position;
}
@Override
public long getItemId(int position)//no purpose. only to fill the requirement of needing the method.
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Holder holder = new Holder();
View vi = convertView;
if(vi == null)
{
//create layout of what we want one grid section to look like
vi = getLayoutInflater().inflate(R.layout.grid_schema, null);
holder.textView = (TextView)vi.findViewById(R.id.textView1);
holder.imageView = (ImageView)vi.findViewById(R.id.imageView1);
vi.setTag(holder);//associate the views in the holder to the grid
}
else
{
holder = (Holder)(vi.getTag());
}
//set the views in the grid to what was loaded
holder.textView.setText(getString(R.string.download_error));
if(bitmapList.get(position)!=null)
{
holder.imageView.setImageBitmap(bitmapList.get(position));
holder.textView.setText(bitmapNames.get(position));
}
return vi;
}
}
//views included in one grid section
static class Holder
{
TextView textView;
ImageView imageView;
}
}