Add storage permission check

master^2
fengyuecanzhu 2 years ago
parent 7bd5e1d0c4
commit ab67ab6f10
No known key found for this signature in database
GPG Key ID: 04B78AD06A9D6E6C
  1. 19
      app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java

@ -37,6 +37,7 @@ import androidx.activity.result.contract.ActivityResultContract;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.hjq.permissions.OnPermissionCallback;
import com.kongzue.dialogx.dialogs.BottomMenu; import com.kongzue.dialogx.dialogs.BottomMenu;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -45,6 +46,7 @@ import java.io.File;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import io.reactivex.Single; import io.reactivex.Single;
import io.reactivex.SingleOnSubscribe; import io.reactivex.SingleOnSubscribe;
@ -84,6 +86,7 @@ import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils; import xyz.fycz.myreader.util.utils.AdUtils;
import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.RxUtils; import xyz.fycz.myreader.util.utils.RxUtils;
import xyz.fycz.myreader.util.utils.StoragePermissionUtils;
/** /**
* @author fengyue * @author fengyue
@ -206,13 +209,15 @@ public class MineFragment extends BaseFragment {
protected void initClick() { protected void initClick() {
super.initClick(); super.initClick();
binding.mineRlUser.setOnClickListener(v -> { binding.mineRlUser.setOnClickListener(v -> {
if (isLogin) { StoragePermissionUtils.request(this, (permissions, all) -> {
Intent intent = new Intent(getActivity(), UserInfoActivity.class); if (isLogin) {
startActivityForResult(intent, APPCONST.REQUEST_LOGOUT); Intent intent = new Intent(getActivity(), UserInfoActivity.class);
} else { startActivityForResult(intent, APPCONST.REQUEST_LOGOUT);
Intent intent = new Intent(getActivity(), LoginActivity.class); } else {
getActivity().startActivityForResult(intent, APPCONST.REQUEST_LOGIN); Intent intent = new Intent(getActivity(), LoginActivity.class);
} getActivity().startActivityForResult(intent, APPCONST.REQUEST_LOGIN);
}
});
}); });
binding.mineRlSyn.setOnClickListener(v -> { binding.mineRlSyn.setOnClickListener(v -> {
if (!isLogin) { if (!isLogin) {

Loading…
Cancel
Save