mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
More work on "downloads" fragment
Need to clean up animations yet, add "last update" label, etc.
This commit is contained in:
parent
98aa9bd3fe
commit
204e940dcb
@ -1,6 +1,8 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
@ -10,11 +12,15 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@ -36,12 +42,6 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
private ReposFragment reposFragment;
|
||||
private final List<Repo> mList;
|
||||
List<Boolean> mExpandedList;
|
||||
@BindView(R.id.update)
|
||||
ImageView updateImage;
|
||||
@BindView(R.id.installed)
|
||||
ImageView installedImage;
|
||||
@BindView(R.id.expand_layout)
|
||||
LinearLayout expandedLayout;
|
||||
private View viewMain;
|
||||
private Context context;
|
||||
private boolean mIsInstalled, mCanUpdate;
|
||||
@ -99,12 +99,6 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
mHolder.description.setText(repo.getDescription());
|
||||
String authorString = this.context.getResources().getString(R.string.author) + " " + repo.getmAuthor();
|
||||
mHolder.author.setText(authorString);
|
||||
if ((repo.getmLogUrl() != null) && (repo.getmLogUrl().equals(""))) {
|
||||
mHolder.log.setText(repo.getmLogUrl());
|
||||
Linkify.addLinks(mHolder.log, Linkify.WEB_URLS);
|
||||
} else {
|
||||
mHolder.log.setVisibility(View.GONE);
|
||||
}
|
||||
mHolder.installedStatus.setText(repo.isInstalled() ? this.context.getResources().getString(R.string.module_installed) : this.context.getResources().getString(R.string.module_not_installed));
|
||||
if (mExpandedList.get(mPosition)) {
|
||||
mHolder.expandLayout.setVisibility(View.VISIBLE);
|
||||
@ -115,13 +109,15 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
mHolder.installedStatus.setTextColor(Color.parseColor("#14AD00"));
|
||||
mHolder.updateStatus.setText(repo.canUpdate() ? this.context.getResources().getString(R.string.module_update_available) : this.context.getResources().getString(R.string.module_up_to_date));
|
||||
}
|
||||
|
||||
Log.d("Magisk", "ReposAdapter: Setting up info " + repo.getId() + " and " + repo.getDescription() + " and " + repo.getmVersion());
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
updateImage.setImageResource(R.drawable.ic_system_update_alt_black);
|
||||
mHolder.updateImage.setImageResource(R.drawable.ic_file_download_black);
|
||||
mCanUpdate = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
||||
|
||||
View.OnClickListener oCl = view -> {
|
||||
if (view == updateImage) {
|
||||
Log.d("Magisk","Onlick captured, view is " + view.getId());
|
||||
if (view.getId() == mHolder.updateImage.getId()) {
|
||||
if (!mIsInstalled | mCanUpdate) {
|
||||
|
||||
Utils.DownloadReceiver receiver = new Utils.DownloadReceiver() {
|
||||
@ -136,13 +132,12 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
} else {
|
||||
Toast.makeText(context, repo.getId() + " is already installed.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else if (view == mHolder.log) {
|
||||
new WebWindow("Changelog", repo.getmLogUrl(), this.context);
|
||||
} else if (view.getId() == mHolder.changeLog.getId()) {
|
||||
new WebWindow("Changelog",repo.getmLogUrl(),this.context);
|
||||
}
|
||||
};
|
||||
|
||||
updateImage.setOnClickListener(oCl);
|
||||
mHolder.log.setOnClickListener(oCl);
|
||||
mHolder.changeLog.setOnClickListener(oCl);
|
||||
mHolder.updateImage.setOnClickListener(oCl);
|
||||
if (prefs.contains("repo-isInstalled_" + repo.getId())) {
|
||||
mIsInstalled = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
|
||||
|
||||
@ -151,9 +146,6 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
}
|
||||
}
|
||||
|
||||
// protected List<Repo> mListRepos() {
|
||||
// return ReposFragment.listModulesDownload;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
@ -170,15 +162,20 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
TextView description;
|
||||
@BindView(R.id.author)
|
||||
TextView author;
|
||||
@BindView(R.id.log)
|
||||
TextView log;
|
||||
@BindView(R.id.installedStatus)
|
||||
TextView installedStatus;
|
||||
@BindView(R.id.updateStatus)
|
||||
TextView updateStatus;
|
||||
@BindView(R.id.expand_layout)
|
||||
LinearLayout expandLayout;
|
||||
@BindView(R.id.update)
|
||||
ImageView updateImage;
|
||||
@BindView(R.id.installed)
|
||||
ImageView installedImage;
|
||||
@BindView(R.id.changeLog)
|
||||
ImageView changeLog;
|
||||
private ValueAnimator mAnimator;
|
||||
private AnimatorSet animSetUpRight, animSetDownLeft;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -197,6 +194,15 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
expandLayout.setVisibility(View.GONE);
|
||||
expandLayout.measure(widthSpec, heightSpec);
|
||||
mAnimator = slideAnimator(0, expandLayout.getMeasuredHeight());
|
||||
ObjectAnimator animX2 = ObjectAnimator.ofFloat(mHolder.updateImage, "x", -45);
|
||||
ObjectAnimator animY2 = ObjectAnimator.ofFloat(mHolder.updateImage, "y", -134);
|
||||
animSetDownLeft = new AnimatorSet();
|
||||
animSetDownLeft.playTogether(animX2, animY2);
|
||||
ObjectAnimator animX = ObjectAnimator.ofFloat(mHolder.updateImage, "x", 45);
|
||||
ObjectAnimator animY = ObjectAnimator.ofFloat(mHolder.updateImage, "y", 134);
|
||||
animSetUpRight = new AnimatorSet();
|
||||
animSetUpRight.playTogether(animX, animY);
|
||||
animSetUpRight.start();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -218,6 +224,8 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
private void expand(View view) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
mAnimator.start();
|
||||
animSetDownLeft.start();
|
||||
|
||||
}
|
||||
|
||||
private void collapse(View view) {
|
||||
@ -243,6 +251,8 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
||||
}
|
||||
});
|
||||
mAnimator.start();
|
||||
animSetUpRight.start();
|
||||
|
||||
}
|
||||
|
||||
private ValueAnimator slideAnimator(int start, int end) {
|
||||
|
5
app/src/main/res/drawable/ic_author.xml
Normal file
5
app/src/main/res/drawable/ic_author.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="30dp" android:viewportHeight="512.0"
|
||||
android:viewportWidth="512.0" android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M356.2,365.6C326.6,382.4 292.4,392 256,392c-36.4,0 -70.6,-9.6 -100.1,-26.4C77.5,389.5 29.4,443 11.7,512h488.5C482.6,442.9 434.6,389.5 356.2,365.6z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M256,0C158.8,0 80,78.8 80,176s78.8,176 176,176s176,-78.8 176,-176S353.2,0 256,0zM256,308c-56,0 -103.8,-34.8 -123,-84h246C359.8,273.2 312,308 256,308z"/>
|
||||
</vector>
|
4
app/src/main/res/drawable/ic_changelog.xml
Normal file
4
app/src/main/res/drawable/ic_changelog.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<vector android:height="30dp" android:viewportHeight="1024.0"
|
||||
android:viewportWidth="896.0" android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M128,768h256v64L128,832v-64zM448,384L128,384v64h320v-64zM576,576L576,448L384,640l192,192L576,704h320L896,576L576,576zM288,512L128,512v64h160v-64zM128,704h160v-64L128,640v64zM704,768h64v128c-1,18 -7,33 -19,45s-27,18 -45,19L64,960c-35,0 -64,-29 -64,-64L0,192c0,-35 29,-64 64,-64h192C256,57 313,0 384,0s128,57 128,128h192c35,0 64,29 64,64v320h-64L704,320L64,320v576h640L704,768zM128,256h512c0,-35 -29,-64 -64,-64h-64c-35,0 -64,-29 -64,-64s-29,-64 -64,-64 -64,29 -64,64 -29,64 -64,64h-64c-35,0 -64,29 -64,64z"/>
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_file_download_black.xml
Normal file
9
app/src/main/res/drawable/ic_file_download_black.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="30dp"
|
||||
android:height="30dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#000"
|
||||
android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
|
||||
</vector>
|
4
app/src/main/res/drawable/ic_support.xml
Normal file
4
app/src/main/res/drawable/ic_support.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<vector android:height="30dp" android:viewportHeight="512.0"
|
||||
android:viewportWidth="512.0" android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M256,0C114.8,0 0,114.8 0,256C0,397.2 114.8,512 256,512C397.2,512 512,397.2 512,256C512,114.8 397.2,0 256,0zM368.4,302.6c6,-14.4 9.3,-30.1 9.3,-46.6c0,-16.5 -3.3,-32.2 -9.3,-46.6l113.6,-47c12,28.9 18.7,60.5 18.7,93.6c0,33.2 -6.7,64.8 -18.7,93.6L368.4,302.6zM256,366.3c-60.8,0 -110.3,-49.5 -110.3,-110.3c0,-60.8 49.5,-110.3 110.3,-110.3c60.8,0 110.3,49.5 110.3,110.3C366.3,316.8 316.8,366.3 256,366.3zM30,349.6c-12,-28.8 -18.6,-60.4 -18.6,-93.6c0,-33.1 6.7,-64.7 18.6,-93.6l113.6,47c-6,14.3 -9.3,30.1 -9.3,46.6c0,16.5 3.3,32.2 9.3,46.6L30,349.6zM349.6,30L302.6,143.6c-14.4,-6 -30.1,-9.3 -46.6,-9.3c-16.5,0 -32.2,3.3 -46.6,9.3L162.4,30c28.9,-12 60.5,-18.7 93.6,-18.7C289.1,11.4 320.8,18 349.6,30zM162.4,482l47,-113.6c14.4,6 30.1,9.3 46.6,9.3c16.5,0 32.2,-3.3 46.6,-9.3L349.6,482c-28.8,12 -60.5,18.7 -93.6,18.7C222.9,500.6 191.2,494 162.4,482z"/>
|
||||
</vector>
|
@ -2,7 +2,6 @@
|
||||
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
@ -14,10 +13,11 @@
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
card_view:cardCornerRadius="2dp"
|
||||
card_view:cardElevation="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -37,8 +37,8 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="false"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textIsSelectable="false"/>
|
||||
@ -50,7 +50,7 @@
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@android:color/tertiary_text_dark"
|
||||
android:textIsSelectable="false"
|
||||
android:textStyle="bold|italic" />
|
||||
android:textStyle="bold|italic"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
@ -60,63 +60,94 @@
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/expand_layout"
|
||||
android:minHeight="100dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="100dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@android:color/tertiary_text_dark"
|
||||
android:textIsSelectable="false"
|
||||
android:textStyle="bold|italic" />
|
||||
<TextView
|
||||
android:id="@+id/author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@android:color/tertiary_text_dark"
|
||||
android:textIsSelectable="false"
|
||||
android:textStyle="bold|italic"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/installedStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/updateStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/changeLog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@drawable/ic_changelog"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@drawable/ic_author"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@drawable/ic_support"/>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/update"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/installed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:visibility="gone"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/log"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
<TextView
|
||||
android:id="@+id/installedStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
<TextView
|
||||
android:id="@+id/updateStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/installed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false"
|
||||
android:gravity="center"
|
||||
android:padding="5dp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/update"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false"
|
||||
android:gravity="center"
|
||||
android:padding="5dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
@ -1,67 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:id="@+id/popup_layout"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="4dip"
|
||||
android:layout_marginRight="4dip"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:singleLine="false"
|
||||
android:text="Hello"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textIsSelectable="false"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@android:color/tertiary_text_dark"
|
||||
android:textIsSelectable="false"
|
||||
android:textStyle="bold|italic" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/log"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
<TextView
|
||||
android:id="@+id/installedStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
<TextView
|
||||
android:id="@+id/updateStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="false"/>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/downloads"
|
||||
android:icon="@drawable/ic_extension"
|
||||
android:icon="@drawable/ic_file_download_black"
|
||||
android:title="@string/downloads"/>
|
||||
|
||||
<item
|
||||
|
Loading…
Reference in New Issue
Block a user