// Path: vector/src/main/java/im/vector/util/RiotEventDisplay.java
// public class RiotEventDisplay extends EventDisplay {
//     private static final String LOG_TAG = RiotEventDisplay.class.getSimpleName();
// 
//     private static final Map<String, Event> mClosingWidgetEventByStateKey = new HashMap<>();
// 
//     // constructor
//     public RiotEventDisplay(Context context, HtmlToolbox htmlToolbox) {
//         super(context, htmlToolbox);
//     }
// 
//     // constructor
//     public RiotEventDisplay(Context context) {
//         super(context);
//     }
// 
//     /**
//      * Stringify the linked event.
//      *
//      * @param displayNameColor the display name highlighted color.
//      * @return The text or null if it isn't possible.
//      */
//     @Override
//     public CharSequence getTextualDisplay(Integer displayNameColor, Event event, RoomState roomState) {
//         CharSequence text = null;
// 
//         try {
//             if (TextUtils.equals(event.getType(), WidgetsManager.WIDGET_EVENT_TYPE)) {
//                 JsonObject content = event.getContentAsJsonObject();
// 
//                 EventContent eventContent = JsonUtils.toEventContent(event.getContentAsJsonObject());
//                 EventContent prevEventContent = event.getPrevContent();
//                 String senderDisplayName = senderDisplayNameForEvent(event, eventContent, prevEventContent, roomState);
// 
//                 if (0 == content.entrySet().size()) {
//                     Event closingWidgetEvent = mClosingWidgetEventByStateKey.get(event.stateKey);
// 
//                     if (null == closingWidgetEvent) {
//                         List<Event> widgetEvents = roomState.getStateEvents(new HashSet<>(Arrays.asList(WidgetsManager.WIDGET_EVENT_TYPE)));
// 
//                         for (Event widgetEvent : widgetEvents) {
//                             if (TextUtils.equals(widgetEvent.stateKey, event.stateKey) && !widgetEvent.getContentAsJsonObject().entrySet().isEmpty()) {
//                                 closingWidgetEvent = widgetEvent;
//                                 break;
//                             }
//                         }
// 
//                         if (null != closingWidgetEvent) {
//                             mClosingWidgetEventByStateKey.put(event.stateKey, closingWidgetEvent);
//                         }
//                     }
// 
//                     String type = (null != closingWidgetEvent) ?
//                             WidgetContent.toWidgetContent(closingWidgetEvent.getContentAsJsonObject()).getHumanName() : "undefined";
//                     text = mContext.getString(R.string.event_formatter_widget_removed, type, senderDisplayName);
//                 } else {
//                     String type = WidgetContent.toWidgetContent(event.getContentAsJsonObject()).getHumanName();
//                     text = mContext.getString(R.string.event_formatter_widget_added, type, senderDisplayName);
//                 }
//             } else {
//                 text = super.getTextualDisplay(displayNameColor, event, roomState);
//             }
//             if (event.getCryptoError() != null) {
//                 final MXSession session = Matrix.getInstance(mContext).getDefaultSession();
//                 VectorApp.getInstance()
//                         .getDecryptionFailureTracker()
//                         .reportUnableToDecryptError(event, roomState, session.getMyUserId());
//             }
// 
//         } catch (Exception e) {
//             Log.e(LOG_TAG, "getTextualDisplay() " + e.getMessage(), e);
//         }
// 
//         return text;
//     }
// }


import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import org.matrix.androidsdk.MXDataHandler;
import org.matrix.androidsdk.MXSession;
import org.matrix.androidsdk.core.EventDisplay;
import org.matrix.androidsdk.core.Log;
import org.matrix.androidsdk.data.Room;
import org.matrix.androidsdk.data.RoomState;
import org.matrix.androidsdk.data.RoomSummary;
import org.matrix.androidsdk.data.RoomTag;
import org.matrix.androidsdk.rest.model.Event;
import org.matrix.androidsdk.rest.model.User;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import im.vector.Matrix;
import im.vector.PublicRoomsManager;
import im.vector.R;
import im.vector.settings.VectorLocale;
import im.vector.ui.themes.ThemeUtils;
import im.vector.util.RiotEventDisplay;
import im.vector.util.RoomUtils;
import im.vector.util.VectorUtils;
import im.vector.util.ViewUtilKt;

        if ((null == aMatrixId) || (null == aUserId)) {
            displayNameRetValue = null;
        } else if ((null == (session = Matrix.getMXSession(mContext, aMatrixId))) || (!session.isAlive())) {
            displayNameRetValue = null;
        } else {
            User user = session.getDataHandler().getStore().getUser(aUserId);

            if ((null != user) && !TextUtils.isEmpty(user.displayname)) {
                displayNameRetValue = user.displayname;
            } else {
                displayNameRetValue = aUserId;
            }
        }

        return displayNameRetValue;
    }

    /**
     * Retrieves the text to display for a RoomSummary.
     *
     * @param aChildRoomSummary the roomSummary.
     * @return the text to display.
     */
    private CharSequence getChildMessageToDisplay(RoomSummary aChildRoomSummary) {
        CharSequence messageToDisplayRetValue = null;
        EventDisplay eventDisplay;

        if (null != aChildRoomSummary) {
            if (aChildRoomSummary.getLatestReceivedEvent() != null) {
// Path: vector/src/main/java/im/vector/util/RiotEventDisplay.java
// public class RiotEventDisplay extends EventDisplay {
//     private static final String LOG_TAG = RiotEventDisplay.class.getSimpleName();
// 
//     private static final Map<String, Event> mClosingWidgetEventByStateKey = new HashMap<>();
// 
//     // constructor
//     public RiotEventDisplay(Context context, HtmlToolbox htmlToolbox) {
//         super(context, htmlToolbox);
//     }
// 
//     // constructor
//     public RiotEventDisplay(Context context) {
//         super(context);
//     }
// 
//     /**
//      * Stringify the linked event.
//      *
//      * @param displayNameColor the display name highlighted color.
//      * @return The text or null if it isn't possible.
//      */
//     @Override
//     public CharSequence getTextualDisplay(Integer displayNameColor, Event event, RoomState roomState) {
//         CharSequence text = null;
// 
//         try {
//             if (TextUtils.equals(event.getType(), WidgetsManager.WIDGET_EVENT_TYPE)) {
//                 JsonObject content = event.getContentAsJsonObject();
// 
//                 EventContent eventContent = JsonUtils.toEventContent(event.getContentAsJsonObject());
//                 EventContent prevEventContent = event.getPrevContent();
//                 String senderDisplayName = senderDisplayNameForEvent(event, eventContent, prevEventContent, roomState);
// 
//                 if (0 == content.entrySet().size()) {
//                     Event closingWidgetEvent = mClosingWidgetEventByStateKey.get(event.stateKey);
// 
//                     if (null == closingWidgetEvent) {
//                         List<Event> widgetEvents = roomState.getStateEvents(new HashSet<>(Arrays.asList(WidgetsManager.WIDGET_EVENT_TYPE)));
// 
//                         for (Event widgetEvent : widgetEvents) {
//                             if (TextUtils.equals(widgetEvent.stateKey, event.stateKey) && !widgetEvent.getContentAsJsonObject().entrySet().isEmpty()) {
//                                 closingWidgetEvent = widgetEvent;
//                                 break;
//                             }
//                         }
// 
//                         if (null != closingWidgetEvent) {
//                             mClosingWidgetEventByStateKey.put(event.stateKey, closingWidgetEvent);
//                         }
//                     }
// 
//                     String type = (null != closingWidgetEvent) ?
//                             WidgetContent.toWidgetContent(closingWidgetEvent.getContentAsJsonObject()).getHumanName() : "undefined";
//                     text = mContext.getString(R.string.event_formatter_widget_removed, type, senderDisplayName);
//                 } else {
//                     String type = WidgetContent.toWidgetContent(event.getContentAsJsonObject()).getHumanName();
//                     text = mContext.getString(R.string.event_formatter_widget_added, type, senderDisplayName);
//                 }
//             } else {
//                 text = super.getTextualDisplay(displayNameColor, event, roomState);
//             }
//             if (event.getCryptoError() != null) {
//                 final MXSession session = Matrix.getInstance(mContext).getDefaultSession();
//                 VectorApp.getInstance()
//                         .getDecryptionFailureTracker()
//                         .reportUnableToDecryptError(event, roomState, session.getMyUserId());
//             }
// 
//         } catch (Exception e) {
//             Log.e(LOG_TAG, "getTextualDisplay() " + e.getMessage(), e);
//         }
// 
//         return text;
//     }
// }


// Path: vector/src/main/java/im/vector/adapters/VectorRoomSummaryAdapter.java
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import org.matrix.androidsdk.MXDataHandler;
import org.matrix.androidsdk.MXSession;
import org.matrix.androidsdk.core.EventDisplay;
import org.matrix.androidsdk.core.Log;
import org.matrix.androidsdk.data.Room;
import org.matrix.androidsdk.data.RoomState;
import org.matrix.androidsdk.data.RoomSummary;
import org.matrix.androidsdk.data.RoomTag;
import org.matrix.androidsdk.rest.model.Event;
import org.matrix.androidsdk.rest.model.User;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import im.vector.Matrix;
import im.vector.PublicRoomsManager;
import im.vector.R;
import im.vector.settings.VectorLocale;
import im.vector.ui.themes.ThemeUtils;
import im.vector.util.RiotEventDisplay;
import im.vector.util.RoomUtils;
import im.vector.util.VectorUtils;
import im.vector.util.ViewUtilKt;


        if ((null == aMatrixId) || (null == aUserId)) {
            displayNameRetValue = null;
        } else if ((null == (session = Matrix.getMXSession(mContext, aMatrixId))) || (!session.isAlive())) {
            displayNameRetValue = null;
        } else {
            User user = session.getDataHandler().getStore().getUser(aUserId);

            if ((null != user) && !TextUtils.isEmpty(user.displayname)) {
                displayNameRetValue = user.displayname;
            } else {
                displayNameRetValue = aUserId;
            }
        }

        return displayNameRetValue;
    }

    /**
     * Retrieves the text to display for a RoomSummary.
     *
     * @param aChildRoomSummary the roomSummary.
     * @return the text to display.
     */
    private CharSequence getChildMessageToDisplay(RoomSummary aChildRoomSummary) {
        CharSequence messageToDisplayRetValue = null;
        EventDisplay eventDisplay;

        if (null != aChildRoomSummary) {
            if (aChildRoomSummary.getLatestReceivedEvent() != null) {
                eventDisplay = new RiotEventDisplay(mContext);