mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-20 14:54:09 +00:00
Merge branch 'master' into groups
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.ContentObserver;
|
||||
@@ -8,6 +9,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.Telephony;
|
||||
import android.support.v4.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.util.Log;
|
||||
@@ -51,6 +53,7 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
||||
private ConversationListFragment fragment;
|
||||
private MasterSecret masterSecret;
|
||||
private DrawerLayout drawerLayout;
|
||||
private DrawerToggle drawerToggle;
|
||||
private ListView drawerList;
|
||||
|
||||
@Override
|
||||
@@ -71,6 +74,12 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
||||
DirectoryRefreshListener.schedule(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostCreate(Bundle bundle) {
|
||||
super.onPostCreate(bundle);
|
||||
drawerToggle.syncState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@@ -230,6 +239,13 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
||||
}
|
||||
|
||||
DrawerLayout drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
|
||||
drawerToggle = new DrawerToggle(this, drawerLayout,
|
||||
R.drawable.ic_drawer,
|
||||
R.string.conversation_list__drawer_open,
|
||||
R.string.conversation_list__drawer_close);
|
||||
|
||||
drawerLayout.setDrawerListener(drawerToggle);
|
||||
|
||||
ListView drawer = (ListView)findViewById(R.id.left_drawer);
|
||||
SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.navigation_drawer_item, from, to);
|
||||
|
||||
@@ -287,4 +303,31 @@ public class ConversationListActivity extends PassphraseRequiredSherlockFragment
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
class DrawerToggle extends ActionBarDrawerToggle {
|
||||
|
||||
public DrawerToggle(Activity activity, DrawerLayout drawerLayout,
|
||||
int drawerImageRes, int openDrawerContentDescRes,
|
||||
int closeDrawerContentDescRes) {
|
||||
|
||||
super(activity, drawerLayout, drawerImageRes,
|
||||
openDrawerContentDescRes, closeDrawerContentDescRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
|
||||
super.onDrawerClosed(drawerView);
|
||||
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
|
||||
super.onDrawerOpened(drawerView);
|
||||
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
@@ -18,9 +19,11 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
||||
if (!intent.getAction().equals(CLEAR_ACTION))
|
||||
return;
|
||||
|
||||
final long[] threadIds = intent.getLongArrayExtra("thread_ids");
|
||||
final MasterSecret masterSecret = intent.getParcelableExtra("master_secret");
|
||||
|
||||
if (masterSecret != null) {
|
||||
if (threadIds != null && masterSecret != null) {
|
||||
Log.w("MarkReadReceiver", "threadIds length: " + threadIds.length);
|
||||
|
||||
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
||||
.cancel(MessageNotifier.NOTIFICATION_ID);
|
||||
@@ -28,7 +31,10 @@ public class MarkReadReceiver extends BroadcastReceiver {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getThreadDatabase(context).setAllThreadsRead();
|
||||
for (long threadId : threadIds) {
|
||||
Log.w("MarkReadReceiver", "Marking as read: " + threadId);
|
||||
DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
||||
}
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
return null;
|
||||
|
@@ -72,6 +72,7 @@ public class NotificationItem {
|
||||
|
||||
if (recipients != null) {
|
||||
intent.putExtra("recipients", recipients);
|
||||
intent.putExtra("thread_id", threadId);
|
||||
}
|
||||
|
||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
||||
|
@@ -4,6 +4,7 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
|
||||
@@ -42,10 +43,25 @@ public class NotificationState {
|
||||
}
|
||||
|
||||
public PendingIntent getMarkAsReadIntent(Context context, MasterSecret masterSecret) {
|
||||
long[] threadArray = new long[threads.size()];
|
||||
int index = 0;
|
||||
|
||||
for (long thread : threads) {
|
||||
Log.w("NotificationState", "Added thread: " + thread);
|
||||
threadArray[index++] = thread;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(MarkReadReceiver.CLEAR_ACTION);
|
||||
intent.putExtra("thread_ids", threadArray);
|
||||
intent.putExtra("master_secret", masterSecret);
|
||||
intent.setPackage(context.getPackageName());
|
||||
|
||||
// XXX : This is an Android bug. If we don't pull off the extra
|
||||
// once before handing off the PendingIntent, the array will be
|
||||
// truncated to one element when the PendingIntent fires. Thanks guys!
|
||||
Log.w("NotificationState", "Pending array off intent length: " +
|
||||
intent.getLongArrayExtra("thread_ids").length);
|
||||
|
||||
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user