diff options
Diffstat (limited to 'src/main/java/de/pixart')
13 files changed, 176 insertions, 47 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java index 40bd69976..6d07c5901 100644 --- a/src/main/java/de/pixart/messenger/entities/Contact.java +++ b/src/main/java/de/pixart/messenger/entities/Contact.java @@ -159,6 +159,9 @@ public class Contact implements ListItem, Blockable { if (isBlocked()) { tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b, 0)); } + if (showInPhoneBook()) { + tags.add(new Tag(context.getString(R.string.phone_book), 0xFF1E88E5, 0)); + } return tags; } @@ -384,6 +387,10 @@ public class Contact implements ListItem, Blockable { || (this.getOption(Contact.Options.DIRTY_PUSH)); } + public boolean showInPhoneBook() { + return systemAccount != null && !systemAccount.trim().isEmpty(); + } + public void parseSubscriptionFromElement(Element item) { String ask = item.getAttribute("ask"); String subscription = item.getAttribute("subscription"); diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index cc995a30b..1e5224489 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -1135,6 +1135,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl && !contact.isOwnServer() && !contact.showInRoster() && !contact.isSelf() + && !contact.showInPhoneBook() && sentMessagesCount() == 0; } diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 6b35219e4..0c3028feb 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -367,7 +367,12 @@ public class FileBackend { private String getExtensionFromUri(Uri uri) { String[] projection = {MediaStore.MediaColumns.DATA}; String filename = null; - Cursor cursor = mXmppConnectionService.getContentResolver().query(uri, projection, null, null, null); + Cursor cursor; + try { + cursor = mXmppConnectionService.getContentResolver().query(uri, projection, null, null, null); + } catch (IllegalArgumentException e) { + cursor = null; + } if (cursor != null) { try { if (cursor.moveToFirst()) { diff --git a/src/main/java/de/pixart/messenger/services/AudioPlayer.java b/src/main/java/de/pixart/messenger/services/AudioPlayer.java index 120a810e1..e3e17fdb0 100644 --- a/src/main/java/de/pixart/messenger/services/AudioPlayer.java +++ b/src/main/java/de/pixart/messenger/services/AudioPlayer.java @@ -12,6 +12,7 @@ import android.media.AudioManager; import android.media.MediaPlayer; import android.os.Build; import android.os.Handler; +import android.os.PowerManager; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.util.Log; @@ -42,18 +43,34 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti private final WeakReferenceSet<RelativeLayout> audioPlayerLayouts = new WeakReferenceSet<>(); private final SensorManager sensorManager; private final Sensor proximitySensor; + private static PowerManager.WakeLock wakeLock; private final PendingItem<WeakReference<ImageButton>> pendingOnClickView = new PendingItem<>(); private final Handler handler = new Handler(); public AudioPlayer(MessageAdapter adapter) { + final Context context = adapter.getContext(); this.messageAdapter = adapter; - this.sensorManager = (SensorManager) adapter.getActivity().getSystemService(Context.SENSOR_SERVICE); - this.proximitySensor = sensorManager != null ? sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY) : null; + this.sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); + this.proximitySensor = this.sensorManager == null ? null : this.sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); + if (Build.VERSION.SDK_INT >= 21) { + synchronized (AudioPlayer.LOCK) { + if (AudioPlayer.wakeLock == null) { + final PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + AudioPlayer.wakeLock = powerManager == null ? null : powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, AudioPlayer.class.getSimpleName()); + AudioPlayer.wakeLock.setReferenceCounted(false); + } + } + } else { + AudioPlayer.wakeLock = null; + } synchronized (AudioPlayer.LOCK) { if (AudioPlayer.player != null) { AudioPlayer.player.setOnCompletionListener(this); + if (AudioPlayer.player.isPlaying() && sensorManager != null) { + sensorManager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_NORMAL); + } } } } @@ -103,6 +120,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti viewHolder.progress.setProgress(0); viewHolder.progress.setEnabled(false); messageAdapter.flagScreenOff(); + releaseProximityWakeLock(); messageAdapter.flagEnableInputs(); return false; } @@ -139,12 +157,14 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti viewHolder.progress.setEnabled(false); player.pause(); messageAdapter.flagScreenOff(); + releaseProximityWakeLock(); messageAdapter.flagEnableInputs(); viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_play_arrow_white_36dp : R.drawable.ic_play_arrow_black_36dp); } else { viewHolder.progress.setEnabled(true); player.start(); messageAdapter.flagScreenOn(); + acquireProximityWakeLock(); this.stopRefresher(true); viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_pause_white_36dp : R.drawable.ic_pause_black_36dp); } @@ -167,6 +187,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti AudioPlayer.player.prepare(); AudioPlayer.player.start(); messageAdapter.flagScreenOn(); + acquireProximityWakeLock(); if (earpiece) { messageAdapter.flagDisableInputs(); } else { @@ -178,6 +199,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti return true; } catch (Exception e) { messageAdapter.flagScreenOff(); + releaseProximityWakeLock(); messageAdapter.flagEnableInputs(); AudioPlayer.currentlyPlayingMessage = null; sensorManager.unregisterListener(this); @@ -211,6 +233,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } AudioPlayer.player.release(); messageAdapter.flagScreenOff(); + releaseProximityWakeLock(); messageAdapter.flagEnableInputs(); AudioPlayer.player = null; resetPlayerUi(); @@ -238,7 +261,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } @Override - public void onCompletion(MediaPlayer mediaPlayer) { + public void onCompletion(android.media.MediaPlayer mediaPlayer) { synchronized (AudioPlayer.LOCK) { this.stopRefresher(false); if (AudioPlayer.player == mediaPlayer) { @@ -247,6 +270,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } mediaPlayer.release(); messageAdapter.flagScreenOff(); + releaseProximityWakeLock(); messageAdapter.flagEnableInputs(); resetPlayerUi(); sensorManager.unregisterListener(this); @@ -284,6 +308,11 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti stopCurrent(); } AudioPlayer.currentlyPlayingMessage = null; + sensorManager.unregisterListener(this); + if (wakeLock != null && wakeLock.isHeld()) { + wakeLock.release(); + } + wakeLock = null; } } @@ -294,6 +323,12 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } } + public void unregisterListener() { + if (sensorManager != null) { + sensorManager.unregisterListener(this); + } + } + @Override public void run() { synchronized (AudioPlayer.LOCK) { @@ -346,11 +381,10 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti try { ViewHolder currentViewHolder = getCurrentViewHolder(); if (currentViewHolder != null) { - Log.d(Config.LOGTAG, "AudioPlayer start playing - progress: " + progress); play(currentViewHolder, currentlyPlayingMessage, streamType == AudioManager.STREAM_VOICE_CALL, progress); } } catch (Exception e) { - Log.w(Config.LOGTAG, "AudioPlayer Exception: " + e); + Log.d(Config.LOGTAG, "AudioPlayer Exception: " + e); } } } @@ -359,7 +393,20 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti @Override public void onAccuracyChanged(Sensor sensor, int i) { } - + private void acquireProximityWakeLock() { + synchronized (AudioPlayer.LOCK) { + if (wakeLock != null) { + wakeLock.acquire(); + } + } + } + private void releaseProximityWakeLock() { + synchronized (AudioPlayer.LOCK) { + if (wakeLock != null && wakeLock.isHeld()) { + wakeLock.release(); + } + } + } private ViewHolder getCurrentViewHolder() { for (WeakReference<RelativeLayout> audioPlayer : audioPlayerLayouts) { final Message message = (Message) audioPlayer.get().getTag(); diff --git a/src/main/java/de/pixart/messenger/services/MediaPlayer.java b/src/main/java/de/pixart/messenger/services/MediaPlayer.java new file mode 100644 index 000000000..59e8bfecb --- /dev/null +++ b/src/main/java/de/pixart/messenger/services/MediaPlayer.java @@ -0,0 +1,15 @@ +package de.pixart.messenger.services; + +public class MediaPlayer extends android.media.MediaPlayer { + private int streamType; + + public int getAudioStreamType() { + return streamType; + } + + @Override + public void setAudioStreamType(int streamType) { + this.streamType = streamType; + super.setAudioStreamType(streamType); + } +}
\ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index ec9dcf8f0..877696824 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -850,7 +850,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } final Conversation conversation_preview = conversation; final Uri uri_preview = uri; - Bitmap bitmap = BitmapFactory.decodeFile(FileUtils.getPath(activity, uri)); + Bitmap bitmap = null; + try { + bitmap = BitmapFactory.decodeFile(FileUtils.getPath(activity, uri)); + } catch (Exception e) { + e.printStackTrace(); + } File file = null; ExifInterface exif = null; int orientation = 0; @@ -870,7 +875,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke Log.d(Config.LOGTAG, "EXIF: " + orientation); Bitmap rotated_image = null; Log.d(Config.LOGTAG, "Rotate image"); - rotated_image = FileBackend.rotateBitmap(file, bitmap, orientation); + try { + rotated_image = FileBackend.rotateBitmap(file, bitmap, orientation); + } catch (Exception e) { + e.printStackTrace(); + } if (rotated_image != null) { int scaleSize = 600; int originalWidth = rotated_image.getWidth(); @@ -891,28 +900,36 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke newWidth = scaleSize; } Log.d(Config.LOGTAG, "Scaling preview image from " + originalHeight + "px x " + originalWidth + "px to " + newHeight + "px x " + newWidth + "px"); - Bitmap preview = Bitmap.createScaledBitmap(rotated_image, newWidth, newHeight, false); - ImageView ImagePreview = new ImageView(activity); - LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); - ImagePreview.setLayoutParams(vp); - ImagePreview.setMaxWidth(newWidth); - ImagePreview.setMaxHeight(newHeight); - //ImagePreview.setScaleType(ImageView.ScaleType.FIT_XY); - //ImagePreview.setAdjustViewBounds(true); - ImagePreview.setPadding(5, 5, 5, 5); - ImagePreview.setImageBitmap(preview); - getActivity().runOnUiThread(() -> { - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setView(ImagePreview); - builder.setTitle(R.string.send_image); - builder.setPositiveButton(R.string.ok, (dialog, which) -> sendImage(conversation_preview, uri_preview)); - builder.setOnCancelListener(dialog -> mPendingImageUris.clear()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - builder.setOnDismissListener(dialog -> mPendingImageUris.clear()); - } - AlertDialog alertDialog = builder.create(); - alertDialog.show(); - }); + Bitmap preview = null; + + try { + preview = Bitmap.createScaledBitmap(rotated_image, newWidth, newHeight, false); + } catch (Exception e) { + e.printStackTrace(); + } + if (preview != null) { + ImageView ImagePreview = new ImageView(activity); + LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); + ImagePreview.setLayoutParams(vp); + ImagePreview.setMaxWidth(newWidth); + ImagePreview.setMaxHeight(newHeight); + ImagePreview.setPadding(5, 5, 5, 5); + ImagePreview.setImageBitmap(preview); + getActivity().runOnUiThread(() -> { + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setView(ImagePreview); + builder.setTitle(R.string.send_image); + builder.setPositiveButton(R.string.ok, (dialog, which) -> sendImage(conversation_preview, uri_preview)); + builder.setOnCancelListener(dialog -> mPendingImageUris.clear()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + builder.setOnDismissListener(dialog -> mPendingImageUris.clear()); + } + AlertDialog alertDialog = builder.create(); + alertDialog.show(); + }); + } else { + getActivity().runOnUiThread(() -> Toast.makeText(getActivity(), getText(R.string.error_file_not_found), Toast.LENGTH_LONG).show()); + } } else { getActivity().runOnUiThread(() -> Toast.makeText(getActivity(), getText(R.string.error_file_not_found), Toast.LENGTH_LONG).show()); } @@ -2114,6 +2131,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public void onStop() { super.onStop(); final Activity activity = getActivity(); + messageListAdapter.unregisterListenerInAudioPlayer(); if (activity == null || !activity.isChangingConfigurations()) { hideSoftKeyboard(activity); messageListAdapter.stopAudioPlayer(); diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index 9c9949770..dcb15fec1 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -548,7 +548,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio if (fm.getBackStackEntryCount() > 0) { try { fm.popBackStack(); - } catch (IllegalArgumentException e) { + } catch (IllegalStateException e) { Log.w(Config.LOGTAG, "Unable to pop back stack after pressing home button"); } return true; @@ -559,7 +559,9 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio return true; case R.id.action_check_updates: if (xmppConnectionService.hasInternetConnection()) { - if (!installFromUnknownSourceAllowed() && (xmppConnectionService.installedFrom() != null && !xmppConnectionService.installedFrom().equals(PlayStore))) { + if (!installFromUnknownSourceAllowed() && xmppConnectionService.installedFrom() == null) { + openInstallFromUnknownSourcesDialogIfNeeded(); + } else if (!installFromUnknownSourceAllowed() && (xmppConnectionService.installedFrom() != null && !xmppConnectionService.installedFrom().equalsIgnoreCase(PlayStore))) { openInstallFromUnknownSourcesDialogIfNeeded(); } else { UpdateService task = new UpdateService(this, xmppConnectionService.installedFrom(), xmppConnectionService); @@ -950,7 +952,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio Log.d(Config.LOGTAG, "AppUpdater: CurrentTime: " + lastUpdateTime); if (!installFromUnknownSourceAllowed() && Store == null) { openInstallFromUnknownSourcesDialogIfNeeded(); - } else if (Store != null && (Store.equals(PlayStore) || Store.equals(FDroid))) { + } else if (Store != null && (Store.equalsIgnoreCase(PlayStore) || Store.equalsIgnoreCase(FDroid))) { Log.d(Config.LOGTAG, "AppUpdater aborted because app store is " + Store); } else { UpdateService task = new UpdateService(this, Store, xmppConnectionService); diff --git a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java index 15d193886..455bbf3c3 100644 --- a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java +++ b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java @@ -65,7 +65,8 @@ public class RecordingActivity extends Activity implements View.OnClickListener super.onStart(); if (!startRecording()) { this.binding.shareButton.setEnabled(false); - Toast.makeText(this, R.string.unable_to_start_recording, Toast.LENGTH_SHORT).show(); + this.binding.timer.setTextAppearance(this, R.style.TextAppearance_Conversations_Title); + this.binding.timer.setText(R.string.unable_to_start_recording); } } @@ -108,12 +109,15 @@ public class RecordingActivity extends Activity implements View.OnClickListener mShouldFinishAfterWrite = saveFile; try { mRecorder.stop(); - } catch (RuntimeException stopException) { - //handle cleanup here + mRecorder.release(); + } catch (Exception e) { + if (saveFile) { + Toast.makeText(this,R.string.unable_to_save_recording, Toast.LENGTH_SHORT).show(); + } + } finally { + mRecorder = null; + mStartTime = 0; } - mRecorder.release(); - mRecorder = null; - mStartTime = 0; if (!saveFile && mOutputFile != null) { if (mOutputFile.delete()) { Log.d(Config.LOGTAG,"deleted canceled recording"); diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 4e02df3ea..f9d373b27 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -874,11 +874,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne protected void filterContacts(String needle) { this.contacts.clear(); - for (Account account : xmppConnectionService.getAccounts()) { + final List<Account> accounts = xmppConnectionService.getAccounts(); + final boolean singleAccountActive = isSingleAccountActive(accounts); + for (Account account : accounts) { if (account.getStatus() != Account.State.DISABLED) { for (Contact contact : account.getRoster().getContacts()) { Presence.Status s = contact.getShownStatus(); - if (contact.showInRoster() && contact.match(this, needle) + if ((contact.showInRoster() || (singleAccountActive && contact.showInPhoneBook())) && contact.match(this, needle) && (!this.mHideOfflineContacts || (needle != null && !needle.trim().isEmpty()) || s.compareTo(Presence.Status.OFFLINE) < 0)) { @@ -891,6 +893,16 @@ public class StartConversationActivity extends XmppActivity implements XmppConne mContactsAdapter.notifyDataSetChanged(); } + private static boolean isSingleAccountActive(final List<Account> accounts) { + int i = 0; + for(Account account : accounts) { + if (account.getStatus() != Account.State.DISABLED) { + ++i; + } + } + return i == 1; + } + protected void filterConferences(String needle) { this.conferences.clear(); for (Account account : xmppConnectionService.getAccounts()) { @@ -1059,9 +1071,11 @@ public class StartConversationActivity extends XmppActivity implements XmppConne final Contact contact = (Contact) activity.contacts.get(acmi.position); final MenuItem blockUnblockItem = menu.findItem(R.id.context_contact_block_unblock); final MenuItem showContactDetailsItem = menu.findItem(R.id.context_contact_details); + final MenuItem deleteContactMenuItem = menu.findItem(R.id.context_delete_contact); if (contact.isSelf()) { showContactDetailsItem.setVisible(false); } + deleteContactMenuItem.setVisible(contact.showInRoster()); XmppConnection xmpp = contact.getAccount().getXmppConnection(); if (xmpp != null && xmpp.getFeatures().blocking() && !contact.isSelf()) { if (contact.isBlocked()) { diff --git a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java index 0c59b06c6..f35436df6 100644 --- a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java +++ b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java @@ -57,7 +57,10 @@ public class UpdaterActivity extends XmppActivity { //set activity setContentView(R.layout.activity_updater); - this.mUseTor = mXmppConnectionService.useTorToConnect(); + this.mUseTor = false; + if (mXmppConnectionService != null) { + this.mUseTor = mXmppConnectionService.useTorToConnect(); + } this.mTheme = findTheme(); setTheme(this.mTheme); @@ -131,7 +134,7 @@ public class UpdaterActivity extends XmppActivity { //ask for permissions on devices >= SDK 23 if (isStoragePermissionGranted() && isNetworkAvailable(getApplicationContext())) { //start downloading the file using the download manager - if (store.equals(PlayStore)) { + if (store.equalsIgnoreCase(PlayStore)) { Uri uri = Uri.parse("market://details?id=de.pixart.messenger"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, uri); PackageManager manager = getApplicationContext().getPackageManager(); @@ -145,7 +148,7 @@ public class UpdaterActivity extends XmppActivity { startActivity(browserIntent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } - } else if (store.equals(FDroid)) { + } else if (store.equalsIgnoreCase(FDroid)) { Uri uri = Uri.parse("https://f-droid.org/de/packages/de.pixart.messenger/"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, uri); PackageManager manager = getApplicationContext().getPackageManager(); diff --git a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java index 3c03542ee..9d5b76c1c 100644 --- a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java +++ b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java @@ -152,6 +152,8 @@ public class WelcomeActivity extends XmppActivity { checkDatabase(password); } catch (IOException e) { e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } pd.dismiss(); } @@ -225,6 +227,9 @@ public class WelcomeActivity extends XmppActivity { } catch (IOException e) { Log.d(Config.LOGTAG, "Database importer: decryption failed (IO) with " + e); e.printStackTrace(); + } catch (Exception e) { + Log.d(Config.LOGTAG, "Database importer: Error " + e); + e.printStackTrace(); } SQLiteDatabase checkDB = null; @@ -236,10 +241,11 @@ public class WelcomeActivity extends XmppActivity { checkDB = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READONLY); Backup_DB_Version = checkDB.getVersion(); Log.d(Config.LOGTAG, "Backup found: " + checkDB + " Version: " + checkDB.getVersion()); - } catch (SQLiteException e) { //database does't exist yet. Log.d(Config.LOGTAG, "No backup found: " + checkDB); + } catch (Exception e) { + Log.d(Config.LOGTAG, "Error importing backup: " + e); } if (checkDB != null) { diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index f3b04ff8a..0c42d11b4 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -1027,6 +1027,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie audioPlayer.stop(); } + public void unregisterListenerInAudioPlayer() { + audioPlayer.unregisterListener(); + } + public void startStopPending() { audioPlayer.startStopPending(); } diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index f33817f09..1def41694 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -466,7 +466,7 @@ public class XmppConnection implements Runnable { * * @return true if server returns with valid xmpp, false otherwise */ - private synchronized boolean startXmpp(Socket socket) throws Exception { + private boolean startXmpp(Socket socket) throws Exception { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } @@ -481,6 +481,9 @@ public class XmppConnection implements Runnable { tagWriter.beginDocument(); sendStartStream(); final Tag tag = tagReader.readTag(); + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } return tag != null && tag.isStart("stream"); } |