Fix crash until chat fragment was opened once
This commit is contained in:
parent
be1623d6fd
commit
a9c43923fc
3 changed files with 25 additions and 1 deletions
|
@ -30,7 +30,9 @@ import org.linphone.core.LinphoneCoreFactory;
|
|||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
@ -120,6 +122,16 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isVersionUsingNewChatStorage() {
|
||||
try {
|
||||
Context context = LinphoneActivity.instance();
|
||||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode >= 2200;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
@ -129,6 +141,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
useLinphoneStorage = getResources().getBoolean(R.bool.use_linphone_chat_storage);
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
||||
boolean updateNeeded = prefs.getBoolean(getString(R.string.pref_first_time_linphone_chat_storage), true);
|
||||
updateNeeded = updateNeeded && !isVersionUsingNewChatStorage();
|
||||
if (useLinphoneStorage && updateNeeded) {
|
||||
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
|
||||
private ProgressDialog pd;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.linphone.mediastream.Log;
|
|||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
@ -64,11 +65,21 @@ public class ChatStorage {
|
|||
instance = new ChatStorage(LinphoneService.instance().getApplicationContext());
|
||||
}
|
||||
|
||||
private boolean isVersionUsingNewChatStorage() {
|
||||
try {
|
||||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode >= 2200;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private ChatStorage(Context c) {
|
||||
context = c;
|
||||
boolean useLinphoneStorage = c.getResources().getBoolean(R.bool.use_linphone_chat_storage);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneService.instance());
|
||||
boolean updateNeeded = prefs.getBoolean(c.getString(R.string.pref_first_time_linphone_chat_storage), !LinphonePreferences.instance().isFirstLaunch());
|
||||
updateNeeded = updateNeeded && !isVersionUsingNewChatStorage();
|
||||
useNativeAPI = useLinphoneStorage && !updateNeeded;
|
||||
Log.d("Using native API: " + useNativeAPI);
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
|
||||
if (isTablet() && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else {
|
||||
} else if (!isTablet() && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue