2018-08-30 03:57:48 -04:00
|
|
|
package com.topjohnwu.magisk.fragments;
|
2017-01-26 01:13:23 +08:00
|
|
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2018-12-13 04:35:50 -05:00
|
|
|
import com.topjohnwu.core.container.Policy;
|
2018-08-30 03:57:48 -04:00
|
|
|
import com.topjohnwu.magisk.R;
|
2017-01-26 01:13:23 +08:00
|
|
|
import com.topjohnwu.magisk.adapters.PolicyAdapter;
|
2018-08-01 17:57:11 +08:00
|
|
|
import com.topjohnwu.magisk.components.BaseFragment;
|
2017-01-26 01:13:23 +08:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2018-09-10 02:27:45 -04:00
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
2018-10-16 21:00:01 -04:00
|
|
|
import butterknife.BindView;
|
2017-01-26 01:13:23 +08:00
|
|
|
|
2018-08-01 17:57:11 +08:00
|
|
|
public class SuperuserFragment extends BaseFragment {
|
2017-01-26 01:13:23 +08:00
|
|
|
|
2018-10-16 21:00:01 -04:00
|
|
|
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
|
|
|
@BindView(R.id.empty_rv) TextView emptyRv;
|
2018-09-14 23:00:39 -04:00
|
|
|
|
2018-07-28 14:11:24 +02:00
|
|
|
private PackageManager pm;
|
2017-01-26 01:13:23 +08:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
View view = inflater.inflate(R.layout.fragment_superuser, container, false);
|
2018-10-16 21:00:01 -04:00
|
|
|
unbinder = new SuperuserFragment_ViewBinding(this, view);
|
2017-01-26 01:13:23 +08:00
|
|
|
|
2018-10-17 19:44:48 -04:00
|
|
|
pm = requireActivity().getPackageManager();
|
2017-01-26 01:13:23 +08:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStart() {
|
|
|
|
super.onStart();
|
2018-08-01 14:30:59 +08:00
|
|
|
requireActivity().setTitle(getString(R.string.superuser));
|
2017-01-26 01:13:23 +08:00
|
|
|
}
|
|
|
|
|
2018-07-28 14:11:24 +02:00
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
displayPolicyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void displayPolicyList() {
|
2018-12-13 04:35:50 -05:00
|
|
|
List<Policy> policyList = app.mDB.getPolicyList();
|
2018-07-28 14:11:24 +02:00
|
|
|
|
|
|
|
if (policyList.size() == 0) {
|
|
|
|
emptyRv.setVisibility(View.VISIBLE);
|
|
|
|
recyclerView.setVisibility(View.GONE);
|
|
|
|
} else {
|
2018-12-13 04:35:50 -05:00
|
|
|
recyclerView.setAdapter(new PolicyAdapter(policyList, app.mDB, pm));
|
2018-07-28 14:11:24 +02:00
|
|
|
emptyRv.setVisibility(View.GONE);
|
|
|
|
recyclerView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 01:13:23 +08:00
|
|
|
}
|