1
0
mirror of https://github.com/stom79/exodus-android-app synced 2024-12-23 18:28:00 +01:00

Merge pull request #15 from stom79/expand_buttons

Expand buttons
This commit is contained in:
Schoumi 2018-06-27 10:44:22 +02:00 committed by GitHub
commit a0f1896dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 25 deletions

View File

@ -1,7 +1,6 @@
package org.eu.exodus_privacy.exodusprivacy.adapters; package org.eu.exodus_privacy.exodusprivacy.adapters;
import android.databinding.DataBindingUtil; import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -10,12 +9,9 @@ import android.view.ViewGroup;
import org.eu.exodus_privacy.exodusprivacy.R; import org.eu.exodus_privacy.exodusprivacy.R;
import org.eu.exodus_privacy.exodusprivacy.databinding.PermissionItemBinding; import org.eu.exodus_privacy.exodusprivacy.databinding.PermissionItemBinding;
import org.eu.exodus_privacy.exodusprivacy.databinding.TrackerItemBinding;
import org.eu.exodus_privacy.exodusprivacy.objects.Permission; import org.eu.exodus_privacy.exodusprivacy.objects.Permission;
import org.eu.exodus_privacy.exodusprivacy.objects.Tracker;
import java.util.List; import java.util.List;
import java.util.Set;
public class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAdapter.TrackerListViewHolder>{ public class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAdapter.TrackerListViewHolder>{
@ -68,24 +64,31 @@ public class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAd
permissionItemBinding.permissionDescription.setText(permission.description); permissionItemBinding.permissionDescription.setText(permission.description);
manageExpanded(permission); manageExpanded(permission);
permissionItemBinding.mainLayout.setOnClickListener((View.OnClickListener) v -> { permissionItemBinding.mainLayout.setOnClickListener((View.OnClickListener) v -> {
if( permission.description != null && permission.description.trim().length() > 0) {
permission.expanded = !permission.expanded; permission.expanded = !permission.expanded;
manageExpanded(permission); manageExpanded(permission);
});
} }
else });
}
else {
permissionItemBinding.permissionName.setText(R.string.no_permissions); permissionItemBinding.permissionName.setText(R.string.no_permissions);
permissionItemBinding.arrow.setText(" ");
}
} }
void manageExpanded(Permission permission) { void manageExpanded(Permission permission) {
if(permission.expanded) { if(permission.expanded) {
permissionItemBinding.rightArrow.setVisibility(View.GONE); permissionItemBinding.arrow.setText("");
permissionItemBinding.downArrow.setVisibility(View.VISIBLE);
permissionItemBinding.permissionDescription.setVisibility(View.VISIBLE); permissionItemBinding.permissionDescription.setVisibility(View.VISIBLE);
} else { } else {
permissionItemBinding.rightArrow.setVisibility(View.VISIBLE); if( permission.description != null && permission.description.trim().length() > 0 )
permissionItemBinding.downArrow.setVisibility(View.GONE); permissionItemBinding.arrow.setText("");
else
permissionItemBinding.arrow.setText("");
permissionItemBinding.permissionDescription.setVisibility(View.GONE); permissionItemBinding.permissionDescription.setVisibility(View.GONE);
} }
} }
} }

View File

@ -14,27 +14,14 @@
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView
android:text="▶"
android:id="@+id/right_arrow"
android:textColor="@android:color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
/>
<TextView <TextView
android:text="▼" android:text="▼"
android:id="@+id/down_arrow" android:id="@+id/arrow"
android:textColor="@android:color/black" android:textColor="@android:color/black"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
/> />