# HG changeset patch
# User "Vincent Veronis"
# Date 1302952588 -7200
# Node ID b5104ccb1916b38ddbd99dbca089dd3adb75b8ee
# Parent 4e23720db26d952888318f19053f77ff07ab9184
Override AccountSettings
diff -r 4e23720db26d -r b5104ccb1916 AndroidManifest.xml
--- a/AndroidManifest.xml Wed Apr 13 22:51:44 2011 +0200
+++ b/AndroidManifest.xml Sat Apr 16 13:16:28 2011 +0200
@@ -34,9 +34,10 @@
-
+
+ android:name="com.beem.project.beem.SETTINGS" />
@@ -62,6 +63,13 @@
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden">
+
+
+
+
@@ -116,6 +124,18 @@
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 4e23720db26d -r b5104ccb1916 res/xml/authenticator.xml
--- a/res/xml/authenticator.xml Wed Apr 13 22:51:44 2011 +0200
+++ b/res/xml/authenticator.xml Sat Apr 16 13:16:28 2011 +0200
@@ -4,6 +4,7 @@
android:accountType="com.beem.project.com"
android:icon="@drawable/beem_launcher_icon_silver"
android:smallIcon="@drawable/beem_status_icon"
- android:label="@string/app_name"
- android:accountPreferences="@xml/preferences" />
+ android:label="@string/app_name"
+ />
+
\ No newline at end of file
diff -r 4e23720db26d -r b5104ccb1916 res/xml/contacts.xml
--- a/res/xml/contacts.xml Wed Apr 13 22:51:44 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
diff -r 4e23720db26d -r b5104ccb1916 res/xml/preferences.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/xml/preferences.xml Sat Apr 16 13:16:28 2011 +0200
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 4e23720db26d -r b5104ccb1916 src/com/beem/project/beem/account/AccountPreferences.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/account/AccountPreferences.java Sat Apr 16 13:16:28 2011 +0200
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package com.beem.project.beem.account;
+
+import android.accounts.Account;
+import android.accounts.OnAccountsUpdateListener;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.util.Log;
+
+/**
+ * @author marseille
+ */
+public class AccountPreferences extends PreferenceActivity implements OnAccountsUpdateListener {
+
+ private static final String TAG = "AccountPreferences";
+
+
+ /**
+ *
+ */
+ @Override
+ public void onAccountsUpdated(Account[] accounts) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ Log.e(TAG, "ONCREATE");
+ }
+
+
+}
diff -r 4e23720db26d -r b5104ccb1916 src/com/beem/project/beem/account/ManageAccountsSettings.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/account/ManageAccountsSettings.java Sat Apr 16 13:16:28 2011 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.beem.project.beem.account;
+
+import android.app.Dialog;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+import android.view.View;
+
+import com.beem.project.beem.R;
+
+public class ManageAccountsSettings extends AccountPreferences implements View.OnClickListener {
+
+ protected static final String TAG = "AccountSettings";
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ Log.e(TAG,"ONCREATE");
+ setContentView(R.layout.account_settings);
+ addPreferencesFromResource(R.xml.preferences);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferences, Preference preference) {
+ Log.e(TAG,"OnTreeclick()");
+ return true;
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ Log.e(TAG,"OnCreateDialog()");
+ return null;
+ }
+
+ @Override
+ public void onClick(View v) {
+ Log.e(TAG, "onClick");
+ }
+
+}
diff -r 4e23720db26d -r b5104ccb1916 src/com/beem/project/beem/account/SyncAdapterService.java
--- a/src/com/beem/project/beem/account/SyncAdapterService.java Wed Apr 13 22:51:44 2011 +0200
+++ b/src/com/beem/project/beem/account/SyncAdapterService.java Sat Apr 16 13:16:28 2011 +0200
@@ -7,6 +7,7 @@
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry;
+import org.jivesoftware.smack.RosterGroup;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
@@ -28,6 +29,8 @@
import android.os.IBinder;
import android.os.RemoteException;
import android.provider.ContactsContract;
+import android.provider.ContactsContract.StatusUpdates;
+import android.provider.ContactsContract.CommonDataKinds.Im;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.util.Log;
@@ -102,7 +105,7 @@
Log.d(TAG, "Error during sync of contact", e);
}
}
-
+
private static void manageRoster(final Roster r, final Account a) {
ArrayList ops = new ArrayList();
@@ -113,13 +116,18 @@
if (ops.size() > 100)
executeOperation(ops);
}
+ for (RosterGroup group : r.getGroups()) {
+ if (group != null) {
+ manageGroup(ops, a, group);
+ }
+ }
if (ops.size() > 0)
executeOperation(ops);
}
private static void manageEntry(ArrayList ops, Account account, RosterEntry entry) {
-
long rawContactID = getRawContactID(account.name, entry.getUser());
+ Log.i(TAG, "Sync Contact : " + entry.getUser());
if (rawContactID == -1) { // Not found in database, add new
ContentValues values = new ContentValues();
values.put(ContactsContract.RawContacts.ACCOUNT_TYPE, account.type);
@@ -138,6 +146,14 @@
ops.add(builder.build());
}
}
+
+ private static void manageGroup(ArrayList ops, Account account, RosterGroup group) {
+ Log.i(TAG, "Sync Group : " + group.getName());
+ ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(ContactsContract.Groups.CONTENT_URI );
+ builder.withValue(ContactsContract.Groups.TITLE, group.getName());
+ }
+
+
private static ContentProviderOperation.Builder buildStructuredName(ContentProviderOperation.Builder builder,
RosterEntry entry, long rawContactID) {
@@ -148,6 +164,15 @@
return builder;
}
+ private static ContentProviderOperation.Builder BuildImProtocol(RosterEntry entry, long rawContactID) {
+ ContentProviderOperation.Builder builder = ContentProviderOperation
+ .newInsert(ContactsContract.StatusUpdates.CONTENT_URI);
+ builder.withValue(ContactsContract.StatusUpdates.DATA_ID, rawContactID);
+ builder.withValue(ContactsContract.StatusUpdates.PROTOCOL, ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER);
+ //TODO: ajouter le protocol jabber
+ return builder;
+ }
+
private static long getRawContactID(String account, String jid) {
long authorId = -1;
final Cursor c = mContentResolver.query(ContactsContract.RawContacts.CONTENT_URI, new String[] {
diff -r 4e23720db26d -r b5104ccb1916 src/com/beem/project/beem/ui/ChangeStatus.java
--- a/src/com/beem/project/beem/ui/ChangeStatus.java Wed Apr 13 22:51:44 2011 +0200
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java Sat Apr 16 13:16:28 2011 +0200
@@ -148,12 +148,12 @@
@Override
protected void onResume() {
super.onResume();
- if (!BeemConnectivity.isConnected(getApplicationContext())) {
- Intent i = new Intent(this, Login.class);
- startActivity(i);
- finish();
- }
- bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+// if (!BeemConnectivity.isConnected(getApplicationContext())) {
+// Intent i = new Intent(this, Login.class);
+// startActivity(i);
+// finish();
+// }
+// bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
}
/**
@@ -162,7 +162,7 @@
@Override
protected void onPause() {
super.onPause();
- unbindService(mServConn);
+// unbindService(mServConn);
}
/* (non-Javadoc)