Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/add_get_key_request_support' int…
Browse files Browse the repository at this point in the history
…o develop

# Conflicts:
#	vector/libs/matrix-sdk.aar

Add the e2e devices list refresh from the /sync request

Should fix element-hq/element-web#2305
  • Loading branch information
ylecollen committed Feb 17, 2017
2 parents 150e8e9 + ba3ace9 commit 6c2e04a
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 59 deletions.
Binary file modified vector/libs/matrix-sdk.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion vector/src/main/java/im/vector/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void onLiveEvent(Event event, RoomState roomState) {
}

@Override
public void onLiveEventsChunkProcessed() {
public void onLiveEventsChunkProcessed(String fromToken, String toToken) {
// when the client does not use GCM (ie. FDroid),
// we need to compute the application badge values

Expand Down
125 changes: 73 additions & 52 deletions vector/src/main/java/im/vector/activity/SplashActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2014 OpenMarket Ltd
*
* Copyright 2017 Vector Creations Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -143,75 +144,95 @@ protected void onCreate(Bundle savedInstanceState) {
session.getDataHandler().getStore().open();

final IMXEventListener eventListener = new MXEventListener() {
@Override
public void onInitialSyncComplete() {
super.onInitialSyncComplete();
boolean noMoreListener;
private void onReady() {
boolean isAlreadyDone;

Log.e(LOG_TAG, "Session " + fSession.getCredentials().userId + " is initialized");
synchronized (LOG_TAG) {
isAlreadyDone = mDoneListeners.containsKey(fSession);
}

synchronized(LOG_TAG) {
mDoneListeners.put(fSession, mListeners.get(fSession));
// do not remove the listeners here
// it crashes the application because of the upper loop
//fSession.getDataHandler().removeListener(mListeners.get(fSession));
// remove from the pending list
if (!isAlreadyDone) {
synchronized (LOG_TAG) {
boolean noMoreListener;

mListeners.remove(fSession);
noMoreListener = (mListeners.size() == 0);
}
Log.e(LOG_TAG, "Session " + fSession.getCredentials().userId + " is initialized");

try {
int nbrRooms = fSession.getDataHandler().getStore().getRooms().size();
mDoneListeners.put(fSession, mListeners.get(fSession));
// do not remove the listeners here
// it crashes the application because of the upper loop
//fSession.getDataHandler().removeListener(mListeners.get(fSession));
// remove from the pending list

VectorApp.sendGAStats(getApplicationContext(),
VectorApp.GOOGLE_ANALYTICS_STATS_CATEGORY,
VectorApp.GOOGLE_ANALYTICS_STARTUP_MOUNT_DATA_ACTION,
nbrRooms + " rooms in " + (System.currentTimeMillis() - mLaunchTime) + " ms",
System.currentTimeMillis() - mLaunchTime
);
mListeners.remove(fSession);
noMoreListener = (mListeners.size() == 0);

VectorApp.sendGAStats(getApplicationContext(),
VectorApp.GOOGLE_ANALYTICS_STATS_CATEGORY,
VectorApp.GOOGLE_ANALYTICS_STATS_ROOMS_ACTION,
null,
nbrRooms
);
try {
int nbrRooms = fSession.getDataHandler().getStore().getRooms().size();

long preloadTime = fSession.getDataHandler().getStore().getPreloadTime();
String label = nbrRooms + " rooms in " + preloadTime + " ms";
VectorApp.sendGAStats(getApplicationContext(),
VectorApp.GOOGLE_ANALYTICS_STATS_CATEGORY,
VectorApp.GOOGLE_ANALYTICS_STARTUP_MOUNT_DATA_ACTION,
nbrRooms + " rooms in " + (System.currentTimeMillis() - mLaunchTime) + " ms",
System.currentTimeMillis() - mLaunchTime
);

if (0 != nbrRooms) {
label += "(" + preloadTime / nbrRooms + " ms per room)";
}
VectorApp.sendGAStats(getApplicationContext(),
VectorApp.GOOGLE_ANALYTICS_STATS_CATEGORY,
VectorApp.GOOGLE_ANALYTICS_STATS_ROOMS_ACTION,
null,
nbrRooms
);

VectorApp.sendGAStats(getApplicationContext(),
VectorApp.GOOGLE_ANALYTICS_STATS_CATEGORY,
VectorApp.GOOGLE_ANALYTICS_STARTUP_STORE_PRELOAD_ACTION,
label,
fSession.getDataHandler().getStore().getPreloadTime()
);
long preloadTime = fSession.getDataHandler().getStore().getPreloadTime();
String label = nbrRooms + " rooms in " + preloadTime + " ms";

Map<String, Long> storeStats = session.getDataHandler().getStore().getStats();
if (0 != nbrRooms) {
label += "(" + preloadTime / nbrRooms + " ms per room)";
}

if (null != storeStats) {
for (String key : storeStats.keySet()) {
VectorApp.sendGAStats(getApplicationContext(),
VectorApp.GOOGLE_ANALYTICS_STATS_CATEGORY,
key,
null,
storeStats.get(key)
VectorApp.GOOGLE_ANALYTICS_STARTUP_STORE_PRELOAD_ACTION,
label,
fSession.getDataHandler().getStore().getPreloadTime()
);

Map<String, Long> storeStats = session.getDataHandler().getStore().getStats();

if (null != storeStats) {
for (String key : storeStats.keySet()) {
VectorApp.sendGAStats(getApplicationContext(),
VectorApp.GOOGLE_ANALYTICS_STATS_CATEGORY,
key,
null,
storeStats.get(key)
);
}
}
} catch (Exception e) {
Log.e(LOG_TAG, "Fail to send stats " + e.getMessage());
}

if (noMoreListener) {
VectorApp.addSyncingSession(session);
onFinish();
}
}
} catch (Exception e) {
Log.e(LOG_TAG, "Fail to send stats " + e.getMessage());
}
}

if (noMoreListener) {
VectorApp.addSyncingSession(session);
onFinish();
}
// should be called if the application was already initialized
@Override
public void onLiveEventsChunkProcessed(String fromToken, String toToken) {
super.onLiveEventsChunkProcessed(fromToken, toToken);
onReady();
}

// first application launched
@Override
public void onInitialSyncComplete(String toToken) {
super.onInitialSyncComplete(toToken);
onReady();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public void run() {
// + other actions which require a background listener
mLiveEventListener = new MXEventListener() {
@Override
public void onLiveEventsChunkProcessed() {
public void onLiveEventsChunkProcessed(String fromToken, String toToken) {
// treat any pending URL link workflow, that was started previously
processIntentUniversalLink();

Expand Down Expand Up @@ -570,7 +570,7 @@ public void onAccountInfoUpdate(MyUser myUser) {
}

@Override
public void onLiveEventsChunkProcessed() {
public void onLiveEventsChunkProcessed(String fromToken, String toToken) {
mSyncInProgressView.setVisibility(View.GONE);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2016 OpenMarket Ltd
* Copyright 2017 Vector Creations Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -514,7 +515,7 @@ private void addSessionListener() {
private boolean mInitialSyncComplete = false;

@Override
public void onInitialSyncComplete() {
public void onInitialSyncComplete(String toToken) {
Log.d(LOG_TAG, "## onInitialSyncComplete()");
getActivity().runOnUiThread(new Runnable() {
@Override
Expand All @@ -526,7 +527,7 @@ public void run() {
}

@Override
public void onLiveEventsChunkProcessed() {
public void onLiveEventsChunkProcessed(String fromToken, String toToken) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2015 OpenMarket Ltd
*
* Copyright 2017 Vector Creations Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -284,7 +285,7 @@ public void onBingEvent(Event event, RoomState roomState, BingRule bingRule) {
}

@Override
public void onLiveEventsChunkProcessed() {
public void onLiveEventsChunkProcessed(String fromToken, String toToken) {
triggerPreparedNotification(true);
mPendingNotifications.clear();

Expand Down

0 comments on commit 6c2e04a

Please sign in to comment.