mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-21 11:58:26 +00:00
Add 'mark all as read' option
This commit is contained in:
parent
4af7fdabda
commit
1aa84b145f
@ -9,6 +9,10 @@
|
|||||||
android:id="@+id/menu_clear_passphrase"
|
android:id="@+id/menu_clear_passphrase"
|
||||||
android:icon="@android:drawable/ic_menu_close_clear_cancel" />
|
android:icon="@android:drawable/ic_menu_close_clear_cancel" />
|
||||||
|
|
||||||
|
<item android:title="@string/text_secure_normal__mark_all_as_read"
|
||||||
|
android:id="@+id/menu_mark_all_read"
|
||||||
|
android:icon="@android:drawable/ic_menu_set_as" />
|
||||||
|
|
||||||
<item android:title="@string/text_secure_normal__menu_import_export"
|
<item android:title="@string/text_secure_normal__menu_import_export"
|
||||||
android:icon="@android:drawable/ic_menu_save">
|
android:icon="@android:drawable/ic_menu_save">
|
||||||
<menu>
|
<menu>
|
||||||
|
@ -504,7 +504,8 @@
|
|||||||
<string name="text_secure_normal__menu_import">Import</string>
|
<string name="text_secure_normal__menu_import">Import</string>
|
||||||
<string name="text_secure_normal__menu_export">Export</string>
|
<string name="text_secure_normal__menu_export">Export</string>
|
||||||
<string name="text_secure_normal__menu_clear_passphrase">Clear Passphrase</string>
|
<string name="text_secure_normal__menu_clear_passphrase">Clear Passphrase</string>
|
||||||
|
<string name="text_secure_normal__mark_all_as_read">Mark All Read</string>
|
||||||
|
|
||||||
<!-- verify_keys -->
|
<!-- verify_keys -->
|
||||||
<string name="verify_keys__menu_verified">Verified</string>
|
<string name="verify_keys__menu_verified">Verified</string>
|
||||||
|
|
||||||
|
@ -2,25 +2,27 @@ package org.thoughtcrime.securesms;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.view.Menu;
|
||||||
|
import com.actionbarsherlock.view.MenuInflater;
|
||||||
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
import org.thoughtcrime.securesms.ApplicationExportManager.ApplicationExportListener;
|
import org.thoughtcrime.securesms.ApplicationExportManager.ApplicationExportListener;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
import org.thoughtcrime.securesms.service.SendReceiveService;
|
import org.thoughtcrime.securesms.service.SendReceiveService;
|
||||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.Menu;
|
|
||||||
import com.actionbarsherlock.view.MenuInflater;
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
|
||||||
|
|
||||||
public class ConversationListActivity extends PassphraseRequiredSherlockFragmentActivity
|
public class ConversationListActivity extends PassphraseRequiredSherlockFragmentActivity
|
||||||
implements ConversationListFragment.ConversationSelectedListener
|
implements ConversationListFragment.ConversationSelectedListener
|
||||||
{
|
{
|
||||||
@ -76,6 +78,7 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
|||||||
case R.id.menu_export: handleExportDatabase(); return true;
|
case R.id.menu_export: handleExportDatabase(); return true;
|
||||||
case R.id.menu_import: handleImportDatabase(); return true;
|
case R.id.menu_import: handleImportDatabase(); return true;
|
||||||
case R.id.menu_clear_passphrase: handleClearPassphrase(); return true;
|
case R.id.menu_clear_passphrase: handleClearPassphrase(); return true;
|
||||||
|
case R.id.menu_mark_all_read: handleMarkAllRead(); return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -127,6 +130,17 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
|||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleMarkAllRead() {
|
||||||
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
DatabaseFactory.getThreadDatabase(ConversationListActivity.this).setAllThreadsRead();
|
||||||
|
MessageNotifier.updateNotification(ConversationListActivity.this, masterSecret);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
}
|
||||||
|
|
||||||
private void initializeContactUpdatesReceiver() {
|
private void initializeContactUpdatesReceiver() {
|
||||||
ContentObserver observer = new ContentObserver(null) {
|
ContentObserver observer = new ContentObserver(null) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -273,6 +273,14 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
|||||||
database.update(TABLE_NAME, contentValues, THREAD_ID + " = ?", new String[] {threadId+""});
|
database.update(TABLE_NAME, contentValues, THREAD_ID + " = ?", new String[] {threadId+""});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAllMessagesRead() {
|
||||||
|
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||||
|
ContentValues contentValues = new ContentValues();
|
||||||
|
contentValues.put(READ, 1);
|
||||||
|
|
||||||
|
database.update(TABLE_NAME, contentValues, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public SendReq[] getOutgoingMessages(MasterSecret masterSecret, long messageId)
|
public SendReq[] getOutgoingMessages(MasterSecret masterSecret, long messageId)
|
||||||
throws MmsException
|
throws MmsException
|
||||||
{
|
{
|
||||||
|
@ -182,11 +182,17 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
|
|||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
contentValues.put(READ, 1);
|
contentValues.put(READ, 1);
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
database.update(TABLE_NAME, contentValues,
|
||||||
database.update(TABLE_NAME, contentValues, THREAD_ID + " = ? AND " + READ + " = 0", new String[] {threadId+""});
|
THREAD_ID + " = ? AND " + READ + " = 0",
|
||||||
long end = System.currentTimeMillis();
|
new String[] {threadId+""});
|
||||||
|
}
|
||||||
|
|
||||||
Log.w("SmsDatabase", "setMessagesRead time: " + (end - start));
|
public void setAllMessagesRead() {
|
||||||
|
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||||
|
ContentValues contentValues = new ContentValues();
|
||||||
|
contentValues.put(READ, 1);
|
||||||
|
|
||||||
|
database.update(TABLE_NAME, contentValues, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateMessageBodyAndType(long messageId, String body, long maskOff, long maskOn) {
|
protected void updateMessageBodyAndType(long messageId, String body, long maskOff, long maskOn) {
|
||||||
|
@ -205,6 +205,18 @@ public class ThreadDatabase extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAllThreadsRead() {
|
||||||
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
|
ContentValues contentValues = new ContentValues(1);
|
||||||
|
contentValues.put(READ, 1);
|
||||||
|
|
||||||
|
db.update(TABLE_NAME, contentValues, null, null);
|
||||||
|
|
||||||
|
DatabaseFactory.getSmsDatabase(context).setAllMessagesRead();
|
||||||
|
DatabaseFactory.getMmsDatabase(context).setAllMessagesRead();
|
||||||
|
notifyConversationListListeners();
|
||||||
|
}
|
||||||
|
|
||||||
public void setRead(long threadId) {
|
public void setRead(long threadId) {
|
||||||
ContentValues contentValues = new ContentValues(1);
|
ContentValues contentValues = new ContentValues(1);
|
||||||
contentValues.put(READ, 1);
|
contentValues.put(READ, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user