Permalink
Browse files

Initial recommit of guidebook. Added swipe functionality and the star…

…t of getting data to the right pages

git-svn-id: file:///var/ifixit/CodeRepos/Apps/Android/Guidebook@13339 3574e4b1-9a2c-0410-9c1c-83071a6f58f1
  • Loading branch information...
0 parents commit f199076bbab26925be7bed965a814c7696bf41a4 @timothyasp timothyasp committed Sep 4, 2011
@@ -0,0 +1,8 @@
+<?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="lib" path="/Work/Code/Libraries/android-sdk-mac_x86/extras/android/compatibility/v4/android-support-v4.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>iFixit</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>
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.ifixit.guidebook"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="13" />
+ <uses-permission android:name="android.permission.INTERNET" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".GuidebookActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".GuideView"
+ android:label="@string/app_name">
+ </activity>
+ </application>
+</manifest>
@@ -0,0 +1,11 @@
+# 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-13
Binary file not shown.
@@ -0,0 +1,40 @@
+-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>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,14 @@
+<?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"
+ android:background="#0000FF">
+ <TextView android:id="@+id/guide_title" xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_weight="4"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:textSize="18px"
+ android:textColor="#FFFFFF" />
+
+</LinearLayout>
@@ -0,0 +1,10 @@
+<?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">
+ <android.support.v4.view.ViewPager
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/guide_pager"/>
+</LinearLayout>
@@ -0,0 +1,19 @@
+<?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"
+ android:background="#000000">
+ <TextView android:id="@+id/step_title" xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="18px"
+ android:textColor="#FFFFFF" />
+ <TextView android:id="@+id/step_text" xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="12px"
+ android:textColor="#FFFFFF" />
+
+
+</LinearLayout>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, GuidebookActivity!</string>
+ <string name="app_name">iFixit Guidebook</string>
+</resources>
@@ -0,0 +1,101 @@
+package com.ifixit.guidebook;
+
+import java.util.ArrayList;
+
+public class Guide {
+ protected int mGuideid;
+ protected String mTitle;
+ protected String mDevice;
+ protected String mAuthor;
+ protected String mTimeRequired;
+ protected String mDifficulty;
+ protected String mIntroduction;
+ protected String mSummary;
+ protected ArrayList<GuideStep> mSteps;
+
+ public Guide(int guideid) {
+ mGuideid = guideid;
+ mSteps = new ArrayList<GuideStep>();
+ }
+
+ public void addStep(GuideStep step) {
+ mSteps.add(step);
+ }
+
+ public int getNumSteps() {
+ return mSteps.size();
+ }
+ public GuideStep getStep(int position) {
+ return mSteps.get(position);
+ }
+
+ public void setGuideid(int guideid) {
+ mGuideid = guideid;
+ }
+
+ public int getGuideid() {
+ return mGuideid;
+ }
+
+ public void setTitle(String title) {
+ mTitle = title;
+ }
+
+ public String getTitle() {
+ return mTitle;
+ }
+
+ public void setDevice(String device) {
+ mDevice = device;
+ }
+
+ public String getDevice() {
+ return mDevice;
+ }
+
+ public void setAuthor(String author) {
+ mAuthor = author;
+ }
+
+ public String getAuthor() {
+ return mAuthor;
+ }
+
+ public void setTimeRequired(String timeRequired) {
+ mTimeRequired = timeRequired;
+ }
+
+ public String getTimeRequired() {
+ return mTimeRequired;
+ }
+
+ public void setDifficulty(String difficulty) {
+ mDifficulty = difficulty;
+ }
+
+ public String getDifficulty() {
+ return mDifficulty;
+ }
+
+ public void setIntroduction(String introduction) {
+ mIntroduction = introduction;
+ }
+
+ public String getIntroduction() {
+ return mIntroduction;
+ }
+
+ public void setSummary(String summary) {
+ mSummary = summary;
+ }
+
+ public String getSummary() {
+ return mSummary;
+ }
+
+ public String toString() {
+ return "{" + mGuideid + "\n" + mTitle + "\n" + mDevice + "\n" + mAuthor +
+ "\n" + mTimeRequired + "\n" + mDifficulty + "\n" + mIntroduction + "\n"
+ + mSummary + "\n\n" + mSteps + "}";
+ }
+}
@@ -0,0 +1,27 @@
+package com.ifixit.guidebook;
+
+import android.content.Context;
+import android.support.v4.view.ViewPager;
+import android.view.LayoutInflater;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+public class GuideIntroView extends LinearLayout {
+ private Context mContext;
+ private TextView mTitle;
+
+ public GuideIntroView(Context context, Guide guide) {
+ super(context);
+ this.mContext = context;
+
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+
+ inflater.inflate(R.layout.guide_intro, this, true);
+
+ mTitle = (TextView) findViewById(R.id.guide_title);
+ mTitle.setText(guide.getTitle());
+
+ }
+
+}
@@ -0,0 +1,81 @@
+package com.ifixit.guidebook;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.util.Log;
+
+public class GuideJSONHelper {
+ public static Guide parseGuide(String json) {
+ try {
+ JSONObject jGuideInfo = new JSONObject(json);
+ JSONObject jGuide = jGuideInfo.getJSONObject("guide");
+ JSONArray jSteps = jGuide.getJSONArray("steps");
+ Guide guide = new Guide(jGuideInfo.getInt("guideid"));
+
+ guide.setTitle(jGuide.getString("title"));
+ guide.setDevice(jGuideInfo.getString("device"));
+ guide.setAuthor(jGuide.getString("author"));
+ guide.setTimeRequired(jGuide.getString("time_required"));
+ guide.setDifficulty(jGuide.getString("difficulty"));
+ guide.setIntroduction(jGuide.getString("introduction"));
+ guide.setSummary(jGuide.getString("summary"));
+
+ for (int i = 0; i < jSteps.length(); i++) {
+ guide.addStep(parseStep(jSteps.getJSONObject(i)));
+ }
+
+ return guide;
+ }
+ catch (JSONException e) {
+ Log.e("iFixit", "Error parsing guide: " + e);
+ return null;
+ }
+ }
+
+ public static GuideStep parseStep(JSONObject jStep) throws JSONException {
+ JSONArray jImages = jStep.getJSONArray("images");
+ JSONArray jLines = jStep.getJSONArray("lines");
+ GuideStep step = new GuideStep(jStep.getInt("number"));
+
+ step.setTitle(jStep.getString("title"));
+
+ for (int i = 0; i < jImages.length(); i++) {
+ step.addImage(parseImage(jImages.getJSONObject(i)));
+ }
+
+ for (int i = 0; i < jLines.length(); i++) {
+ step.addLine(parseLine(jLines.getJSONObject(i)));
+ }
+
+ return step;
+ }
+
+ public static StepImage parseImage(JSONObject jImage) throws JSONException {
+ Log.w("iFixit", jImage.toString());
+ StepImage image = new StepImage(jImage.getInt("imageid"));
+
+ //last image doesn't have orderby so this is necessary. Could be a bug?
+ try {
+ image.setOrderby(jImage.getInt("orderby"));
+ }
+ catch (JSONException e) {
+ image.setOrderby(1);
+ }
+
+ image.setText(jImage.getString("text"));
+
+ return image;
+ }
+
+ public static StepLine parseLine(JSONObject jLine) throws JSONException {
+ StepLine line = new StepLine();
+
+ line.setColor(jLine.getString("bullet"));
+ line.setLevel(jLine.getInt("level"));
+ line.setText(jLine.getString("text"));
+
+ return line;
+ }
+}
Oops, something went wrong.

0 comments on commit f199076

Please sign in to comment.