Merge branch 'new-ui--app-deatils-scroll' into 'master'
Scroll app details appropriately when expanding sections. Closes #875 See merge request !445
This commit is contained in:
		
						commit
						a7828bcb9e
					
				| @ -6,6 +6,7 @@ import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.graphics.Bitmap; | ||||
| import android.net.Uri; | ||||
| import android.support.annotation.DrawableRes; | ||||
| import android.support.annotation.LayoutRes; | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.v4.view.ViewCompat; | ||||
| @ -145,6 +146,9 @@ public class AppDetailsRecyclerViewAdapter | ||||
|         if (showVersions) { | ||||
|             items.addAll(startIndex, versions); | ||||
|             notifyItemRangeInserted(startIndex, versions.size()); | ||||
|             if (recyclerView != null) { | ||||
|                 ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(startIndex - 1, 0); | ||||
|             } | ||||
|         } else if (itemsWereRemoved) { | ||||
|             notifyItemRangeRemoved(startIndex, versions.size()); | ||||
|         } | ||||
| @ -575,6 +579,16 @@ public class AppDetailsRecyclerViewAdapter | ||||
|             headerView = (TextView) view.findViewById(R.id.information); | ||||
|             contentView = (LinearLayout) view.findViewById(R.id.ll_content); | ||||
|         } | ||||
| 
 | ||||
|         protected abstract @DrawableRes int getIcon(); | ||||
| 
 | ||||
|         /** | ||||
|          * Depending on whether we are expanded or not, update the icon which indicates whether the | ||||
|          * user can expand/collapse this item. | ||||
|          */ | ||||
|         protected void updateExpandableItem(boolean isExpanded) { | ||||
|             TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, getIcon(), 0, isExpanded ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private class VersionsViewHolder extends ExpandableLinearLayoutViewHolder { | ||||
| @ -588,10 +602,15 @@ public class AppDetailsRecyclerViewAdapter | ||||
|                 @Override | ||||
|                 public void onClick(View v) { | ||||
|                     setShowVersions(!showVersions); | ||||
|                     updateExpandableItem(showVersions); | ||||
|                 } | ||||
|             }); | ||||
|             headerView.setText(R.string.versions); | ||||
|             TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_access_time_24dp_grey600, 0, showVersions ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0); | ||||
|             updateExpandableItem(showVersions); | ||||
|         } | ||||
| 
 | ||||
|         protected @DrawableRes int getIcon() { | ||||
|             return R.drawable.ic_access_time_24dp_grey600; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -607,16 +626,23 @@ public class AppDetailsRecyclerViewAdapter | ||||
|                 public void onClick(View v) { | ||||
|                     boolean shouldBeVisible = contentView.getVisibility() != View.VISIBLE; | ||||
|                     contentView.setVisibility(shouldBeVisible ? View.VISIBLE : View.GONE); | ||||
|                     TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_lock_24dp_grey600, 0, shouldBeVisible ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0); | ||||
|                     updateExpandableItem(shouldBeVisible); | ||||
|                     if (shouldBeVisible && recyclerView != null) { | ||||
|                         ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(items.indexOf(VIEWTYPE_PERMISSIONS), 0); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|             headerView.setText(R.string.permissions); | ||||
|             TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_lock_24dp_grey600, 0, R.drawable.ic_expand_more_grey600, 0); | ||||
|             updateExpandableItem(false); | ||||
|             contentView.removeAllViews(); | ||||
|             AppDiff appDiff = new AppDiff(context.getPackageManager(), versions.get(0)); | ||||
|             AppSecurityPermissions perms = new AppSecurityPermissions(context, appDiff.pkgInfo); | ||||
|             contentView.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_ALL)); | ||||
|         } | ||||
| 
 | ||||
|         protected @DrawableRes int getIcon() { | ||||
|             return R.drawable.ic_lock_24dp_grey600; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private class LinksViewHolder extends ExpandableLinearLayoutViewHolder { | ||||
| @ -631,11 +657,14 @@ public class AppDetailsRecyclerViewAdapter | ||||
|                 public void onClick(View v) { | ||||
|                     boolean shouldBeVisible = contentView.getVisibility() != View.VISIBLE; | ||||
|                     contentView.setVisibility(shouldBeVisible ? View.VISIBLE : View.GONE); | ||||
|                     TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_website, 0, shouldBeVisible ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0); | ||||
|                     updateExpandableItem(shouldBeVisible); | ||||
|                     if (shouldBeVisible && recyclerView != null) { | ||||
|                         ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(items.indexOf(VIEWTYPE_LINKS), 0); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|             headerView.setText(R.string.links); | ||||
|             TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_website, 0, R.drawable.ic_expand_more_grey600, 0); | ||||
|             updateExpandableItem(false); | ||||
|             contentView.removeAllViews(); | ||||
| 
 | ||||
|             // Source button | ||||
| @ -665,6 +694,10 @@ public class AppDetailsRecyclerViewAdapter | ||||
|                 addLinkItemView(contentView, R.string.menu_email, R.drawable.ic_email, emailUrl); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         protected @DrawableRes int getIcon() { | ||||
|             return R.drawable.ic_website; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private class VersionViewHolder extends RecyclerView.ViewHolder { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Mikael
						Mikael