Merge pull request #95 from Vodes/patch-1
Possible fix to #89 and mentioning both container and codec in the title
This commit is contained in:
commit
99b1aae57a
5 changed files with 62 additions and 45 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package com.dkanada.gramophone.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -16,7 +15,7 @@ import com.dkanada.gramophone.model.DirectPlayCodec;
|
|||
import java.util.List;
|
||||
|
||||
public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodecAdapter.ViewHolder> {
|
||||
private List<DirectPlayCodec> directPlayCodecs;
|
||||
private final List<DirectPlayCodec> directPlayCodecs;
|
||||
|
||||
public DirectPlayCodecAdapter(List<DirectPlayCodec> directPlayCodecs) {
|
||||
this.directPlayCodecs = directPlayCodecs;
|
||||
|
|
@ -29,17 +28,17 @@ public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodec
|
|||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DirectPlayCodecAdapter.ViewHolder holder, int position) {
|
||||
DirectPlayCodec directPlayCodec = directPlayCodecs.get(position);
|
||||
|
||||
holder.checkBox.setChecked(directPlayCodec.selected);
|
||||
holder.title.setText(directPlayCodec.title);
|
||||
holder.checkbox.setChecked(directPlayCodec.selected);
|
||||
holder.container.setText(directPlayCodec.codec.container);
|
||||
holder.codec.setText(directPlayCodec.codec.codec);
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
directPlayCodec.selected = !directPlayCodec.selected;
|
||||
holder.checkBox.setChecked(directPlayCodec.selected);
|
||||
holder.checkbox.setChecked(directPlayCodec.selected);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -53,13 +52,16 @@ public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodec
|
|||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public CheckBox checkBox;
|
||||
public TextView title;
|
||||
public CheckBox checkbox;
|
||||
public TextView container;
|
||||
public TextView codec;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
checkBox = view.findViewById(R.id.checkbox);
|
||||
title = view.findViewById(R.id.title);
|
||||
|
||||
checkbox = view.findViewById(R.id.checkbox);
|
||||
container = view.findViewById(R.id.container);
|
||||
codec = view.findViewById(R.id.codec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
package com.dkanada.gramophone.model;
|
||||
|
||||
public class DirectPlayCodec {
|
||||
public String codecName;
|
||||
public String title;
|
||||
public String value;
|
||||
public Codec codec;
|
||||
public boolean selected;
|
||||
|
||||
public DirectPlayCodec(String codecName, String title, String value, boolean selected) {
|
||||
this.codecName = codecName;
|
||||
this.title = title;
|
||||
this.value = value;
|
||||
public DirectPlayCodec(Codec codec, boolean selected) {
|
||||
this.codec = codec;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public enum Codec {
|
||||
FLAC("FLAC","flac|flac"),
|
||||
MP3("MP3", "mp3|mp3"),
|
||||
AAC("AAC", "m4a|aac"),
|
||||
OGG("OGG", "ogg|vorbis"),
|
||||
MKA("MKA", "mka|opus");
|
||||
FLAC("FLAC", "FLAC", "flac|flac"),
|
||||
MP3("MP3", "MP3", "mp3|mp3"),
|
||||
OPUS("Opus", "Opus", "opus|opus"),
|
||||
AAC("M4A", "AAC", "m4a|aac"),
|
||||
VORBIS("OGG", "Vorbis", "ogg|vorbis"),
|
||||
OGG("OGG", "Opus", "ogg|opus"),
|
||||
MKA("MKA", "Opus", "mka|opus");
|
||||
|
||||
public final String title;
|
||||
public final String container;
|
||||
public final String codec;
|
||||
public final String value;
|
||||
|
||||
Codec(String title, String value) {
|
||||
Codec(String container, String codec, String value) {
|
||||
this.container = container;
|
||||
this.codec = codec;
|
||||
this.value = value;
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class MusicUtil {
|
|||
containerAdded = true;
|
||||
}
|
||||
|
||||
builder.append(directPlayCodec.value).append(',');
|
||||
builder.append(directPlayCodec.codec.value).append(',');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -432,6 +432,7 @@ public final class PreferenceUtil {
|
|||
|
||||
Set<String> selectedCodecNames = new HashSet<>();
|
||||
for (DirectPlayCodec.Codec codec : codecs) {
|
||||
// this will be the default value
|
||||
selectedCodecNames.add(codec.name());
|
||||
}
|
||||
|
||||
|
|
@ -441,7 +442,7 @@ public final class PreferenceUtil {
|
|||
for (DirectPlayCodec.Codec codec : codecs) {
|
||||
String name = codec.name();
|
||||
boolean selected = selectedCodecNames.contains(name);
|
||||
directPlayCodecs.add(new DirectPlayCodec(name, codec.title, codec.value, selected));
|
||||
directPlayCodecs.add(new DirectPlayCodec(codec, selected));
|
||||
}
|
||||
|
||||
return directPlayCodecs;
|
||||
|
|
@ -451,7 +452,7 @@ public final class PreferenceUtil {
|
|||
Set<String> codecNames = new HashSet<>();
|
||||
for (DirectPlayCodec directPlayCodec : directPlayCodecs) {
|
||||
if (directPlayCodec.selected) {
|
||||
codecNames.add(directPlayCodec.codecName);
|
||||
codecNames.add(directPlayCodec.codec.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/rectSelector"
|
||||
android:minHeight="@dimen/md_listitem_height"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="@dimen/md_dialog_frame_margin"
|
||||
android:paddingLeft="@dimen/md_dialog_frame_margin"
|
||||
android:paddingRight="@dimen/md_dialog_frame_margin"
|
||||
android:paddingStart="@dimen/md_dialog_frame_margin"
|
||||
tools:gravity="start|center_vertical">
|
||||
android:minHeight="24dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingStart="20dp">
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.views.ATECheckBox
|
||||
android:id="@+id/checkbox"
|
||||
|
|
@ -21,21 +20,36 @@
|
|||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:gravity="center_vertical" />
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/md_listitem_height"
|
||||
android:paddingBottom="@dimen/md_listitem_vertical_margin_choice"
|
||||
android:paddingStart="@dimen/md_listitem_control_margin"
|
||||
android:paddingTop="@dimen/md_listitem_vertical_margin_choice"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/md_listitem_textsize"
|
||||
app:layout_constraintStart_toEndOf="@id/checkbox"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Item" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/codec"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingBottom="1dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="12sp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
app:layout_constraintStart_toEndOf="@id/container"
|
||||
app:layout_constraintBottom_toBottomOf="@id/container"
|
||||
tools:text="Item" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue