From 7d9c88b173a92c8749ac897e6db897a6707bff47 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 18 Jun 2024 15:02:16 +0200 Subject: [PATCH] Test Signed-off-by: alperozturk --- .../ui/activity/FileDisplayActivity.java | 29 +++++++++++++++++++ .../ui/adapter/UnifiedSearchItemViewHolder.kt | 12 ++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index b9105cb833..83668fd170 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.app.Dialog; import android.content.BroadcastReceiver; import android.content.ComponentName; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -27,6 +28,7 @@ import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources.NotFoundException; +import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -35,6 +37,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Parcelable; +import android.provider.ContactsContract; import android.text.TextUtils; import android.view.Menu; import android.view.MenuInflater; @@ -131,6 +134,8 @@ import com.owncloud.android.utils.PushUtils; import com.owncloud.android.utils.StringUtils; import com.owncloud.android.utils.theme.CapabilityUtils; +import net.fortuna.ical4j.model.property.Contact; + import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -278,6 +283,30 @@ public class FileDisplayActivity extends FileActivity initSyncBroadcastReceiver(); observeWorkerState(); registerRefreshFolderEventReceiver(); + getAllContacts(); + } + + public void getAllContacts() { + ContentResolver contentResolver = getContentResolver(); + Uri uri = ContactsContract.Contacts.CONTENT_URI; + String[] projection = new String[]{ + ContactsContract.Contacts._ID, + ContactsContract.Contacts.DISPLAY_NAME + }; + Cursor cursor = contentResolver.query(uri, projection, null, null, null); + + if (cursor != null && cursor.getCount() > 0) { + while (cursor.moveToNext()) { + String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); + String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); + Log_OC.d(TAG, "CONTACT_ID: " + id); + Log_OC.d(TAG, "CONTACT_NAME: " + name); + + } + cursor.close(); + } + + // Do something with the list of contacts } @SuppressWarnings("unchecked") diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt b/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt index b6a58f4726..5ce2ddf1b8 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt @@ -8,8 +8,11 @@ package com.owncloud.android.ui.adapter import android.content.Context +import android.content.Intent import android.graphics.Bitmap import android.graphics.drawable.Drawable +import android.net.Uri +import android.provider.ContactsContract import android.view.View import androidx.core.content.res.ResourcesCompat import com.afollestad.sectionedrecyclerview.SectionedViewHolder @@ -70,12 +73,17 @@ class UnifiedSearchItemViewHolder( if (entry.isFile) { binding.more.visibility = View.VISIBLE - binding.more.setOnClickListener { filesAction.showFilesAction(entry) } + binding.more.setOnClickListener { + filesAction.showFilesAction(entry) + } } else { binding.more.visibility = View.GONE } - binding.unifiedSearchItemLayout.setOnClickListener { listInterface.onSearchResultClicked(entry) } + binding.unifiedSearchItemLayout.setOnClickListener { + + // listInterface.onSearchResultClicked(entry) + } } private fun getPlaceholder(entry: SearchResultEntry, mimetype: String?): Drawable {