mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 14:54:09 +01:00
reformat code
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
61e0c88188
commit
a8c8fbe191
@ -131,7 +131,11 @@ public class DisplayUtils {
|
|||||||
public void onClick(@NonNull View widget) {
|
public void onClick(@NonNull View widget) {
|
||||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
NextcloudTalkApplication.Companion.getSharedApplication().getApplicationContext().startActivity(browserIntent);
|
NextcloudTalkApplication
|
||||||
|
.Companion
|
||||||
|
.getSharedApplication()
|
||||||
|
.getApplicationContext()
|
||||||
|
.startActivity(browserIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -173,7 +177,8 @@ public class DisplayUtils {
|
|||||||
|
|
||||||
public static Bitmap getBitmap(Drawable drawable) {
|
public static Bitmap getBitmap(Drawable drawable) {
|
||||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
|
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
|
||||||
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
drawable.getIntrinsicHeight(),
|
||||||
|
Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||||
drawable.draw(canvas);
|
drawable.draw(canvas);
|
||||||
@ -182,7 +187,9 @@ public class DisplayUtils {
|
|||||||
|
|
||||||
public static ImageRequest getImageRequestForUrl(String url, @Nullable UserEntity userEntity) {
|
public static ImageRequest getImageRequestForUrl(String url, @Nullable UserEntity userEntity) {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
if (userEntity != null && url.startsWith(userEntity.getBaseUrl()) && (url.contains("index.php/core/preview?fileId=") || url.contains("/avatar/"))) {
|
if (userEntity != null &&
|
||||||
|
url.startsWith(userEntity.getBaseUrl()) &&
|
||||||
|
(url.contains("index.php/core/preview?fileId=") || url.contains("/avatar/"))) {
|
||||||
headers.put("Authorization", ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken()));
|
headers.put("Authorization", ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +209,9 @@ public class DisplayUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinalImageSet(String id, @androidx.annotation.Nullable Object imageInfo, @androidx.annotation.Nullable Animatable animatable) {
|
public void onFinalImageSet(String id,
|
||||||
|
@androidx.annotation.Nullable Object imageInfo,
|
||||||
|
@androidx.annotation.Nullable Animatable animatable) {
|
||||||
updateViewSize((ImageInfo) imageInfo, draweeView);
|
updateViewSize((ImageInfo) imageInfo, draweeView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,8 +251,10 @@ public class DisplayUtils {
|
|||||||
if (Build.VERSION.SDK_INT < 23) {
|
if (Build.VERSION.SDK_INT < 23) {
|
||||||
try {
|
try {
|
||||||
@SuppressLint("RestrictedApi") AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
|
@SuppressLint("RestrictedApi") AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
|
||||||
Class<?> inflateDelegateClass = Class.forName("android.support.v7.widget.AppCompatDrawableManager$InflateDelegate");
|
Class<?> inflateDelegateClass = Class.forName(
|
||||||
Class<?> vdcInflateDelegateClass = Class.forName("android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate");
|
"android.support.v7.widget.AppCompatDrawableManager$InflateDelegate");
|
||||||
|
Class<?> vdcInflateDelegateClass = Class.forName(
|
||||||
|
"android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate");
|
||||||
|
|
||||||
Constructor<?> constructor = vdcInflateDelegateClass.getDeclaredConstructor();
|
Constructor<?> constructor = vdcInflateDelegateClass.getDeclaredConstructor();
|
||||||
constructor.setAccessible(true);
|
constructor.setAccessible(true);
|
||||||
@ -261,7 +272,8 @@ public class DisplayUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) {
|
public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) {
|
||||||
Drawable drawable = ResourcesCompat.getDrawable(res, drawableResId,null);;
|
Drawable drawable = ResourcesCompat.getDrawable(res, drawableResId, null);
|
||||||
|
;
|
||||||
int color = res.getColor(colorResId);
|
int color = res.getColor(colorResId);
|
||||||
if (drawable != null) {
|
if (drawable != null) {
|
||||||
drawable.setTint(color);
|
drawable.setTint(color);
|
||||||
@ -303,11 +315,15 @@ public class DisplayUtils {
|
|||||||
if (!isCall) {
|
if (!isCall) {
|
||||||
String url = ApiUtils.getUrlForAvatarWithName(conversationUser.getBaseUrl(), id, R.dimen.avatar_size_big);
|
String url = ApiUtils.getUrlForAvatarWithName(conversationUser.getBaseUrl(), id, R.dimen.avatar_size_big);
|
||||||
if ("guests".equals(type) || "guest".equals(type)) {
|
if ("guests".equals(type) || "guest".equals(type)) {
|
||||||
url = ApiUtils.getUrlForAvatarWithNameForGuests(conversationUser.getBaseUrl(), String.valueOf(label), R.dimen.avatar_size_big);
|
url = ApiUtils.getUrlForAvatarWithNameForGuests(
|
||||||
|
conversationUser.getBaseUrl(),
|
||||||
|
String.valueOf(label), R.dimen.avatar_size_big);
|
||||||
}
|
}
|
||||||
ImageRequest imageRequest = getImageRequestForUrl(url, null);
|
ImageRequest imageRequest = getImageRequestForUrl(url, null);
|
||||||
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
||||||
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
|
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(
|
||||||
|
imageRequest,
|
||||||
|
context);
|
||||||
|
|
||||||
dataSource.subscribe(
|
dataSource.subscribe(
|
||||||
new BaseBitmapDataSubscriber() {
|
new BaseBitmapDataSubscriber() {
|
||||||
@ -318,7 +334,9 @@ public class DisplayUtils {
|
|||||||
|
|
||||||
// A hack to refresh the chip icon
|
// A hack to refresh the chip icon
|
||||||
if (emojiEditText != null) {
|
if (emojiEditText != null) {
|
||||||
emojiEditText.post(() -> emojiEditText.setTextKeepState(emojiEditText.getText(), TextView.BufferType.SPANNABLE));
|
emojiEditText.post(() -> emojiEditText.setTextKeepState(
|
||||||
|
emojiEditText.getText(),
|
||||||
|
TextView.BufferType.SPANNABLE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,7 +377,12 @@ public class DisplayUtils {
|
|||||||
int end = start + m.group().length();
|
int end = start + m.group().length();
|
||||||
lastStartIndex = end;
|
lastStartIndex = end;
|
||||||
mentionChipSpan = new Spans.MentionChipSpan(DisplayUtils.getDrawableForMentionChipSpan(context,
|
mentionChipSpan = new Spans.MentionChipSpan(DisplayUtils.getDrawableForMentionChipSpan(context,
|
||||||
id, label, conversationUser, type, chipXmlRes, null),
|
id,
|
||||||
|
label,
|
||||||
|
conversationUser,
|
||||||
|
type,
|
||||||
|
chipXmlRes,
|
||||||
|
null),
|
||||||
BetterImageSpan.ALIGN_CENTER, id,
|
BetterImageSpan.ALIGN_CENTER, id,
|
||||||
label);
|
label);
|
||||||
spannableString.setSpan(mentionChipSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
spannableString.setSpan(mentionChipSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
@ -401,8 +424,10 @@ public class DisplayUtils {
|
|||||||
return spannableString;
|
return spannableString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor,
|
public static Drawable getMessageSelector(@ColorInt int normalColor,
|
||||||
@ColorInt int pressedColor, @DrawableRes int shape) {
|
@ColorInt int selectedColor,
|
||||||
|
@ColorInt int pressedColor,
|
||||||
|
@DrawableRes int shape) {
|
||||||
|
|
||||||
Drawable vectorDrawable = ContextCompat.getDrawable(NextcloudTalkApplication.Companion.getSharedApplication()
|
Drawable vectorDrawable = ContextCompat.getDrawable(NextcloudTalkApplication.Companion.getSharedApplication()
|
||||||
.getApplicationContext(),
|
.getApplicationContext(),
|
||||||
@ -436,7 +461,8 @@ public class DisplayUtils {
|
|||||||
if (isLightTheme) {
|
if (isLightTheme) {
|
||||||
int systemUiFlagLightStatusBar;
|
int systemUiFlagLightStatusBar;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
systemUiFlagLightStatusBar = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
systemUiFlagLightStatusBar = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR |
|
||||||
|
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||||
} else {
|
} else {
|
||||||
systemUiFlagLightStatusBar = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
systemUiFlagLightStatusBar = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||||
}
|
}
|
||||||
@ -561,7 +587,8 @@ public class DisplayUtils {
|
|||||||
avatarImageView.setController(draweeController);
|
avatarImageView.setController(draweeController);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @StringRes int getSortOrderStringId(FileSortOrder sortOrder) {
|
public static @StringRes
|
||||||
|
int getSortOrderStringId(FileSortOrder sortOrder) {
|
||||||
switch (sortOrder.name) {
|
switch (sortOrder.name) {
|
||||||
case sort_z_to_a_id:
|
case sort_z_to_a_id:
|
||||||
return R.string.menu_item_sort_by_name_z_a;
|
return R.string.menu_item_sort_by_name_z_a;
|
||||||
@ -579,4 +606,3 @@ public class DisplayUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user