Skip to content

Commit

Permalink
audio messages layout tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Sep 20, 2024
1 parent cb1205f commit e1ad2ca
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public void onPause()
try
{
RecyclerView.ViewHolder vh = listingsView.getChildViewHolder(child);
((GroupMessageListHolder_file_outgoing_state_cancel) vh).DetachedFromWindow();
((GroupMessageListHolder_file_outgoing_state_cancel) vh).DetachedFromWindow(true);
}
catch(Exception e1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void bindMessageList(GroupMessage m)
message_ = m;

ft_audio_player.setVisibility(View.GONE);
ft_preview_image.getLayoutParams().height = (int)dp2px(150);

int drawable_id = R.drawable.rounded_blue_bg;
try
Expand Down Expand Up @@ -317,8 +318,21 @@ public boolean onTouch(View v, MotionEvent event)
}
else if (is_audio) // ---- an audio file ----
{
if (PREF__compact_chatlist)
{
textView.setVisibility(View.GONE);
imageView.setVisibility(View.GONE);
}

ft_progressbar.setVisibility(View.GONE);
ft_buttons_container.setVisibility(View.GONE);
button_ok.setVisibility(View.GONE);
button_cancel.setVisibility(View.GONE);

ft_preview_container.setVisibility(View.VISIBLE);
ft_preview_image.setVisibility(View.GONE);
ft_preview_image.getLayoutParams().height = 2;

ft_audio_player.setVisibility(View.VISIBLE);
ft_audio_player.refreshPlayer(message.filename_fullpath);
ft_audio_player.refreshVisualizer();
Expand Down Expand Up @@ -357,9 +371,13 @@ public void onClick(View v)
// Log.i(TAG, "onClick");
}

void DetachedFromWindow()
void DetachedFromWindow(boolean release)
{
ft_audio_player.onPause();
if (release)
{
ft_audio_player.onStop();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public GroupMessagelistAdapter(Context context, List<GroupMessage> items)
public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) {
try
{
((GroupMessageListHolder_file_outgoing_state_cancel) holder).DetachedFromWindow();
((GroupMessageListHolder_file_outgoing_state_cancel) holder).DetachedFromWindow(false);
}
catch(Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public void onPause()
try
{
RecyclerView.ViewHolder vh = listingsView.getChildViewHolder(child);
((MessageListHolder_file_outgoing_state_cancel) vh).DetachedFromWindow();
((MessageListHolder_file_outgoing_state_cancel) vh).DetachedFromWindow(true);
}
catch(Exception e1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void bindMessageList(Message m)
message_ = m;

ft_audio_player.setVisibility(View.GONE);
ft_preview_image.getLayoutParams().height = (int)dp2px(150);

int drawable_id = R.drawable.rounded_blue_bg_with_border;
try
Expand Down Expand Up @@ -384,8 +385,21 @@ public boolean onTouch(View v, MotionEvent event)
}
else if (is_audio) // ---- an audio file ----
{
if (PREF__compact_chatlist)
{
textView.setVisibility(View.GONE);
imageView.setVisibility(View.GONE);
}

ft_progressbar.setVisibility(View.GONE);
ft_buttons_container.setVisibility(View.GONE);
button_ok.setVisibility(View.GONE);
button_cancel.setVisibility(View.GONE);

ft_preview_container.setVisibility(View.VISIBLE);
ft_preview_image.setVisibility(View.GONE);
ft_preview_image.getLayoutParams().height = 2;

ft_audio_player.setVisibility(View.VISIBLE);
ft_audio_player.refreshPlayer(message.filename_fullpath);
ft_audio_player.refreshVisualizer();
Expand Down Expand Up @@ -445,9 +459,13 @@ public void onClick(View v)
// Log.i(TAG, "onClick");
}

void DetachedFromWindow()
void DetachedFromWindow(boolean release)
{
ft_audio_player.onPause();
if (release)
{
ft_audio_player.onStop();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder)
Log.i(TAG, "onViewDetachedFromWindow:M");
try
{
((MessageListHolder_file_outgoing_state_cancel) holder).DetachedFromWindow();
((MessageListHolder_file_outgoing_state_cancel) holder).DetachedFromWindow(false);
}
catch(Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,11 @@ public void run() {
try {
update(mediaPlayer, time, seekBar, context);
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
}
}
}catch (Exception e){
e.printStackTrace();
// e.printStackTrace();
}
}
};
Expand All @@ -439,15 +439,39 @@ private static String convertSecondsToHMmSs(long seconds) {

//These both functions to avoid mediaplayer errors

public void onStop(){
try{
public void onStop()
{
try
{
mediaPlayer.stop();
}
catch (Exception e)
{
e.printStackTrace();
Log.i("VoicePlayerView", "VoicePlayerView:onStop:EE01:" + e.getMessage());
}

try
{
mediaPlayer.reset();
}
catch (Exception e)
{
e.printStackTrace();
Log.i("VoicePlayerView", "VoicePlayerView:onStop:EE02:" + e.getMessage());
}

try
{
mediaPlayer.release();
}catch (Exception e){
Log.i("VoicePlayerView", "VoicePlayerView:mediaPlayer.release()");
}
catch (Exception e)
{
e.printStackTrace();
Log.i("VoicePlayerView", "VoicePlayerView:onStop:EE01:" + e.getMessage());
Log.i("VoicePlayerView", "VoicePlayerView:onStop:EE03:" + e.getMessage());
}

mediaPlayer = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<LinearLayout
android:id="@+id/ft_preview_container"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_height="wrap_content"
android:layout_marginRight="0dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
Expand All @@ -114,17 +114,17 @@
android:layout_height="wrap_content"
app:enableVisualizer="true"
app:visualizationPlayedColor="#ff7700"
app:visualizationNotPlayedColor="#727171"
app:visualizationNotPlayedColor="#000"
app:playPauseBackgroundColor="#ff7700"
app:timingBackgroundColor="#6AFF7700"
app:seekBarProgressColor="#000"
app:seekBarProgressColor="#000000"
app:showShareButton="false"
app:shareCornerRadius="100"
app:playPauseCornerRadius="100"
app:showTiming="true"
app:viewCornerRadius="100"
app:viewBackground="#C6C4CF"
app:progressTimeColor="#000"
app:viewCornerRadius="10"
app:viewBackground="@android:color/holo_blue_light"
app:progressTimeColor="#000000"
app:timingBackgroundColor="#b0b0b0"
app:seekBarThumbColor="#FFC107"
app:shareBackgroundColor="#ff7700"
app:playProgressbarColor="#ff7700"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:padding="1dp"
android:layout_gravity="end"
android:layout_marginEnd="16dp"
android:textSize="10sp"
android:textSize="12sp"
android:text="00:00:00 / 00:00:00"
android:layout_marginRight="16dp" />
<SeekBar
Expand Down

0 comments on commit e1ad2ca

Please sign in to comment.