Allow to navigate through viewpager
This commit is contained in:
parent
3bf596f1cf
commit
efe9a88209
|
@ -3,7 +3,7 @@
|
||||||
<color name="colorPrimary">#005e8b</color>
|
<color name="colorPrimary">#005e8b</color>
|
||||||
<color name="colorPrimaryDark">#3d2b43</color>
|
<color name="colorPrimaryDark">#3d2b43</color>
|
||||||
<color name="colorAccent">#007bff</color>
|
<color name="colorAccent">#007bff</color>
|
||||||
|
<color name="percent">#77005e8b</color>
|
||||||
<color name="colorGreen">#6fc384</color>
|
<color name="colorGreen">#6fc384</color>
|
||||||
<color name="colorLightRed">#e46772</color>
|
<color name="colorLightRed">#e46772</color>
|
||||||
<color name="colorLightYellow">#ffdb66</color>
|
<color name="colorLightYellow">#ffdb66</color>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<color name="colorPrimary">#684971</color>
|
<color name="colorPrimary">#684971</color>
|
||||||
<color name="colorPrimaryDark">#3d2b43</color>
|
<color name="colorPrimaryDark">#3d2b43</color>
|
||||||
<color name="colorAccent">#3d2b43</color>
|
<color name="colorAccent">#3d2b43</color>
|
||||||
|
<color name="percent">#77684971</color>
|
||||||
|
|
||||||
<color name="colorGreen">#6fc384</color>
|
<color name="colorGreen">#6fc384</color>
|
||||||
<color name="colorLightRed">#e46772</color>
|
<color name="colorLightRed">#e46772</color>
|
||||||
|
|
|
@ -51,8 +51,6 @@ public class CheckAppActivity extends AppCompatActivity implements NetworkListen
|
||||||
|
|
||||||
private static final Pattern fdroidRegex = Pattern.compile("https?://f-droid\\.org/([\\w-]+/)?packages/([\\w.-]+)");
|
private static final Pattern fdroidRegex = Pattern.compile("https?://f-droid\\.org/([\\w-]+/)?packages/([\\w.-]+)");
|
||||||
private static final Pattern googleRegex = Pattern.compile("https?://play\\.google\\.com/store/apps/details\\?id=([\\w.-]+)");
|
private static final Pattern googleRegex = Pattern.compile("https?://play\\.google\\.com/store/apps/details\\?id=([\\w.-]+)");
|
||||||
private String app_id;
|
|
||||||
|
|
||||||
ArrayList<Updatable> fragments;
|
ArrayList<Updatable> fragments;
|
||||||
AppCheckActivityBinding binding;
|
AppCheckActivityBinding binding;
|
||||||
TrackerListAdapter.OnTrackerClickListener onTrackerClickListener = id -> {
|
TrackerListAdapter.OnTrackerClickListener onTrackerClickListener = id -> {
|
||||||
|
@ -65,6 +63,7 @@ public class CheckAppActivity extends AppCompatActivity implements NetworkListen
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
};
|
};
|
||||||
|
private String app_id;
|
||||||
private TrackerListAdapter.OnTrackerClickListener trackerClickListener;
|
private TrackerListAdapter.OnTrackerClickListener trackerClickListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -72,8 +72,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private Menu toolbarMenu;
|
private Menu toolbarMenu;
|
||||||
private String packageName;
|
private String packageName;
|
||||||
private MainBinding binding;
|
private MainBinding binding;
|
||||||
private ApplicationListAdapter.OnAppClickListener onAppClickListener;
|
|
||||||
private String previousQuery = "";
|
|
||||||
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||||
= item -> {
|
= item -> {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
|
@ -84,6 +82,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
private ApplicationListAdapter.OnAppClickListener onAppClickListener;
|
||||||
|
private TrackerListAdapter.OnTrackerClickListener onTrackerClickListener;
|
||||||
|
private String previousQuery = "";
|
||||||
private HomeFragment home;
|
private HomeFragment home;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,13 +143,19 @@ public class MainActivity extends AppCompatActivity {
|
||||||
binding.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
binding.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
MenuItem item = binding.navView.getMenu().getItem(position);
|
MenuItem item = binding.navView.getMenu().getItem(position);
|
||||||
binding.navView.setSelectedItemId(item.getItemId());
|
binding.navView.setSelectedItemId(item.getItemId());
|
||||||
|
if (binding.fragmentContainer.getVisibility() == View.VISIBLE) {
|
||||||
|
while (fragments.size() > 0) {
|
||||||
|
getSupportFragmentManager().popBackStack();
|
||||||
|
fragments.remove(fragments.size() - 1);
|
||||||
|
}
|
||||||
|
binding.fragmentContainer.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,18 +164,20 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TrackerListAdapter.OnTrackerClickListener onTrackerClickListener = id -> {
|
onTrackerClickListener = id -> {
|
||||||
TrackerFragment tracker = TrackerFragment.newInstance(id);
|
TrackerFragment tracker = TrackerFragment.newInstance(id);
|
||||||
tracker.setOnAppClickListener(onAppClickListener);
|
tracker.setOnAppClickListener(onAppClickListener);
|
||||||
fragments.add(tracker);
|
fragments.add(tracker);
|
||||||
FragmentManager manager = getSupportFragmentManager();
|
FragmentManager manager = getSupportFragmentManager();
|
||||||
FragmentTransaction transaction = manager.beginTransaction();
|
FragmentTransaction transaction = manager.beginTransaction();
|
||||||
|
binding.fragmentContainer.setVisibility(View.VISIBLE);
|
||||||
transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_right, R.anim.slide_in_left, R.anim.slide_out_left)
|
transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_right, R.anim.slide_in_left, R.anim.slide_out_left)
|
||||||
.replace(R.id.fragment_container, tracker)
|
.replace(R.id.fragment_container, tracker)
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
onAppClickListener = (vm) -> {
|
onAppClickListener = (vm) -> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -256,8 +265,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MenuItem settingsMenuItem = menu.findItem(R.id.action_settings);
|
MenuItem settingsMenuItem = menu.findItem(R.id.action_settings);
|
||||||
|
if (fragments.size() > 0) {
|
||||||
Updatable fragment = fragments.get(fragments.size() - 1);
|
Updatable fragment = fragments.get(fragments.size() - 1);
|
||||||
settingsMenuItem.setVisible(fragment instanceof ReportFragment);
|
settingsMenuItem.setVisible(fragment instanceof ReportFragment);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,9 +342,12 @@ public class MainActivity extends AppCompatActivity {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(final int position) {
|
public Fragment getItem(final int position) {
|
||||||
|
//noinspection SwitchStatementWithTooFewBranches
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 1:
|
case 1:
|
||||||
return new MyTrackersFragment();
|
MyTrackersFragment myTrackersFragment = new MyTrackersFragment();
|
||||||
|
myTrackersFragment.setOnTrackerClickListener(onTrackerClickListener);
|
||||||
|
return myTrackersFragment;
|
||||||
default:
|
default:
|
||||||
return home;
|
return home;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@ import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -16,14 +18,8 @@ import java.security.cert.CertificateFactory;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -289,15 +285,16 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <K, V> Map<K, V> sortByValue(Map<K, V> map) {
|
/**
|
||||||
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
|
* Converts dp to pixel
|
||||||
Collections.sort(list, (Comparator<Object>) (o1, o2) -> ((Comparable<V>) ((Map.Entry<K, V>) (o1)).getValue()).compareTo(((Map.Entry<K, V>) (o2)).getValue()));
|
*
|
||||||
|
* @param dp float - the value in dp to convert
|
||||||
Map<K, V> result = new LinkedHashMap<>();
|
* @param context Context
|
||||||
for (Map.Entry<K, V> entry : list) {
|
* @return float - the converted value in pixel
|
||||||
result.put(entry.getKey(), entry.getValue());
|
*/
|
||||||
}
|
public static float convertDpToPixel(float dp, Context context) {
|
||||||
|
Resources resources = context.getResources();
|
||||||
return result;
|
DisplayMetrics metrics = resources.getDisplayMetrics();
|
||||||
|
return dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.eu.exodus_privacy.exodusprivacy.adapters;
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
@ -26,9 +27,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.R;
|
import org.eu.exodus_privacy.exodusprivacy.R;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.databinding.MyTrackerItemBinding;
|
import org.eu.exodus_privacy.exodusprivacy.databinding.MyTrackerItemBinding;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.objects.MyTracker;
|
import org.eu.exodus_privacy.exodusprivacy.objects.MyTracker;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.objects.Tracker;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,13 +35,13 @@ public class MyTrackersListAdapter extends RecyclerView.Adapter<MyTrackersListAd
|
||||||
|
|
||||||
private final TrackerClickListener trackerClickListener;
|
private final TrackerClickListener trackerClickListener;
|
||||||
private final List<MyTracker> myTrackers;
|
private final List<MyTracker> myTrackers;
|
||||||
private List<Tracker> trackersList;
|
private final int max;
|
||||||
|
private int viewWidth = 0;
|
||||||
|
|
||||||
public MyTrackersListAdapter(List<MyTracker> mTrackers, TrackerClickListener listener) {
|
public MyTrackersListAdapter(List<MyTracker> mTrackers, TrackerClickListener listener, int maxValue) {
|
||||||
myTrackers = mTrackers;
|
myTrackers = mTrackers;
|
||||||
setTrackers(mTrackers);
|
|
||||||
trackerClickListener = listener;
|
trackerClickListener = listener;
|
||||||
|
max = maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -54,35 +53,33 @@ public class MyTrackersListAdapter extends RecyclerView.Adapter<MyTrackersListAd
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull MyTrackersListAdapter.TrackerListViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull MyTrackersListAdapter.TrackerListViewHolder holder, int position) {
|
||||||
Tracker tracker = trackersList.get(position);
|
MyTracker myTracker = myTrackers.get(position);
|
||||||
if (tracker != null) {
|
if (myTrackers != null) {
|
||||||
holder.viewDataBinding.trackerName.setText(tracker.name);
|
holder.viewDataBinding.trackerName.setText(myTracker.tracker.name);
|
||||||
holder.viewDataBinding.trackerCount.setText(String.valueOf(countOccurences(tracker.codeSignature)));
|
holder.viewDataBinding.trackerCount.setText(String.valueOf(myTracker.number));
|
||||||
holder.viewDataBinding.getRoot().setOnClickListener(v -> trackerClickListener.onTrackerClick(tracker.id));
|
holder.viewDataBinding.getRoot().setOnClickListener(v -> {
|
||||||
|
trackerClickListener.onTrackerClick(myTracker.tracker.id);
|
||||||
|
});
|
||||||
|
float percent = (float) myTracker.number / max;
|
||||||
|
holder.viewDataBinding.percent.getLayoutParams().width = (int) (viewWidth * percent);
|
||||||
|
holder.viewDataBinding.percentVal.setText(String.format("%s %%", myTracker.number * 100 / myTrackers.size()));
|
||||||
|
holder.viewDataBinding.percent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
holder.viewDataBinding.percent.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
if (viewWidth == 0) {
|
||||||
|
viewWidth = holder.viewDataBinding.percent.getWidth();
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} else
|
} else
|
||||||
holder.viewDataBinding.trackerName.setText(R.string.no_trackers);
|
holder.viewDataBinding.trackerName.setText(R.string.no_trackers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return trackersList.size();
|
return myTrackers.size();
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrackers(List<MyTracker> myTrackers) {
|
|
||||||
trackersList = new ArrayList<>();
|
|
||||||
if (myTrackers != null) {
|
|
||||||
for (MyTracker myTracker : myTrackers) {
|
|
||||||
trackersList.add(myTracker.tracker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int countOccurences(String signature) {
|
|
||||||
if (myTrackers == null) return 0;
|
|
||||||
for (MyTracker myTracker : myTrackers) {
|
|
||||||
if (myTracker.signature.compareTo(signature) == 0) return myTracker.number;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface TrackerClickListener {
|
public interface TrackerClickListener {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.databinding.DataBindingUtil;
|
import androidx.databinding.DataBindingUtil;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import org.eu.exodus_privacy.exodusprivacy.R;
|
import org.eu.exodus_privacy.exodusprivacy.R;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.adapters.ApplicationListAdapter;
|
import org.eu.exodus_privacy.exodusprivacy.adapters.ApplicationListAdapter;
|
||||||
|
@ -22,7 +21,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class AppListFragment extends Fragment {
|
public class AppListFragment extends Fragment {
|
||||||
|
|
||||||
private static int firstVisiblePosition = 0;
|
|
||||||
private ApplistBinding applistBinding;
|
private ApplistBinding applistBinding;
|
||||||
private List<ApplicationViewModel> applications;
|
private List<ApplicationViewModel> applications;
|
||||||
private ApplicationListAdapter adapter;
|
private ApplicationListAdapter adapter;
|
||||||
|
@ -43,18 +42,6 @@ public class AppListFragment extends Fragment {
|
||||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
|
||||||
applistBinding.appList.setLayoutManager(linearLayoutManager);
|
applistBinding.appList.setLayoutManager(linearLayoutManager);
|
||||||
applistBinding.appList.setVerticalScrollBarEnabled(scrollbarEnabled);
|
applistBinding.appList.setVerticalScrollBarEnabled(scrollbarEnabled);
|
||||||
applistBinding.appList.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
|
||||||
super.onScrollStateChanged(recyclerView, newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
|
||||||
firstVisiblePosition = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
adapter = new ApplicationListAdapter(onAppClickListener);
|
adapter = new ApplicationListAdapter(onAppClickListener);
|
||||||
adapter.displayAppList(applications);
|
adapter.displayAppList(applications);
|
||||||
adapter.filter(filterType, filterObject);
|
adapter.filter(filterType, filterObject);
|
||||||
|
@ -105,9 +92,6 @@ public class AppListFragment extends Fragment {
|
||||||
return adapter.getDisplayedApps();
|
return adapter.getDisplayedApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollTo() {
|
|
||||||
applistBinding.appList.scrollToPosition(firstVisiblePosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
NAME,
|
NAME,
|
||||||
|
|
|
@ -114,7 +114,6 @@ public class HomeFragment extends Fragment implements ComputeAppList.Listener, U
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
appListFragment.scrollTo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
import org.eu.exodus_privacy.exodusprivacy.R;
|
import org.eu.exodus_privacy.exodusprivacy.R;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.adapters.MyTrackersListAdapter;
|
import org.eu.exodus_privacy.exodusprivacy.adapters.MyTrackersListAdapter;
|
||||||
|
import org.eu.exodus_privacy.exodusprivacy.adapters.TrackerListAdapter;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.databinding.MyTrackersBinding;
|
import org.eu.exodus_privacy.exodusprivacy.databinding.MyTrackersBinding;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.manager.DatabaseManager;
|
import org.eu.exodus_privacy.exodusprivacy.manager.DatabaseManager;
|
||||||
import org.eu.exodus_privacy.exodusprivacy.objects.MyTracker;
|
import org.eu.exodus_privacy.exodusprivacy.objects.MyTracker;
|
||||||
|
@ -50,6 +51,8 @@ public class MyTrackersFragment extends Fragment implements MyTrackersListAdapte
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private MyTrackersBinding trackerBinding;
|
private MyTrackersBinding trackerBinding;
|
||||||
|
private TrackerListAdapter.OnTrackerClickListener onTrackerClickListener;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -75,6 +78,7 @@ public class MyTrackersFragment extends Fragment implements MyTrackersListAdapte
|
||||||
List<PackageInfo> packageInstalled = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
|
List<PackageInfo> packageInstalled = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
|
||||||
List<MyTracker> myTrackers = new ArrayList<>();
|
List<MyTracker> myTrackers = new ArrayList<>();
|
||||||
List<String> added = new ArrayList<>();
|
List<String> added = new ArrayList<>();
|
||||||
|
int maxValue = 0;
|
||||||
for (PackageInfo pkgInfo : packageInstalled) {
|
for (PackageInfo pkgInfo : packageInstalled) {
|
||||||
Report report;
|
Report report;
|
||||||
if (pkgInfo.versionName != null)
|
if (pkgInfo.versionName != null)
|
||||||
|
@ -102,10 +106,15 @@ public class MyTrackersFragment extends Fragment implements MyTrackersListAdapte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (MyTracker myTracker : myTrackers) {
|
||||||
|
if (myTracker.number > maxValue)
|
||||||
|
maxValue = myTracker.number;
|
||||||
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
int finalMaxValue = maxValue;
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
Collections.sort(myTrackers, (obj1, obj2) -> Integer.compare(obj2.number, obj1.number));
|
Collections.sort(myTrackers, (obj1, obj2) -> Integer.compare(obj2.number, obj1.number));
|
||||||
MyTrackersListAdapter myTrackersListAdapter = new MyTrackersListAdapter(myTrackers, MyTrackersFragment.this);
|
MyTrackersListAdapter myTrackersListAdapter = new MyTrackersListAdapter(myTrackers, MyTrackersFragment.this, finalMaxValue);
|
||||||
trackerBinding.trackers.setAdapter(myTrackersListAdapter);
|
trackerBinding.trackers.setAdapter(myTrackersListAdapter);
|
||||||
trackerBinding.trackers.setLayoutManager(new LinearLayoutManager(context));
|
trackerBinding.trackers.setLayoutManager(new LinearLayoutManager(context));
|
||||||
trackerBinding.trackers.setVisibility(View.VISIBLE);
|
trackerBinding.trackers.setVisibility(View.VISIBLE);
|
||||||
|
@ -132,9 +141,12 @@ public class MyTrackersFragment extends Fragment implements MyTrackersListAdapte
|
||||||
menu.findItem(R.id.action_filter_options).setVisible(false);
|
menu.findItem(R.id.action_filter_options).setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnTrackerClickListener(TrackerListAdapter.OnTrackerClickListener listener) {
|
||||||
|
onTrackerClickListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrackerClick(long trackerId) {
|
public void onTrackerClick(long trackerId) {
|
||||||
|
onTrackerClickListener.onTrackerClick(trackerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,6 @@ public class NetworkManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void getApplications(Message mes) {
|
private void getApplications(Message mes) {
|
||||||
mes.listener.onProgress(R.string.get_reports_connection, 0, 0);
|
mes.listener.onProgress(R.string.get_reports_connection, 0, 0);
|
||||||
URL url;
|
URL url;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="64dp"
|
||||||
android:height="24dp"
|
android:height="64dp"
|
||||||
android:tint="?attr/colorControlNormal"
|
android:tint="?attr/colorControlNormal"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24">
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/percent" />
|
||||||
|
<stroke
|
||||||
|
android:width="2dp"
|
||||||
|
android:color="@color/colorPrimary" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<padding
|
||||||
|
android:bottom="0dp"
|
||||||
|
android:left="0dp"
|
||||||
|
android:right="0dp"
|
||||||
|
android:top="0dp" />
|
||||||
|
</shape>
|
|
@ -1,25 +1,38 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<data />
|
<data />
|
||||||
|
<LinearLayout
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/percent"
|
android:id="@+id/percent"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="10dp"
|
android:layout_height="25dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:background="@color/colorPrimary"
|
android:background="@drawable/percent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/details"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/percent_val"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/percent"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/percent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/percent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tracker_name"
|
android:id="@+id/tracker_name"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -27,29 +40,30 @@
|
||||||
android:textColor="@color/textColorDark"
|
android:textColor="@color/textColorDark"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/percent"
|
app:layout_constraintEnd_toStartOf="@+id/tracker_count"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/percent" />
|
app:layout_constraintTop_toBottomOf="@+id/percent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tracker_count"
|
android:id="@+id/tracker_count"
|
||||||
android:layout_width="50dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/percent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/tracker_name"
|
app:layout_constraintStart_toEndOf="@+id/tracker_name"
|
||||||
app:layout_constraintTop_toTopOf="@id/tracker_name" />
|
app:layout_constraintTop_toTopOf="@id/tracker_name" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/details"
|
android:id="@+id/details"
|
||||||
android:layout_width="24dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="40dp"
|
||||||
android:layout_margin="10dp"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/ic_baseline_navigate_next_24"
|
android:src="@drawable/ic_baseline_navigate_next_24"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:contentDescription="@string/list_of_apps" />
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
</LinearLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</layout>
|
</layout>
|
|
@ -64,6 +64,7 @@
|
||||||
<string name="app_not_analyzed_title">This app has not been analyzed!</string>
|
<string name="app_not_analyzed_title">This app has not been analyzed!</string>
|
||||||
<string name="title_apps">My apps</string>
|
<string name="title_apps">My apps</string>
|
||||||
<string name="title_trackers">Trackers</string>
|
<string name="title_trackers">Trackers</string>
|
||||||
|
<string name="list_of_apps">See the list of apps</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue