Add clickable resources

This commit is contained in:
Mario Danic 2018-09-06 20:45:03 +02:00
parent 3e6b5f8382
commit 1800209999
2 changed files with 17 additions and 0 deletions

View file

@ -21,8 +21,11 @@
package com.nextcloud.talk.adapters.messages; package com.nextcloud.talk.adapters.messages;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
@ -145,6 +148,12 @@ public class MagicIncomingTextMessageViewHolder
messageString = DisplayUtils.searchAndColor(messageText.getText().toString(), messageString = DisplayUtils.searchAndColor(messageText.getText().toString(),
messageString, "@" + individualHashMap.get("name"), color); messageString, "@" + individualHashMap.get("name"), color);
} else if (individualHashMap.get("type").equals("file")) {
itemView.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
context.startActivity(browserIntent);
});
} }
} }

View file

@ -21,8 +21,10 @@
package com.nextcloud.talk.adapters.messages; package com.nextcloud.talk.adapters.messages;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
@ -95,6 +97,12 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default)); .getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default));
} }
} else if (individualHashMap.get("type").equals("file")) {
itemView.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
context.startActivity(browserIntent);
});
} }
} }