Skip to content

Commit

Permalink
android library
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Gehring committed Jul 4, 2011
1 parent d321ad2 commit bb8bf4e
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 23 deletions.
7 changes: 7 additions & 0 deletions .classpath
@@ -0,0 +1,7 @@
<?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 kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions .project
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GraphView</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>
12 changes: 12 additions & 0 deletions AndroidManifest.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jjoe64.graphview"
android:versionCode="1"
android:versionName="1.0">


<application android:icon="@drawable/icon" android:label="@string/app_name">


</application>
</manifest>
12 changes: 12 additions & 0 deletions default.properties
@@ -0,0 +1,12 @@
# 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 use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-7
android.library=true
36 changes: 36 additions & 0 deletions proguard.cfg
@@ -0,0 +1,36 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Binary file added res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions res/layout/main.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
5 changes: 5 additions & 0 deletions res/values/strings.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World!</string>
<string name="app_name">GraphView</string>
</resources>
42 changes: 21 additions & 21 deletions GraphView.java → src/com/jjoe64/graphview/GraphView.java
@@ -1,4 +1,4 @@
package arnodenhond.graphviewdemo; package com.jjoe64.graphview;


import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
Expand All @@ -8,21 +8,21 @@
import android.view.View; import android.view.View;


/** /**
* GraphView creates a scaled line or bar graph with x and y axis labels. * GraphView creates a scaled line or bar graph with x and y axis labels.
* @author Arno den Hond * @author originally: Arno den Hond
* *
*/ */
public class GraphView extends View { public class GraphView extends View {


public static boolean BAR = true; public static boolean BAR = true;
public static boolean LINE = false; public static boolean LINE = false;


private Paint paint; private final Paint paint;
private float[] values; private float[] values;
private String[] horlabels; private String[] horlabels;
private String[] verlabels; private String[] verlabels;
private String title; private String title;
private boolean type; private final boolean type;


public GraphView(Context context, float[] values, String title, String[] horlabels, String[] verlabels, boolean type) { public GraphView(Context context, float[] values, String title, String[] horlabels, String[] verlabels, boolean type) {
super(context); super(context);
Expand All @@ -46,6 +46,22 @@ public GraphView(Context context, float[] values, String title, String[] horlabe
paint = new Paint(); paint = new Paint();
} }


private float getMax() {
float largest = Integer.MIN_VALUE;
for (int i = 0; i < values.length; i++)
if (values[i] > largest)
largest = values[i];
return largest;
}

private float getMin() {
float smallest = Integer.MAX_VALUE;
for (int i = 0; i < values.length; i++)
if (values[i] < smallest)
smallest = values[i];
return smallest;
}

@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
float border = 20; float border = 20;
Expand Down Expand Up @@ -112,20 +128,4 @@ protected void onDraw(Canvas canvas) {
} }
} }


private float getMax() {
float largest = Integer.MIN_VALUE;
for (int i = 0; i < values.length; i++)
if (values[i] > largest)
largest = values[i];
return largest;
}

private float getMin() {
float smallest = Integer.MAX_VALUE;
for (int i = 0; i < values.length; i++)
if (values[i] < smallest)
smallest = values[i];
return smallest;
}

} }
@@ -1,11 +1,11 @@
package arnodenhond.graphviewdemo; package com.jjoe64.graphview;


import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;


/** /**
* GraphViewDemo creates some dummy data to demonstrate the GraphView component. * GraphViewDemo creates some dummy data to demonstrate the GraphView component.
* @author Arno den Hond * @author originally: Arno den Hond
* *
*/ */
public class GraphViewDemo extends Activity { public class GraphViewDemo extends Activity {
Expand Down

0 comments on commit bb8bf4e

Please sign in to comment.