From da140289d4ef6d19bad41fe4e7a4067446266590 Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Fri, 15 Mar 2024 21:23:38 +0100 Subject: [PATCH] v1.2.2 Long click player to highlight recording. --- app/build.gradle.kts | 4 ++-- app/src/main/AndroidManifest.xml | 1 + .../ui/adapters/CallLogAdapter.java | 21 +++++++++++++++++++ .../it/dhd/bcrmanager/ui/fragments/Home.java | 15 ++++++++++++- build.gradle.kts | 2 +- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index adaa94b..3e0bf20 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -26,8 +26,8 @@ android { applicationId = "it.dhd.bcrmanager" minSdk = 28 targetSdk = 34 - versionCode = 16 - versionName = "1.2.0" + versionCode = 20 + versionName = "1.2.2" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" setProperty("archivesBaseName", rootProject.name + "-v" + versionName + "-" + versionCode) resourceConfigurations.addAll(listOf( diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2fed0cf..4d18752 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppTheme" + android:localeConfig="@xml/locales_config" android:grantUriPermissions="true" android:requestLegacyExternalStorage="true" tools:targetApi="31"> diff --git a/app/src/main/java/it/dhd/bcrmanager/ui/adapters/CallLogAdapter.java b/app/src/main/java/it/dhd/bcrmanager/ui/adapters/CallLogAdapter.java index 1c2cc5c..a73754c 100644 --- a/app/src/main/java/it/dhd/bcrmanager/ui/adapters/CallLogAdapter.java +++ b/app/src/main/java/it/dhd/bcrmanager/ui/adapters/CallLogAdapter.java @@ -7,6 +7,8 @@ import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Handler; +import android.os.Looper; import android.provider.ContactsContract; import android.view.LayoutInflater; import android.view.View; @@ -64,12 +66,23 @@ public class CallLogAdapter extends RecyclerView.Adapter filteredList) { callLogItems.clear(); callLogItems.addAll(filteredList); notifyDataSetChanged(); } + public void highLight(int pos) { + highlightPos = pos; + notifyItemChanged(pos); + new Handler(Looper.getMainLooper()).postDelayed(() -> { + highlightPos = RecyclerView.NO_POSITION; + notifyItemChanged(pos); + }, 350); + } + public interface onActionPlayListener { void onActionPlay(MaterialButton playButton, CallLogItem item, RecyclerView.Adapter bindingAdapter); } @@ -344,6 +357,14 @@ public void bind(CallLogItem item, int position) { binding.rootLayout.setCardBackgroundColor(ContextCompat.getColor(mContext, R.color.trans)); } + if (position == highlightPos) { + binding.rootLayout.setCardBackgroundColor(ThemeUtils.getColorSurfaceHighest(mContext)); + } else if (position == expandedPosition) { + binding.rootLayout.setCardBackgroundColor(ThemeUtils.getColorSurfaceHigh(mContext)); + } else { + binding.rootLayout.setCardBackgroundColor(ContextCompat.getColor(mContext, R.color.trans)); + } + binding.expandingLayout.setVisibility(position == expandedPosition ? View.VISIBLE : View.GONE); // Set Contact Name diff --git a/app/src/main/java/it/dhd/bcrmanager/ui/fragments/Home.java b/app/src/main/java/it/dhd/bcrmanager/ui/fragments/Home.java index cfab91a..3228689 100644 --- a/app/src/main/java/it/dhd/bcrmanager/ui/fragments/Home.java +++ b/app/src/main/java/it/dhd/bcrmanager/ui/fragments/Home.java @@ -8,10 +8,12 @@ import android.content.res.Configuration; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.RippleDrawable; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; +import android.os.Looper; import android.os.SystemClock; import android.provider.ContactsContract; import android.text.TextUtils; @@ -533,7 +535,7 @@ private void setupBottomPlayer() { mStarredAdapter.notifyItemChanged(starredListFiltered.indexOf(currentlyPlaying)); }); binding.playerInfoBarContainer.setOnLongClickListener(v -> { - binding.recyclerView.smoothScrollToPosition(sortedListFiltered.indexOf(currentlyPlaying)); + highlightRecording(); return true; }); } @@ -1270,4 +1272,15 @@ private void onTrimAudioClip(CallLogItem item) { fm.beginTransaction().replace(R.id.frame_layout, new TrimAudioFragment(item)).addToBackStack(null).commit(); } + private void highlightRecording() { + if (binding == null) return; + if (!sortedListFiltered.contains(currentlyPlaying)) return; + int pos = sortedListFiltered.indexOf(currentlyPlaying); + binding.recyclerView.scrollToPosition(pos); + binding.recyclerView.postDelayed(() -> { + mRegAdapter.highLight(pos); + //highlightFallback(prefsFragment, prefResult); + }, 200); + } + } diff --git a/build.gradle.kts b/build.gradle.kts index a71970e..b26d150 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.2.1" apply false + id("com.android.application") version "8.2.2" apply false id("dev.rikka.tools.materialthemebuilder") version "1.4.1" }