From: <Rol...@us...> - 2010-12-06 12:47:36
|
Revision: 4011 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4011&view=rev Author: Rollsroyc3 Date: 2010-12-06 12:47:28 +0000 (Mon, 06 Dec 2010) Log Message: ----------- Removed Paths: ------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicTab.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylistXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/setup.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/splash.java Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,44 +0,0 @@ -package mediaportal.remote; - -import java.io.IOException; - -import android.media.MediaPlayer; - -public class mediaplayercontrol { - - private static mediaplayercontrol instance; - private static MediaPlayer mp; - - public static mediaplayercontrol getinstance() { - if (mp == null) - mp = new MediaPlayer(); - if (instance == null) - instance = new mediaplayercontrol(); - return instance; - } - - public void Stop() - { - mp.stop(); - } - public void Play(String Path) - { - - try { -// mp.stop(); - - mp.setDataSource(Path); - mp.prepare(); - mp.start(); - } catch (IllegalStateException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } - -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,218 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.util.ArrayList; -import mediaportal.remote.R; -import mediaportal.remote.receivedirectoryxmlhandler.DirItems; -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.GridView; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.Toast; - -public class musicdir extends Activity { - - private Handler mHandler = new Handler(); - private String actualDir = ""; - private static ArrayList<receivedirectoryxmlhandler.DirItems> musicList; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.music); - - mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, 100); - - GridView gridview = (GridView) findViewById(R.id.music_grid); - gridview.setAdapter(new ImageAdapter2(musicdir.this)); - gridview.setOnItemClickListener(new OnItemClickListener() { - public void onItemClick(AdapterView<?> parent, View v, - int position, long id) { - - // TextView tv = (TextView) v.findViewById(R.id.icon_text); - // ImageView - ImageView iv = (ImageView) v.findViewById(R.id.icon_image); - musicItem music = (musicItem) iv.getTag(); - - if (music.typ == "item") { - // Picturesfullscreen.selectedPicture = position - 1; - // Intent myIntent = new Intent(MusicDir.this, - // Picturesfullscreen.class); - // startActivityForResult(myIntent, 0); - } - - if (music.typ == "folder") { - actualDir += music.title + "/"; - - mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, 0); - } - - if (music.typ == "oneup") { - if (actualDir.endsWith("/")) - actualDir = actualDir.substring(0, - actualDir.length() - 1); - - int x = actualDir.lastIndexOf("/"); - if (x >= 0) { - actualDir = actualDir.substring(0, x + 1); - } else - actualDir = ""; - - mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, 0); - } - - } - }); - } - - @Override - public void onStart() { - super.onStart(); - - // mHandler.removeCallbacks(mUpdateTimeTask); - // mHandler.postDelayed(mUpdateTimeTask, 100); - } - - private Runnable mUpdateTimeTask = new Runnable() { - public void run() { - update(); - } - }; - - private void update() { - - Log.d("update music dir", "do update folder : " + actualDir); - - receivedirhandler h = receivedirhandler.getinstance(); - musicList = h.getMusicDir(actualDir); - - if (musicList.size() == 0) { - Toast.makeText(musicdir.this, "TIME OUT SERVER", Toast.LENGTH_SHORT) - .show(); - } else { - GridView gridview = (GridView) findViewById(R.id.music_grid); - gridview.invalidateViews(); - } - } - - public class ImageAdapter2 extends BaseAdapter { - private Context mContext; - public static final int ACTIVITY_CREATE = 10; - - public ImageAdapter2(Context c) { - mContext = c; - } - - public int getCount() { - if (musicList != null) - return musicList.size() + 1; - else - return 0; - } - - public Object getItem(int position) { - return null; - } - - public long getItemId(int position) { - return 0; - } - - // @Override - // create a new ImageView for each item referenced by the Adapter - public View getView(int position, View convertView, ViewGroup parent) { - View v; - if (convertView == null) { // if it's not recycled, initialize some - // attributes - - if (position > 0) { - position = position - 1; - - DirItems item1 = musicList.get(position); - - String txtName = item1.File; - Boolean isFolder = item1.isFolder; - - LayoutInflater li = LayoutInflater.from(mContext); - v = li.inflate(R.layout.icon, null); - - TextView tv = (TextView) v.findViewById(R.id.icon_text); - tv.setText(txtName); - - ImageView iv = (ImageView) v.findViewById(R.id.icon_image); - - if (isFolder) { - iv.setImageResource(R.drawable.folder); - musicItem item = new musicItem(); - item.title = txtName; - item.typ = "folder"; - iv.setTag(item); - } else { - iv.setImageResource(R.drawable.audio); - musicItem item = new musicItem(); - item.title = txtName; - item.typ = "item"; - iv.setTag(item); - } - } else { - LayoutInflater li = LayoutInflater.from(mContext); - v = li.inflate(R.layout.icon, null); - - TextView tv = (TextView) v.findViewById(R.id.icon_text); - tv.setText(".."); - - ImageView iv = (ImageView) v.findViewById(R.id.icon_image); - iv.setImageResource(R.drawable.folderback); - musicItem item = new musicItem(); - item.title = ".."; - item.typ = "oneup"; - iv.setTag(item); - } - - } else { - v = convertView; - } - - return v; - } - } - - public class musicItem { - public String title; - public String typ; - } - -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.io.IOException; - -import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; - -public class postwebserver { - - public String httpServer = ""; - public String httpPort = ""; - - public postwebserver(String Server, String Port) { - httpServer = Server; - httpPort = Port; - } - - public boolean Post(String Data) { - - boolean result = false; - try { - HttpParams httpParameters = new BasicHttpParams(); - HttpConnectionParams.setConnectionTimeout(httpParameters, 5000); - HttpConnectionParams.setSoTimeout(httpParameters, 5000); - - DefaultHttpClient httpclient = new DefaultHttpClient(httpParameters); - HttpPost httppost = new HttpPost("http://" + httpServer + ":" - + httpPort); - - StringEntity se = new StringEntity(Data, "UTF-8"); - se.setContentType("application/atom+xml"); - - httppost.setEntity(se); - - @SuppressWarnings("unused") - HttpResponse response; - response = httpclient.execute(httppost); - - result = true; - } catch (ClientProtocolException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - return result; - } -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import mediaportal.remote.receivedbxmlhandler.DbItems; - -public class receivedbhandler { - - private static receivedbhandler instance; - - public int selectedMusic; - - public static receivedbhandler getinstance() { - if (instance == null) - instance = new receivedbhandler(); - return instance; - } - - public ArrayList<DbItems> GetAlbums() { - return fetchData("album.xml"); - } - - public ArrayList<DbItems> GetArtist() { - return fetchData("artist.xml"); - } - - public ArrayList<DbItems> GetSongs() { - return fetchData("song.xml"); - } - - public ArrayList<DbItems> GetSongsByArtist(String Artist) { - return fetchData("song.xml?artist=" + Artist); - } - - private ArrayList<DbItems> fetchData(String Data) { - - receivedbxmlhandler handler = new receivedbxmlhandler(); - receivehandler hand = new receivehandler(handler); - - try { - Data = URLEncoder.encode(Data, "UTF-8"); - } catch (UnsupportedEncodingException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - hand.readValues("/db_music/" + Data); - return handler.DbList; - } -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.util.ArrayList; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -public class receivedbxmlhandler extends DefaultHandler { - Boolean currentElement = false; - String currentValue = null; - - public ArrayList<DbItems> DbList = new ArrayList<DbItems>(); - - public static class DbItems - { - public String Title = ""; - public String Artist= ""; - public String Album= ""; - public String AlbumArtist= ""; - public String Track= ""; - public String Rating= ""; - public String Filename= ""; - } - private DbItems currentDbItem; - - /** - * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) - */ - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - currentElement = true; - - currentValue = ""; - if (localName == "Database")DbList = new ArrayList<DbItems>(); - if (localName == "Item")currentDbItem = new DbItems(); - } - - /** - * Called when tag closing ( example:- <name>AndroidPeople</name> -- </name> ) - */ - @Override - public void endElement(String uri, String localName, String qName) - throws SAXException { - - currentElement = false; - - /** set value */ - if (localName == "Artist") {currentDbItem.Artist =currentValue;} - if (localName == "Title") {currentDbItem.Title =currentValue;} - if (localName == "Album") {currentDbItem.Album =currentValue;} - if (localName == "AlbumArtist") {currentDbItem.AlbumArtist =currentValue;} - if (localName == "Track") {currentDbItem.Track =currentValue;} - if (localName == "Rating") {currentDbItem.Rating =currentValue;} - if (localName == "Filename") {currentDbItem.Filename =currentValue;} - - if (localName == "Item")DbList.add(currentDbItem); - } - - /** - * Called to get tag characters ( example:- <name>AndroidPeople</name> -- to get - * AndroidPeople Character ) - */ - @Override - public void characters(char[] ch, int start, int length) - throws SAXException { - if (currentElement) { - currentValue = new String(ch, start, length); - currentElement = false; - } - - } - -} \ No newline at end of file Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.util.ArrayList; -import mediaportal.remote.receivedirectoryxmlhandler.DirItems; - -public class receivedirhandler { - - private static receivedirhandler instance; - private static String actualDir; - - public static receivedirhandler getinstance() { - if (instance == null) - instance = new receivedirhandler(); - return instance; - } - - public ArrayList<DirItems> getMusicDir(String Dir) { - - return fetchData("/music/" + Dir); - } - - public ArrayList<DirItems> getPictureDir(String Dir) { - - return fetchData("/pictures/" + Dir); - } - - public ArrayList<DirItems> gotodir(String dir) { - actualDir += "/" + dir; - return fetchData(actualDir); - } - - public ArrayList<DirItems> oneup() { - int x = actualDir.lastIndexOf("/"); - if (x >= 0) { - actualDir = actualDir.substring(0, x); - } - return fetchData(actualDir); - } - - private ArrayList<DirItems> fetchData(String Data) { - - receivedirectoryxmlhandler handler = new receivedirectoryxmlhandler(); - receivehandler hand = new receivehandler(handler); - hand.readValues(Data); - - return handler.DirList; - } -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.util.ArrayList; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -import android.graphics.Bitmap; - -public class receivedirectoryxmlhandler extends DefaultHandler { - Boolean currentElement = false; - String currentValue = null; - - public ArrayList<DirItems> DirList = new ArrayList<DirItems>(); - - public static class DirItems - { - public boolean isFolder = false; - public String File= ""; - public Bitmap Picture = null; - } - private DirItems currentdirItem; - - /** - * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) - */ - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - currentElement = true; - - currentValue = ""; - if (localName == "Directory") {DirList = new ArrayList<DirItems>(); } - if (localName == "Folder") {currentdirItem = new DirItems(); } - if (localName == "File") {currentdirItem = new DirItems(); } - } - - /** - * Called when tag closing ( example:- <name>AndroidPeople</name> -- </name> ) - */ - @Override - public void endElement(String uri, String localName, String qName) - throws SAXException { - - currentElement = false; - - /** set value */ - if (localName == "Folder") { - currentdirItem.isFolder = true; - currentdirItem.File = currentValue; - DirList.add(currentdirItem); - } - if (localName == "File") { - currentdirItem.isFolder = false; - currentdirItem.File = currentValue; - DirList.add(currentdirItem); - } - } - - /** - * Called to get tag characters ( example:- <name>AndroidPeople</name> -- to get - * AndroidPeople Character ) - */ - @Override - public void characters(char[] ch, int start, int length) - throws SAXException { - if (currentElement) { - currentValue = new String(ch, start, length); - currentElement = false; - } - - } - -} \ No newline at end of file Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -public class receivehandler { - - private org.xml.sax.ContentHandler _handler; - - public receivehandler(org.xml.sax.ContentHandler Handler) { - _handler = Handler; - } - - public void readValues(String Url) - { - String fileUrl = "http://" + Settings.Server + ":" + Settings.Port + Url; - - URL myFileUrl = null; - try { - myFileUrl = new URL(fileUrl); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - try { - HttpURLConnection conn = (HttpURLConnection) myFileUrl - .openConnection(); - conn.setConnectTimeout(5000); - conn.setReadTimeout(10000); - conn.setDoInput(true); - conn.connect(); - - InputStream is = conn.getInputStream(); - - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser sp = null; - try { - sp = spf.newSAXParser(); - } catch (ParserConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - XMLReader reader = null; - try { - reader = sp.getXMLReader(); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - reader.setContentHandler((org.xml.sax.ContentHandler) _handler); - try { - reader.parse(new InputSource(is)); - } catch (SAXException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - is.close(); - sp.reset(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } - -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.io.IOException; -import java.io.InputStream; - -import mediaportal.remote.R; - -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.res.AssetManager; -import android.os.Bundle; -import android.view.GestureDetector; -import android.view.MotionEvent; -import android.view.View; -import android.view.GestureDetector.OnGestureListener; -import android.widget.Button; - -public class remote_01 extends Activity implements OnGestureListener { - - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - private String HttpServer = ""; - private String HttpPort = ""; - - private GestureDetector gestureScanner; - private static final int SWIPE_MIN_DISTANCE = 120; - private static final int SWIPE_MAX_OFF_PATH = 250; - private static final int SWIPE_THRESHOLD_VELOCITY = 200; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.remote01); - - gestureScanner = new GestureDetector(this); - - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); - - HttpServer = settings.getString("Server", "192.168.0.30"); - HttpPort = settings.getString("Port", "8200"); - - Button can = (Button) findViewById(R.id.btnBack); - can.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("previousMenu"); - } - }); - - Button menu = (Button) findViewById(R.id.btnMenu); - menu.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("contextMenu"); - } - }); - - Button home = (Button) findViewById(R.id.btnHome); - home.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("parentDir"); - } - }); - - Button info = (Button) findViewById(R.id.btnInfo); - info.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("showInfo"); - } - }); - - Button left = (Button) findViewById(R.id.btnLeft); - left.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("moveLeft"); - } - }); - - Button right = (Button) findViewById(R.id.btnRight); - right.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("moveRight"); - } - }); - - Button up = (Button) findViewById(R.id.btnUp); - up.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("moveUp"); - } - }); - - Button down = (Button) findViewById(R.id.btnDown); - down.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("moveDown"); - } - }); - - Button ok = (Button) findViewById(R.id.btnOk); - ok.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("selectItem"); - } - }); - - Button play = (Button) findViewById(R.id.btnPlay); - play.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("play"); - } - }); - - Button pause = (Button) findViewById(R.id.btnPause); - pause.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("pause"); - } - }); - - Button stop = (Button) findViewById(R.id.btnStop); - stop.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("stop"); - } - }); - - Button skipForw = (Button) findViewById(R.id.btnSkipForw); - skipForw.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("nextItem"); - } - }); - - Button skipBack = (Button) findViewById(R.id.btnSkipBack); - skipBack.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("prevItem"); - } - }); - - Button fForw = (Button) findViewById(R.id.btnFForw); - fForw.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("forward"); - } - }); - - Button fBackw = (Button) findViewById(R.id.btnFBack); - fBackw.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("rewind"); - } - }); - } - - public void PostCommand(String button) { - - postwebserver post = new postwebserver(HttpServer, HttpPort); - - AssetManager assetManager = getAssets(); - String xml = ""; - - try { - InputStream inputStream = null; - inputStream = assetManager.open("cmd_" + button + ".xml"); - - int x = inputStream.read(); - - while (x != -1) { - xml = xml + (char) x; - x = inputStream.read(); - } - post.Post(xml); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public boolean onTouchEvent(MotionEvent me) { - return gestureScanner.onTouchEvent(me); - } - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, - float velocityY) { - try { - if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) - return false; - // right to left swipe - if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE - && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { - Intent myIntent = new Intent(this, remote_02.class); - startActivityForResult(myIntent, 0); - - } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE - && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { - - } - } catch (Exception e) { - // nothing - } - return false; - } - - public boolean onDown(MotionEvent arg0) { - return true; - } - public void onLongPress(MotionEvent arg0) { - } - public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, - float arg3) { - return false; - } - public void onShowPress(MotionEvent arg0) { - } - public boolean onSingleTapUp(MotionEvent arg0) { - return false; - } -} \ No newline at end of file Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,197 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.io.IOException; -import java.io.InputStream; -import mediaportal.remote.R; -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.res.AssetManager; -import android.os.Bundle; -import android.view.GestureDetector; -import android.view.MotionEvent; -import android.view.View; -import android.view.GestureDetector.OnGestureListener; -import android.widget.Button; - -public class remote_02 extends Activity implements OnGestureListener { - - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - private String HttpServer = ""; - private String HttpPort = ""; - - private GestureDetector gestureScanner; - private static final int SWIPE_MIN_DISTANCE = 120; - private static final int SWIPE_MAX_OFF_PATH = 250; - private static final int SWIPE_THRESHOLD_VELOCITY = 200; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.remote02); - - gestureScanner = new GestureDetector(this); - - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); - - HttpServer = settings.getString("Server", "192.168.0.30"); - HttpPort = settings.getString("Port", "8200"); - - Button btnVolumeUp = (Button) findViewById(R.id.btnVolumeUp); - btnVolumeUp.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("volumeUp"); - } - }); - Button btnVolumeDown = (Button) findViewById(R.id.btnVolumeDown); - btnVolumeDown.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("volumeDown"); - } - }); - Button btnVolumeMute = (Button) findViewById(R.id.btnVolumeMute); - btnVolumeMute.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("volumeMute"); - } - }); - - Button btnChannelUp = (Button) findViewById(R.id.btnChannelUp); - btnChannelUp.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("nextChannel"); - } - }); - Button btnChannelDown = (Button) findViewById(R.id.btnChannelDown); - btnChannelDown.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("prevChannel"); - } - }); - - Button btnExit = (Button) findViewById(R.id.btnExit); - btnExit.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("exit"); - } - }); - Button btnSuspend = (Button) findViewById(R.id.btnSuspend); - btnSuspend.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("suspend"); - } - }); - Button btnHibernate = (Button) findViewById(R.id.btnHibernate); - btnHibernate.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("hibernate"); - } - }); - Button btnRestart = (Button) findViewById(R.id.btnRestart); - btnRestart.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("restart"); - } - }); - Button btnShutOff = (Button) findViewById(R.id.btnShutOff); - btnShutOff.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("shutoff"); - } - }); - - Button btnWakeOnLan = (Button) findViewById(R.id.btnWakeOnLan); - btnWakeOnLan.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - PostCommand("wakeonlan"); - } - }); - } - - - public void PostCommand(String button) { - - postwebserver post = new postwebserver(HttpServer, HttpPort); - - AssetManager assetManager = getAssets(); - String xml = ""; - - try { - InputStream inputStream = null; - inputStream = assetManager.open("cmd_" + button + ".xml"); - - int x = inputStream.read(); - - while (x != -1) { - xml = xml + (char) x; - x = inputStream.read(); - } - post.Post(xml); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public boolean onTouchEvent(MotionEvent me) { - return gestureScanner.onTouchEvent(me); - } - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, - float velocityY) { - try { - if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) - return false; - // right to left swipe - if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE - && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { - - - } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE - && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { - Intent myIntent = new Intent(this, remote_01.class); - startActivityForResult(myIntent, 0); - } - } catch (Exception e) { - // nothing - } - return false; - } - - public boolean onDown(MotionEvent arg0) { - return true; - } - public void onLongPress(MotionEvent arg0) { - } - public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, - float arg3) { - return false; - } - public void onShowPress(MotionEvent arg0) { - } - public boolean onSingleTapUp(MotionEvent arg0) { - return false; - } -} \ No newline at end of file Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -public class Settings{ - - public static String Server = "192.168.0.30"; - public static String Port = "8200"; - public static String MacId = "11-22-33-44-55-66"; - -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,116 +0,0 @@ -package mediaportal.remote; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; - -import org.apache.http.util.ByteArrayBuffer; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.os.Environment; - -public class httphandler { - - String extStorageDirectory; - - public httphandler() { - - } - - public InputStream openHttpConnection(String urlStr) { - InputStream in = null; - int resCode = -1; - - try { - URL url = new URL(urlStr); - URLConnection urlConn = url.openConnection(); - - if (!(urlConn instanceof HttpURLConnection)) { - throw new IOException("URL is not an Http URL"); - } - - HttpURLConnection httpConn = (HttpURLConnection) urlConn; - httpConn.setAllowUserInteraction(false); - httpConn.setInstanceFollowRedirects(true); - httpConn.setRequestMethod("GET"); - httpConn.connect(); - resCode = httpConn.getResponseCode(); - - if (resCode == HttpURLConnection.HTTP_OK) { - in = httpConn.getInputStream(); - } - - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - return in; - } - - public Bitmap DownloadImage(String urlStr) { - - final String url = urlStr; - Bitmap bitmap = null; - - InputStream in = null; - - try { - in = openHttpConnection(url); - bitmap = BitmapFactory.decodeStream(in); - if (in != null) - in.close(); - } catch (IOException e1) { - e1.printStackTrace(); - } - - return bitmap; - } - - public void DownloadFile() { - extStorageDirectory = Environment.getExternalStorageDirectory() - .toString(); - - try { - InputStream in = openHttpConnection("http://"+ Settings.Server + ":" + Settings.Port + - "/music/Clementi_Sonatina_Op.36_No.1_Movement_1.mp3"); - - // BufferedInputStream bis = new BufferedInputStream(in); - ByteArrayBuffer baf = new ByteArrayBuffer(50); - //int current = 0; - - byte[] bb = new byte[1024]; - int l = in.read(bb, 0, 1024); - - while (l > -0) { - baf.append(bb, 0, l); - l = in.read(bb, 0, 1024); - } - - OutputStream outStream = null; - File file = new File(extStorageDirectory, "test.mp3"); - - outStream = new FileOutputStream(file); - outStream.write(baf.toByteArray()); - outStream.flush(); - outStream.close(); - - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.io.IOException; - -import mediaportal.remote.R; -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.media.MediaPlayer; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.*; - -public class main extends Activity { - - private static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); - - Settings.Server = settings.getString("Server", "192.168.0.30"); - Settings.Port = settings.getString("Port", "8200"); - Settings.MacId = settings.getString("MacId", "11-22-33-44-55-66"); - - Toast.makeText(getBaseContext(), "Press 'menu' for settings", - Toast.LENGTH_LONG).show(); - - Button btnPictures = (Button) findViewById(R.id.MainButton1); - btnPictures.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), pictures.class); - startActivityForResult(myIntent, 0); - } - }); - - Button btnMusic = (Button) findViewById(R.id.MainButton2); - btnMusic.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), musictab.class); - startActivityForResult(myIntent, 0); - } - }); - - Button btnVideo = (Button) findViewById(R.id.MainButton3); - btnVideo.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - MediaPlayer mp = new MediaPlayer(); - try { - String p = "http://" - + Settings.Server - + ":" - + Settings.Port - + "/music/" - + "laserkraft_3d_-_nein_mann.mp3"; - mp.setDataSource(p); - mp.prepare(); - mp.start(); - } catch (IllegalStateException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - }); - - Button btnRemote = (Button) findViewById(R.id.MainButton4); - btnRemote.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), remote_01.class); - startActivityForResult(myIntent, 0); - } - }); - - Button btnNowPlaying = (Button) findViewById(R.id.MainButton5); - btnNowPlaying.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Intent myIntent = new Intent(view.getContext(), - nowplaying.class); - startActivityForResult(myIntent, 0); - } - }); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - menu.add(0, 111, 0, "Settings"); - menu.add(0, 112, 0, "Exit"); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case 111: - Intent myIntent = new Intent(this, setup.class); - startActivityForResult(myIntent, 0); - return true; - case 112: - this.finish(); - return true; - } - return true; - } -} \ No newline at end of file Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.util.ArrayList; - -import android.app.Activity; -import android.content.Context; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.os.Handler; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -public class musicalbum extends Activity { - - private Handler mHandler = new Handler(); - - private static ArrayList<receivedbxmlhandler.DbItems> albumList; - - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.music_album); - - ListView l1 = (ListView) findViewById(R.id.list_album); - l1.setAdapter(new EfficientAdapter(musicalbum.this)); - - ColorDrawable divcolor = new ColorDrawable(Color.DKGRAY); - l1.setDivider(divcolor); - l1.setDividerHeight(2); - - l1.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { - public boolean onItemLongClick(AdapterView<?> arg0, View arg1, - int arg2, long arg3) { - // TODO Auto-generated method stub - return false; - } - }); - } - - @Override - public void onStart() { - super.onStart(); - - mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, 100); - } - - private Runnable mUpdateTimeTask = new Runnable() { - public void run() { - update(); - } - }; - - private void update() { - - Log.d("update album", "do update"); - - receivedbhandler handler = receivedbhandler.getinstance(); - albumList = handler.GetAlbums(); - - if (albumList.size() == 0) { - Toast.makeText(musicalbum.this, "TIME OUT SERVER", - Toast.LENGTH_LONG).show(); - } - - ListView l1 = (ListView) findViewById(R.id.list_album); - l1.invalidateViews(); - } - - private static class EfficientAdapter extends BaseAdapter { - - private LayoutInflater mInflater; - - public EfficientAdapter(Context context) { - mInflater = LayoutInflater.from(context); - } - - public int getCount() { - if (albumList != null) - return albumList.size(); - else - return 0; - } - - public Object getItem(int position) { - return position; - } - - public long getItemId(int position) { - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder holder; - - if (convertView == null) { - convertView = mInflater.inflate(R.layout.list_item, null); - holder = new ViewHolder(); - holder.text = (TextView) convertView - .findViewById(R.id.TextView01); - holder.text2 = (TextView) convertView - .findViewById(R.id.TextView02); - - convertView.setTag(holder); - } else { - holder = (ViewHolder) convertView.getTag(); - } - - receivedbxmlhandler.DbItems item = albumList.get(position); - - holder.text.setText(String.valueOf(position + 1)); - holder.text2.setText(item.Album + " - " + item.Artist); - - convertView.setBackgroundColor((position & 1) == 1 ? Color.WHITE - : Color.LTGRAY); - - return convertView; - } - - static class ViewHolder { - TextView text; - TextView text2; - } - } - -} \ No newline at end of file Deleted: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java 2010-12-06 12:45:19 UTC (rev 4010) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java 2010-12-06 12:47:28 UTC (rev 4011) @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2005-2010 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -package mediaportal.remote; - -import java.util.ArrayList; -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.os.Handler; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -public class musicartist extends Activity{ - - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - private Handler mHandler = new Handler(); - - private static ArrayList<receivedbxmlhandler.DbItems> artistList; - - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.music_artist); - - ListView l1 = (ListView) findViewById(R.id.list_artist); - l1.setAdapter(new EfficientAdapter(musicartist.this)); - - l1.setOnItemClickListener(new AdapterView.OnItemClickListener() - { - //@override - public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, - long arg3) { - - receivedbxmlhandler.DbItems item = artistList.get(arg2); - musicresults.Select = item.Artist; - Intent myIntent = new Intent(arg1.getContext(), musicresults.class); - startActivityForResult(myIntent, 0); - } - } - ); - - ColorDrawable divcolor = new ColorDrawable(Color.DKGRAY); - l1.setDivider(divcolor); - l1.setDividerHeight(2); - } - - @Override - public void onStart() { - super.onStart(); - - mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, 100); - } - private Runnable mUpdateTimeTask = new Runnable() { - public void run() { - update(); - } - }; - - private void update() { - - Log.d("update artist", "do update"); - - receivedbhandler handler = receivedbhandler .getinstance(); - artistList = handler.GetArtist(); - - if (artistList.size() == 0) { - Toast.makeText(musicartist.this, "TIME OUT SERVER", - Toast.LENGTH_LONG).show(); - } - - ListView l1 = (ListView) findViewById(R.id.list_artist); - l1.invalidateViews(); - } - - private static class Efficie... [truncated message content] |
From: <Rol...@us...> - 2010-12-06 12:55:25
|
Revision: 4013 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4013&view=rev Author: Rollsroyc3 Date: 2010-12-06 12:55:15 +0000 (Mon, 06 Dec 2010) Log Message: ----------- Added Paths: ----------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicTab.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylistXmlHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/setup.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/splash.java Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MediaPlayerControl.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,44 @@ +package mediaportal.remote; + +import java.io.IOException; + +import android.media.MediaPlayer; + +public class mediaplayercontrol { + + private static mediaplayercontrol instance; + private static MediaPlayer mp; + + public static mediaplayercontrol getinstance() { + if (mp == null) + mp = new MediaPlayer(); + if (instance == null) + instance = new mediaplayercontrol(); + return instance; + } + + public void Stop() + { + mp.stop(); + } + public void Play(String Path) + { + + try { +// mp.stop(); + + mp.setDataSource(Path); + mp.prepare(); + mp.start(); + } catch (IllegalStateException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; +import mediaportal.remote.R; +import mediaportal.remote.receivedirectoryxmlhandler.DirItems; +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.os.Handler; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.Toast; + +public class musicdir extends Activity { + + private Handler mHandler = new Handler(); + private String actualDir = ""; + private static ArrayList<receivedirectoryxmlhandler.DirItems> musicList; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.music); + + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, 100); + + GridView gridview = (GridView) findViewById(R.id.music_grid); + gridview.setAdapter(new ImageAdapter2(musicdir.this)); + gridview.setOnItemClickListener(new OnItemClickListener() { + public void onItemClick(AdapterView<?> parent, View v, + int position, long id) { + + // TextView tv = (TextView) v.findViewById(R.id.icon_text); + // ImageView + ImageView iv = (ImageView) v.findViewById(R.id.icon_image); + musicItem music = (musicItem) iv.getTag(); + + if (music.typ == "item") { + // Picturesfullscreen.selectedPicture = position - 1; + // Intent myIntent = new Intent(MusicDir.this, + // Picturesfullscreen.class); + // startActivityForResult(myIntent, 0); + } + + if (music.typ == "folder") { + actualDir += music.title + "/"; + + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, 0); + } + + if (music.typ == "oneup") { + if (actualDir.endsWith("/")) + actualDir = actualDir.substring(0, + actualDir.length() - 1); + + int x = actualDir.lastIndexOf("/"); + if (x >= 0) { + actualDir = actualDir.substring(0, x + 1); + } else + actualDir = ""; + + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, 0); + } + + } + }); + } + + @Override + public void onStart() { + super.onStart(); + + // mHandler.removeCallbacks(mUpdateTimeTask); + // mHandler.postDelayed(mUpdateTimeTask, 100); + } + + private Runnable mUpdateTimeTask = new Runnable() { + public void run() { + update(); + } + }; + + private void update() { + + Log.d("update music dir", "do update folder : " + actualDir); + + receivedirhandler h = receivedirhandler.getinstance(); + musicList = h.getMusicDir(actualDir); + + if (musicList.size() == 0) { + Toast.makeText(musicdir.this, "TIME OUT SERVER", Toast.LENGTH_SHORT) + .show(); + } else { + GridView gridview = (GridView) findViewById(R.id.music_grid); + gridview.invalidateViews(); + } + } + + public class ImageAdapter2 extends BaseAdapter { + private Context mContext; + public static final int ACTIVITY_CREATE = 10; + + public ImageAdapter2(Context c) { + mContext = c; + } + + public int getCount() { + if (musicList != null) + return musicList.size() + 1; + else + return 0; + } + + public Object getItem(int position) { + return null; + } + + public long getItemId(int position) { + return 0; + } + + // @Override + // create a new ImageView for each item referenced by the Adapter + public View getView(int position, View convertView, ViewGroup parent) { + View v; + if (convertView == null) { // if it's not recycled, initialize some + // attributes + + if (position > 0) { + position = position - 1; + + DirItems item1 = musicList.get(position); + + String txtName = item1.File; + Boolean isFolder = item1.isFolder; + + LayoutInflater li = LayoutInflater.from(mContext); + v = li.inflate(R.layout.icon, null); + + TextView tv = (TextView) v.findViewById(R.id.icon_text); + tv.setText(txtName); + + ImageView iv = (ImageView) v.findViewById(R.id.icon_image); + + if (isFolder) { + iv.setImageResource(R.drawable.folder); + musicItem item = new musicItem(); + item.title = txtName; + item.typ = "folder"; + iv.setTag(item); + } else { + iv.setImageResource(R.drawable.audio); + musicItem item = new musicItem(); + item.title = txtName; + item.typ = "item"; + iv.setTag(item); + } + } else { + LayoutInflater li = LayoutInflater.from(mContext); + v = li.inflate(R.layout.icon, null); + + TextView tv = (TextView) v.findViewById(R.id.icon_text); + tv.setText(".."); + + ImageView iv = (ImageView) v.findViewById(R.id.icon_image); + iv.setImageResource(R.drawable.folderback); + musicItem item = new musicItem(); + item.title = ".."; + item.typ = "oneup"; + iv.setTag(item); + } + + } else { + v = convertView; + } + + return v; + } + } + + public class musicItem { + public String title; + public String typ; + } + +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/PostWebserver.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; + +public class postwebserver { + + public String httpServer = ""; + public String httpPort = ""; + + public postwebserver(String Server, String Port) { + httpServer = Server; + httpPort = Port; + } + + public boolean Post(String Data) { + + boolean result = false; + try { + HttpParams httpParameters = new BasicHttpParams(); + HttpConnectionParams.setConnectionTimeout(httpParameters, 5000); + HttpConnectionParams.setSoTimeout(httpParameters, 5000); + + DefaultHttpClient httpclient = new DefaultHttpClient(httpParameters); + HttpPost httppost = new HttpPost("http://" + httpServer + ":" + + httpPort); + + StringEntity se = new StringEntity(Data, "UTF-8"); + se.setContentType("application/atom+xml"); + + httppost.setEntity(se); + + @SuppressWarnings("unused") + HttpResponse response; + response = httpclient.execute(httppost); + + result = true; + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return result; + } +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbHandler.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import mediaportal.remote.receivedbxmlhandler.DbItems; + +public class receivedbhandler { + + private static receivedbhandler instance; + + public int selectedMusic; + + public static receivedbhandler getinstance() { + if (instance == null) + instance = new receivedbhandler(); + return instance; + } + + public ArrayList<DbItems> GetAlbums() { + return fetchData("album.xml"); + } + + public ArrayList<DbItems> GetArtist() { + return fetchData("artist.xml"); + } + + public ArrayList<DbItems> GetSongs() { + return fetchData("song.xml"); + } + + public ArrayList<DbItems> GetSongsByArtist(String Artist) { + return fetchData("song.xml?artist=" + Artist); + } + + private ArrayList<DbItems> fetchData(String Data) { + + receivedbxmlhandler handler = new receivedbxmlhandler(); + receivehandler hand = new receivehandler(handler); + + try { + Data = URLEncoder.encode(Data, "UTF-8"); + } catch (UnsupportedEncodingException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + hand.readValues("/db_music/" + Data); + return handler.DbList; + } +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDbXmlHandler.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +public class receivedbxmlhandler extends DefaultHandler { + Boolean currentElement = false; + String currentValue = null; + + public ArrayList<DbItems> DbList = new ArrayList<DbItems>(); + + public static class DbItems + { + public String Title = ""; + public String Artist= ""; + public String Album= ""; + public String AlbumArtist= ""; + public String Track= ""; + public String Rating= ""; + public String Filename= ""; + } + private DbItems currentDbItem; + + /** + * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) + */ + @Override + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException { + currentElement = true; + + currentValue = ""; + if (localName == "Database")DbList = new ArrayList<DbItems>(); + if (localName == "Item")currentDbItem = new DbItems(); + } + + /** + * Called when tag closing ( example:- <name>AndroidPeople</name> -- </name> ) + */ + @Override + public void endElement(String uri, String localName, String qName) + throws SAXException { + + currentElement = false; + + /** set value */ + if (localName == "Artist") {currentDbItem.Artist =currentValue;} + if (localName == "Title") {currentDbItem.Title =currentValue;} + if (localName == "Album") {currentDbItem.Album =currentValue;} + if (localName == "AlbumArtist") {currentDbItem.AlbumArtist =currentValue;} + if (localName == "Track") {currentDbItem.Track =currentValue;} + if (localName == "Rating") {currentDbItem.Rating =currentValue;} + if (localName == "Filename") {currentDbItem.Filename =currentValue;} + + if (localName == "Item")DbList.add(currentDbItem); + } + + /** + * Called to get tag characters ( example:- <name>AndroidPeople</name> -- to get + * AndroidPeople Character ) + */ + @Override + public void characters(char[] ch, int start, int length) + throws SAXException { + if (currentElement) { + currentValue = new String(ch, start, length); + currentElement = false; + } + + } + +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirHandler.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; +import mediaportal.remote.receivedirectoryxmlhandler.DirItems; + +public class receivedirhandler { + + private static receivedirhandler instance; + private static String actualDir; + + public static receivedirhandler getinstance() { + if (instance == null) + instance = new receivedirhandler(); + return instance; + } + + public ArrayList<DirItems> getMusicDir(String Dir) { + + return fetchData("/music/" + Dir); + } + + public ArrayList<DirItems> getPictureDir(String Dir) { + + return fetchData("/pictures/" + Dir); + } + + public ArrayList<DirItems> gotodir(String dir) { + actualDir += "/" + dir; + return fetchData(actualDir); + } + + public ArrayList<DirItems> oneup() { + int x = actualDir.lastIndexOf("/"); + if (x >= 0) { + actualDir = actualDir.substring(0, x); + } + return fetchData(actualDir); + } + + private ArrayList<DirItems> fetchData(String Data) { + + receivedirectoryxmlhandler handler = new receivedirectoryxmlhandler(); + receivehandler hand = new receivehandler(handler); + hand.readValues(Data); + + return handler.DirList; + } +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveDirectoryXmlHandler.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import android.graphics.Bitmap; + +public class receivedirectoryxmlhandler extends DefaultHandler { + Boolean currentElement = false; + String currentValue = null; + + public ArrayList<DirItems> DirList = new ArrayList<DirItems>(); + + public static class DirItems + { + public boolean isFolder = false; + public String File= ""; + public Bitmap Picture = null; + } + private DirItems currentdirItem; + + /** + * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) + */ + @Override + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException { + currentElement = true; + + currentValue = ""; + if (localName == "Directory") {DirList = new ArrayList<DirItems>(); } + if (localName == "Folder") {currentdirItem = new DirItems(); } + if (localName == "File") {currentdirItem = new DirItems(); } + } + + /** + * Called when tag closing ( example:- <name>AndroidPeople</name> -- </name> ) + */ + @Override + public void endElement(String uri, String localName, String qName) + throws SAXException { + + currentElement = false; + + /** set value */ + if (localName == "Folder") { + currentdirItem.isFolder = true; + currentdirItem.File = currentValue; + DirList.add(currentdirItem); + } + if (localName == "File") { + currentdirItem.isFolder = false; + currentdirItem.File = currentValue; + DirList.add(currentdirItem); + } + } + + /** + * Called to get tag characters ( example:- <name>AndroidPeople</name> -- to get + * AndroidPeople Character ) + */ + @Override + public void characters(char[] ch, int start, int length) + throws SAXException { + if (currentElement) { + currentValue = new String(ch, start, length); + currentElement = false; + } + + } + +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +public class receivehandler { + + private org.xml.sax.ContentHandler _handler; + + public receivehandler(org.xml.sax.ContentHandler Handler) { + _handler = Handler; + } + + public void readValues(String Url) + { + String fileUrl = "http://" + Settings.Server + ":" + Settings.Port + Url; + + URL myFileUrl = null; + try { + myFileUrl = new URL(fileUrl); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + HttpURLConnection conn = (HttpURLConnection) myFileUrl + .openConnection(); + conn.setConnectTimeout(5000); + conn.setReadTimeout(10000); + conn.setDoInput(true); + conn.connect(); + + InputStream is = conn.getInputStream(); + + SAXParserFactory spf = SAXParserFactory.newInstance(); + SAXParser sp = null; + try { + sp = spf.newSAXParser(); + } catch (ParserConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + XMLReader reader = null; + try { + reader = sp.getXMLReader(); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + reader.setContentHandler((org.xml.sax.ContentHandler) _handler); + try { + reader.parse(new InputSource(is)); + } catch (SAXException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + is.close(); + sp.reset(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_01.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,240 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.io.IOException; +import java.io.InputStream; + +import mediaportal.remote.R; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.AssetManager; +import android.os.Bundle; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.view.View; +import android.view.GestureDetector.OnGestureListener; +import android.widget.Button; + +public class remote_01 extends Activity implements OnGestureListener { + + public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + private String HttpServer = ""; + private String HttpPort = ""; + + private GestureDetector gestureScanner; + private static final int SWIPE_MIN_DISTANCE = 120; + private static final int SWIPE_MAX_OFF_PATH = 250; + private static final int SWIPE_THRESHOLD_VELOCITY = 200; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.remote01); + + gestureScanner = new GestureDetector(this); + + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, + MODE_PRIVATE); + + HttpServer = settings.getString("Server", "192.168.0.30"); + HttpPort = settings.getString("Port", "8200"); + + Button can = (Button) findViewById(R.id.btnBack); + can.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("previousMenu"); + } + }); + + Button menu = (Button) findViewById(R.id.btnMenu); + menu.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("contextMenu"); + } + }); + + Button home = (Button) findViewById(R.id.btnHome); + home.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("parentDir"); + } + }); + + Button info = (Button) findViewById(R.id.btnInfo); + info.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("showInfo"); + } + }); + + Button left = (Button) findViewById(R.id.btnLeft); + left.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("moveLeft"); + } + }); + + Button right = (Button) findViewById(R.id.btnRight); + right.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("moveRight"); + } + }); + + Button up = (Button) findViewById(R.id.btnUp); + up.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("moveUp"); + } + }); + + Button down = (Button) findViewById(R.id.btnDown); + down.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("moveDown"); + } + }); + + Button ok = (Button) findViewById(R.id.btnOk); + ok.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("selectItem"); + } + }); + + Button play = (Button) findViewById(R.id.btnPlay); + play.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("play"); + } + }); + + Button pause = (Button) findViewById(R.id.btnPause); + pause.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("pause"); + } + }); + + Button stop = (Button) findViewById(R.id.btnStop); + stop.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("stop"); + } + }); + + Button skipForw = (Button) findViewById(R.id.btnSkipForw); + skipForw.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("nextItem"); + } + }); + + Button skipBack = (Button) findViewById(R.id.btnSkipBack); + skipBack.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("prevItem"); + } + }); + + Button fForw = (Button) findViewById(R.id.btnFForw); + fForw.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("forward"); + } + }); + + Button fBackw = (Button) findViewById(R.id.btnFBack); + fBackw.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("rewind"); + } + }); + } + + public void PostCommand(String button) { + + postwebserver post = new postwebserver(HttpServer, HttpPort); + + AssetManager assetManager = getAssets(); + String xml = ""; + + try { + InputStream inputStream = null; + inputStream = assetManager.open("cmd_" + button + ".xml"); + + int x = inputStream.read(); + + while (x != -1) { + xml = xml + (char) x; + x = inputStream.read(); + } + post.Post(xml); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public boolean onTouchEvent(MotionEvent me) { + return gestureScanner.onTouchEvent(me); + } + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) { + try { + if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) + return false; + // right to left swipe + if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE + && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + Intent myIntent = new Intent(this, remote_02.class); + startActivityForResult(myIntent, 0); + + } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE + && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + + } + } catch (Exception e) { + // nothing + } + return false; + } + + public boolean onDown(MotionEvent arg0) { + return true; + } + public void onLongPress(MotionEvent arg0) { + } + public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, + float arg3) { + return false; + } + public void onShowPress(MotionEvent arg0) { + } + public boolean onSingleTapUp(MotionEvent arg0) { + return false; + } +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Remote_02.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.io.IOException; +import java.io.InputStream; +import mediaportal.remote.R; +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.AssetManager; +import android.os.Bundle; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.view.View; +import android.view.GestureDetector.OnGestureListener; +import android.widget.Button; + +public class remote_02 extends Activity implements OnGestureListener { + + public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + private String HttpServer = ""; + private String HttpPort = ""; + + private GestureDetector gestureScanner; + private static final int SWIPE_MIN_DISTANCE = 120; + private static final int SWIPE_MAX_OFF_PATH = 250; + private static final int SWIPE_THRESHOLD_VELOCITY = 200; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.remote02); + + gestureScanner = new GestureDetector(this); + + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, + MODE_PRIVATE); + + HttpServer = settings.getString("Server", "192.168.0.30"); + HttpPort = settings.getString("Port", "8200"); + + Button btnVolumeUp = (Button) findViewById(R.id.btnVolumeUp); + btnVolumeUp.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("volumeUp"); + } + }); + Button btnVolumeDown = (Button) findViewById(R.id.btnVolumeDown); + btnVolumeDown.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("volumeDown"); + } + }); + Button btnVolumeMute = (Button) findViewById(R.id.btnVolumeMute); + btnVolumeMute.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("volumeMute"); + } + }); + + Button btnChannelUp = (Button) findViewById(R.id.btnChannelUp); + btnChannelUp.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("nextChannel"); + } + }); + Button btnChannelDown = (Button) findViewById(R.id.btnChannelDown); + btnChannelDown.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("prevChannel"); + } + }); + + Button btnExit = (Button) findViewById(R.id.btnExit); + btnExit.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("exit"); + } + }); + Button btnSuspend = (Button) findViewById(R.id.btnSuspend); + btnSuspend.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("suspend"); + } + }); + Button btnHibernate = (Button) findViewById(R.id.btnHibernate); + btnHibernate.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("hibernate"); + } + }); + Button btnRestart = (Button) findViewById(R.id.btnRestart); + btnRestart.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("restart"); + } + }); + Button btnShutOff = (Button) findViewById(R.id.btnShutOff); + btnShutOff.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("shutoff"); + } + }); + + Button btnWakeOnLan = (Button) findViewById(R.id.btnWakeOnLan); + btnWakeOnLan.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + PostCommand("wakeonlan"); + } + }); + } + + + public void PostCommand(String button) { + + postwebserver post = new postwebserver(HttpServer, HttpPort); + + AssetManager assetManager = getAssets(); + String xml = ""; + + try { + InputStream inputStream = null; + inputStream = assetManager.open("cmd_" + button + ".xml"); + + int x = inputStream.read(); + + while (x != -1) { + xml = xml + (char) x; + x = inputStream.read(); + } + post.Post(xml); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public boolean onTouchEvent(MotionEvent me) { + return gestureScanner.onTouchEvent(me); + } + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) { + try { + if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) + return false; + // right to left swipe + if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE + && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + + + } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE + && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + Intent myIntent = new Intent(this, remote_01.class); + startActivityForResult(myIntent, 0); + } + } catch (Exception e) { + // nothing + } + return false; + } + + public boolean onDown(MotionEvent arg0) { + return true; + } + public void onLongPress(MotionEvent arg0) { + } + public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, + float arg3) { + return false; + } + public void onShowPress(MotionEvent arg0) { + } + public boolean onSingleTapUp(MotionEvent arg0) { + return false; + } +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/Settings.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +public class Settings{ + + public static String Server = "192.168.0.30"; + public static String Port = "8200"; + public static String MacId = "11-22-33-44-55-66"; + +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,116 @@ +package mediaportal.remote; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + +import org.apache.http.util.ByteArrayBuffer; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.Environment; + +public class httphandler { + + String extStorageDirectory; + + public httphandler() { + + } + + public InputStream openHttpConnection(String urlStr) { + InputStream in = null; + int resCode = -1; + + try { + URL url = new URL(urlStr); + URLConnection urlConn = url.openConnection(); + + if (!(urlConn instanceof HttpURLConnection)) { + throw new IOException("URL is not an Http URL"); + } + + HttpURLConnection httpConn = (HttpURLConnection) urlConn; + httpConn.setAllowUserInteraction(false); + httpConn.setInstanceFollowRedirects(true); + httpConn.setRequestMethod("GET"); + httpConn.connect(); + resCode = httpConn.getResponseCode(); + + if (resCode == HttpURLConnection.HTTP_OK) { + in = httpConn.getInputStream(); + } + + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return in; + } + + public Bitmap DownloadImage(String urlStr) { + + final String url = urlStr; + Bitmap bitmap = null; + + InputStream in = null; + + try { + in = openHttpConnection(url); + bitmap = BitmapFactory.decodeStream(in); + if (in != null) + in.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + return bitmap; + } + + public void DownloadFile() { + extStorageDirectory = Environment.getExternalStorageDirectory() + .toString(); + + try { + InputStream in = openHttpConnection("http://"+ Settings.Server + ":" + Settings.Port + + "/music/Clementi_Sonatina_Op.36_No.1_Movement_1.mp3"); + + // BufferedInputStream bis = new BufferedInputStream(in); + ByteArrayBuffer baf = new ByteArrayBuffer(50); + //int current = 0; + + byte[] bb = new byte[1024]; + int l = in.read(bb, 0, 1024); + + while (l > -0) { + baf.append(bb, 0, l); + l = in.read(bb, 0, 1024); + } + + OutputStream outStream = null; + File file = new File(extStorageDirectory, "test.mp3"); + + outStream = new FileOutputStream(file); + outStream.write(baf.toByteArray()); + outStream.flush(); + outStream.close(); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.io.IOException; + +import mediaportal.remote.R; +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.media.MediaPlayer; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.*; + +public class main extends Activity { + + private static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, + MODE_PRIVATE); + + Settings.Server = settings.getString("Server", "192.168.0.30"); + Settings.Port = settings.getString("Port", "8200"); + Settings.MacId = settings.getString("MacId", "11-22-33-44-55-66"); + + Toast.makeText(getBaseContext(), "Press 'menu' for settings", + Toast.LENGTH_LONG).show(); + + Button btnPictures = (Button) findViewById(R.id.MainButton1); + btnPictures.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + Intent myIntent = new Intent(view.getContext(), pictures.class); + startActivityForResult(myIntent, 0); + } + }); + + Button btnMusic = (Button) findViewById(R.id.MainButton2); + btnMusic.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + Intent myIntent = new Intent(view.getContext(), musictab.class); + startActivityForResult(myIntent, 0); + } + }); + + Button btnVideo = (Button) findViewById(R.id.MainButton3); + btnVideo.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + MediaPlayer mp = new MediaPlayer(); + try { + String p = "http://" + + Settings.Server + + ":" + + Settings.Port + + "/music/" + + "laserkraft_3d_-_nein_mann.mp3"; + mp.setDataSource(p); + mp.prepare(); + mp.start(); + } catch (IllegalStateException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }); + + Button btnRemote = (Button) findViewById(R.id.MainButton4); + btnRemote.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + Intent myIntent = new Intent(view.getContext(), remote_01.class); + startActivityForResult(myIntent, 0); + } + }); + + Button btnNowPlaying = (Button) findViewById(R.id.MainButton5); + btnNowPlaying.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + Intent myIntent = new Intent(view.getContext(), + nowplaying.class); + startActivityForResult(myIntent, 0); + } + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + menu.add(0, 111, 0, "Settings"); + menu.add(0, 112, 0, "Exit"); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case 111: + Intent myIntent = new Intent(this, setup.class); + startActivityForResult(myIntent, 0); + return true; + case 112: + this.finish(); + return true; + } + return true; + } +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.os.Handler; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +public class musicalbum extends Activity { + + private Handler mHandler = new Handler(); + + private static ArrayList<receivedbxmlhandler.DbItems> albumList; + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.music_album); + + ListView l1 = (ListView) findViewById(R.id.list_album); + l1.setAdapter(new EfficientAdapter(musicalbum.this)); + + ColorDrawable divcolor = new ColorDrawable(Color.DKGRAY); + l1.setDivider(divcolor); + l1.setDividerHeight(2); + + l1.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { + public boolean onItemLongClick(AdapterView<?> arg0, View arg1, + int arg2, long arg3) { + // TODO Auto-generated method stub + return false; + } + }); + } + + @Override + public void onStart() { + super.onStart(); + + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, 100); + } + + private Runnable mUpdateTimeTask = new Runnable() { + public void run() { + update(); + } + }; + + private void update() { + + Log.d("update album", "do update"); + + receivedbhandler handler = receivedbhandler.getinstance(); + albumList = handler.GetAlbums(); + + if (albumList.size() == 0) { + Toast.makeText(musicalbum.this, "TIME OUT SERVER", + Toast.LENGTH_LONG).show(); + } + + ListView l1 = (ListView) findViewById(R.id.list_album); + l1.invalidateViews(); + } + + private static class EfficientAdapter extends BaseAdapter { + + private LayoutInflater mInflater; + + public EfficientAdapter(Context context) { + mInflater = LayoutInflater.from(context); + } + + public int getCount() { + if (albumList != null) + return albumList.size(); + else + return 0; + } + + public Object getItem(int position) { + return position; + } + + public long getItemId(int position) { + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder holder; + + if (convertView == null) { + convertView = mInflater.inflate(R.layout.list_item, null); + holder = new ViewHolder(); + holder.text = (TextView) convertView + .findViewById(R.id.TextView01); + holder.text2 = (TextView) convertView + .findViewById(R.id.TextView02); + + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + receivedbxmlhandler.DbItems item = albumList.get(position); + + holder.text.setText(String.valueOf(position + 1)); + holder.text2.setText(item.Album + " - " + item.Artist); + + convertView.setBackgroundColor((position & 1) == 1 ? Color.WHITE + : Color.LTGRAY); + + return convertView; + } + + static class ViewHolder { + TextView text; + TextView text2; + } + } + +} \ No newline at end of file Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java 2010-12-06 12:55:15 UTC (rev 4013) @@ -0,0 +1,159 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import java.util.ArrayList; +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.os.Handler; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +public class musicartist extends Activity{ + + public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; + private Handler mHandler = new Handler(); + + private static ArrayList<receivedbxmlhandler.DbItems> artistList; + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.music_artist); + + ListView l1 = (ListView) findViewById(R.id.list_artist); + l1.setAdapter(new EfficientAdapter(musicartist.this)); + + l1.setOnItemClickListener(new AdapterView.OnItemClickListener() + { + //@override + public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, + long arg3) { + + receivedbxmlhandler.DbItems item = artistList.get(arg2); + musicresults.Select = item.Artist; + Intent myIntent = new Intent(arg1.getContext(), musicresults.class); + startActivityForResult(myIntent, 0); + } + } + ); + + ColorDrawable divcolor = new ColorDrawable(Color.DKGRAY); + l1.setDivider(divcolor); + l1.setDividerHeight(2); + } + + @Override + public void onStart() { + super.onStart(); + + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, 100); + } + private Runnable mUpdateTimeTask = new Runnable() { + public void run() { + update(); + } + }; + + private void update() { + + Log.d("update artist", "do update"); + + receivedbhandler handler = receivedbhandler .getinstance(); + artistList = handler.GetArtist(); + + if (artistList.size() == 0) { + Toast.makeText(musicartist.this, "TIME OUT SERVER", + Toast.LENGTH_LONG).show(); + } + + ListView l1 = (ListView) findViewById(R.id.list_artist); + l1.invalidateViews(); + } + + private static class EfficientAdapter extends BaseAdapter { + + private LayoutInflater mInflater; + + ... [truncated message content] |
From: <Rol...@us...> - 2010-12-14 04:10:16
|
Revision: 4030 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4030&view=rev Author: Rollsroyc3 Date: 2010-12-14 04:10:10 +0000 (Tue, 14 Dec 2010) Log Message: ----------- added worker thread code with dialogs to pictures. started swipe code with context menu. Modified Paths: -------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-12-11 11:49:00 UTC (rev 4029) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-12-14 04:10:10 UTC (rev 4030) @@ -28,6 +28,7 @@ import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.util.Log; @@ -112,35 +113,50 @@ private Runnable mUpdateTimeTask = new Runnable() { public void run() { - update(); + new update().execute(); + //update(); } }; - private void update() { + + + private class update extends AsyncTask<String, Void, Void> { + private final ProgressDialog dialog = new ProgressDialog(pictures.this); + + // can use UI thread here + protected void onPreExecute() { + this.dialog.setMessage("Loading..."); + this.dialog.show(); + } + + // automatically done on worker thread (separate from UI thread) + protected Void doInBackground(final String... args) { + Log.d("update pictures", "do update folder : " + actualDir); + + ReceiveDirHandler h = ReceiveDirHandler.getinstance(); + pictureList = h.getPictureDir(actualDir); - ProgressDialog dialog = new ProgressDialog(this); - dialog.setCancelable(true); - dialog.setMessage("Loading..."); - dialog.show(); - + return null; + } + + // can use UI thread here + protected void onPostExecute(final Void unused) { + if (this.dialog.isShowing()) { + this.dialog.dismiss(); + } - Log.d("update pictures", "do update folder : " + actualDir); - - ReceiveDirHandler h = ReceiveDirHandler.getinstance(); - pictureList = h.getPictureDir(actualDir); - - if (pictureList.size() == 0) { + if (pictureList.size() == 0) { Toast.makeText(pictures.this, "TIME OUT SERVER", Toast.LENGTH_SHORT) .show(); - } else { - GridView gridview = (GridView) findViewById(R.id.GridView01); - gridview.setAdapter(new ImageAdapter2(this)); - } - - dialog.cancel(); - } - - public class ImageAdapter2 extends BaseAdapter { + } else { + GridView gridview = (GridView) findViewById(R.id.GridView01); + gridview.setAdapter(new ImageAdapter2(pictures.this)); + } + } + } + + + public class ImageAdapter2 extends BaseAdapter { private Context mContext; public static final int ACTIVITY_CREATE = 10; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java 2010-12-11 11:49:00 UTC (rev 4029) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/picturesfullscreen.java 2010-12-14 04:10:10 UTC (rev 4030) @@ -29,30 +29,40 @@ import mediaportal.remote.R; import mediaportal.remote.ReceiveDirectoryXmlHandler.DirItems; import android.app.Activity; +import android.app.ProgressDialog; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.util.Log; import android.view.ContextMenu; +import android.view.GestureDetector; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.ContextMenu.ContextMenuInfo; +import android.view.GestureDetector.OnGestureListener; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; -public class picturesfullscreen extends Activity { +public class picturesfullscreen extends Activity implements OnGestureListener { private Handler mHandler = new Handler(); - + private GestureDetector gestureScanner; + private static final int SWIPE_MIN_DISTANCE = 120; + private static final int SWIPE_MAX_OFF_PATH = 250; + private static final int SWIPE_THRESHOLD_VELOCITY = 200; private boolean slideShow; private boolean randomShow; + public static boolean SlideshowPaused = false; + private static long SlideInterval = 6000; /** Called when the activity is first created. */ @Override @@ -65,33 +75,63 @@ setContentView(R.layout.picturesfullscreen); ImageView imagev = (ImageView) findViewById(R.id.ImageView01); - registerForContextMenu(imagev); - - setPicture(); + //registerForContextMenu(imagev); + + gestureScanner = new GestureDetector(this); + + new setPicture().execute(); + } - private void setPicture() { - ImageView imagev = (ImageView) findViewById(R.id.ImageView01); - DirItems item = pictures.pictureList.get(pictures.selectedPicture); - if (!item.isFolder) { - httpHandler http = new httpHandler(); - String file = "http://" + Settings.Server + ":" + Settings.Port - + "/pictures/"; - file += pictures.actualDir + item.File; - item.Picture = http.DownloadImage(file.replaceAll(" ", "%20")); - imagev.setImageBitmap(item.Picture); + + + + private class setPicture extends AsyncTask<String, Void, Void> { + private final ProgressDialog dialog = new ProgressDialog(picturesfullscreen.this); + DirItems item = pictures.pictureList.get(pictures.selectedPicture); + + // can use UI thread here + protected void onPreExecute() { + this.dialog.setMessage("Loading..."); + this.dialog.show(); + } + + // automatically done on worker thread (separate from UI thread) + protected Void doInBackground(final String... args) { + if (!item.isFolder) { + httpHandler http = new httpHandler(); + String file = "http://" + Settings.Server + ":" + Settings.Port + + "/pictures/"; + file += pictures.actualDir + item.File; + item.Picture = http.DownloadImage(file.replaceAll(" ", "%20")); + } + + return null; + } + + // can use UI thread here + protected void onPostExecute(final Void unused) { + if (this.dialog.isShowing()) { + this.dialog.dismiss(); + } + + if (item.isFolder != true){ + ImageView imagev = (ImageView) findViewById(R.id.ImageView01); + imagev.setImageBitmap(item.Picture); + TextView txt = (TextView) findViewById(R.id.full_text); + txt.setText(item.File); + } - TextView txt = (TextView) findViewById(R.id.full_text); - txt.setText(item.File); - } - } + } + } + @Override public void onStart() { super.onStart(); mHandler.removeCallbacks(mUpdateTimeTask); - mHandler.postDelayed(mUpdateTimeTask, 2000); + mHandler.postDelayed(mUpdateTimeTask, SlideInterval); } private Runnable mUpdateTimeTask = new Runnable() { @@ -105,7 +145,8 @@ pictures.selectedPicture++; else pictures.selectedPicture = 0; - setPicture(); + + new setPicture().execute(); } else { String req = "http://" + Settings.Server + ":" + Settings.Port + "/random/pictures/random.jpg"; @@ -121,16 +162,26 @@ } } - mHandler.postDelayed(mUpdateTimeTask, 2000); + mHandler.postDelayed(mUpdateTimeTask, SlideInterval); } }; @Override public void onPause() { super.onPause(); + SlideshowPaused = true; mHandler.removeCallbacks(mUpdateTimeTask); } - + + + @Override + protected void onResume() { + super.onResume(); + SlideshowPaused = false; + mHandler.removeCallbacks(mUpdateTimeTask); + mHandler.postDelayed(mUpdateTimeTask, SlideInterval); + } + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); @@ -257,5 +308,88 @@ // e.printStackTrace(); } } + + + @Override + public boolean onTouchEvent(MotionEvent me) { + this.gestureScanner.onTouchEvent(me); + return super.onTouchEvent(me); + } + + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) { + try { + int max = pictures.pictureList.size(); + + if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) + return false; + // right to left swipe + if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE + && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + + if (pictures.selectedPicture < max - 1) { + pictures.selectedPicture++; + new setPicture().execute(); + } else + Toast.makeText(this, "reached end +", + Toast.LENGTH_SHORT).show(); + return true; + } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE + && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + + if (pictures.selectedPicture > 0) { + pictures.selectedPicture--; + new setPicture().execute(); + } else + Toast.makeText(this, "reached end -", + Toast.LENGTH_SHORT).show(); + return true; + } + } catch (Exception e) { + // nothing + } + return false; + } + + public boolean onDown(MotionEvent arg0) { + return false; + } + + public void onLongPress(MotionEvent arg0) { + } + + public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, + float arg3) { + return false; + } + + public void onShowPress(MotionEvent arg0) { + } + + public boolean onSingleTapUp(MotionEvent arg0) { + if (slideShow == true || randomShow == true){ + if (SlideshowPaused == false) + { + onPause(); + Toast.makeText(this, "Pause", + Toast.LENGTH_SHORT).show(); + return true; + } + else + { + onResume(); + Toast.makeText(this, "Play", + Toast.LENGTH_SHORT).show(); + return true; + } + } + else + { + return false; + } + } + + + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kro...@us...> - 2010-12-16 10:58:31
|
Revision: 4035 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4035&view=rev Author: kroko_koenig Date: 2010-12-16 10:58:24 +0000 (Thu, 16 Dec 2010) Log Message: ----------- add exception handler and send report via email Modified Paths: -------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java Added Paths: ----------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/TopExceptionHandler.java Added: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/TopExceptionHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/TopExceptionHandler.java (rev 0) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/TopExceptionHandler.java 2010-12-16 10:58:24 UTC (rev 4035) @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +package mediaportal.remote; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import java.io.*; + +public class TopExceptionHandler implements Thread.UncaughtExceptionHandler { + + private Thread.UncaughtExceptionHandler defaultUEH; + + private Activity app = null; + + public TopExceptionHandler(Activity app) { + this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); + this.app = app; + } + + public void uncaughtException(Thread t, Throwable e) { + StackTraceElement[] arr = e.getStackTrace(); + String report = e.toString() + "\n\n"; + report += "--------- Stack trace ---------\n\n"; + for (int i = 0; i < arr.length; i++) { + report += " " + arr[i].toString() + "\n"; + } + report += "-------------------------------\n\n"; + + // If the exception was thrown in a background thread inside + // AsyncTask, then the actual exception can be found with getCause + report += "--------- Cause ---------\n\n"; + Throwable cause = e.getCause(); + if (cause != null) { + report += cause.toString() + "\n\n"; + arr = cause.getStackTrace(); + for (int i = 0; i < arr.length; i++) { + report += " " + arr[i].toString() + "\n"; + } + } + + report += "-------------------------------\n\n"; + report += "--------- Device ---------\n\n"; + report += "Brand: " + Build.BRAND + "\n"; + report += "Device: " + Build.DEVICE + "\n"; + report += "Model: " + Build.MODEL + "\n"; + report += "Id: " + Build.ID + "\n"; + report += "Product: " + Build.PRODUCT + "\n"; + report += "-------------------------------\n\n"; + report += "--------- Firmware ---------\n\n"; + report += "SDK: " + Build.VERSION.SDK + "\n"; + report += "Release: " + Build.VERSION.RELEASE + "\n"; + report += "Incremental: " + Build.VERSION.INCREMENTAL + "\n"; + report += "-------------------------------\n\n"; + + try { + FileOutputStream trace = app.openFileOutput("stack.trace", + Context.MODE_PRIVATE); + trace.write(report.getBytes()); + trace.close(); + } catch (IOException ioe) { + // ... + } + + defaultUEH.uncaughtException(t, e); + } + +} Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-12-15 21:33:12 UTC (rev 4034) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/main.java 2010-12-16 10:58:24 UTC (rev 4035) @@ -21,11 +21,16 @@ package mediaportal.remote; +import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import mediaportal.remote.R; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.AssetManager; @@ -42,17 +47,39 @@ private static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; private Handler mHandler = new Handler(); private static String display = "nothing playing"; - + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); + if (reportExist()) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage("Do you want to send a crash report ?") + .setTitle("Sorry .. remote has crashed") + .setPositiveButton("Yes", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int item) { + sendReport(); + } + }) + .setNegativeButton("No", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int item) { + deleteReport(); + } + }).show(); + + } + + Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler(this)); chkStatus(); - + mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 1000); - + SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, MODE_PRIVATE); @@ -86,6 +113,11 @@ Toast.makeText(view.getContext(), "not implemented yet. Sorry !", Toast.LENGTH_LONG) .show(); + + int x = 0; + int y = 1; + + int z = y / x; } }); @@ -142,6 +174,57 @@ }); } + private boolean reportExist() { + try { + BufferedReader reader = new BufferedReader(new InputStreamReader( + this.openFileInput("stack.trace"))); + return true; + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + + private void sendReport() { + try { + String trace = ""; + String line = ""; + + BufferedReader reader = new BufferedReader(new InputStreamReader( + this.openFileInput("stack.trace"))); + while ((line = reader.readLine()) != null) { + trace += line + "\n"; + } + + Intent sendIntent = new Intent(Intent.ACTION_SEND); + String subject = "Error report"; + String body = "Mail this to mar...@go...: " + + "\n\n" + trace + "\n\n"; + + sendIntent.putExtra(Intent.EXTRA_EMAIL, + new String[] { "mar...@go..." }); + sendIntent.putExtra(Intent.EXTRA_TEXT, body); + sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); + sendIntent.setType("message/rfc822"); + + startActivity(Intent + .createChooser(sendIntent, "Send crash report:")); + this.deleteFile("stack.trace"); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void deleteReport() { + this.deleteFile("stack.trace"); + } + void chkStatus() { final ConnectivityManager connMgr = (ConnectivityManager) this .getSystemService(Context.CONNECTIVITY_SERVICE); @@ -153,16 +236,15 @@ .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (!wifi.isAvailable()) { - Toast.makeText(this, "Wifi is not available !", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, "Warning : Wifi is not available !", + Toast.LENGTH_SHORT).show(); } - + /* - else if (mobile.isAvailable()) { - Toast.makeText(this, "Mobile 3G ", Toast.LENGTH_LONG).show(); - } else { - Toast.makeText(this, "No Network ", Toast.LENGTH_LONG).show(); - } - */ + * else if (mobile.isAvailable()) { Toast.makeText(this, "Mobile 3G ", + * Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, + * "No Network ", Toast.LENGTH_LONG).show(); } + */ } public void PostCommand(String button) { @@ -211,7 +293,7 @@ private class update extends AsyncTask<String, Void, Void> { // can use UI thread here - protected void onPreExecute() { + protected void onPreExecute() { } // automatically done on worker thread (separate from UI thread) @@ -227,21 +309,23 @@ handler.fetchdata(); if ((nowplayinghandler.PlayerState != null) - && (!nowplayinghandler.PlayerState.equals("no player active"))) { + && (!nowplayinghandler.PlayerState + .equals("no player active"))) { display = nowplayinghandler.Artist + " - " + nowplayinghandler.Title; } - + return null; } // can use UI thread here protected void onPostExecute(final Void unused) { - - TextView txt0 = (TextView) findViewById(R.id.main_now_playing); + + TextView txt0 = (TextView) findViewById(R.id.main_now_playing); txt0.setText(display); - + mHandler.postDelayed(mUpdateTimeTask, 1000); } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |