Inject ShortcutUtil instead of manually creating it

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-11-22 10:11:02 +01:00
parent d555847fea
commit 8a24ea03a0
No known key found for this signature in database
GPG key ID: 2585783189A62105
2 changed files with 5 additions and 3 deletions

View file

@ -42,11 +42,12 @@ import com.owncloud.android.ui.activity.FileActivity
import com.owncloud.android.ui.activity.FileDisplayActivity
import com.owncloud.android.utils.MimeTypeUtil
import com.owncloud.android.utils.theme.ViewThemeUtils
import javax.inject.Inject
import kotlin.math.roundToInt
private const val i = 108
class ShortcutUtil(val mContext: Context) {
class ShortcutUtil @Inject constructor(private val mContext: Context) {
/**
* Adds a pinned shortcut to the home screen that points to the passed file/folder.
@ -121,4 +122,4 @@ class ShortcutUtil(val mContext: Context) {
drawable.draw(canvas)
return bitmap
}
}
}

View file

@ -199,6 +199,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
@Inject ViewThemeUtils viewThemeUtils;
@Inject FastScrollUtils fastScrollUtils;
@Inject EditorUtils editorUtils;
@Inject ShortcutUtil shortcutUtil;
protected FileFragment.ContainerActivity mContainerActivity;
@ -1150,7 +1151,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
mContainerActivity.getFileOperationsHelper().toggleFileLock(singleFile, false);
} else if (itemId == R.id.action_pin_to_homescreen) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
new ShortcutUtil(getContext()).addShortcutToHomescreen(singleFile, viewThemeUtils);
shortcutUtil.addShortcutToHomescreen(singleFile, viewThemeUtils);
}
return true;
}