Selaa lähdekoodia

Make sound choice icons simple radio buttons

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 vuotta sitten
vanhempi
commit
5aa28e4477

+ 10 - 34
app/src/main/java/com/nextcloud/talk/adapters/items/NotificationSoundItem.java

@@ -20,27 +20,24 @@
 
 
 package com.nextcloud.talk.adapters.items;
 package com.nextcloud.talk.adapters.items;
 
 
-import android.content.res.Resources;
-import android.graphics.drawable.ColorDrawable;
 import android.view.View;
 import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
+
+import com.google.android.material.radiobutton.MaterialRadioButton;
+import com.nextcloud.talk.R;
+
+import java.util.List;
+
 import butterknife.BindView;
 import butterknife.BindView;
 import butterknife.ButterKnife;
 import butterknife.ButterKnife;
-import com.facebook.drawee.view.SimpleDraweeView;
-import com.nextcloud.talk.R;
-import com.nextcloud.talk.application.NextcloudTalkApplication;
 import eu.davidea.flexibleadapter.FlexibleAdapter;
 import eu.davidea.flexibleadapter.FlexibleAdapter;
 import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
 import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
 import eu.davidea.flexibleadapter.items.IFlexible;
 import eu.davidea.flexibleadapter.items.IFlexible;
 import eu.davidea.viewholders.FlexibleViewHolder;
 import eu.davidea.viewholders.FlexibleViewHolder;
 
 
-import java.util.List;
-
 public class NotificationSoundItem extends AbstractFlexibleItem<NotificationSoundItem.NotificationSoundItemViewHolder> {
 public class NotificationSoundItem extends AbstractFlexibleItem<NotificationSoundItem.NotificationSoundItemViewHolder> {
 
 
-    private String notificationSoundName;
-    private String notificationSoundUri;
+    private final String notificationSoundName;
+    private final String notificationSoundUri;
 
 
     public NotificationSoundItem(String notificationSoundName, String notificationSoundUri) {
     public NotificationSoundItem(String notificationSoundName, String notificationSoundUri) {
         this.notificationSoundName = notificationSoundName;
         this.notificationSoundName = notificationSoundName;
@@ -73,31 +70,12 @@ public class NotificationSoundItem extends AbstractFlexibleItem<NotificationSoun
     @Override
     @Override
     public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, NotificationSoundItemViewHolder holder, int position, List<Object> payloads) {
     public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, NotificationSoundItemViewHolder holder, int position, List<Object> payloads) {
         holder.notificationName.setText(notificationSoundName);
         holder.notificationName.setText(notificationSoundName);
-
-        if (adapter.isSelected(position)) {
-            holder.checkedImageView.setVisibility(View.VISIBLE);
-        } else {
-            holder.checkedImageView.setVisibility(View.GONE);
-        }
-
-        Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
-        holder.simpleDraweeView.getHierarchy().setBackgroundImage(new ColorDrawable(resources.getColor(R.color.colorPrimary)));
-        if (position == 0) {
-            holder.simpleDraweeView.getHierarchy().setImage(resources.getDrawable(R.drawable.ic_stop_white_24dp), 100,
-                    true);
-        } else {
-            holder.simpleDraweeView.getHierarchy().setImage(resources.getDrawable(R.drawable.ic_play_circle_outline_white_24dp), 100,
-                    true);
-        }
+        holder.notificationName.setChecked(adapter.isSelected(position));
     }
     }
 
 
     static class NotificationSoundItemViewHolder extends FlexibleViewHolder {
     static class NotificationSoundItemViewHolder extends FlexibleViewHolder {
         @BindView(R.id.notificationNameTextView)
         @BindView(R.id.notificationNameTextView)
-        public TextView notificationName;
-        @BindView(R.id.simpleDraweeView)
-        SimpleDraweeView simpleDraweeView;
-        @BindView(R.id.checkedImageView)
-        ImageView checkedImageView;
+        public MaterialRadioButton notificationName;
 
 
         /**
         /**
          * Default constructor.
          * Default constructor.
@@ -107,6 +85,4 @@ public class NotificationSoundItem extends AbstractFlexibleItem<NotificationSoun
             ButterKnife.bind(this, view);
             ButterKnife.bind(this, view);
         }
         }
     }
     }
-
-
 }
 }

+ 0 - 25
app/src/main/res/drawable/ic_play_circle_outline_white_24dp.xml

@@ -1,25 +0,0 @@
-<!--
-  ~ Nextcloud Talk application
-  ~
-  ~ @author Mario Danic
-  ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
-  ~
-  ~ This program is free software: you can redistribute it and/or modify
-  ~ it under the terms of the GNU General Public License as published by
-  ~ the Free Software Foundation, either version 3 of the License, or
-  ~ at your option) any later version.
-  ~
-  ~ This program is distributed in the hope that it will be useful,
-  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
-  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  ~ GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License
-  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
-  -->
-
-<vector android:autoMirrored="true" android:height="24dp"
-    android:tint="#FFFFFF" android:viewportHeight="24.0"
-    android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
-    <path android:fillColor="#FF000000" android:pathData="M10,16.5l6,-4.5 -6,-4.5v9zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
-</vector>

+ 0 - 25
app/src/main/res/drawable/ic_stop_white_24dp.xml

@@ -1,25 +0,0 @@
-<!--
-  ~ Nextcloud Talk application
-  ~
-  ~ @author Mario Danic
-  ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
-  ~
-  ~ This program is free software: you can redistribute it and/or modify
-  ~ it under the terms of the GNU General Public License as published by
-  ~ the Free Software Foundation, either version 3 of the License, or
-  ~ at your option) any later version.
-  ~
-  ~ This program is distributed in the hope that it will be useful,
-  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
-  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  ~ GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License
-  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
-  -->
-
-<vector android:autoMirrored="true" android:height="24dp"
-    android:tint="#FFFFFF" android:viewportHeight="24.0"
-    android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
-    <path android:fillColor="#FF000000" android:pathData="M6,6h12v12H6z"/>
-</vector>

+ 4 - 23
app/src/main/res/layout/rv_item_notification_sound.xml

@@ -21,7 +21,6 @@
   -->
   -->
 
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <RelativeLayout 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"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_height="wrap_content"
@@ -32,35 +31,17 @@
     android:animateLayoutChanges="true"
     android:animateLayoutChanges="true"
     android:orientation="vertical">
     android:orientation="vertical">
 
 
-    <ImageView
-        android:id="@+id/checkedImageView"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentEnd="true"
-        android:layout_centerVertical="true"
-        android:layout_marginStart="@dimen/standard_margin"
-        android:contentDescription="@string/selected_list_item"
-        android:src="@drawable/ic_check_black_24dp"
-        app:tint="@color/colorPrimary" />
-
-    <TextView
+    <com.google.android.material.radiobutton.MaterialRadioButton
         android:id="@+id/notificationNameTextView"
         android:id="@+id/notificationNameTextView"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
         android:layout_centerVertical="true"
-        android:layout_toStartOf="@id/checkedImageView"
-        android:layout_toEndOf="@id/simpleDraweeView"
+        android:clickable="false"
         android:ellipsize="end"
         android:ellipsize="end"
         android:lines="1"
         android:lines="1"
+        android:paddingStart="24dp"
+        android:paddingEnd="0dp"
         android:textAppearance="@style/ListItem"
         android:textAppearance="@style/ListItem"
         tools:text="Ringy Gone" />
         tools:text="Ringy Gone" />
 
 
-    <com.facebook.drawee.view.SimpleDraweeView
-        android:id="@+id/simpleDraweeView"
-        android:layout_width="@dimen/avatar_size"
-        android:layout_height="@dimen/avatar_size"
-        android:layout_centerVertical="true"
-        android:layout_marginEnd="@dimen/standard_margin"
-        app:roundAsCircle="true" />
-
 </RelativeLayout>
 </RelativeLayout>