diff --git a/README.md b/README.md index 3455384e..105b868e 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ _(To download the app from here, please look at the [latest release](https://git - Offline-mode - Markdown and code highlighting support - Notifications overview and "Mark all as read" + - Search users/orgs, repos, issues/prs & code. - Pinned Repos - **Repositories** - Search Repos @@ -54,6 +55,11 @@ _(To download the app from here, please look at the [latest release](https://git - Comment on Commits/Gists - Manage Commit/Gist comments - Create/Delete Gists +- **Orgs** + - Overview + - Feeds + - Teams & Teams repos + - Repos - **Users** - Follow/unfollow users - Search Users, Repos, Issues,Pull Requests and Code diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 27f4128d..6af3918e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -197,6 +197,10 @@ android:host="raw.githubusercontent.com" android:scheme="https"/> + + @@ -206,8 +210,7 @@ - + android:permission="android.permission.BIND_JOB_SERVICE"/> diff --git a/app/src/main/java/com/fastaccess/helper/InputHelper.java b/app/src/main/java/com/fastaccess/helper/InputHelper.java index 5e8732fd..36182cc7 100644 --- a/app/src/main/java/com/fastaccess/helper/InputHelper.java +++ b/app/src/main/java/com/fastaccess/helper/InputHelper.java @@ -67,4 +67,8 @@ public class InputHelper { } return 0; } + + public static int getSafeIntId(long id) { + return id > Integer.MAX_VALUE ? (int) (id - Integer.MAX_VALUE) : (int) id; + } } diff --git a/app/src/main/java/com/fastaccess/provider/scheme/LinkParserHelper.java b/app/src/main/java/com/fastaccess/provider/scheme/LinkParserHelper.java new file mode 100644 index 00000000..a272abd7 --- /dev/null +++ b/app/src/main/java/com/fastaccess/provider/scheme/LinkParserHelper.java @@ -0,0 +1,30 @@ +package com.fastaccess.provider.scheme; + +import android.support.annotation.NonNull; + +import com.annimon.stream.Collectors; +import com.annimon.stream.Optional; +import com.annimon.stream.Stream; + +import java.util.ArrayList; + +/** + * Created by Kosh on 11 Apr 2017, 10:02 PM + */ + +class LinkParserHelper { + static final String HOST_DEFAULT = "github.com"; + static final String HOST_GISTS = "gist.github.com"; + static final String HOST_GISTS_RAW = "gist.githubusercontent.com"; + static final String RAW_AUTHORITY = "raw.githubusercontent.com"; + static final String API_AUTHORITY = "api.github.com"; + static final String PROTOCOL_HTTPS = "https"; + static final ArrayList IGNORED_LIST = Stream.of("notifications", "settings", "blog", "explore", + "dashboard", "repositories", "site", "security", "contact", "about", "") + .collect(Collectors.toCollection(ArrayList::new)); + + + @SafeVarargs static Optional returnNonNull(@NonNull T... t) { + return Stream.of(t).filter(value -> value != null).findFirst(); + } +} diff --git a/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java b/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java index 73e2cd6f..3843f61e 100644 --- a/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java +++ b/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java @@ -10,9 +10,7 @@ import android.support.annotation.Nullable; import android.text.TextUtils; import android.webkit.MimeTypeMap; -import com.annimon.stream.Collectors; import com.annimon.stream.Optional; -import com.annimon.stream.Stream; import com.fastaccess.helper.ActivityHelper; import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.Logger; @@ -25,23 +23,22 @@ import com.fastaccess.ui.modules.repos.issues.issue.details.IssuePagerView; import com.fastaccess.ui.modules.repos.pull_requests.pull_request.details.PullRequestPagerView; import com.fastaccess.ui.modules.user.UserPagerView; -import java.util.ArrayList; import java.util.List; +import static com.fastaccess.provider.scheme.LinkParserHelper.*; +import static com.fastaccess.provider.scheme.LinkParserHelper.API_AUTHORITY; +import static com.fastaccess.provider.scheme.LinkParserHelper.HOST_DEFAULT; +import static com.fastaccess.provider.scheme.LinkParserHelper.HOST_GISTS; +import static com.fastaccess.provider.scheme.LinkParserHelper.HOST_GISTS_RAW; +import static com.fastaccess.provider.scheme.LinkParserHelper.PROTOCOL_HTTPS; +import static com.fastaccess.provider.scheme.LinkParserHelper.RAW_AUTHORITY; +import static com.fastaccess.provider.scheme.LinkParserHelper.returnNonNull; + /** * Created by Kosh on 09 Dec 2016, 4:44 PM */ public class SchemeParser { - private static final String HOST_DEFAULT = "github.com"; - private static final String HOST_GISTS = "gist.github.com"; - private static final String RAW_AUTHORITY = "raw.githubusercontent.com"; - private static final String API_AUTHORITY = "api.github.com"; - private static final String PROTOCOL_HTTPS = "https"; - - static final ArrayList IGNORED_LIST = Stream.of("notifications", "settings", "blog", "explore", - "dashboard", "repositories", "site", "security", "contact", "about", "") - .collect(Collectors.toCollection(ArrayList::new)); public static void launchUri(@NonNull Context context, @NonNull Uri data) { launchUri(context, data, false); @@ -79,8 +76,8 @@ public class SchemeParser { } } if (!data.getPathSegments().isEmpty()) { - Logger.e(SchemeParser.IGNORED_LIST.contains(data.getPath()), data.getPathSegments().get(0)); - if (SchemeParser.IGNORED_LIST.contains(data.getPathSegments().get(0))) return null; + Logger.e(IGNORED_LIST.contains(data.getPath()), data.getPathSegments().get(0)); + if (IGNORED_LIST.contains(data.getPathSegments().get(0))) return null; } else { return null; } @@ -93,6 +90,8 @@ public class SchemeParser { if (gist != null) { return GistView.createIntent(context, gist); } + } else if (HOST_GISTS_RAW.equalsIgnoreCase(data.getHost())) { + return getGistFile(context, data); } else { String authority = data.getAuthority(); if (TextUtils.equals(authority, HOST_DEFAULT) || TextUtils.equals(authority, RAW_AUTHORITY) || @@ -205,7 +204,7 @@ public class SchemeParser { @Nullable private static Intent getCommits(@NonNull Context context, @NonNull Uri uri, boolean showRepoBtn) { List segments = uri.getPathSegments(); - if (segments == null || segments.isEmpty() || segments.size() < 4) return null; + if (segments == null || segments.isEmpty() || segments.size() < 3) return null; if (segments.get(3).equals("commits")) { String login = segments.get(1); String repoId = segments.get(2); @@ -217,7 +216,7 @@ public class SchemeParser { @Nullable private static Intent getCommit(@NonNull Context context, @NonNull Uri uri, boolean showRepoBtn) { List segments = uri.getPathSegments(); - if (segments == null || segments.size() < 4 || !"commit".equals(segments.get(2))) return null; + if (segments == null || segments.size() < 3 || !"commit".equals(segments.get(2))) return null; String login = segments.get(0); String repoId = segments.get(1); String sha = segments.get(3); @@ -283,7 +282,10 @@ public class SchemeParser { return null; } - @SafeVarargs private static Optional returnNonNull(@NonNull T... t) { - return Stream.of(t).filter(value -> value != null).findFirst(); + @Nullable private static Intent getGistFile(@NonNull Context context, @NonNull Uri uri) { + if (uri.getHost().equalsIgnoreCase(HOST_GISTS_RAW)) { + return CodeViewerView.createIntent(context, uri.toString()); + } + return null; } } diff --git a/app/src/main/java/com/fastaccess/provider/scheme/StackBuilderSchemeParser.java b/app/src/main/java/com/fastaccess/provider/scheme/StackBuilderSchemeParser.java index 7160951b..0e3b4f80 100644 --- a/app/src/main/java/com/fastaccess/provider/scheme/StackBuilderSchemeParser.java +++ b/app/src/main/java/com/fastaccess/provider/scheme/StackBuilderSchemeParser.java @@ -10,7 +10,6 @@ import android.text.TextUtils; import android.webkit.MimeTypeMap; import com.annimon.stream.Optional; -import com.annimon.stream.Stream; import com.fastaccess.helper.ActivityHelper; import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.Logger; @@ -28,16 +27,20 @@ import com.fastaccess.ui.modules.user.UserPagerView; import java.util.List; +import static com.fastaccess.provider.scheme.LinkParserHelper.API_AUTHORITY; +import static com.fastaccess.provider.scheme.LinkParserHelper.HOST_DEFAULT; +import static com.fastaccess.provider.scheme.LinkParserHelper.HOST_GISTS; +import static com.fastaccess.provider.scheme.LinkParserHelper.HOST_GISTS_RAW; +import static com.fastaccess.provider.scheme.LinkParserHelper.IGNORED_LIST; +import static com.fastaccess.provider.scheme.LinkParserHelper.PROTOCOL_HTTPS; +import static com.fastaccess.provider.scheme.LinkParserHelper.RAW_AUTHORITY; +import static com.fastaccess.provider.scheme.LinkParserHelper.returnNonNull; + /** * Created by Kosh on 09 Dec 2016, 4:44 PM */ public class StackBuilderSchemeParser { - private static final String HOST_DEFAULT = "github.com"; - private static final String HOST_GISTS = "gist.github.com"; - private static final String RAW_AUTHORITY = "raw.githubusercontent.com"; - private static final String API_AUTHORITY = "api.github.com"; - private static final String PROTOCOL_HTTPS = "https"; public static void launchUri(@NonNull Context context, @NonNull Intent data) { if (data.getData() != null) { @@ -74,8 +77,7 @@ public class StackBuilderSchemeParser { } } if (!data.getPathSegments().isEmpty()) { - Logger.e(SchemeParser.IGNORED_LIST.contains(data.getPath()), data.getPathSegments().get(0)); - if (SchemeParser.IGNORED_LIST.contains(data.getPathSegments().get(0))) return null; + if (IGNORED_LIST.contains(data.getPathSegments().get(0))) return null; } else { return null; } @@ -91,6 +93,8 @@ public class StackBuilderSchemeParser { .addNextIntentWithParentStack(new Intent(context, MainView.class)) .addNextIntent(GistView.createIntent(context, gist)); } + } else if (HOST_GISTS_RAW.equalsIgnoreCase(data.getHost())) { + return getGistFile(context, data); } else { String authority = data.getAuthority(); if (TextUtils.equals(authority, HOST_DEFAULT) || TextUtils.equals(authority, RAW_AUTHORITY) || @@ -311,9 +315,6 @@ public class StackBuilderSchemeParser { return null; } - /** - * https://github.com/owner/repo/issues/new - */ @Nullable private static TaskStackBuilder getCreateIssueIntent(@NonNull Context context, @NonNull Uri uri) { List segments = uri.getPathSegments(); Logger.e(segments); @@ -331,8 +332,15 @@ public class StackBuilderSchemeParser { return null; } - @SafeVarargs private static Optional returnNonNull(T... t) { - return Stream.of(t).filter(value -> value != null).findFirst(); + @Nullable private static TaskStackBuilder getGistFile(@NonNull Context context, @NonNull Uri uri) { + if (uri.getHost().equalsIgnoreCase(HOST_GISTS_RAW)) { + return TaskStackBuilder.create(context) + .addParentStack(MainView.class) + .addNextIntentWithParentStack(new Intent(context, MainView.class)) + .addNextIntentWithParentStack(GistView.createIntent(context, uri.getPathSegments().get(1))) + .addNextIntent(CodeViewerView.createIntent(context, uri.toString())); + } + return null; } @Nullable private static String getGistId(@NonNull Uri uri) { diff --git a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java index 072062c6..230f340b 100644 --- a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java +++ b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java @@ -15,6 +15,7 @@ import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; +import android.support.v4.content.ContextCompat; import com.annimon.stream.Stream; import com.fastaccess.R; @@ -22,15 +23,17 @@ import com.fastaccess.data.dao.model.Comment; import com.fastaccess.data.dao.model.Login; import com.fastaccess.data.dao.model.Notification; import com.fastaccess.helper.AppHelper; +import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.Logger; import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.RxHelper; -import com.fastaccess.helper.ViewHelper; import com.fastaccess.provider.rest.RestProvider; import java.util.List; import java.util.concurrent.TimeUnit; +import rx.Observable; import rx.schedulers.Schedulers; /** @@ -50,11 +53,14 @@ public class NotificationSchedulerJobTask extends JobService { .subscribe(item -> { AppHelper.cancelAllNotifications(getApplicationContext()); if (item != null) { - onSave(item.getItems()); + onSave(item.getItems(), job); + } else { + finishJob(job); } scheduleJob(getApplicationContext()); - jobFinished(job, false); - }, Throwable::printStackTrace); + }, throwable -> finishJob(job)); + } else { + finishJob(job); } return true; } @@ -69,41 +75,35 @@ public class NotificationSchedulerJobTask extends JobService { } public static void scheduleJob(@NonNull Context context, long duration, boolean cancel) { - JobScheduler mJobScheduler = (JobScheduler) - context.getSystemService( Context.JOB_SCHEDULER_SERVICE ); + JobScheduler mJobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); if (cancel) mJobScheduler.cancel(JOB_ID_EVERY_30_MINS); if (duration == -1) { mJobScheduler.cancel(JOB_ID_EVERY_30_MINS); return; } duration = duration <= 0 ? THIRTY_MINUTES : duration; - JobInfo.Builder builder = new JobInfo.Builder(JOB_ID_EVERY_30_MINS, new ComponentName(context.getPackageName(), NotificationSchedulerJobTask.class.getName())) .setBackoffCriteria(JobInfo.DEFAULT_INITIAL_BACKOFF_MILLIS, JobInfo.BACKOFF_POLICY_LINEAR) .setPersisted(true) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && - duration < JobInfo.getMinPeriodMillis()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && duration < JobInfo.getMinPeriodMillis()) { builder.setMinimumLatency(duration); } else { builder.setPeriodic(duration); } - - if (mJobScheduler.schedule(builder.build()) <= 0) { - // something gone wrong - } + mJobScheduler.schedule(builder.build()); } - private void onSave(@Nullable List notificationThreadModels) { + private void onSave(@Nullable List notificationThreadModels, JobParameters job) { if (notificationThreadModels != null) { RxHelper.safeObservable(Notification.save(notificationThreadModels)).subscribe(); - onNotifyUser(notificationThreadModels); + onNotifyUser(notificationThreadModels, job); } } - private void onNotifyUser(@NonNull List notificationThreadModels) { + private void onNotifyUser(@NonNull List notificationThreadModels, JobParameters job) { long count = Stream.of(notificationThreadModels) .filter(Notification::isUnread) .count(); @@ -112,82 +112,90 @@ public class NotificationSchedulerJobTask extends JobService { return; } Context context = getApplicationContext(); + int accentColor = ContextCompat.getColor(this, R.color.material_blue_700); Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher); - int accentColor = ViewHelper.getAccentColor(context); - Notification firstNotification = notificationThreadModels.get(0); - android.app.Notification grouped = getSummaryGroupNotification(firstNotification, accentColor, largeIcon); - showNotification((int) firstNotification.getId(), grouped); - Stream.of(notificationThreadModels) - .filter(notification -> notification.isUnread() && notification.getId() != firstNotification.getId()) + Observable.from(notificationThreadModels) + .subscribeOn(Schedulers.io()) + .filter(Notification::isUnread) .limit(10) - .forEach(thread -> { + .flatMap(notification -> RestProvider.getNotificationService() + .getComment(notification.getSubject().getLatestCommentUrl()) + .subscribeOn(Schedulers.io()), (thread, comment) -> { if (!InputHelper.isEmpty(thread.getSubject().getLatestCommentUrl())) { - RestProvider.getNotificationService().getComment(thread.getSubject().getLatestCommentUrl()) - .subscribeOn(Schedulers.io()) - .subscribe(comment -> { - android.app.Notification toAdd = getNotificationWithComment(context, largeIcon, accentColor, thread, comment); - showNotification((int) thread.getId(), toAdd); - }, Throwable::printStackTrace); - } else { - showNotificationWithoutCommnet(context, largeIcon, accentColor, thread); + android.app.Notification toAdd = getNotificationWithComment(context, accentColor, largeIcon, thread, comment); + showNotification((int) comment.getId(), toAdd); + return null; } + return thread; + }) + .subscribeOn(Schedulers.io()) + .subscribe(thread -> { + if (thread != null) { + showNotificationWithoutComment(context, accentColor, thread, largeIcon); + } + }, throwable -> finishJob(job), () -> { + Logger.e(); + android.app.Notification grouped = getSummaryGroupNotification(accentColor); + showNotification(BundleConstant.REQUEST_CODE, grouped); + finishJob(job); }); } - private void showNotificationWithoutCommnet(Context context, Bitmap largeIcon, int accentColor, Notification thread) { - android.app.Notification toAdd = getNotification(thread.getSubject().getTitle(), - thread.getRepository().getFullName()) + private void finishJob(JobParameters job) { + jobFinished(job, false); + } + + private void showNotificationWithoutComment(Context context, int accentColor, Notification thread, Bitmap largeIcon) { + android.app.Notification toAdd = getNotification(thread.getSubject().getTitle(), thread.getRepository().getFullName()) .setLargeIcon(largeIcon) .setContentIntent(getPendingIntent(thread.getId(), thread.getSubject().getUrl())) - .setGroup(NOTIFICATION_GROUP_ID) - .setColor(accentColor) .addAction(R.drawable.ic_github, context.getString(R.string.open), getPendingIntent(thread.getId(), thread .getSubject().getUrl())) .addAction(R.drawable.ic_eye_off, context.getString(R.string.mark_as_read), getReadOnlyPendingIntent(thread.getId(), thread .getSubject().getUrl())) + .setWhen(thread.getUpdatedAt() != null ? thread.getUpdatedAt().getTime() : System.currentTimeMillis()) + .setShowWhen(true) + .setColor(accentColor) + .setGroup(NOTIFICATION_GROUP_ID) .build(); showNotification((int) thread.getId(), toAdd); } - private android.app.Notification getNotificationWithComment(Context context, Bitmap largeIcon, int accentColor, + private android.app.Notification getNotificationWithComment(Context context, int accentColor, Bitmap largeIcon, Notification thread, Comment comment) { - return getNotification(thread.getSubject().getTitle(), - thread.getRepository().getFullName()) - .setStyle(new NotificationCompat.BigTextStyle() - .bigText(comment.getBody()) - .setBigContentTitle(comment.getUser() != null ? comment.getUser().getLogin() : "")) + return getNotification(comment.getUser() != null ? comment.getUser().getLogin() : "", comment.getBody()) + .setSmallIcon(R.drawable.ic_notification) .setLargeIcon(largeIcon) - .setContentIntent(getPendingIntent(thread.getId(), thread.getSubject().getUrl())) - .setGroup(NOTIFICATION_GROUP_ID) - .setColor(accentColor) + .setStyle(new NotificationCompat.BigTextStyle() + .setBigContentTitle(comment.getUser() != null ? comment.getUser().getLogin() : "") + .bigText(comment.getBody())) + .setWhen(comment.getCreatedAt().getTime()) + .setShowWhen(true) .addAction(R.drawable.ic_github, context.getString(R.string.open), getPendingIntent(thread.getId(), thread.getSubject().getUrl())) .addAction(R.drawable.ic_eye_off, context.getString(R.string.mark_as_read), getReadOnlyPendingIntent(thread.getId(), thread.getSubject().getUrl())) + .setContentIntent(getPendingIntent(thread.getId(), thread.getSubject().getUrl())) + .setColor(accentColor) + .setGroup(NOTIFICATION_GROUP_ID) .build(); } - private android.app.Notification getSummaryGroupNotification(@NonNull Notification notification, int accentColor, Bitmap largeIcon) { - return getNotification(notification.getSubject().getTitle(), notification.getRepository().getFullName()) - .setLargeIcon(largeIcon) + private android.app.Notification getSummaryGroupNotification(int accentColor) { + return getNotification(getString(R.string.notifications), getString(R.string.unread_notification)) + .setSmallIcon(R.drawable.ic_notification) + .setColor(accentColor) .setGroup(NOTIFICATION_GROUP_ID) .setGroupSummary(true) - .setColor(accentColor) - .setContentIntent(getPendingIntent(notification.getId(), notification.getSubject().getUrl())) - .addAction(R.drawable.ic_github, getString(R.string.open), - getPendingIntent(notification.getId(), notification.getSubject().getUrl())) - .addAction(R.drawable.ic_eye_off, getString(R.string.mark_as_read), getReadOnlyPendingIntent(notification.getId(), - notification.getSubject().getUrl())) - .setAutoCancel(true) .build(); } private NotificationCompat.Builder getNotification(@NonNull String title, @NonNull String message) { return new NotificationCompat.Builder(this) - .setSmallIcon(R.drawable.ic_notification) .setContentTitle(title) - .setContentText(message); + .setContentText(message) + .setAutoCancel(true); } private void showNotification(int id, android.app.Notification notification) { @@ -197,13 +205,13 @@ public class NotificationSchedulerJobTask extends JobService { private PendingIntent getReadOnlyPendingIntent(long id, @NonNull String url) { Intent intent = ReadNotificationService.start(this, id, url, true); - return PendingIntent.getService(this, (int) (id / 2), intent, + return PendingIntent.getService(this, InputHelper.getSafeIntId(id) / 2, intent, PendingIntent.FLAG_UPDATE_CURRENT); } private PendingIntent getPendingIntent(long id, @NonNull String url) { Intent intent = ReadNotificationService.start(this, id, url); - return PendingIntent.getService(this, (int) id, intent, + return PendingIntent.getService(this, InputHelper.getSafeIntId(id), intent, PendingIntent.FLAG_UPDATE_CURRENT); } } diff --git a/app/src/main/java/com/fastaccess/provider/tasks/notification/ReadNotificationService.java b/app/src/main/java/com/fastaccess/provider/tasks/notification/ReadNotificationService.java index b364fd47..35b004e0 100644 --- a/app/src/main/java/com/fastaccess/provider/tasks/notification/ReadNotificationService.java +++ b/app/src/main/java/com/fastaccess/provider/tasks/notification/ReadNotificationService.java @@ -15,6 +15,7 @@ import com.fastaccess.R; import com.fastaccess.helper.AppHelper; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.Bundler; +import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.PrefGetter; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.provider.scheme.SchemeParser; @@ -87,7 +88,7 @@ public class ReadNotificationService extends IntentService { private void openNotification(long id, @Nullable String url, boolean readOnly) { if (id > 0 && url != null) { - AppHelper.cancelNotification(this, (int) id); + AppHelper.cancelNotification(this, InputHelper.getSafeIntId(id)); if (!PrefGetter.isMarkAsReadEnabled() || readOnly) { markSingleAsRead(id); } @@ -104,7 +105,7 @@ public class ReadNotificationService extends IntentService { private void markSingleAsRead(long id) { RestProvider.getNotificationService() .markAsRead(String.valueOf(id)) - .doOnSubscribe(() -> getNotificationManager().notify((int) id, getNotification().build())) + .doOnSubscribe(() -> getNotificationManager().notify(InputHelper.getSafeIntId(id), getNotification().build())) .subscribeOn(Schedulers.io()) .subscribe(booleanResponse -> { }, Throwable::printStackTrace, () -> getNotificationManager().cancel((int) id)); diff --git a/app/src/main/java/com/fastaccess/ui/modules/code/CodeViewerView.java b/app/src/main/java/com/fastaccess/ui/modules/code/CodeViewerView.java index d34c31e9..bbf10c02 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/code/CodeViewerView.java +++ b/app/src/main/java/com/fastaccess/ui/modules/code/CodeViewerView.java @@ -19,6 +19,7 @@ import com.fastaccess.helper.InputHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.BaseActivity; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; +import com.fastaccess.ui.modules.gists.gist.GistView; import com.fastaccess.ui.modules.repos.code.files.activity.RepoFilesActivity; import com.fastaccess.ui.modules.repos.code.prettifier.ViewerView; @@ -103,7 +104,14 @@ public class CodeViewerView extends BaseActivity { ActivityHelper.shareUrl(this, url); return true; } else if (item.getItemId() == android.R.id.home) { - RepoFilesActivity.startActivity(this, url); + Uri uri = Uri.parse(url); + if (uri.getHost().contains("gist.github")) { + if (uri.getPathSegments() != null && !uri.getPathSegments().isEmpty() && uri.getPathSegments().size() >= 1) { + GistView.createIntent(this, uri.getPathSegments().get(1)); + } + } else { + RepoFilesActivity.startActivity(this, url); + } finish(); return true; } diff --git a/app/src/main/java/com/fastaccess/ui/modules/login/LoginView.java b/app/src/main/java/com/fastaccess/ui/modules/login/LoginView.java index 6fdceb9f..d4778a40 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/login/LoginView.java +++ b/app/src/main/java/com/fastaccess/ui/modules/login/LoginView.java @@ -47,18 +47,11 @@ public class LoginView extends BaseActivity imple Toasty.info(this, getString(R.string.open_in_browser)).show(); } - public void doLogin() { - if(progress.getVisibility() == View.GONE) { - getPresenter().login(InputHelper.toString(username), - InputHelper.toString(password), InputHelper.toString(twoFactor)); - } - } - @OnClick(R.id.login) public void onClick() { doLogin(); } - @OnEditorAction(R.id.passwordEditText) public boolean onSendPassword(int actionId) { + @OnEditorAction(R.id.passwordEditText) public boolean onSendPassword() { if (twoFactor.getVisibility() == View.VISIBLE) { twoFactorEditText.requestFocus(); } else { @@ -67,7 +60,7 @@ public class LoginView extends BaseActivity imple return true; } - @OnEditorAction(R.id.twoFactorEditText) public boolean onSend2FA(int actionId) { + @OnEditorAction(R.id.twoFactorEditText) public boolean onSend2FA() { doLogin(); return true; } @@ -159,4 +152,11 @@ public class LoginView extends BaseActivity imple getPresenter().onHandleAuthIntent(getIntent()); setIntent(null); } + + private void doLogin() { + if (progress.getVisibility() == View.GONE) { + getPresenter().login(InputHelper.toString(username), + InputHelper.toString(password), InputHelper.toString(twoFactor)); + } + } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsView.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsView.java index e12d7e45..6b66be3b 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsView.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/comments/CommitCommentsView.java @@ -205,7 +205,6 @@ public class CommitCommentsView extends BaseFragment + app:statusBarBackground="@color/material_indigo_900" + tools:context=".ui.modules.login.LoginView"> + android:maxLines="1"/> + android:maxLines="1"/>