adapter = ArrayAdapter.createFromResource(this,
@@ -42,8 +78,16 @@ protected void onCreate(Bundle savedInstanceState) {
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
-
-/*
+ spinner.setVisibility(View.INVISIBLE);
+
+ spinOpen = (Button) findViewById(R.id.button5);
+ spinOpen.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ spinner.performClick();
+ }
+ });
+/*
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
@@ -137,7 +181,5 @@ public void review(View view)
Intent intent = new Intent(MainMenuActivity.this, ReviewPage.class);
intent.putExtra("language", language);
startActivity(intent);
-
-
}
}
diff --git a/src/usbong/android/questionloader/NetUtil.java b/src/usbong/android/questionloader/NetUtil.java
new file mode 100644
index 0000000..4357f31
--- /dev/null
+++ b/src/usbong/android/questionloader/NetUtil.java
@@ -0,0 +1,123 @@
+package usbong.android.questionloader;
+
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+public class NetUtil {
+
+ private static DefaultHttpClient httpClient = new DefaultHttpClient();
+
+ public static String postJsonDataToUrl(String url, String json) throws Exception
+ {
+ InputStream is = null;
+ try {
+ HttpPost httpPost = new HttpPost(url);
+ httpPost.setEntity(new StringEntity(json));
+ httpPost.setHeader("Accept", "application/json");
+ httpPost.setHeader("Content-type", "application/json");
+
+ HttpResponse httpResponse = httpClient.execute(httpPost);
+ HttpEntity httpEntity = httpResponse.getEntity();
+ is = httpEntity.getContent();
+ InputStreamReader isr = new InputStreamReader(is);
+
+ BufferedReader reader = new BufferedReader(isr);
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + "\n");
+ }
+
+ return sb.toString();
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch(Exception e)
+ {
+ }
+ }
+ }
+
+
+ public static String postFormDataToUrl(String url, String data) throws Exception
+ {
+ InputStream is = null;
+ try {
+ HttpPost httpPost = new HttpPost(url);
+ httpPost.setEntity(new StringEntity(data));
+ httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
+
+ HttpResponse httpResponse = httpClient.execute(httpPost);
+ HttpEntity httpEntity = httpResponse.getEntity();
+ is = httpEntity.getContent();
+ InputStreamReader isr = new InputStreamReader(is);
+
+ BufferedReader reader = new BufferedReader(isr);
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + "\n");
+ }
+
+ return sb.toString();
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch(Exception e)
+ {
+ }
+ }
+ }
+
+ public static String readUrlContentAsString(String url) throws Exception
+ {
+ InputStream is = null;
+ try
+ {
+ // Making HTTP request
+ HttpGet httpGet = new HttpGet(url);
+
+ HttpResponse httpResponse = httpClient.execute(httpGet);
+ HttpEntity httpEntity = httpResponse.getEntity();
+ is = httpEntity.getContent();
+ InputStreamReader isr = new InputStreamReader(is);
+
+ BufferedReader reader = new BufferedReader(isr);
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + "\n");
+ }
+
+ return sb.toString();
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch(Exception e)
+ {
+ }
+ }
+ }
+
+}
diff --git a/src/usbong/android/questionloader/ParseToUnicode.java b/src/usbong/android/questionloader/ParseToUnicode.java
new file mode 100644
index 0000000..604d2d2
--- /dev/null
+++ b/src/usbong/android/questionloader/ParseToUnicode.java
@@ -0,0 +1,84 @@
+package usbong.android.questionloader;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Operations on char primitives and Character objects.
+ *
+ * This class tries to handle null input gracefully.
+ * An exception will not be thrown for a null input.
+ * Each method documents its behaviour in more detail.
+ *
+ * @author Stephen Colebourne
+ * @since 2.1
+ * @version $Id: CharUtils.java 437554 2006-08-28 06:21:41Z bayard $
+ */
+public class ParseToUnicode {
+
+ //--------------------------------------------------------------------------
+ /**
+ * Converts the string to the unicode format '\u0020'.
+ *
+ * This format is the Java source code format.
+ *
+ *
+ * CharUtils.unicodeEscaped(' ') = "\u0020"
+ * CharUtils.unicodeEscaped('A') = "\u0041"
+ *
+ *
+ * @param ch the character to convert
+ * @return the escaped unicode string
+ */
+ public static String unicodeEscaped(char ch) {
+ if (ch < 0x10) {
+ return "\\u000" + Integer.toHexString(ch);
+ } else if (ch < 0x100) {
+ return "\\u00" + Integer.toHexString(ch);
+ } else if (ch < 0x1000) {
+ return "\\u0" + Integer.toHexString(ch);
+ }
+ return "\\u" + Integer.toHexString(ch);
+ }
+
+ /**
+ * Converts the string to the unicode format '\u0020'.
+ *
+ * This format is the Java source code format.
+ *
+ * If null is passed in, null will be returned.
+ *
+ *
+ * CharUtils.unicodeEscaped(null) = null
+ * CharUtils.unicodeEscaped(' ') = "\u0020"
+ * CharUtils.unicodeEscaped('A') = "\u0041"
+ *
+ *
+ * @param ch the character to convert, may be null
+ * @return the escaped unicode string, null if null input
+ */
+ public static String unicodeEscaped(Character ch) {
+ if (ch == null) {
+ return null;
+ }
+ return unicodeEscaped(ch.charValue());
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/src/usbong/android/questionloader/QuestionManager.java b/src/usbong/android/questionloader/QuestionManager.java
index f378272..da97484 100644
--- a/src/usbong/android/questionloader/QuestionManager.java
+++ b/src/usbong/android/questionloader/QuestionManager.java
@@ -13,27 +13,24 @@ public void loadQuestions(InputStream is, int difficulty)
{
QuestionParser parser = new QuestionParser();
List questionList = parser.parse(is, difficulty);
-
//System.out.println(questionList);
-
+ System.out.println("loading..."+difficulty+questionList);
questionMap.put(difficulty, questionList);
}
-
-
public Question getQuestion(int difficulty, int index)
{
list = questionMap.get(difficulty);
//int randomIndex = (int) (Math.random() * list.size());
- return list.get(index);
-
+ return list.get(index);
}
-
public int getCount()
{
return list.size();
}
-
-
+ public int getCountMap()
+ {
+ return questionMap.size();
+ }
}
diff --git a/src/usbong/android/questionloader/ResultPage.java b/src/usbong/android/questionloader/ResultPage.java
index 861c251..4951db7 100644
--- a/src/usbong/android/questionloader/ResultPage.java
+++ b/src/usbong/android/questionloader/ResultPage.java
@@ -139,9 +139,9 @@ public void onClick(DialogInterface dialog, int id) {
public void back(View view)
{
- Intent intent = new Intent(ResultPage.this, SongSelection.class);
- intent.putExtra("language", language);
- startActivity(intent);
+ //Intent intent = new Intent(ResultPage.this, SongSelection.class);
+ //intent.putExtra("language", language);
+ //startActivity(intent);
ResultPage.this.finish();
}
diff --git a/src/usbong/android/questionloader/ReviewPage.java b/src/usbong/android/questionloader/ReviewPage.java
index d5215cd..cbbe69c 100644
--- a/src/usbong/android/questionloader/ReviewPage.java
+++ b/src/usbong/android/questionloader/ReviewPage.java
@@ -125,8 +125,8 @@ public void exitReviewPage(View view)
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- Intent intent = new Intent(ReviewPage.this, MainMenuActivity.class);
- startActivity(intent);
+ //Intent intent = new Intent(ReviewPage.this, MainMenuActivity.class);
+ //startActivity(intent);
ReviewPage.this.finish();
}
})
diff --git a/src/usbong/android/questionloader/SettingSelection.java b/src/usbong/android/questionloader/SettingSelection.java
index 34f7231..b8732b8 100644
--- a/src/usbong/android/questionloader/SettingSelection.java
+++ b/src/usbong/android/questionloader/SettingSelection.java
@@ -89,6 +89,7 @@ public void easy(View view)
{
Intent intent = new Intent(SettingSelection.this, MainActivity.class);
+ //Intent intent = new Intent(SettingSelection.this, LoadingScreen.class);
intent.putExtra("difficulty", "easy");
intent.putExtra("song_title", songname);
intent.putExtra("language", language);
@@ -99,6 +100,7 @@ public void easy(View view)
public void medium(View view)
{
Intent intent = new Intent(SettingSelection.this, MainActivity.class);
+ //Intent intent = new Intent(SettingSelection.this, LoadingScreen.class);
intent.putExtra("difficulty", "medium");
intent.putExtra("song_title", songname);
intent.putExtra("language", language);
@@ -113,13 +115,13 @@ public void exitSettingSelection(View view)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Exiting...");
- builder.setMessage("Are you sure you want to return to Main Menu?")
+ builder.setMessage("Are you sure you want to return to Song Selection?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- Intent intent = new Intent(SettingSelection.this, MainMenuActivity.class);
- startActivity(intent);
+ //Intent intent = new Intent(SettingSelection.this, MainMenuActivity.class);
+ //startActivity(intent);
SettingSelection.this.finish();
}
})
@@ -132,4 +134,12 @@ public void onClick(DialogInterface dialog, int id) {
alert.show();
}
+ public void loadingScreen(View view)
+ {
+ Intent intent = new Intent(SettingSelection.this,LoadingScreen.class);
+ intent.putExtra("difficulty", "medium");
+ intent.putExtra("song_title", songname);
+ intent.putExtra("language", language);
+ startActivity(intent);
+ }
}
diff --git a/src/usbong/android/questionloader/SongSelection.java b/src/usbong/android/questionloader/SongSelection.java
index fa95d35..3a163de 100644
--- a/src/usbong/android/questionloader/SongSelection.java
+++ b/src/usbong/android/questionloader/SongSelection.java
@@ -14,7 +14,9 @@
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Point;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.StateListDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.Display;
@@ -22,7 +24,9 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.view.MotionEvent;
import android.view.View;
+import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -37,7 +41,7 @@ public class SongSelection extends ListActivity {
Button review;
Resources myRes;
Drawable myDrawableImage;
-
+ View selected = null;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -65,6 +69,8 @@ protected void onCreate(Bundle savedInstanceState) {
//System.out.println(Arrays.toString(fileList));
ListView list = getListView();
+ list.setDividerHeight(0);
+ //list.setDivider(new ColorDrawable(0xFF613318));
//added by Mike, 12 June 2015
list.setCacheColorHint(0);
// list.setBackgroundResource(R.drawable.japanbanner);
@@ -87,47 +93,48 @@ else if (language.equalsIgnoreCase("Korean"))
}
list.addHeaderView(v);
- list.setBackgroundColor(Color.parseColor("#36342a")); //6f5c44
-
+ list.setBackgroundColor(Color.parseColor("#FFFFFF")); //6f5c44 36342a
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> arg0, View arg1,
int position, long id) {
- arg1.setBackgroundColor(Color.parseColor("#4e4b3c"));
-
- // TODO Auto-generated method stub
- TextView textPlaceHolder = (TextView) arg1.findViewById(R.id.textViewPlaceHolder);
- //System.out.println(text.getText());
- if (language.equalsIgnoreCase("Japanese"))
- {
- Intent intent = new Intent(SongSelection.this, SettingSelection.class);
- intent.putExtra("song_title", textPlaceHolder.getText());
- intent.putExtra("language", language);
- //System.out.println("LAnguage"+language);
- startActivity(intent);
- SongSelection.this.finish();
- }
- else if (language.equalsIgnoreCase("Mandarin"))
- {
- Intent intent = new Intent(SongSelection.this, SettingSelection.class);
- intent.putExtra("song_title", textPlaceHolder.getText());
- intent.putExtra("language", language);
- //System.out.println("LAnguage"+language);
- startActivity(intent);
- SongSelection.this.finish();
- }
- else
+ if(position!=0)
{
- Intent intent = new Intent(SongSelection.this, MainActivity.class);
- intent.putExtra("difficulty", "easy");
- intent.putExtra("song_title", textPlaceHolder.getText());
- intent.putExtra("language", language);
- startActivity(intent);
- SongSelection.this.finish();
-
+ arg1.setBackgroundColor(Color.parseColor("#BDD09F"));
+ selected = arg1;
+ // TODO Auto-generated method stub
+ TextView textPlaceHolder = (TextView) arg1.findViewById(R.id.textViewPlaceHolder);
+ //System.out.println(text.getText());
+ if (language.equalsIgnoreCase("Japanese"))
+ {
+ Intent intent = new Intent(SongSelection.this, SettingSelection.class);
+ intent.putExtra("song_title", textPlaceHolder.getText());
+ intent.putExtra("language", language);
+ //System.out.println("LAnguage"+language);
+ startActivity(intent);
+ //SongSelection.this.finish();
+ }
+ else if (language.equalsIgnoreCase("Mandarin"))
+ {
+ Intent intent = new Intent(SongSelection.this, SettingSelection.class);
+ intent.putExtra("song_title", textPlaceHolder.getText());
+ intent.putExtra("language", language);
+ //System.out.println("LAnguage"+language);
+ startActivity(intent);
+ //SongSelection.this.finish();
+ }
+ else
+ {
+ Intent intent = new Intent(SongSelection.this, MainActivity.class);
+ intent.putExtra("difficulty", "easy");
+ intent.putExtra("song_title", textPlaceHolder.getText());
+ intent.putExtra("language", language);
+ startActivity(intent);
+ //SongSelection.this.finish();
+
+ }
}
-
}
});
@@ -183,8 +190,6 @@ public void onClick(DialogInterface dialog, int id) {
}
}
-
-
private class MyListAdapter extends BaseAdapter
{
private String[] fileList;
@@ -233,43 +238,11 @@ public View getView(int position, View convertView, ViewGroup arg2) {
*//*
ImageView banner_image = (ImageView) view.findViewById(R.id.banner_imageView);
*/
-
- TextView text = (TextView) view.findViewById(R.id.textView1);
+
+ TextView text = (TextView) view.findViewById(R.id.textView1);
+ TextView artist = (TextView) view.findViewById(R.id.textView2);
TextView textPlaceHolder = (TextView) view.findViewById(R.id.textViewPlaceHolder);
-/*
- // set the image here
- try {
- String bannerString = "banner";
- if (language.equalsIgnoreCase("Japanese")) {
- myDrawableImage = myRes.getDrawable(myRes.getIdentifier("japan"+bannerString, "drawable", UsbongUtils.myPackageName));
- banner_image.setImageDrawable(myDrawableImage);
- }
- else if (language.equalsIgnoreCase("Mandarin")) {
- myDrawableImage = myRes.getDrawable(myRes.getIdentifier("china"+bannerString, "drawable", UsbongUtils.myPackageName));
- banner_image.setImageDrawable(myDrawableImage);
- }
- else if (language.equalsIgnoreCase("Korean")) {
- myDrawableImage = myRes.getDrawable(myRes.getIdentifier("korea"+bannerString, "drawable", UsbongUtils.myPackageName));
- banner_image.setImageDrawable(myDrawableImage);
- }
- }
- catch (NotFoundException e) { //if song is not found
- //use default image
- }
-*/
-/* //commented out by Mike, 25 May 2015
- // set the image here
- try {
-
- String imgFile = (fileList[position].replaceAll("[()?:!.,;{}\\'\\s+]", "")).toLowerCase();
- System.out.println("Image here" + imgFile);
- myDrawableImage = myRes.getDrawable(myRes.getIdentifier(imgFile, "drawable", UsbongUtils.myPackageName));
- image.setImageDrawable(myDrawableImage);
- }
- catch (NotFoundException e) { //if song is not found
- //use default image
- }
-*/
+
//System.out.println(text);
// set the text
@@ -282,7 +255,8 @@ else if (language.equalsIgnoreCase("Korean")) {
InputStream is = getResources().getAssets().open(language+"/" + fileList[position]);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String currentLine=br.readLine();
- text.setText(currentLine+"\n"+br.readLine());
+ text.setText(currentLine);
+ artist.setText(br.readLine());
/*
String currentLine;
while((currentLine=br.readLine())!=null){
@@ -293,9 +267,14 @@ else if (language.equalsIgnoreCase("Korean")) {
catch(Exception e) {
e.printStackTrace();
}
-
return view;
}
-
}
+ @Override
+ protected void onStart()
+ {
+ super.onStart();
+ if (selected!=null)
+ selected.setBackgroundColor(Color.parseColor("#ffffff"));
+ }
}
\ No newline at end of file
diff --git a/src/usbong/android/questionloader/YoutubeConnector.java b/src/usbong/android/questionloader/YoutubeConnector.java
index c2e73b3..29866e7 100644
--- a/src/usbong/android/questionloader/YoutubeConnector.java
+++ b/src/usbong/android/questionloader/YoutubeConnector.java
@@ -19,6 +19,7 @@
public class YoutubeConnector {
private YouTube youtube;
private YouTube.Search.List query;
+
// private YouTube.Channels.List query2; //added by Mike, 22 May 2015
// Your developer key goes here
@@ -48,12 +49,10 @@ public List search(String keywords){
try{
SearchListResponse response = query.execute();
List results = response.getItems();
-
List items = new ArrayList();
for(SearchResult result:results){
VideoItem item = new VideoItem();
item.setTitle(result.getSnippet().getTitle());
-
//commented out by Mike, 22 May 2015
// item.setDescription(result.getSnippet().getDescription());
item.setThumbnailURL(result.getSnippet().getThumbnails().getDefault().getUrl());
diff --git a/src/usbong/android/utils/UsbongUtils.java b/src/usbong/android/utils/UsbongUtils.java
index 90cdb17..e12d198 100644
--- a/src/usbong/android/utils/UsbongUtils.java
+++ b/src/usbong/android/utils/UsbongUtils.java
@@ -25,7 +25,7 @@
import android.widget.ImageView;
public class UsbongUtils {
- public final static String APP_VERSION="June15,2015 (Google Play)";
+ public final static String APP_VERSION="20151120 (Google Play)";
public final static String API_KEY = "AIzaSyB5mM_lk_bbdT5nUWQTO6S5FyZ9IgaxqXc";
public final static String myPackageName="usbong.android.questionloader";