This commit is contained in:
k0shk0sh 2019-12-29 12:17:11 +01:00
parent 455d2b0ee1
commit ba3d0ea296
13 changed files with 35 additions and 301 deletions

View File

@ -306,7 +306,6 @@
</service> </service>
<service android:name=".provider.tasks.notification.ReadNotificationService" /> <service android:name=".provider.tasks.notification.ReadNotificationService" />
<service android:name=".provider.tasks.git.GithubActionService" /> <service android:name=".provider.tasks.git.GithubActionService" />
<service android:name=".provider.tasks.slack.SlackInvitationService" />
<service android:name=".provider.tasks.version.CheckVersionService" /> <service android:name=".provider.tasks.version.CheckVersionService" />
<service <service
android:name=".provider.fcm.PushNotificationService" android:name=".provider.fcm.PushNotificationService"

View File

@ -1,39 +0,0 @@
package com.fastaccess.data.dao;
import android.os.Parcel;
import android.os.Parcelable;
import lombok.Getter;
import lombok.Setter;
/**
* Created by Kosh on 01 May 2017, 1:06 AM
*/
@Getter @Setter public class SlackInvitePostModel implements Parcelable {
private String email;
private String first_name;
private String last_name;
@Override public int describeContents() { return 0; }
@Override public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.email);
dest.writeString(this.first_name);
dest.writeString(this.last_name);
}
public SlackInvitePostModel() {}
private SlackInvitePostModel(Parcel in) {
this.email = in.readString();
this.first_name = in.readString();
this.last_name = in.readString();
}
public static final Parcelable.Creator<SlackInvitePostModel> CREATOR = new Parcelable.Creator<SlackInvitePostModel>() {
@Override public SlackInvitePostModel createFromParcel(Parcel source) {return new SlackInvitePostModel(source);}
@Override public SlackInvitePostModel[] newArray(int size) {return new SlackInvitePostModel[size];}
};
}

View File

@ -1,36 +0,0 @@
package com.fastaccess.data.dao;
import android.os.Parcel;
import android.os.Parcelable;
import lombok.Getter;
import lombok.Setter;
/**
* Created by Kosh on 01 May 2017, 1:05 AM
*/
@Getter @Setter public class SlackResponseModel implements Parcelable {
private boolean ok;
private String error;
@Override public int describeContents() { return 0; }
@Override public void writeToParcel(Parcel dest, int flags) {
dest.writeByte(this.ok ? (byte) 1 : (byte) 0);
dest.writeString(this.error);
}
public SlackResponseModel() {}
private SlackResponseModel(Parcel in) {
this.ok = in.readByte() != 0;
this.error = in.readString();
}
public static final Parcelable.Creator<SlackResponseModel> CREATOR = new Parcelable.Creator<SlackResponseModel>() {
@Override public SlackResponseModel createFromParcel(Parcel source) {return new SlackResponseModel(source);}
@Override public SlackResponseModel[] newArray(int size) {return new SlackResponseModel[size];}
};
}

View File

@ -1,20 +0,0 @@
package com.fastaccess.data.service;
import com.fastaccess.data.dao.SlackInvitePostModel;
import com.fastaccess.data.dao.SlackResponseModel;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import io.reactivex.Observable;
/**
* Created by Kosh on 01 May 2017, 1:04 AM
*/
public interface SlackService {
@POST("FastHubSlackInvite")
@Headers("X-API-Key: MvFQyrJ9703DYmKHvk13I3agw3AdH8vh1lKbKGx4")
Observable<SlackResponseModel> invite(@Body SlackInvitePostModel body);
}

View File

@ -22,7 +22,6 @@ import com.fastaccess.data.service.ReactionsService;
import com.fastaccess.data.service.RepoService; import com.fastaccess.data.service.RepoService;
import com.fastaccess.data.service.ReviewService; import com.fastaccess.data.service.ReviewService;
import com.fastaccess.data.service.SearchService; import com.fastaccess.data.service.SearchService;
import com.fastaccess.data.service.SlackService;
import com.fastaccess.data.service.UserRestService; import com.fastaccess.data.service.UserRestService;
import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.PrefGetter;
@ -180,15 +179,6 @@ public class RestProvider {
return provideRetrofit(enterprise).create(SearchService.class); return provideRetrofit(enterprise).create(SearchService.class);
} }
@NonNull public static SlackService getSlackService() {
return new Retrofit.Builder()
.baseUrl("https://ok13pknpj4.execute-api.eu-central-1.amazonaws.com/prod/")
.addConverterFactory(new GithubResponseConverter(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
.create(SlackService.class);
}
@NonNull public static ContentService getContentService(boolean enterprise) { @NonNull public static ContentService getContentService(boolean enterprise) {
return provideRetrofit(enterprise).create(ContentService.class); return provideRetrofit(enterprise).create(ContentService.class);
} }

View File

@ -1,5 +1,6 @@
package com.fastaccess.provider.tasks.git; package com.fastaccess.provider.tasks.git;
import android.annotation.SuppressLint;
import android.app.IntentService; import android.app.IntentService;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
@ -26,7 +27,7 @@ import io.reactivex.schedulers.Schedulers;
/** /**
* Created by Kosh on 12 Mar 2017, 2:25 PM * Created by Kosh on 12 Mar 2017, 2:25 PM
*/ */
@SuppressWarnings("ResultOfMethodCallIgnored") @SuppressLint("CheckResult")
public class GithubActionService extends IntentService { public class GithubActionService extends IntentService {
public static final int STAR_REPO = 1; public static final int STAR_REPO = 1;
@ -39,7 +40,6 @@ public class GithubActionService extends IntentService {
public static final int FORK_GIST = 8; public static final int FORK_GIST = 8;
private NotificationCompat.Builder notification; private NotificationCompat.Builder notification;
private NotificationManager notificationManager; private NotificationManager notificationManager;
private CompositeDisposable disposable = new CompositeDisposable();
@IntDef({ @IntDef({
STAR_REPO, STAR_REPO,
@ -116,113 +116,102 @@ public class GithubActionService extends IntentService {
} }
@Override public void onDestroy() { @Override public void onDestroy() {
disposable.clear();
super.onDestroy(); super.onDestroy();
} }
private void forkGist(@Nullable String id, boolean isEnterprise) { private void forkGist(@Nullable String id, boolean isEnterprise) {
if (id != null) { if (id != null) {
String msg = getString(R.string.forking, getString(R.string.gist)); String msg = getString(R.string.forking, getString(R.string.gist));
disposable.add( RestProvider.getGistService(isEnterprise)
RestProvider.getGistService(isEnterprise) .forkGist(id)
.forkGist(id) .doOnSubscribe(disposable -> showNotification(msg))
.doOnSubscribe(disposable -> showNotification(msg)) .subscribeOn(Schedulers.io())
.subscribeOn(Schedulers.io()) .subscribe(response -> {
.subscribe(response -> { }, throwable -> hideNotification(msg), () -> hideNotification(msg));
}, throwable -> hideNotification(msg), () -> hideNotification(msg))
);
} }
} }
private void forkRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) { private void forkRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) {
if (id != null && login != null) { if (id != null && login != null) {
String msg = getString(R.string.forking, id); String msg = getString(R.string.forking, id);
disposable.add( RestProvider.getRepoService(isEnterprise)
RestProvider.getRepoService(isEnterprise) .forkRepo(login, id)
.forkRepo(login, id) .doOnSubscribe(disposable -> showNotification(msg))
.doOnSubscribe(disposable -> showNotification(msg)) .subscribeOn(Schedulers.io())
.subscribeOn(Schedulers.io()) .subscribe(response -> {
.subscribe(response -> { }, throwable -> hideNotification(msg), () -> hideNotification(msg));
}, throwable -> hideNotification(msg), () -> hideNotification(msg))
);
} }
} }
private void starGist(@Nullable String id, boolean isEnterprise) { private void starGist(@Nullable String id, boolean isEnterprise) {
if (id != null) { if (id != null) {
String msg = getString(R.string.starring, getString(R.string.gist)); String msg = getString(R.string.starring, getString(R.string.gist));
disposable.add(RestProvider.getGistService(isEnterprise) RestProvider.getGistService(isEnterprise)
.starGist(id) .starGist(id)
.doOnSubscribe(disposable -> showNotification(msg)) .doOnSubscribe(disposable -> showNotification(msg))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(response -> { .subscribe(response -> {
}, throwable -> hideNotification(msg), () -> hideNotification(msg)) }, throwable -> hideNotification(msg), () -> hideNotification(msg));
);
} }
} }
private void starRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) { private void starRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) {
if (id != null && login != null) { if (id != null && login != null) {
String msg = getString(R.string.starring, id); String msg = getString(R.string.starring, id);
disposable.add(RestProvider.getRepoService(isEnterprise) RestProvider.getRepoService(isEnterprise)
.starRepo(login, id) .starRepo(login, id)
.doOnSubscribe(disposable -> showNotification(msg)) .doOnSubscribe(disposable -> showNotification(msg))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(response -> { .subscribe(response -> {
}, throwable -> hideNotification(msg), () -> hideNotification(msg)) }, throwable -> hideNotification(msg), () -> hideNotification(msg));
);
} }
} }
private void unStarGist(@Nullable String id, boolean isEnterprise) { private void unStarGist(@Nullable String id, boolean isEnterprise) {
if (id != null) { if (id != null) {
String msg = getString(R.string.un_starring, getString(R.string.gist)); String msg = getString(R.string.un_starring, getString(R.string.gist));
disposable.add(RestProvider.getGistService(isEnterprise) RestProvider.getGistService(isEnterprise)
.unStarGist(id) .unStarGist(id)
.doOnSubscribe(disposable -> showNotification(msg)) .doOnSubscribe(disposable -> showNotification(msg))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(response -> { .subscribe(response -> {
}, throwable -> hideNotification(msg), () -> hideNotification(msg)) }, throwable -> hideNotification(msg), () -> hideNotification(msg));
);
} }
} }
private void unStarRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) { private void unStarRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) {
if (id != null && login != null) { if (id != null && login != null) {
String msg = getString(R.string.un_starring, id); String msg = getString(R.string.un_starring, id);
disposable.add(RestProvider.getRepoService(isEnterprise) RestProvider.getRepoService(isEnterprise)
.unstarRepo(login, id) .unstarRepo(login, id)
.doOnSubscribe(disposable -> showNotification(msg)) .doOnSubscribe(disposable -> showNotification(msg))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(response -> { .subscribe(response -> {
}, throwable -> hideNotification(msg), () -> hideNotification(msg)) }, throwable -> hideNotification(msg), () -> hideNotification(msg));
);
} }
} }
private void unWatchRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) { private void unWatchRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) {
if (id != null && login != null) { if (id != null && login != null) {
String msg = getString(R.string.un_watching, id); String msg = getString(R.string.un_watching, id);
disposable.add(RestProvider.getRepoService(isEnterprise) RestProvider.getRepoService(isEnterprise)
.unwatchRepo(login, id) .unwatchRepo(login, id)
.doOnSubscribe(disposable -> showNotification(msg)) .doOnSubscribe(disposable -> showNotification(msg))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(response -> { .subscribe(response -> {
}, throwable -> hideNotification(msg), () -> hideNotification(msg)) }, throwable -> hideNotification(msg), () -> hideNotification(msg));
);
} }
} }
private void watchRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) { private void watchRepo(@Nullable String id, @Nullable String login, boolean isEnterprise) {
if (id != null && login != null) { if (id != null && login != null) {
String msg = getString(R.string.watching, id); String msg = getString(R.string.watching, id);
disposable.add(RestProvider.getRepoService(isEnterprise) RestProvider.getRepoService(isEnterprise)
.watchRepo(login, id) .watchRepo(login, id)
.doOnSubscribe(disposable -> showNotification(msg)) .doOnSubscribe(disposable -> showNotification(msg))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(response -> { .subscribe(response -> {
}, throwable -> hideNotification(msg), () -> hideNotification(msg)) }, throwable -> hideNotification(msg), () -> hideNotification(msg));
);
} }
} }

View File

@ -1,46 +0,0 @@
package com.fastaccess.provider.tasks.slack;
import android.app.IntentService;
import android.content.Intent;
import androidx.annotation.Nullable;
import com.fastaccess.App;
import com.fastaccess.R;
import com.fastaccess.data.dao.SlackInvitePostModel;
import com.fastaccess.data.dao.model.Login;
import com.fastaccess.helper.RxHelper;
import com.fastaccess.provider.rest.RestProvider;
import es.dmoral.toasty.Toasty;
/**
* Created by Kosh on 01 May 2017, 1:09 AM
*/
public class SlackInvitationService extends IntentService {
public SlackInvitationService() {
super(SlackInvitationService.class.getName());
}
@Override protected void onHandleIntent(@Nullable Intent intent) {
Login login = Login.getUser();
if (login != null) {
SlackInvitePostModel body = new SlackInvitePostModel();
body.setEmail(login.getEmail());
body.setFirst_name(login.getName());
body.setLast_name(login.getLogin());
RxHelper.getObservable(RestProvider.getSlackService()
.invite(body))
.subscribe(response -> {
if (response != null) {
if (response.isOk()) {
Toasty.success(App.getInstance(), getString(R.string.successfully_invited)).show();
} else {
Toasty.info(App.getInstance(), response.getError().replaceAll("_", " ")).show();
}
}
}, Throwable::printStackTrace);
}
}
}

View File

@ -143,11 +143,6 @@ public class FastHubAboutActivity extends MaterialAboutActivity {
.icon(ContextCompat.getDrawable(context, R.drawable.ic_track_changes)) .icon(ContextCompat.getDrawable(context, R.drawable.ic_track_changes))
.setOnClickAction(() -> new ChangelogBottomSheetDialog().show(getSupportFragmentManager(), "ChangelogBottomSheetDialog")) .setOnClickAction(() -> new ChangelogBottomSheetDialog().show(getSupportFragmentManager(), "ChangelogBottomSheetDialog"))
.build()) .build())
.addItem(new MaterialAboutActionItem.Builder()
.text(R.string.join_slack)
.icon(ContextCompat.getDrawable(context, R.drawable.ic_slack))
.setOnClickAction(() -> ActivityHelper.startCustomTab(this, "http://rebrand.ly/fasthub"))
.build())
.addItem(new MaterialAboutActionItem.Builder() .addItem(new MaterialAboutActionItem.Builder()
.text(R.string.open_source_libs) .text(R.string.open_source_libs)
.icon(ContextCompat.getDrawable(context, R.drawable.ic_github)) .icon(ContextCompat.getDrawable(context, R.drawable.ic_github))

View File

@ -3,28 +3,18 @@ package com.fastaccess.ui.modules.main;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.fastaccess.BuildConfig;
import com.fastaccess.helper.Logger;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.fragment.app.FragmentManager;
import androidx.core.view.GravityCompat;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
import com.evernote.android.state.State; import com.evernote.android.state.State;
import com.fastaccess.App; import com.fastaccess.App;
import com.fastaccess.BuildConfig;
import com.fastaccess.R; import com.fastaccess.R;
import com.fastaccess.data.dao.model.Login; import com.fastaccess.data.dao.model.Login;
import com.fastaccess.data.dao.model.Notification; import com.fastaccess.data.dao.model.Notification;
import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.PrefGetter;
import com.fastaccess.helper.TypeFaceHelper; import com.fastaccess.helper.TypeFaceHelper;
import com.fastaccess.helper.ViewHelper; import com.fastaccess.helper.ViewHelper;
@ -34,11 +24,14 @@ import com.fastaccess.ui.modules.main.issues.pager.MyIssuesPagerFragment;
import com.fastaccess.ui.modules.main.pullrequests.pager.MyPullsPagerFragment; import com.fastaccess.ui.modules.main.pullrequests.pager.MyPullsPagerFragment;
import com.fastaccess.ui.modules.notification.NotificationActivity; import com.fastaccess.ui.modules.notification.NotificationActivity;
import com.fastaccess.ui.modules.search.SearchActivity; import com.fastaccess.ui.modules.search.SearchActivity;
import com.fastaccess.ui.modules.settings.SlackBottomSheetDialog;
import com.fastaccess.ui.modules.user.UserPagerActivity; import com.fastaccess.ui.modules.user.UserPagerActivity;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.GravityCompat;
import androidx.fragment.app.FragmentManager;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import it.sephiroth.android.library.bottomnavigation.BottomNavigation; import it.sephiroth.android.library.bottomnavigation.BottomNavigation;
@ -76,16 +69,9 @@ public class MainActivity extends BaseActivity<MainMvp.View, MainPresenter> impl
@Override protected void onCreate(Bundle savedInstanceState) { @Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
if (getIntent() != null && getIntent().getBooleanExtra(SlackBottomSheetDialog.TAG, false)) {
new SlackBottomSheetDialog().show(getSupportFragmentManager(), SlackBottomSheetDialog.TAG);
}
}
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(o -> { FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(o -> Logger.e(o.getId(), o.getToken()));
Logger.e(o.getId(), o.getToken());
});
} }
getPresenter().setEnterprise(PrefGetter.isEnterprise()); getPresenter().setEnterprise(PrefGetter.isEnterprise());

View File

@ -1,78 +0,0 @@
package com.fastaccess.ui.modules.settings;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
import com.fastaccess.R;
import com.fastaccess.helper.ActivityHelper;
import com.fastaccess.ui.base.BaseBottomSheetDialog;
import com.fastaccess.ui.widgets.FontButton;
import com.fastaccess.ui.widgets.FontTextView;
import butterknife.BindView;
import butterknife.OnClick;
/**
* Created by Kosh on 01 May 2017, 12:58 AM
*/
public class SlackBottomSheetDialog extends BaseBottomSheetDialog {
public interface SlackDialogListener {
void onDismissed();
}
public static final String TAG = SlackBottomSheetDialog.class.getSimpleName();
@BindView(R.id.title) FontTextView title;
@BindView(R.id.message) FontTextView message;
@BindView(R.id.cancel) FontButton cancel;
@BindView(R.id.ok) FontButton ok;
private SlackDialogListener listener;
@Override public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof SlackDialogListener) {
listener = (SlackDialogListener) context;
}
}
@Override public void onDetach() {
listener = null;
super.onDetach();
}
@Override protected int layoutRes() {
return R.layout.message_dialog;
}
@OnClick({R.id.cancel, R.id.ok}) public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.ok:
ActivityHelper.startCustomTab(getActivity(), "http://rebrand.ly/fasthub");
break;
}
if (listener != null) listener.onDismissed();
dismiss();
}
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
cancel.setText(R.string.no);
ok.setText(R.string.yes);
title.setText(R.string.join_slack);
message.setText(getString(R.string.join_slack_message));
}
@Override protected void onHidden() {
if (listener != null) listener.onDismissed();
super.onHidden();
}
@Override protected void onDismissedByScrolling() {
if (listener != null) listener.onDismissed();
super.onDismissedByScrolling();
}
}

View File

@ -14,7 +14,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/spacing_large" android:layout_marginEnd="@dimen/spacing_large"
tools:src="@drawable/ic_slack"/> tools:src="@drawable/ic_fasthub_mascot"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -487,7 +487,6 @@
<string name="files_only">In Files</string> <string name="files_only">In Files</string>
<string name="paths_only">In Paths</string> <string name="paths_only">In Paths</string>
<string name="review_requests">Review Requests</string> <string name="review_requests">Review Requests</string>
<string name="join_slack">Join Slack</string>
<string name="join_slack_message">Would you like to join FastHub Slack group?</string> <string name="join_slack_message">Would you like to join FastHub Slack group?</string>
<string name="successfully_invited">Successfully invited</string> <string name="successfully_invited">Successfully invited</string>
<string name="reply">Reply</string> <string name="reply">Reply</string>

View File

@ -3,11 +3,6 @@
xmlns:android="http://schemas.android.com/apk/res/android" 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">
<Preference
android:icon="@drawable/ic_slack"
android:key="joinSlack"
android:title="@string/join_slack"/>
<Preference <Preference
android:icon="@drawable/ic_track_changes" android:icon="@drawable/ic_track_changes"
android:key="showChangelog" android:key="showChangelog"