From 89352e902dbb84387ca6c2b7dde19062f94d0899 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Sun, 28 Jan 2018 23:01:25 +0100 Subject: [PATCH] More refactoring Signed-off-by: Mario Danic --- .../bottomsheet/OperationsMenuController.java | 8 ++--- .../com/nextcloud/talk/utils/ColorUtils.java | 35 ------------------- .../nextcloud/talk/utils/DisplayUtils.java | 9 +++++ .../talk/utils/database/user/UserUtils.java | 1 - 4 files changed, 13 insertions(+), 40 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index 731cdc716..4c164dfee 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -43,7 +43,7 @@ import com.nextcloud.talk.controllers.base.BaseController; import com.nextcloud.talk.events.BottomSheetLockEvent; import com.nextcloud.talk.persistence.entities.UserEntity; import com.nextcloud.talk.utils.ApplicationWideMessageHolder; -import com.nextcloud.talk.utils.ColorUtils; +import com.nextcloud.talk.utils.DisplayUtils; import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.database.user.UserUtils; @@ -199,10 +199,10 @@ public class OperationsMenuController extends BaseController { progressBar.setVisibility(View.GONE); if (everythingOK) { - resultImageView.setImageDrawable(ColorUtils.getTintedDrawable(getResources(), R.drawable + resultImageView.setImageDrawable(DisplayUtils.getTintedDrawable(getResources(), R.drawable .ic_check_circle_black_24dp, R.color.nc_darkGreen)); } else { - resultImageView.setImageDrawable(ColorUtils.getTintedDrawable(getResources(), R.drawable + resultImageView.setImageDrawable(DisplayUtils.getTintedDrawable(getResources(), R.drawable .ic_cancel_black_24dp, R.color.nc_darkRed)); } @@ -219,7 +219,7 @@ public class OperationsMenuController extends BaseController { if (everythingOK) { eventBus.post(new BottomSheetLockEvent(true, 2500, true, true)); } else { - resultImageView.setImageDrawable(ColorUtils.getTintedDrawable(getResources(), R.drawable + resultImageView.setImageDrawable(DisplayUtils.getTintedDrawable(getResources(), R.drawable .ic_cancel_black_24dp, R.color.nc_darkRed)); okButton.setOnClickListener(v -> eventBus.post(new BottomSheetLockEvent(true, 0, operationCode != 99, true))); diff --git a/app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java b/app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java deleted file mode 100644 index bd56859b9..000000000 --- a/app/src/main/java/com/nextcloud/talk/utils/ColorUtils.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.utils; - -import android.content.res.Resources; -import android.graphics.drawable.Drawable; -import android.support.annotation.ColorRes; -import android.support.annotation.DrawableRes; - -public class ColorUtils { - public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) { - Drawable drawable = res.getDrawable(drawableResId); - int color = res.getColor(colorResId); - drawable.setTint(color); - return drawable; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java index 258efe714..9fc74c2a7 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java @@ -23,7 +23,10 @@ package com.nextcloud.talk.utils; import android.annotation.SuppressLint; import android.content.Context; import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.os.Build; +import android.support.annotation.ColorRes; +import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatDrawableManager; import android.util.DisplayMetrics; import android.util.Log; @@ -66,4 +69,10 @@ public class DisplayUtils { } } + public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) { + Drawable drawable = res.getDrawable(drawableResId); + int color = res.getColor(colorResId); + drawable.setTint(color); + return drawable; + } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/database/user/UserUtils.java b/app/src/main/java/com/nextcloud/talk/utils/database/user/UserUtils.java index d4a086d71..f03301b2e 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/database/user/UserUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/database/user/UserUtils.java @@ -42,7 +42,6 @@ public class UserUtils { UserUtils(ReactiveEntityStore dataStore) { this.dataStore = dataStore; - } public boolean anyUserExists() {