Chat importing finished for text messages (todo images) + waiting dialog during import
This commit is contained in:
parent
4475002bcc
commit
7348384b68
6 changed files with 47 additions and 8 deletions
|
@ -371,4 +371,7 @@
|
|||
|
||||
<string name="download_image">Télécharger</string>
|
||||
<string name="download_image_failed">Téléchargement échoué. Vérifiez votre connexion internet ou reéssayez plus tard.</string>
|
||||
|
||||
<string name="wait">Merci de patienter...</string>
|
||||
<string name="importing_messages">Mise à jour de la base des messages</string>
|
||||
</resources>
|
||||
|
|
|
@ -425,4 +425,7 @@
|
|||
<string name="pref_help_auth_userid">Enter authentication userid (optionnal)</string>
|
||||
|
||||
<string name="pref_upnp_enable">Enable UPNP</string>
|
||||
|
||||
<string name="wait">Please wait...</string>
|
||||
<string name="importing_messages">Updating messages database</string>
|
||||
</resources>
|
||||
|
|
|
@ -26,7 +26,9 @@ import org.linphone.core.LinphoneCoreException;
|
|||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -119,13 +121,38 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
|
||||
//Check if the is the first time we show the chat view since we use liblinphone chat storage
|
||||
boolean useLinphoneStorage = getResources().getBoolean(R.bool.use_linphone_chat_storage);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
||||
boolean updateNeeded = prefs.getBoolean(getString(R.string.pref_first_time_linphone_chat_storage), true);
|
||||
if (useLinphoneStorage && updateNeeded) {
|
||||
if (importAndroidStoredMessagedIntoLibLinphoneStorage()) {
|
||||
prefs.edit().putBoolean(getString(R.string.pref_first_time_linphone_chat_storage), false).commit();
|
||||
LinphoneActivity.instance().getChatStorage().restartChatStorage();
|
||||
}
|
||||
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
|
||||
private ProgressDialog pd;
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
pd = new ProgressDialog(LinphoneActivity.instance());
|
||||
pd.setTitle(getString(R.string.wait));
|
||||
pd.setMessage(getString(R.string.importing_messages));
|
||||
pd.setCancelable(false);
|
||||
pd.setIndeterminate(true);
|
||||
pd.show();
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
try {
|
||||
if (importAndroidStoredMessagedIntoLibLinphoneStorage()) {
|
||||
prefs.edit().putBoolean(getString(R.string.pref_first_time_linphone_chat_storage), false).commit();
|
||||
LinphoneActivity.instance().getChatStorage().restartChatStorage();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
pd.dismiss();
|
||||
}
|
||||
};
|
||||
task.execute((Void[])null);
|
||||
}
|
||||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
|
@ -225,7 +252,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
String correspondent = conversations.get(j);
|
||||
LinphoneChatRoom room = LinphoneManager.getLc().getOrCreateChatRoom(correspondent);
|
||||
for (ChatMessage message : db.getMessages(correspondent)) {
|
||||
LinphoneChatMessage msg = room.createLinphoneChatMessage(message.getMessage(), message.getUrl(), message.getStatus(), Long.parseLong(message.getTimestamp()), message.isIncoming(), message.isRead());
|
||||
LinphoneChatMessage msg = room.createLinphoneChatMessage(message.getMessage(), message.getUrl(), message.getStatus(), Long.parseLong(message.getTimestamp()), message.isRead(), message.isIncoming());
|
||||
msg.store();
|
||||
}
|
||||
db.removeDiscussion(correspondent);
|
||||
|
|
|
@ -109,4 +109,8 @@ public class ChatMessage {
|
|||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.id + " : " + this.message + " (" + this.url + ") @ " + this.timestamp + ", read= " + this.isRead + ", incoming= " + this.incoming + ", status = " + this.status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
|
@ -31,8 +32,8 @@ import android.database.Cursor;
|
|||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
/**
|
||||
|
@ -69,6 +70,7 @@ public class ChatStorage {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
||||
boolean updateNeeded = prefs.getBoolean(c.getString(R.string.pref_first_time_linphone_chat_storage), true);
|
||||
useNativeAPI = useLinphoneStorage && !updateNeeded;
|
||||
Log.d("Using native API: " + useNativeAPI);
|
||||
|
||||
if (!useNativeAPI) {
|
||||
ChatHelper chatHelper = new ChatHelper(context);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 90b6aa36f2982cb7cce7ebd50d9dfafd20d4274e
|
||||
Subproject commit 440fabd247fbbb5865754951fa8ed3834fa92d5c
|
Loading…
Reference in a new issue