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

Commit

Permalink
Merge branch 'release/0.9.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed Nov 25, 2019
2 parents b987985 + 673d852 commit 5da259a
Show file tree
Hide file tree
Showing 82 changed files with 3,916 additions and 1,062 deletions.
22 changes: 22 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
Changes in Riot 0.9.9 (2019-11-25)
===================================================

MatrixSdk 🚀:
- Upgrade to version 0.9.32
- Changelog: https://github.com/matrix-org/matrix-android-sdk/releases/tag/v0.9.32

Features ✨:
- Privacy / Room Widget permissions (#3378)
- Privacy / Widget Permission for jitsi widgets (#3391)

Improvements 🙌:
- Jitsi / Use mx display name in Jitsi conf

Other changes:
- Add User-Interactive Auth to /account/3pid/add (#3333)

Bugfix 🐛:
- Crash / potential NPE after logout (#3367)
- Fix infinite restart loop after token expiration (#3249)


Changes in Riot 0.9.8 (2019-10-09)
===================================================

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Riot-Android [![Buildkite](https://badge.buildkite.com/5ae4f24dd485562a5b59a9f84
Important Announcement
======================

The core team is now working mainly on [RiotX](https://github.com/vector-im/riotX-android). New contributions (PR, issues) are still welcome, but be aware that this codebase will be replaced in the future by the RiotX implementation.
The core team is now working mainly on [RiotX](https://github.com/vector-im/riotX-android). New contributions about security concerns (PR, issues) are still welcome. Other subjects may rarely be addressed, as we do not have time to spend on maintenance on new features. Please contribute to RiotX now!

Contributing
============
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ buildscript {

// global properties used in sub modules
ext {
versionCodeProp = 90800
versionNameProp = "0.9.8"
versionCodeProp = 90900
versionNameProp = "0.9.9"
versionBuild = System.getenv("BUILD_NUMBER") as Integer ?: 0
buildNumberProp = "${versionBuild}"
}
Expand Down
2 changes: 1 addition & 1 deletion vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ dependencies {
/************* Matrix SDK management **************/
// update settings.gradle
// use the matrix SDK as external dependency
implementation 'com.github.matrix-org:matrix-android-sdk:v0.9.30'
implementation 'com.github.matrix-org:matrix-android-sdk:v0.9.32'
// use the matrix SDK as a sub project
// you have to uncomment some lines in settings.gradle
//implementation project(':matrix-sdk')
Expand Down
33 changes: 28 additions & 5 deletions vector/src/main/java/im/vector/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public class Matrix {
@Nullable
private KeyRequestHandler mKeyRequestHandler;

private Map<String, WidgetManagerProvider> mWidgetManagerProviders = new HashMap<>();

// i.e the event has been read from another client
private static final MXEventListener mLiveEventListener = new MXEventListener() {
boolean mClearCacheRequired = false;
Expand All @@ -133,10 +135,12 @@ public void onIgnoredUsersListUpdate() {
public void onLiveEvent(Event event, RoomState roomState) {
mRefreshUnreadCounter |= Event.EVENT_TYPE_MESSAGE.equals(event.getType()) || Event.EVENT_TYPE_RECEIPT.equals(event.getType());

// TODO update to manage multisessions
WidgetsManager wm = WidgetManagerProvider.INSTANCE.getWidgetManager(VectorApp.getInstance().getApplicationContext());
if (wm != null) {
wm.onLiveEvent(instance.getDefaultSession(), event);
WidgetManagerProvider wp = instance.mWidgetManagerProviders.get(instance.getDefaultSession().getMyUserId());
if (wp != null) {
WidgetsManager wm = wp.getWidgetManager(VectorApp.getInstance().getApplicationContext());
if (wm != null) {
wm.onLiveEvent(instance.getDefaultSession(), event);
}
}
}

Expand Down Expand Up @@ -306,6 +310,23 @@ public List<MXSession> getSessions() {
return sessions;
}

@Nullable
public WidgetManagerProvider getWidgetManagerProvider(MXSession session) {
if (session == null) {
return null;
}
return mWidgetManagerProviders.get(session.getMyUserId());
}

@Nullable
public static WidgetsManager getWidgetManager(Context activity) {
if (Matrix.getInstance(activity) == null) return null;
MXSession session = Matrix.getInstance(activity).getDefaultSession();
if (session == null) return null;
WidgetManagerProvider widgetManagerProvider = Matrix.getInstance(activity).getWidgetManagerProvider(session);
if (widgetManagerProvider == null) return null;
return widgetManagerProvider.getWidgetManager(activity);
}
/**
* Retrieve the default session if one exists.
* <p>
Expand Down Expand Up @@ -648,7 +669,9 @@ public synchronized void addSession(MXSession session) {
* @return The session.
*/
public MXSession createSession(HomeServerConnectionConfig hsConfig) {
return createSession(mAppContext, hsConfig);
MXSession session = createSession(mAppContext, hsConfig);
mWidgetManagerProviders.put(session.getMyUserId(), new WidgetManagerProvider(session));
return session;
}

/**
Expand Down
6 changes: 0 additions & 6 deletions vector/src/main/java/im/vector/VectorApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -197,11 +196,6 @@ public void onCreate() {
Log.d(LOG_TAG, "onCreate");
super.onCreate();

PreferencesManager.setIntegrationManagerUrls(this,
getString(R.string.integrations_ui_url),
getString(R.string.integrations_rest_url),
getString(R.string.integrations_jitsi_widget_url));

mLifeCycleListener = new VectorLifeCycleObserver();
ProcessLifecycleOwner.get().getLifecycle().addObserver(mLifeCycleListener);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import im.vector.Matrix
import im.vector.R
import im.vector.activity.util.INTEGRATION_MANAGER_ACTIVITY_REQUEST_CODE
import im.vector.activity.util.TERMS_REQUEST_CODE
import im.vector.fragments.roomwidgets.WebviewPermissionUtils
import im.vector.types.JsonDict
import im.vector.types.WidgetEventData
import im.vector.util.AssetReader
import im.vector.util.toJsonMap
import im.vector.widgets.WidgetManagerProvider
import im.vector.widgets.WidgetsManager
import org.jetbrains.anko.toast
import org.matrix.androidsdk.MXSession
Expand Down Expand Up @@ -88,7 +88,8 @@ abstract class AbstractWidgetActivity : VectorAppCompatActivity() {

@CallSuper
override fun initUiAndData() {
mSession = Matrix.getInstance(this).getSession(intent.getStringExtra(EXTRA_MATRIX_ID))
val matrix = Matrix.getInstance(this)
mSession = matrix.getSession(intent.getStringExtra(EXTRA_MATRIX_ID))

if (null == mSession || !mSession!!.isAlive) {
Log.e(LOG_TAG, "## onCreate() : invalid session")
Expand All @@ -100,7 +101,7 @@ abstract class AbstractWidgetActivity : VectorAppCompatActivity() {

mRoom = mSession!!.dataHandler.getRoom(intent.getStringExtra(EXTRA_ROOM_ID))

widgetManager = WidgetManagerProvider.getWidgetManager(this) ?: run {
widgetManager = matrix.getWidgetManagerProvider(mSession)?.getWidgetManager(this) ?: run {
finish()
return
}
Expand Down Expand Up @@ -149,7 +150,7 @@ abstract class AbstractWidgetActivity : VectorAppCompatActivity() {
}

private fun presentTermsForServices(token: String) {
val wm = WidgetManagerProvider.getWidgetManager(this)
val wm = Matrix.getInstance(this).getWidgetManagerProvider(mSession)?.getWidgetManager(this)//WidgetManagerProvider.getWidgetManagerProvider(this)
if (wm == null) { // should not happen
finish()
return
Expand Down Expand Up @@ -194,7 +195,7 @@ abstract class AbstractWidgetActivity : VectorAppCompatActivity() {
// Permission requests
it.webChromeClient = object : WebChromeClient() {
override fun onPermissionRequest(request: PermissionRequest) {
runOnUiThread { request.grant(request.resources) }
WebviewPermissionUtils.promptForPermissions(R.string.room_widget_resource_permission_title, request, this@AbstractWidgetActivity)
}

override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
Expand Down
43 changes: 13 additions & 30 deletions vector/src/main/java/im/vector/activity/CommonActivityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,39 +316,34 @@ public static void logout(Activity activity) {
private static boolean isRecoveringFromInvalidatedToken = false;

public static void recoverInvalidatedToken() {
Log.e(LOG_TAG, "## recoverInvalidatedToken: Start Recover ");

if (isRecoveringFromInvalidatedToken) {
//ignore, we are doing it
Log.e(LOG_TAG, "## recoverInvalidatedToken: ignore, we are doing it");
return;
}
isRecoveringFromInvalidatedToken = true;
Context context = VectorApp.getCurrentActivity() != null ? VectorApp.getCurrentActivity() : VectorApp.getInstance();

try {

// Clear the credentials
Matrix.getInstance(context).getLoginStorage().clear() ;


VectorApp.getInstance().getNotificationDrawerManager().clearAllEvents();
EventStreamServiceX.Companion.onLogout(context);
// stopEventStream(context);
EventStreamServiceX.Companion.onApplicationStopped(context);

BadgeProxy.INSTANCE.updateBadgeCount(context, 0);

MXSession session = Matrix.getInstance(context).getDefaultSession();

// Publish to the server that we're now offline
MyPresenceManager.getInstance(context, session).advertiseOffline();
MyPresenceManager.remove(session);

// clear the preferences
PreferencesManager.clearPreferences(context);

// reset the FCM
Matrix.getInstance(context).getPushManager().resetFCMRegistration();

// clear the preferences
Matrix.getInstance(context).getPushManager().clearPreferences();

// Clear the credentials
Matrix.getInstance(context).getLoginStorage().clear();

// clear the tmp store list
Matrix.getInstance(context).clearTmpStoresList();

Expand All @@ -358,20 +353,11 @@ public static void recoverInvalidatedToken() {

MXMediaCache.clearThumbnailsCache(context);

Matrix.getInstance(context).clearSessions(context, true, new SimpleApiCallback<Void>() {

@Override
public void onSuccess(Void info) {

}
});
session.clear(context);
} catch (Exception e) {
Log.e(LOG_TAG, "## recoverInvalidatedToken: Error while cleaning: ", e);
} finally {
// go to login page
CommonActivityUtils.restartApp(context, true);
isRecoveringFromInvalidatedToken = false;
CommonActivityUtils.restartApp(context, true);
}
}

Expand Down Expand Up @@ -436,15 +422,12 @@ public void onSuccess(Void info) {
if (goToLoginPage) {
Activity activeActivity = VectorApp.getCurrentActivity();

final Context activeContext = (null == activeActivity) ? VectorApp.getInstance().getApplicationContext() : activeActivity;

// go to login page
Intent intent = new Intent(activeActivity, LoginActivity.class);
Intent intent = new Intent(activeContext, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

if (null != activeActivity) {
activeActivity.startActivity(intent);
} else {
context.startActivity(intent);
}
activeContext.startActivity(intent);
}
}
});
Expand Down
67 changes: 67 additions & 0 deletions vector/src/main/java/im/vector/activity/DialogUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2019 New Vector 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.activity

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.textfield.TextInputLayout
import im.vector.R
import im.vector.extensions.showPassword

object DialogUtils {

fun promptPassword(context: Context, errorText: String? = null, defaultPwd: String? = null,
done: (String) -> Unit,
cancel: (() -> Unit)? = null) {
val view: ViewGroup = LayoutInflater.from(context).inflate(R.layout.dialog_confirm_password, null) as ViewGroup

val showPassword: ImageView = view.findViewById(R.id.confirm_password_show_passwords)
val passwordTil: TextInputLayout = view.findViewById(R.id.confirm_password_til)
val passwordText: TextInputEditText = view.findViewById(R.id.password_label)
passwordText.setText(defaultPwd)

var passwordShown = false

showPassword.setOnClickListener {
passwordShown = !passwordShown
passwordText.showPassword(passwordShown)
showPassword.setImageResource(if (passwordShown) R.drawable.ic_eye_closed_black else R.drawable.ic_eye_black)
}

passwordTil.error = errorText

AlertDialog.Builder(context)
.setView(view)
.setPositiveButton(R.string._continue) { tv, _ ->
done(passwordText.text.toString())
}
.apply {
if (cancel != null) {
setNegativeButton(R.string.cancel) { _, _ ->
cancel()
}
}
}

.show()

}
}
31 changes: 31 additions & 0 deletions vector/src/main/java/im/vector/activity/HandleBackParticipant.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2019 New Vector 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.activity

/**
* A fragment should implement this interface if it wants to intercept backPressed events.
* Any activity extending VectorAppCompatActivity will propagate back pressed event to child
* fragment that implements it.
*/
interface HandleBackParticipant {

/**
* Returns true, if the on back pressed event has been handled by this Fragment.
* Otherwise return false
*/
fun onBackPressed(): Boolean

}
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class IntegrationManagerActivity : AbstractWidgetActivity() {

Log.d(LOG_TAG, "Received request to get widget in room " + mRoom!!.roomId)

val widgets = widgetManager.getActiveWidgets(mSession, mRoom)
val widgets = WidgetsManager.getActiveWidgets(mSession, mRoom)
val responseData = ArrayList<JsonDict<Any>>()

for (widget in widgets) {
Expand Down
Loading

0 comments on commit 5da259a

Please sign in to comment.