diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoActivity.java b/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoActivity.java deleted file mode 100644 index 8374e9ee..00000000 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoActivity.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.fastaccess.ui.modules.profile.banner; - -import android.Manifest; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.widget.Button; - -import com.fastaccess.App; -import com.fastaccess.R; -import com.fastaccess.helper.ActivityHelper; -import com.fastaccess.helper.BundleConstant; -import com.fastaccess.helper.FileHelper; -import com.fastaccess.ui.base.BaseActivity; - -import butterknife.BindView; -import butterknife.OnClick; -import es.dmoral.toasty.Toasty; - -/** - * Created by JediB on 5/25/2017. - */ - -public class BannerInfoActivity extends BaseActivity implements BannerInfoMvp.View { - - @BindView(R.id.imageChooser) Button imageChooser; - - @Override protected int layout() { - return R.layout.activity_banner_info; - } - - @Override protected boolean isTransparent() { - return false; - } - - @Override protected boolean canBack() { - return true; - } - - @Override protected boolean isSecured() { - return false; - } - - @Override public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - @OnClick(R.id.imageChooser) void onChooseImage() { - if (ActivityHelper.checkAndRequestReadWritePermission(this)) { - showFileChooser(); - } - } - - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == BundleConstant.REQUEST_CODE) { - if (resultCode == RESULT_OK) { - String path = FileHelper.getPath(this, data.getData()); - if (path == null) { - showMessage(R.string.error, R.string.image_error); - return; - } - getPresenter().onPostImage(path); - } - - finish(); - } - } - - @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1) { - if (permissions[0].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) { - if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { - showFileChooser(); - } else { - Toasty.error(App.getInstance(), getString(R.string.permission_failed)).show(); - } - } - } - } - - @NonNull @Override public BannerInfoPresenter providePresenter() { - return new BannerInfoPresenter(); - } - - @Override public void onFinishedUploading() { - showMessage(R.string.success, R.string.successfully_submitted); - setResult(RESULT_OK); - finish(); - } - - private void showFileChooser() { - Intent intent = new Intent(); - intent.setType("image/*"); - intent.setAction(Intent.ACTION_GET_CONTENT); - startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)), BundleConstant.REQUEST_CODE); - } -} diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoMvp.java b/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoMvp.java deleted file mode 100644 index a305dcaf..00000000 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoMvp.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fastaccess.ui.modules.profile.banner; - -import android.support.annotation.NonNull; - -import com.fastaccess.ui.base.mvp.BaseMvp; - -/** - * Created by JediB on 5/25/2017. - */ - -public interface BannerInfoMvp { - - interface View extends BaseMvp.FAView { - void onFinishedUploading(); - } - - interface Presenter { - void onPostImage(@NonNull String path); - } - -} diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoPresenter.java deleted file mode 100644 index f85d6d0c..00000000 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/banner/BannerInfoPresenter.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.fastaccess.ui.modules.profile.banner; - -import android.support.annotation.NonNull; - -import com.fastaccess.ui.base.mvp.presenter.BasePresenter; - -/** - * Created by JediB on 5/25/2017. - */ - -public class BannerInfoPresenter extends BasePresenter implements BannerInfoMvp.Presenter { -// @NonNull private Observable getHeaderGist() { -// return RxHelper.getObserver(RestProvider.getGistService(true).getGistFile(ProfileOverviewMvp.HEADER_FST_URL)); -// } - - @Override public void onPostImage(@NonNull String path) { -// Login login = Login.getUser(); -// RequestBody image = RequestBody.create(MediaType.parse("image/*"), new File(path)); -// ImgurProvider.getImgurService().postImage("", image); -// makeRestCall(RxHelper.getObserver(ImgurProvider.getImgurService().postImage("", image)) -// .filter(imgurReponseModel -> imgurReponseModel != null && imgurReponseModel.getData() != null) -// .map(imgurReponseModel -> imgurReponseModel.getData().getLink()) -// .flatMap(link -> getHeaderGist(), (imageLink, gistContent) -> { -// boolean isReplace = false; -// if (gistContent.contains(login.getLogin() + "->")) { -// String[] splitByNewLine = gistContent.split("\n"); -// for (String s : splitByNewLine) { -// String[] splitByUser = s.split("->"); -// if (login.getLogin().equalsIgnoreCase(splitByUser[0])) { -// gistContent = gistContent.replaceFirst(splitByUser[0] + "->" + -// splitByUser[1], login.getLogin() + "->" + imageLink); -// isReplace = true; -// break; -// } -// } -// } -// PrefGetter.setProfileBackgroundUrl(imageLink); -// if (!isReplace) { -// gistContent += "\n" + login.getLogin() + "->" + imageLink; -// } -// return gistContent; -// }) -// .map(s -> { -// CreateGistModel createGistModel = new CreateGistModel(); -// createGistModel.setPublicGist(true); -// HashMap modelHashMap = new HashMap<>(); -// FilesListModel file = new FilesListModel(); -// file.setFilename("header.fst"); -// file.setContent(s); -// modelHashMap.put("header.fst", file); -// createGistModel.setFiles(modelHashMap); -// return createGistModel; -// }) -// .flatMap(body -> RxHelper.getObserver(RestProvider.getGistService().editGist(body, ProfileOverviewMvp.HEADER_GIST_ID))), -// gist -> sendToView(BannerInfoMvp.View::onFinishedUploading)); - } -} \ No newline at end of file diff --git a/app/src/main/res/layouts/main_layouts/layout/activity_banner_info.xml b/app/src/main/res/layouts/main_layouts/layout/activity_banner_info.xml deleted file mode 100644 index 03160511..00000000 --- a/app/src/main/res/layouts/main_layouts/layout/activity_banner_info.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -