From: <kro...@us...> - 2010-12-19 13:44:31
|
Revision: 4046 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4046&view=rev Author: kroko_koenig Date: 2010-12-19 13:44:24 +0000 (Sun, 19 Dec 2010) Log Message: ----------- more vibrations and mp3 fix with menu now Modified Paths: -------------- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.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/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/nowplaylisthandler.java trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java trunk/plugins/AndroidRemote/Release/Android Server communication.docx trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs trunk/plugins/AndroidRemote/Server/AndroidRemote.suo Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/MusicDir.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -25,11 +25,15 @@ import mediaportal.remote.R; import mediaportal.remote.ReceiveDirectoryXmlHandler.DirItems; import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; +import android.content.DialogInterface; import android.os.AsyncTask; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; +import android.os.Vibrator; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -45,11 +49,16 @@ public class MusicDir extends Activity { private Handler mHandler = new Handler(); + private static Vibrator vibrate; + private String actualDir = ""; private static ArrayList<ReceiveDirectoryXmlHandler.DirItems> musicList; - private static ReceiveDirectoryXmlHandler.DirItems selectedItem; - + private static ReceiveDirectoryXmlHandler.DirItems selectedItem; + + final CharSequence[] items = { "Add to playlist", "Clear playlist", + "Save to SD card", "Cancel" }; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -58,6 +67,8 @@ mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 100); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + GridView gridview = (GridView) findViewById(R.id.music_grid); gridview.setOnItemClickListener(new OnItemClickListener() { @@ -67,12 +78,49 @@ ImageView iv = (ImageView) v.findViewById(R.id.icon_image); musicItem music = (musicItem) iv.getTag(); + DoVibrate(); + if (music.typ == "item") { - selectedItem = musicList.get(position); - PostAddFile(actualDir + selectedItem.File.replaceAll(" ", "%20")); - - Toast.makeText(MusicDir.this, - selectedItem.File + " has been added", Toast.LENGTH_SHORT).show(); + selectedItem = musicList.get(position-1); + + AlertDialog.Builder builder = new AlertDialog.Builder( + parent.getContext()); + + builder.setTitle(selectedItem.File); + builder.setItems(items, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int item) { + switch (item) { + case 0: + PostAddFile(actualDir + + selectedItem.File.replaceAll( + " ", "%20")); + Toast.makeText( + MusicDir.this, + selectedItem.File + + " has been added", + Toast.LENGTH_SHORT).show(); + break; + case 1: + PostClear(); + Toast.makeText(MusicDir.this, + "Playlist has been cleared", + Toast.LENGTH_SHORT).show(); + break; + case 2: + SavetoSDCard(selectedItem.File); + Toast.makeText( + MusicDir.this, + selectedItem.File + + " has been transferd", + Toast.LENGTH_SHORT).show(); + break; + } + } + }); + AlertDialog alert = builder.create(); + alert.show(); } if (music.typ == "folder") { @@ -100,6 +148,20 @@ }); } + public void PostClear() { + + PostWebserver post = new PostWebserver(Settings.Server, Settings.Port); + + String xml = ""; + + xml += "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; + xml += "<message>"; + xml += "<command>CLEAR_PLAYLIST</command>"; + xml += "</message>"; + + post.Post(xml); + } + public void PostAddFile(String Filename) { PostWebserver post = new PostWebserver(Settings.Server, Settings.Port); @@ -118,6 +180,18 @@ post.Post(xml); } + private void SavetoSDCard(String File) { + + httpHandler h = new httpHandler(); + h.DownloadFile(File , actualDir); + + String sd = Environment.getExternalStorageDirectory().toString(); + + @SuppressWarnings("unused") + MediaScannerNotifier not = new MediaScannerNotifier(this, sd + "/" + + File, "audio/mpeg"); + } + private Runnable mUpdateTimeTask = new Runnable() { public void run() { new update().execute(); @@ -150,15 +224,21 @@ } if (musicList.size() == 0) { - Toast.makeText(MusicDir.this, "TIME OUT SERVER", Toast.LENGTH_SHORT) - .show(); + Toast.makeText(MusicDir.this, "TIME OUT SERVER", + Toast.LENGTH_SHORT).show(); } else { GridView gridview = (GridView) findViewById(R.id.music_grid); gridview.setAdapter(new ImageAdapter2(MusicDir.this)); } } } - + + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); + } + } + public class ImageAdapter2 extends BaseAdapter { private Context mContext; public static final int ACTIVITY_CREATE = 10; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/ReceiveHandler.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -37,15 +37,15 @@ 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; + public void readValues(String Url) { + String fileUrl = "http://" + Settings.Server + ":" + Settings.Port + + Url; + URL myFileUrl = null; try { myFileUrl = new URL(fileUrl); @@ -91,13 +91,18 @@ e.printStackTrace(); } is.close(); - sp.reset(); + + try { + sp.reset(); + } catch (Exception e) { + // if not supported ... + } + } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - - + } } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/httpHandler.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -76,31 +76,33 @@ return bitmap; } - public void DownloadFile(String Filename, String ID) { - - extStorageDirectory = Environment.getExternalStorageDirectory().toString(); - + public void DownloadFileByID(String Filename, String ID) { + + extStorageDirectory = Environment.getExternalStorageDirectory() + .toString(); + try { - InputStream in = openHttpConnection("http://"+ Settings.Server + ":" + Settings.Port + - "/db_music/getfile?id=" + ID); + InputStream in = openHttpConnection("http://" + Settings.Server + + ":" + Settings.Port + "/db_music/getfile?id=" + ID); // BufferedInputStream bis = new BufferedInputStream(in); ByteArrayBuffer baf = new ByteArrayBuffer(50); - //int current = 0; + // int current = 0; + OutputStream outStream = null; + File file = new File(extStorageDirectory, Filename); + outStream = new FileOutputStream(file); + byte[] bb = new byte[1024]; int l = in.read(bb, 0, 1024); while (l > -0) { - baf.append(bb, 0, l); + //baf.append(bb, 0, l); + outStream.write(bb); l = in.read(bb, 0, 1024); } - - OutputStream outStream = null; - File file = new File(extStorageDirectory, Filename); - - outStream = new FileOutputStream(file); - outStream.write(baf.toByteArray()); + + //outStream.write(baf.toByteArray()); outStream.flush(); outStream.close(); @@ -113,4 +115,46 @@ } } + public void DownloadFile(String Filename, String Path) { + + extStorageDirectory = Environment.getExternalStorageDirectory() + .toString(); + + try { + InputStream in = openHttpConnection("http://" + Settings.Server + + ":" + Settings.Port + "/music/" + Path + Filename.replaceAll( + " ", "%20")); + + if (in != null) { + // BufferedInputStream bis = new BufferedInputStream(in); + ByteArrayBuffer baf = new ByteArrayBuffer(50); + // int current = 0; + + OutputStream outStream = null; + File file = new File(extStorageDirectory, Filename); + outStream = new FileOutputStream(file); + + byte[] bb = new byte[1024]; + int l = in.read(bb, 0, 1024); + + while (l > -0) { + //baf.append(bb, 0, l); + outStream.write(bb); + l = in.read(bb, 0, 1024); + } + + //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(); + } + } + } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicAlbum.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -45,6 +45,7 @@ public class musicAlbum extends Activity { private Handler mHandler = new Handler(); + private static Vibrator vibrate; private static ArrayList<ReceiveDbXmlHandler.DbItems> albumList; @@ -55,6 +56,8 @@ mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 100); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + ListView l1 = (ListView) findViewById(R.id.list_album); l1.setOnItemClickListener(new AdapterView.OnItemClickListener() @@ -67,6 +70,8 @@ musicResults.Select = item.Album + "&" + item.Artist; musicResults.Mode = musicResults.SelectMode.Album; + musicAlbum.DoVibrate(); + Intent myIntent = new Intent(arg1.getContext(), musicResults.class); startActivityForResult(myIntent, 0); } @@ -116,16 +121,15 @@ listview.setAdapter(new EfficientAdapter(musicAlbum.this)); } } - - public void DoVibrate() { - if (Settings.Vibrate) { - // Get instance of Vibrator from current Context - Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - v.vibrate(100); - } + + } + + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); } } - + private static class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicArtist.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -44,9 +44,9 @@ public class musicArtist extends Activity { - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; private Handler mHandler = new Handler(); - + private static Vibrator vibrate; + private static ArrayList<ReceiveDbXmlHandler.DbItems> artistList; public void onCreate(Bundle savedInstanceState) { @@ -56,6 +56,8 @@ mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 100); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + ListView l1 = (ListView) findViewById(R.id.list_artist); l1.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -67,6 +69,8 @@ musicResults.Select = item.Artist; musicResults.Mode = musicResults.SelectMode.Artist; + musicArtist.DoVibrate(); + Intent myIntent = new Intent(arg1.getContext(), musicResults.class); startActivityForResult(myIntent, 0); @@ -118,15 +122,15 @@ } } - public void DoVibrate() { - if (Settings.Vibrate) { - // Get instance of Vibrator from current Context - Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - v.vibrate(100); - } + + } + + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); } } - + private static class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicResults.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -33,6 +33,7 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; +import android.os.Vibrator; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -50,9 +51,9 @@ Artist,Album; } - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; private Handler mHandler = new Handler(); - + private static Vibrator vibrate; + private static ArrayList<ReceiveDbXmlHandler.DbItems> itemList; public static String Select = ""; @@ -69,6 +70,8 @@ mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 100); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + ListView l1 = (ListView) findViewById(R.id.list_result); ColorDrawable divcolor = new ColorDrawable(Color.DKGRAY); @@ -81,6 +84,8 @@ selectedItem = itemList.get(arg2); + DoVibrate(); + AlertDialog.Builder builder = new AlertDialog.Builder(arg0 .getContext()); builder.setTitle(selectedItem.Title); @@ -146,10 +151,11 @@ String id = Item.ID; httpHandler h = new httpHandler(); - h.DownloadFile(filename,id); + h.DownloadFileByID(filename,id); String sd = Environment.getExternalStorageDirectory().toString(); - MediaScannerNotifier not = new MediaScannerNotifier(this, sd + "/" + filename, "audio/mpeg"); + @SuppressWarnings("unused") + MediaScannerNotifier not = new MediaScannerNotifier(this, sd + "/" + filename, "audio/mpeg"); } private Runnable mUpdateTimeTask = new Runnable() { @@ -196,6 +202,12 @@ } } + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); + } + } + private static class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/musicSong.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -33,6 +33,7 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; +import android.os.Vibrator; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -46,7 +47,8 @@ public class musicSong extends Activity { private Handler mHandler = new Handler(); - + private static Vibrator vibrate; + private static ArrayList<ReceiveDbXmlHandler.DbItems> songList; public static String Select = ""; @@ -62,6 +64,8 @@ mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 100); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + ListView l1 = (ListView) findViewById(R.id.list_song); l1.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -69,6 +73,8 @@ long arg3) { selectedItem = songList.get(arg2); + + DoVibrate(); AlertDialog.Builder builder = new AlertDialog.Builder(arg0 .getContext()); @@ -144,6 +150,12 @@ } } + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); + } + } + public void PostClear() { PostWebserver post = new PostWebserver(Settings.Server, Settings.Port); @@ -180,7 +192,7 @@ String id = Item.ID; httpHandler h = new httpHandler(); - h.DownloadFile(filename,id); + h.DownloadFileByID(filename,id); String sd = Environment.getExternalStorageDirectory().toString(); MediaScannerNotifier not = new MediaScannerNotifier(this, sd + "/" + filename, "audio/mpeg"); Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaying.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.InputStream; - import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; @@ -11,14 +10,15 @@ import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; - import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Handler; +import android.os.Vibrator; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; @@ -28,10 +28,10 @@ public class nowplaying extends Activity { - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; - private static String lastTitle = ""; + private Handler mHandler = new Handler(); + private static Vibrator vibrate; /** Called when the activity is first created. */ @Override @@ -39,6 +39,8 @@ super.onCreate(savedInstanceState); setContentView(R.layout.playingnow); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + ImageButton btn1 = (ImageButton) findViewById(R.id.now_prev); ImageButton btn2 = (ImageButton) findViewById(R.id.now_stop); ImageButton btn4 = (ImageButton) findViewById(R.id.now_play); @@ -98,11 +100,9 @@ }; private void update() { - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); - String HttpServer = settings.getString("Server", "192.168.0.30"); - String HttpPort = settings.getString("Port", "8200"); + String HttpServer = Settings.Server; + String HttpPort = Settings.Port; nowplayinghandler handler = nowplayinghandler.getinstance(); handler.setconnection(HttpServer, HttpPort); @@ -178,11 +178,11 @@ } public void PostCommand(String button) { - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); + + DoVibrate(); - String HttpServer = settings.getString("Server", "192.168.0.30"); - String HttpPort = settings.getString("Port", "8200"); + String HttpServer = Settings.Server; + String HttpPort = Settings.Port; HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 3000); @@ -228,4 +228,10 @@ } } + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); + } + } + } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayingXmlHandler.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -7,10 +7,10 @@ public class nowplayingXmlHandler extends DefaultHandler { Boolean currentElement = false; String currentValue = null; - + /** * Called when tag starts ( example:- <name>AndroidPeople</name> -- <name> ) - */ + */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplayinghandler.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -103,8 +103,15 @@ e.printStackTrace(); } is.close(); - sp.reset(); + try { + sp.reset(); + } + catch (Exception e) + { + // if not supported ... + } + result = true; } catch (IOException e) { @@ -115,5 +122,4 @@ return result; } - } Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylist.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.InputStream; - import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; @@ -11,17 +10,16 @@ import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; - import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; -import android.content.SharedPreferences; import android.content.res.AssetManager; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.os.Handler; +import android.os.Vibrator; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -88,8 +86,8 @@ } } - public static final String PREFS_PRIVATE = "PREFS_MP_REMOTE"; private Handler mHandler = new Handler(); + private static Vibrator vibrate; final CharSequence[] items = { "Delete item", "Clear playlist", "Cancel" }; private nowplaylisthandler.PlayListItem selectedItem; @@ -103,6 +101,8 @@ ListView l1 = (ListView) findViewById(R.id.ListView01); l1.setAdapter(new EfficientAdapter(this)); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + l1.setOnItemClickListener(new AdapterView.OnItemClickListener() { // @override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, @@ -187,11 +187,9 @@ }; private void update() { - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); - String HttpServer = settings.getString("Server", "192.168.0.30"); - String HttpPort = settings.getString("Port", "8200"); + String HttpServer = Settings.Server; + String HttpPort = Settings.Port; nowplaylisthandler handler = nowplaylisthandler.getinstance(); handler.setconnection(HttpServer, HttpPort); @@ -209,12 +207,11 @@ public void PostCommand(String button) { - SharedPreferences settings = getSharedPreferences(PREFS_PRIVATE, - MODE_PRIVATE); + DoVibrate(); + + String HttpServer = Settings.Server; + String HttpPort = Settings.Port; - String HttpServer = settings.getString("Server", "192.168.0.30"); - String HttpPort = settings.getString("Port", "8200"); - HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 3000); HttpConnectionParams.setSoTimeout(httpParameters, 3000); @@ -259,4 +256,10 @@ } } + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); + } + } + } \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/nowplaylisthandler.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -106,8 +106,13 @@ e.printStackTrace(); } is.close(); - sp.reset(); + try { + sp.reset(); + } catch (Exception e) { + // if not supported ... + } + result = true; } catch (IOException e) { Modified: trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java =================================================================== --- trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Android/MediaPortalRemote/src/mediaportal/remote/pictures.java 2010-12-19 13:44:24 UTC (rev 4046) @@ -31,6 +31,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.os.Vibrator; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -46,6 +47,8 @@ public class pictures extends Activity { private Handler mHandler = new Handler(); + private static Vibrator vibrate; + public static String actualDir = ""; public static ArrayList<ReceiveDirectoryXmlHandler.DirItems> pictureList; @@ -59,6 +62,8 @@ mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 100); + vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + GridView gridview = (GridView) findViewById(R.id.GridView01); gridview.setOnItemClickListener(new OnItemClickListener() { @@ -68,6 +73,8 @@ ImageView iv = (ImageView) v.findViewById(R.id.icon_image); picItem pic = (picItem) iv.getTag(); + DoVibrate(); + if (pic.typ == "item") { selectedPicture = position - 1; Intent myIntent = new Intent(pictures.this, @@ -141,6 +148,12 @@ } } } + + private static void DoVibrate() { + if (Settings.Vibrate) { + vibrate.vibrate(100); + } + } public class ImageAdapter2 extends BaseAdapter { private Context mContext; Modified: trunk/plugins/AndroidRemote/Release/Android Server communication.docx =================================================================== (Binary files differ) Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-19 12:43:40 UTC (rev 4045) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-19 13:44:24 UTC (rev 4046) @@ -1216,9 +1216,12 @@ } private void ReplyMusicFile(string Filename, string Mode) { - if (File.Exists(Filename)) + directoryList = GetMpShare("music"); + string dir = GetLocalDir(Filename, directoryList); + + if (File.Exists(dir)) { - byte[] b = FileToByteArray(Filename); + byte[] b = FileToByteArray(dir); string msg = string.Empty; // header Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |