This commit is contained in:
Thomas 2020-12-07 10:48:48 +01:00
parent 18c19ace49
commit 91f5dea591
5 changed files with 29 additions and 6 deletions

View File

@ -60,6 +60,7 @@ public class MainActivity extends AppCompatActivity {
private String packageName; private String packageName;
private MainBinding binding; private MainBinding binding;
private ApplicationListAdapter.OnAppClickListener onAppClickListener; private ApplicationListAdapter.OnAppClickListener onAppClickListener;
private int appPosition;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -70,7 +71,7 @@ public class MainActivity extends AppCompatActivity {
getSupportActionBar().setTitle(R.string.app_title); getSupportActionBar().setTitle(R.string.app_title);
} }
fragments = new ArrayList<>(); fragments = new ArrayList<>();
appPosition = 0;
NetworkListener networkListener = new NetworkListener() { NetworkListener networkListener = new NetworkListener() {
@Override @Override
public void onSuccess() { public void onSuccess() {
@ -119,11 +120,11 @@ public class MainActivity extends AppCompatActivity {
.commit(); .commit();
}; };
onAppClickListener = vm -> { onAppClickListener = (vm, position) -> {
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
PackageInfo packageInfo = pm.getPackageInfo(vm.packageName, PackageManager.GET_PERMISSIONS); PackageInfo packageInfo = pm.getPackageInfo(vm.packageName, PackageManager.GET_PERMISSIONS);
appPosition = position;
ReportFragment report = ReportFragment.newInstance(pm, vm, packageInfo, onTrackerClickListener); ReportFragment report = ReportFragment.newInstance(pm, vm, packageInfo, onTrackerClickListener);
fragments.add(report); fragments.add(report);
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();
@ -166,6 +167,10 @@ public class MainActivity extends AppCompatActivity {
else { else {
getSupportFragmentManager().popBackStack(); getSupportFragmentManager().popBackStack();
fragments.remove(fragments.size() - 1); fragments.remove(fragments.size() - 1);
Updatable updatable = fragments.get(fragments.size() - 1);
if (updatable instanceof HomeFragment) {
((HomeFragment) updatable).scrollTo(appPosition);
}
} }
} }

View File

@ -18,6 +18,7 @@ import java.util.regex.Pattern;
public class Utils { public class Utils {
public static final String TAG = "Exodus_privacy";
@SuppressLint("PackageManagerGetSignatures") @SuppressLint("PackageManagerGetSignatures")
public static String getCertificateSHA1Fingerprint(PackageManager pm, String packageName) { public static String getCertificateSHA1Fingerprint(PackageManager pm, String packageName) {
int flags = PackageManager.GET_SIGNATURES; int flags = PackageManager.GET_SIGNATURES;

View File

@ -90,7 +90,7 @@ public class ApplicationListAdapter extends RecyclerView.Adapter<RecyclerView.Vi
holder.itemView.setOnClickListener(new View.OnClickListener() { holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
onAppClickListener.onAppClick(vm); onAppClickListener.onAppClick(vm, position);
} }
}); });
} else //noinspection RedundantSuppression } else //noinspection RedundantSuppression
@ -151,7 +151,7 @@ public class ApplicationListAdapter extends RecyclerView.Adapter<RecyclerView.Vi
} }
public interface OnAppClickListener { public interface OnAppClickListener {
void onAppClick(ApplicationViewModel vm); void onAppClick(ApplicationViewModel vm, int position);
} }
static class ApplicationEmptyViewHolder extends RecyclerView.ViewHolder { static class ApplicationEmptyViewHolder extends RecyclerView.ViewHolder {

View File

@ -93,6 +93,10 @@ public class AppListFragment extends Fragment {
TRACKER TRACKER
} }
public void scrollTo(int position) {
applistBinding.appList.scrollToPosition(position);
}
public enum Order { public enum Order {
NAME_ASC, NAME_ASC,
NAME_DSC, NAME_DSC,

View File

@ -44,7 +44,7 @@ public class HomeFragment extends Fragment implements ComputeAppListTask.Listene
private int lastResource = 0; private int lastResource = 0;
private int lastProgress = 0; private int lastProgress = 0;
private int lastMaxProgress = 0; private int lastMaxProgress = 0;
private int scrollTo = 0;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (applications == null) if (applications == null)
@ -94,6 +94,19 @@ public class HomeFragment extends Fragment implements ComputeAppListTask.Listene
} }
} }
@Override
public void onResume() {
super.onResume();
if (scrollTo > 0) {
appListFragment.scrollTo(scrollTo);
scrollTo = 0;
}
}
public void scrollTo(int position) {
scrollTo = position;
}
@Override @Override
public void onUpdateComplete() { public void onUpdateComplete() {
refreshInProgress = false; refreshInProgress = false;