summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth/map/BluetoothMapFolderElement.java
diff options
context:
space:
mode:
authorHemant Gupta <hemantg@codeaurora.org>2014-09-24 13:50:26 +0530
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:26:11 -0700
commit54dde23d150c175fbf2f7c86ab280b652ea3627b (patch)
tree8b1ac85fe0afd69d3ab6f7d8fa51608fcba18037 /src/com/android/bluetooth/map/BluetoothMapFolderElement.java
parent1edda87582ee03e5cbb638f397d4d1d8fb382762 (diff)
downloadandroid_packages_apps_Bluetooth-54dde23d150c175fbf2f7c86ab280b652ea3627b.tar.gz
android_packages_apps_Bluetooth-54dde23d150c175fbf2f7c86ab280b652ea3627b.tar.bz2
android_packages_apps_Bluetooth-54dde23d150c175fbf2f7c86ab280b652ea3627b.zip
Revert "BT MAP: added support for email sharing over BT"
This reverts commit 326b5e610063ac24c0ba467ac585bd4c7f618a67. Conflicts: Android.mk res/values/strings.xml src/com/android/bluetooth/map/BluetoothMapService.java src/com/android/bluetooth/map/BluetoothMnsObexClient.java Change-Id: I1c1a3220d229473a6d13a568856d6001277bfa2a
Diffstat (limited to 'src/com/android/bluetooth/map/BluetoothMapFolderElement.java')
-rw-r--r--src/com/android/bluetooth/map/BluetoothMapFolderElement.java209
1 files changed, 41 insertions, 168 deletions
diff --git a/src/com/android/bluetooth/map/BluetoothMapFolderElement.java b/src/com/android/bluetooth/map/BluetoothMapFolderElement.java
index 42728b1ff..d3909ddad 100644
--- a/src/com/android/bluetooth/map/BluetoothMapFolderElement.java
+++ b/src/com/android/bluetooth/map/BluetoothMapFolderElement.java
@@ -1,5 +1,5 @@
/*
-* Copyright (C) 2014 Samsung System LSI
+* Copyright (C) 2013 Samsung System LSI
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,62 +14,32 @@
*/
package com.android.bluetooth.map;
-
-import android.util.Log;
-import org.xmlpull.v1.XmlSerializer;
-
-import com.android.internal.util.FastXmlSerializer;
-
import java.io.IOException;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map.Entry;
+import org.xmlpull.v1.XmlSerializer;
+
+import android.util.Xml;
/**
- * Class to contain a single folder element representation.
+ * @author cbonde
*
*/
public class BluetoothMapFolderElement {
- private String mName;
- private BluetoothMapFolderElement mParent = null;
- private boolean mHasSmsMmsContent = false;
- private long mEmailFolderId = -1;
- private HashMap<String, BluetoothMapFolderElement> mSubFolders;
-
- private static final boolean D = BluetoothMapService.DEBUG;
- private static final boolean V = BluetoothMapService.VERBOSE;
-
- private final static String TAG = "BluetoothMapFolderElement";
+ private String name;
+ private BluetoothMapFolderElement parent = null;
+ private ArrayList<BluetoothMapFolderElement> subFolders;
- public BluetoothMapFolderElement( String name, BluetoothMapFolderElement parrent){
- this.mName = name;
- this.mParent = parrent;
- mSubFolders = new HashMap<String, BluetoothMapFolderElement>();
+ public BluetoothMapFolderElement( String name, BluetoothMapFolderElement parrent ){
+ this.name = name;
+ this.parent = parrent;
+ subFolders = new ArrayList<BluetoothMapFolderElement>();
}
public String getName() {
- return mName;
- }
-
- public boolean hasSmsMmsContent(){
- return mHasSmsMmsContent;
- }
-
- public long getEmailFolderId(){
- return mEmailFolderId;
- }
-
- public void setEmailFolderId(long emailFolderId) {
- this.mEmailFolderId = emailFolderId;
- }
-
- public void setHasSmsMmsContent(boolean hasSmsMmsContent) {
- this.mHasSmsMmsContent = hasSmsMmsContent;
+ return name;
}
/**
@@ -77,68 +47,10 @@ public class BluetoothMapFolderElement {
* @return the parent folder or null if we are at the root folder.
*/
public BluetoothMapFolderElement getParent() {
- return mParent;
+ return parent;
}
/**
- * Build the full path to this folder
- * @return a string representing the full path.
- */
- public String getFullPath() {
- StringBuilder sb = new StringBuilder(mName);
- BluetoothMapFolderElement current = mParent;
- while(current != null) {
- if(current.getParent() != null) {
- sb.insert(0, current.mName + "/");
- }
- current = current.getParent();
- }
- //sb.insert(0, "/"); Should this be included? The MAP spec. do not include it in examples.
- return sb.toString();
- }
-
-
- public BluetoothMapFolderElement getEmailFolderByName(String name) {
- BluetoothMapFolderElement folderElement = this.getRoot();
- folderElement = folderElement.getSubFolder("telecom");
- folderElement = folderElement.getSubFolder("msg");
- folderElement = folderElement.getSubFolder(name);
- if (folderElement != null && folderElement.getEmailFolderId() == -1 )
- folderElement = null;
- return folderElement;
- }
-
- public BluetoothMapFolderElement getEmailFolderById(long id) {
- return getEmailFolderById(id, this);
- }
-
- public static BluetoothMapFolderElement getEmailFolderById(long id,
- BluetoothMapFolderElement folderStructure) {
- if(folderStructure == null) {
- return null;
- }
- return findEmailFolderById(id, folderStructure.getRoot());
- }
-
- private static BluetoothMapFolderElement findEmailFolderById(long id,
- BluetoothMapFolderElement folder) {
- if(folder.getEmailFolderId() == id) {
- return folder;
- }
- /* Else */
- for(BluetoothMapFolderElement subFolder : folder.mSubFolders.values().toArray(
- new BluetoothMapFolderElement[folder.mSubFolders.size()]))
- {
- BluetoothMapFolderElement ret = findEmailFolderById(id, subFolder);
- if(ret != null) {
- return ret;
- }
- }
- return null;
- }
-
-
- /**
* Fetch the root folder.
* @return the parent folder or null if we are at the root folder.
*/
@@ -150,53 +62,13 @@ public class BluetoothMapFolderElement {
}
/**
- * Add a virtual folder.
+ * Add a folder.
* @param name the name of the folder to add.
* @return the added folder element.
*/
public BluetoothMapFolderElement addFolder(String name){
- name = name.toLowerCase(Locale.US);
- BluetoothMapFolderElement newFolder = mSubFolders.get(name);
- if(D) Log.i(TAG,"addFolder():" + name);
- if(newFolder == null) {
- newFolder = new BluetoothMapFolderElement(name, this);
- mSubFolders.put(name, newFolder);
- }
- return newFolder;
- }
-
- /**
- * Add a sms/mms folder.
- * @param name the name of the folder to add.
- * @return the added folder element.
- */
- public BluetoothMapFolderElement addSmsMmsFolder(String name){
- name = name.toLowerCase(Locale.US);
- BluetoothMapFolderElement newFolder = mSubFolders.get(name);
- if(D) Log.i(TAG,"addSmsMmsFolder():" + name);
- if(newFolder == null) {
- newFolder = new BluetoothMapFolderElement(name, this);
- mSubFolders.put(name, newFolder);
- }
- newFolder.setHasSmsMmsContent(true);
- return newFolder;
- }
-
- /**
- * Add an Email folder.
- * @param name the name of the folder to add.
- * @return the added folder element.
- */
- public BluetoothMapFolderElement addEmailFolder(String name, long emailFolderId){
- name = name.toLowerCase();
- BluetoothMapFolderElement newFolder = mSubFolders.get(name);
- if(V) Log.v(TAG,"addEmailFolder(): name = " + name
- + "id = " + emailFolderId);
- if(newFolder == null) {
- newFolder = new BluetoothMapFolderElement(name, this);
- mSubFolders.put(name, newFolder);
- }
- newFolder.setEmailFolderId(emailFolderId);
+ BluetoothMapFolderElement newFolder = new BluetoothMapFolderElement(name, this);
+ subFolders.add(newFolder);
return newFolder;
}
@@ -205,7 +77,7 @@ public class BluetoothMapFolderElement {
* @return returns the number of sub folders.
*/
public int getSubFolderCount(){
- return mSubFolders.size();
+ return subFolders.size();
}
/**
@@ -214,46 +86,47 @@ public class BluetoothMapFolderElement {
* @return the subFolder element if found {@code null} otherwise.
*/
public BluetoothMapFolderElement getSubFolder(String folderName){
- return mSubFolders.get(folderName.toLowerCase());
+ for(BluetoothMapFolderElement subFolder : subFolders){
+ if(subFolder.getName().equals(folderName))
+ return subFolder;
+ }
+ return null;
}
public byte[] encode(int offset, int count) throws UnsupportedEncodingException {
StringWriter sw = new StringWriter();
- XmlSerializer xmlMsgElement = new FastXmlSerializer();
+ XmlSerializer xmlMsgElement = Xml.newSerializer();
int i, stopIndex;
- // We need index based access to the subFolders
- BluetoothMapFolderElement[] folders = mSubFolders.values().toArray(new BluetoothMapFolderElement[mSubFolders.size()]);
-
- if(offset > mSubFolders.size())
+ if(offset > subFolders.size())
throw new IllegalArgumentException("FolderListingEncode: offset > subFolders.size()");
stopIndex = offset + count;
- if(stopIndex > mSubFolders.size())
- stopIndex = mSubFolders.size();
+ if(stopIndex > subFolders.size())
+ stopIndex = subFolders.size();
try {
xmlMsgElement.setOutput(sw);
- xmlMsgElement.startDocument("UTF-8", true);
- xmlMsgElement.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
- xmlMsgElement.startTag(null, "folder-listing");
- xmlMsgElement.attribute(null, "version", "1.0");
+ xmlMsgElement.startDocument(null, null);
+ xmlMsgElement.text("\n");
+ xmlMsgElement.startTag("", "folder-listing");
+ xmlMsgElement.attribute("", "version", "1.0");
for(i = offset; i<stopIndex; i++)
{
- xmlMsgElement.startTag(null, "folder");
- xmlMsgElement.attribute(null, "name", folders[i].getName());
- xmlMsgElement.endTag(null, "folder");
+ xmlMsgElement.startTag("", "folder");
+ xmlMsgElement.attribute("", "name", subFolders.get(i).getName());
+ xmlMsgElement.endTag("", "folder");
}
- xmlMsgElement.endTag(null, "folder-listing");
+ xmlMsgElement.endTag("", "folder-listing");
xmlMsgElement.endDocument();
} catch (IllegalArgumentException e) {
- if(D) Log.w(TAG,e);
- throw new IllegalArgumentException("error encoding folderElement");
+ // TODO Auto-generated catch block
+ e.printStackTrace();
} catch (IllegalStateException e) {
- if(D) Log.w(TAG,e);
- throw new IllegalArgumentException("error encoding folderElement");
+ // TODO Auto-generated catch block
+ e.printStackTrace();
} catch (IOException e) {
- if(D) Log.w(TAG,e);
- throw new IllegalArgumentException("error encoding folderElement");
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
return sw.toString().getBytes("UTF-8");
}