From 926ebca9e949d68b1e29d22107c307982b1b3065 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Thu, 25 Mar 2021 21:07:16 +0900 Subject: [PATCH] Set dm colors for Light themes. Also some dm fixes. --- .../DirectItemProfileViewHolder.java | 9 +++++++-- .../masoudss_waveform/WaveformSeekBar.java | 18 ++++++++++++++++-- .../DirectMessageSettingsFragment.java | 7 +++---- .../DirectMessageThreadFragment.java | 5 ++++- .../layout/fragment_direct_messages_thread.xml | 2 +- app/src/main/res/layout/layout_dm_base.xml | 1 + app/src/main/res/layout/layout_dm_link.xml | 4 ++++ .../main/res/layout/layout_dm_media_share.xml | 2 ++ app/src/main/res/layout/layout_dm_profile.xml | 6 ++++-- .../main/res/layout/layout_dm_reel_share.xml | 1 + .../main/res/layout/layout_dm_story_share.xml | 1 + app/src/main/res/layout/layout_dm_text.xml | 1 + .../main/res/layout/layout_dm_voice_media.xml | 4 +++- app/src/main/res/values/attrs.xml | 8 ++++++++ app/src/main/res/values/themes.xml | 12 ++++++++++++ 15 files changed, 68 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemProfileViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemProfileViewHolder.java index 4b55c59f..0360b6b7 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemProfileViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemProfileViewHolder.java @@ -18,7 +18,6 @@ import awais.instagrabber.adapters.DirectItemsAdapter.DirectItemCallback; import awais.instagrabber.databinding.LayoutDmBaseBinding; import awais.instagrabber.databinding.LayoutDmProfileBinding; import awais.instagrabber.models.enums.DirectItemType; -import awais.instagrabber.repositories.responses.ImageVersions2; import awais.instagrabber.repositories.responses.Location; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.User; @@ -97,7 +96,13 @@ public class DirectItemProfileViewHolder extends DirectItemViewHolder { if (profile == null) return; binding.profilePic.setImageURI(profile.getProfilePicUrl()); binding.username.setText(profile.getUsername()); - binding.fullName.setText(profile.getFullName()); + final String fullName = profile.getFullName(); + if (!TextUtils.isEmpty(fullName)) { + binding.fullName.setVisibility(View.VISIBLE); + binding.fullName.setText(fullName); + } else { + binding.fullName.setVisibility(View.GONE); + } binding.isVerified.setVisibility(profile.isVerified() ? View.VISIBLE : View.GONE); itemView.setOnClickListener(v -> openProfile(profile.getUsername())); } diff --git a/app/src/main/java/awais/instagrabber/customviews/masoudss_waveform/WaveformSeekBar.java b/app/src/main/java/awais/instagrabber/customviews/masoudss_waveform/WaveformSeekBar.java index 9e1cfdb8..a2054df1 100755 --- a/app/src/main/java/awais/instagrabber/customviews/masoudss_waveform/WaveformSeekBar.java +++ b/app/src/main/java/awais/instagrabber/customviews/masoudss_waveform/WaveformSeekBar.java @@ -1,6 +1,7 @@ package awais.instagrabber.customviews.masoudss_waveform; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; @@ -50,8 +51,21 @@ public final class WaveformSeekBar extends View { public WaveformSeekBar(final Context context, @Nullable final AttributeSet attrs, final int defStyleAttr) { super(context, attrs, defStyleAttr); - this.waveBackgroundColor = context.getResources().getColor(R.color.white); - this.waveProgressColor = context.getResources().getColor(R.color.blue_800); + final TypedArray a = context.getTheme().obtainStyledAttributes( + attrs, + R.styleable.WaveformSeekBar, + 0, + 0); + final int backgroundColor; + final int progressColor; + try { + backgroundColor = a.getResourceId(R.styleable.WaveformSeekBar_waveformBackgroundColor, R.color.white); + progressColor = a.getResourceId(R.styleable.WaveformSeekBar_waveformProgressColor, R.color.blue_800); + } finally { + a.recycle(); + } + this.waveBackgroundColor = context.getResources().getColor(backgroundColor); + this.waveProgressColor = context.getResources().getColor(progressColor); } private float getSampleMax() { diff --git a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java index 64c7fbca..a960cd36 100644 --- a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageSettingsFragment.java @@ -140,6 +140,7 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi viewModel.isViewerAdmin().observe(getViewLifecycleOwner(), this::setApprovalRelatedUI); viewModel.getApprovalRequiredToJoin().observe(getViewLifecycleOwner(), required -> binding.approvalRequired.setChecked(required)); viewModel.getPendingRequests().observe(getViewLifecycleOwner(), this::setPendingRequests); + viewModel.isGroup().observe(getViewLifecycleOwner(), this::setupSettings); final NavController navController = NavHostFragment.findNavController(this); final NavBackStackEntry backStackEntry = navController.getCurrentBackStackEntry(); if (backStackEntry != null) { @@ -207,13 +208,11 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi } private void init() { - setupSettings(); + // setupSettings(); setupMembers(); } - private void setupSettings() { - Boolean isGroup = viewModel.isGroup().getValue(); - if (isGroup == null) isGroup = false; + private void setupSettings(final boolean isGroup) { binding.groupSettings.setVisibility(isGroup ? View.VISIBLE : View.GONE); binding.muteMessagesLabel.setOnClickListener(v -> binding.muteMessages.toggle()); binding.muteMessages.setOnCheckedChangeListener((buttonView, isChecked) -> { diff --git a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java index 2962c078..acb1dcde 100644 --- a/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageThreadFragment.java @@ -1227,7 +1227,10 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact if (!isEmojiPickerShown) { binding.emojiPicker.setAlpha(0); } - imm.showSoftInput(binding.input, InputMethodManager.SHOW_IMPLICIT); + final boolean shown = imm.showSoftInput(binding.input, InputMethodManager.SHOW_IMPLICIT); + if (!shown) { + Log.e(TAG, "showKeyboard: System did not display the keyboard"); + } if (!isEmojiPickerShown) { animatePan(keyboardHeight); } diff --git a/app/src/main/res/layout/fragment_direct_messages_thread.xml b/app/src/main/res/layout/fragment_direct_messages_thread.xml index 007005a1..96b0bc34 100644 --- a/app/src/main/res/layout/fragment_direct_messages_thread.xml +++ b/app/src/main/res/layout/fragment_direct_messages_thread.xml @@ -156,7 +156,7 @@ android:hint="@string/message" android:paddingTop="12dp" android:paddingBottom="12dp" - android:textColor="@color/white" + android:textColor="?dmInputTextColor" android:textColorHint="@color/grey_500" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/layout/layout_dm_base.xml b/app/src/main/res/layout/layout_dm_base.xml index 0c389368..fd6c61da 100644 --- a/app/src/main/res/layout/layout_dm_base.xml +++ b/app/src/main/res/layout/layout_dm_base.xml @@ -113,6 +113,7 @@ android:paddingEnd="@dimen/dm_message_card_radius" android:paddingBottom="4dp" android:singleLine="true" + android:textColor="@color/white" app:layout_constraintBottom_toTopOf="@id/chat_message_layout" app:layout_constraintEnd_toEndOf="@id/chat_message_layout" app:layout_constraintHorizontal_bias="0" diff --git a/app/src/main/res/layout/layout_dm_link.xml b/app/src/main/res/layout/layout_dm_link.xml index b5ad42a7..a9b05472 100644 --- a/app/src/main/res/layout/layout_dm_link.xml +++ b/app/src/main/res/layout/layout_dm_link.xml @@ -15,6 +15,7 @@ android:paddingEnd="@dimen/dm_message_card_radius" android:paddingBottom="@dimen/dm_message_card_radius_small" android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" + android:textColor="@color/white" tools:text="Some message" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_dm_media_share.xml b/app/src/main/res/layout/layout_dm_media_share.xml index fcc74942..dfe9e45c 100644 --- a/app/src/main/res/layout/layout_dm_media_share.xml +++ b/app/src/main/res/layout/layout_dm_media_share.xml @@ -86,6 +86,7 @@ android:paddingEnd="8dp" android:paddingBottom="0dp" android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" + android:textColor="@color/white" android:textStyle="bold" app:layout_constraintBottom_toTopOf="@id/caption" app:layout_constraintEnd_toEndOf="parent" @@ -101,6 +102,7 @@ android:layout_height="wrap_content" android:padding="8dp" android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" + android:textColor="@color/white" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout/layout_dm_profile.xml b/app/src/main/res/layout/layout_dm_profile.xml index a8e179b5..fc1e11f5 100644 --- a/app/src/main/res/layout/layout_dm_profile.xml +++ b/app/src/main/res/layout/layout_dm_profile.xml @@ -27,7 +27,7 @@ android:ellipsize="end" android:gravity="bottom" android:singleLine="true" - android:textColor="?android:textColorPrimary" + android:textColor="@color/white" android:textSize="16sp" android:textStyle="bold" app:layout_constrainedWidth="true" @@ -62,12 +62,14 @@ android:ellipsize="end" android:singleLine="true" android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" + android:textColor="@color/white" android:visibility="gone" app:layout_constraintBottom_toTopOf="@id/barrier" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="@id/username" app:layout_constraintTop_toBottomOf="@id/username" - tools:text="Full name" /> + tools:text="Full name" + tools:visibility="visible" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_dm_text.xml b/app/src/main/res/layout/layout_dm_text.xml index 7ec388f9..1e1bdca9 100644 --- a/app/src/main/res/layout/layout_dm_text.xml +++ b/app/src/main/res/layout/layout_dm_text.xml @@ -9,4 +9,5 @@ android:paddingEnd="@dimen/dm_message_card_radius" android:paddingBottom="@dimen/dm_message_card_radius_small" android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" + android:textColor="@color/white" tools:text="Text message" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_dm_voice_media.xml b/app/src/main/res/layout/layout_dm_voice_media.xml index d2c49818..8c8b5968 100644 --- a/app/src/main/res/layout/layout_dm_voice_media.xml +++ b/app/src/main/res/layout/layout_dm_voice_media.xml @@ -66,10 +66,12 @@ android:layout_height="54dp" android:layout_marginStart="8dp" android:layout_marginEnd="4dp" + app:waveformBackgroundColor="?dmWaveformBgColor" app:layout_constraintBottom_toTopOf="@id/duration" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/play_wrapper" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:waveformProgressColor="?dmWaveformProgressColor" /> + + + @@ -26,4 +29,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index b0147225..cd0d78a9 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -20,6 +20,9 @@ @style/ThemeOverlay.MaterialComponents.ActionBar @style/ThemeOverlay.MaterialComponents.MaterialAlertDialog.Light + @color/grey_600 + @color/deep_purple_400 + @color/deep_purple_600