--- 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 @@
<activity
android:name=".ui.Settings"
android:label="@string/edit_settings_name">
- <intent-filter>
+ <intent-filter
+ android:label="Beem Android Account">
<action
- android:name="com.beem.project.beem.MAIN" />
+ android:name="com.beem.project.beem.SETTINGS" />
<category
android:name="android.intent.category.DEFAULT" />
</intent-filter>
@@ -62,6 +63,13 @@
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden">
<intent-filter
+ android:label="Beem Android Account">
+ <action
+ android:name="com.beem.project.beem.CHANGESTATUS" />
+ <category
+ android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter
android:label="Beem Connection">
<action
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
@@ -116,6 +124,18 @@
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
</intent-filter>
</activity>
+ <activity
+ android:name="com.beem.project.beem.account.ManageAccountsSettings"
+ android:label="Sync Settings">
+ <intent-filter>
+ <action
+ android:name="android.intent.action.MAIN" />
+ <action
+ android:name="android.settings.ACCOUNT_SYNC_SETTINGS" />
+ <category
+ android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
<!--
Could be interesting if we would launch beem at startup <receiver
android:name=".tool.BeemBroadcastReceiver" android:enabled="true">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/account_settings.xml Sat Apr 16 13:16:28 2011 +0200
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+ <!--
+ /* //device/apps/common/assets/res/layout/list_content.xml ** **
+ Copyright 2006, 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. */
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+ <LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/title_area"
+ android:orientation="horizontal">
+ <ImageView
+ android:id="@+id/provider_icon"
+ android:layout_width="48dip"
+ android:layout_height="48dip"
+ android:layout_margin="5dip"
+ android:layout_gravity="center_vertical" />
+ <LinearLayout
+ android:layout_width="0dip"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/user_id"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textStyle="bold"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:gravity="center_vertical"
+ android:layout_marginTop="5dip" />
+ <TextView
+ android:id="@+id/provider_id"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:layout_gravity="bottom"
+ android:layout_marginBottom="5dip" />
+ </LinearLayout>
+ </LinearLayout>
+ <ListView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:drawSelectorOnTop="false"
+ android:scrollbarAlwaysDrawVerticalTrack="true" />
+ <TextView
+ android:id="@+id/sync_settings_error_info"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="SYNC FAILING" />
+ <LinearLayout
+ android:id="@+id/remove_account_area"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:background="@android:drawable/bottom_bar">
+ <View
+ android:layout_width="0dip"
+ android:layout_height="match_parent"
+ android:layout_weight="1" />
+ <Button
+ android:id="@+id/remove_account_button"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="2"
+ android:layout_marginTop="5dip"
+ android:text="REMOVE ACCOUNT LABEL" />
+ <View
+ android:layout_width="0dip"
+ android:layout_height="match_parent"
+ android:layout_weight="1" />
+ </LinearLayout>
+ <RelativeLayout
+ android:id="@+id/finish_button_area"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:background="@android:drawable/bottom_bar"
+ android:visibility="gone">
+ <Button
+ android:id="@+id/finish_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:layout_alignParentRight="true"
+ android:drawablePadding="3dip"
+ android:text="FINISH" />
+ </RelativeLayout>
+</LinearLayout>
\ No newline at end of file
--- 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"
+ />
+<!-- android:accountPreferences="@xml/preferences" /> -->
\ No newline at end of file
--- 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 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ContactsSource xmlns:android="http://schemas.android.com/apk/res/android">
-
- <ContactsDataKind
- android:mimeType="vnd.android.cursor.item/vnd.beem.android.profile"
- android:icon="@drawable/icon"
- android:summaryColumn="data2"
- android:detailColumn="data3"
- android:detailSocialSummary="true" />
-
-</ContactsSource>
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory android:key="dataAndSynchronization"
+ android:title="SYNCRHONISATION BEEM" />
+ <PreferenceCategory
+ android:title="General Settings" />
+ <PreferenceScreen
+ android:key="account_settings"
+ android:title="Account Settings"
+ android:summary="Sync frequency, notifications, etc.">
+ <intent
+ android:action="com.beem.project.beem.SETTINGS"
+ android:targetClass="ui.Settings.class" />
+ </PreferenceScreen>
+ <PreferenceCategory
+ android:title="Account Actions" />
+ <PreferenceScreen
+ android:key="second_preferencescreen"
+ android:title="Status Update"
+ android:summary="Connect/Disconnect, Change Status...">
+ <intent
+ android:action="com.beem.project.beem.CHANGESTATUS"
+ android:targetClass="ui.ChangeStatus.class" />
+ </PreferenceScreen>
+ <CheckBoxPreference
+ android:key="prefer wifi"
+ android:title="Prefer WiFi" />
+</PreferenceScreen>
\ No newline at end of file
--- /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");
+ }
+
+
+}
--- /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");
+ }
+
+}
--- 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<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
@@ -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<ContentProviderOperation> 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<ContentProviderOperation> 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[] {
--- 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)