Skip to content

Commit

Permalink
Massive UI Overhual, added a startup menu and compeletely revamped al…
Browse files Browse the repository at this point in the history
…l colors and views for the different components of the app.
  • Loading branch information
ajtoms committed Mar 12, 2014
1 parent 8e1def6 commit 2c1c8e9
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 21 deletions.
12 changes: 8 additions & 4 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@
<activity
android:name="ca.unbc.cpsc472.mynextphone.QuestionActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name="ca.unbc.cpsc472.mynextphone.ResultActivity"
android:label="@string/title_activity_result" >
</activity>
<activity
android:name="ca.unbc.cpsc472.mynextphone.StartupActivity"
android:label="@string/title_activity_startup" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="ca.unbc.cpsc472.mynextphone.ResultActivity"
android:label="@string/title_activity_result" >
</activity>
</application>

</manifest>
12 changes: 12 additions & 0 deletions res/drawable/answer_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<corners
android:radius="10sp"/>

<solid
android:color="@color/medium_blue"/>

</shape>
12 changes: 12 additions & 0 deletions res/drawable/answers_container_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<corners
android:radius="10sp"/>

<solid
android:color="@color/bright_blue"/>

</shape>
2 changes: 1 addition & 1 deletion res/drawable/question_bg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
android:radius="10sp"/>

<solid
android:color="@color/bg_blue"/>
android:color="@color/bright_blue"/>

</shape>
17 changes: 11 additions & 6 deletions res/layout/activity_question.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@color/light_blue"
android:background="@color/dark_blue"
tools:context=".QuestionActivity" >

<TextView
Expand All @@ -29,20 +29,25 @@
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="3"
android:orientation="vertical"
android:background="@color/black">
android:orientation="vertical">
<!-- -->
<ListView
android:id="@+id/question_text_answer_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" />
android:divider="@color/bright_blue"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:paddingTop="20sp"
android:dividerHeight="10.0sp"
android:background="@drawable/answers_container_bg" />
<!-- -->
<GridView
android:paddingTop="20sp"
android:id="@+id/question_tile_answer_view"
android:background="@drawable/answers_container_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_blue"
android:layout_height="match_parent"
android:numColumns="auto_fit"
android:columnWidth="150dp"
android:horizontalSpacing="10dp"
Expand Down
2 changes: 1 addition & 1 deletion res/layout/activity_result.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@color/light_blue"
android:background="@color/dark_blue"
tools:context=".ResultActivity" >

<TextView
Expand Down
48 changes: 48 additions & 0 deletions res/layout/activity_startup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<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=".StartupActivity"
android:background="@color/dark_blue" >

<ImageView
android:id="@+id/central_image"
android:layout_margin="10sp"
android:padding="5sp"
android:background="@drawable/result_img_bg"
android:src="@drawable/cell_phone_placeholder"
android:layout_width="200sp"
android:layout_centerInParent="true"
android:layout_height="200sp"
android:contentDescription="@string/place_holder_short"/>

<TextView
android:id="@+id/main_title"
android:layout_width="wrap_content"
android:layout_above="@id/central_image"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
android:textStyle="bold"
android:textSize="42sp"
android:text="@string/app_name" />

<Button
android:id="@+id/start_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/central_image"
android:layout_centerHorizontal="true"
android:padding="3sp"
android:layout_margin="20sp"
android:text="@string/start"
android:onClick="go"
android:textColor="@color/white"
android:textSize="26sp"
android:background="@drawable/button_shape"/>

</RelativeLayout>
3 changes: 3 additions & 0 deletions res/layout/item_answer_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
android:id="@+id/item_question_answer_text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/place_holder_short"
android:textColor="@color/white"
android:background="@drawable/answer_bg"
android:gravity="center"
android:padding="5sp"
android:textSize="24sp"/>
9 changes: 9 additions & 0 deletions res/menu/startup.xml
Original file line number Diff line number Diff line change
@@ -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>
5 changes: 3 additions & 2 deletions res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<color name="orange">#ffffa900</color>
<color name="black">#ff000000</color>
<color name="white">#ffffffff</color>
<color name="bg_blue">#ff6c8dd5</color>
<color name="bright_blue">#ff6c8dd5</color>
<color name="medium_blue">#ff4573d4</color>
<color name="button_stroke">#ffa66e00</color>
<color name="light_blue">#ff1142aa</color>
<color name="dark_blue">#ff1142aa</color>

</resources>
4 changes: 3 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
<resources>

<string name="app_name">My Next Phone</string>
<string name="start">Begin</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_question">Question</string>
<string name="place_holder_long">This is a Long String with at least a line or two. The purpose of this string is to provide a significantly long string so that the developers can test to see areas where a lot of text will be placed. That cute girl just smiled at me. That\'s always nice.</string>
<string name="place_holder_medium">This is a Medium String, just one run-on sentence long as it should be because I like runon sentences.</string>
<string name="place_holder_short">This is a Short String</string>
<string name="title_activity_result">ResultActivity</string>
<string name="title_activity_result">Your Results</string>
<string name="restart">Restart?</string>
<string name="title_activity_startup">My Next Phone</string>

</resources>
15 changes: 9 additions & 6 deletions src/ca/unbc/cpsc472/mynextphone/QuestionActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.unbc.cpsc472.mynextphone;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
Expand All @@ -9,7 +10,6 @@
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.ListView;
Expand All @@ -19,6 +19,7 @@
import ca.unbc.cpsc472.mynextphone.models.QuestionAnswerType;
import ca.unbc.cpsc472.mynextphone.models.QuestionManager;
import ca.unbc.cpsc472.mynextphone.models.Result;
import ca.unbc.cpsc472.mynextphone.models.TextListAdapter;
import ca.unbc.cpsc472.mynextphone.models.TileListAdapter;

/**
Expand Down Expand Up @@ -156,12 +157,16 @@ public void drawQuestion(){
//what they selected and then fetch a new question. Changes dependent
//upon the type of ui needed to display the question.
if(this.question.getType() == QuestionAnswerType.TEXT){

final TextListAdapter x = new TextListAdapter(this, this.question.getAnswers());
this.textAnswerView.setAdapter(x);
this.textAnswerView.setOnItemClickListener(new OnItemClickListener(){

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
long arg3) {
answerQuestion((QuestionAnswer)arg0.getItemAtPosition(pos));
QuestionAnswer a = x.getAnswer(pos);
answerQuestion(a);
fetchNewQuestion();
if(questionReady())
drawQuestion();
Expand All @@ -171,10 +176,8 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
}

});
ArrayAdapter<QuestionAnswer> x = new ArrayAdapter<QuestionAnswer>(
this, R.layout.item_answer_text,
this.question.getAnswers());
this.textAnswerView.setAdapter(x);


} else {
final TileListAdapter x = new TileListAdapter(this,
this.question.getAnswers());
Expand Down
29 changes: 29 additions & 0 deletions src/ca/unbc/cpsc472/mynextphone/StartupActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ca.unbc.cpsc472.mynextphone;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;

public class StartupActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_startup);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.startup, menu);
return true;
}

public void go(View v){
Intent i = new Intent(this, QuestionActivity.class);
this.startActivity(i);
}

}
2 changes: 2 additions & 0 deletions src/ca/unbc/cpsc472/mynextphone/models/QuestionAnswer.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public View getView(Context c) {
c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View ret = inf.inflate(R.layout.item_answer_text, null);
((TextView) ret).setText(this.toString());
// ((TextView) ret).setBackgroundDrawable(c.getResources().getDrawable(
// R.drawable.question_bg));
return ret;
}

Expand Down
46 changes: 46 additions & 0 deletions src/ca/unbc/cpsc472/mynextphone/models/TextListAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ca.unbc.cpsc472.mynextphone.models;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class TextListAdapter extends BaseAdapter {

private ArrayList<QuestionAnswer> theItems;
private Context context;

public TextListAdapter(Context c, ArrayList<QuestionAnswer> theItems){
this.theItems = theItems;
this.context = c;
}

@Override
public int getCount() {
return theItems.size();
}

@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}

public QuestionAnswer getAnswer(int i){
return theItems.get(i);
}

@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}

@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
return theItems.get(arg0).getView(context);
}

}

0 comments on commit 2c1c8e9

Please sign in to comment.