diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index db70a4b5..a8ede513 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -43,18 +43,33 @@
+ android:parentActivityName=".ui.modules.main.MainView">
+
+
+ android:parentActivityName=".ui.modules.main.MainView">
+
+
+ android:parentActivityName=".ui.modules.repos.RepoPagerView">
+
+
+ android:parentActivityName=".ui.modules.repos.RepoPagerView">
+
+
+ android:parentActivityName=".ui.modules.repos.RepoPagerView">
+
+
+ android:parentActivityName=".ui.modules.main.MainView">
+
+
+ android:parentActivityName=".ui.modules.main.MainView">
+
+
+ android:parentActivityName=".ui.modules.main.MainView">
+
+
intentOptional = returnNonNull(userIntent, pullRequestIntent, commit, commits,
+ issueIntent, repoIntent, blob);
+ Optional empty = Optional.empty();
+ if (intentOptional != null && intentOptional.isPresent() && intentOptional != empty) {
+ return intentOptional.get();
+ } else {
+ return getGeneralRepo(context, data);
+ }
+ }
+ }
+ return null;
+ }
+
+ @Nullable private static TaskStackBuilder getPullRequestIntent(@NonNull Context context, @NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ if (segments == null || segments.size() < 4) return null;
+ String owner;
+ String repo;
+ String number;
+ if ("pull".equals(segments.get(2))) {
+ owner = segments.get(0);
+ repo = segments.get(1);
+ number = segments.get(3);
+ } else if ("pull".equals(segments.get(3))) {//notifications url.
+ owner = segments.get(1);
+ repo = segments.get(2);
+ number = segments.get(4);
+ } else {
+ return null;
+ }
+ if (InputHelper.isEmpty(number))
+ return null;
+ int issueNumber;
+ try {
+ issueNumber = Integer.parseInt(number);
+ } catch (NumberFormatException nfe) {
+ return null;
+ }
+ if (issueNumber < 1) return null;
+ return TaskStackBuilder.create(context)
+ .addNextIntentWithParentStack(RepoPagerView.createIntent(context, repo, owner))
+ .addNextIntent(PullRequestPagerView.createIntent(context, repo, owner, issueNumber));
+ }
+
+ @Nullable private static TaskStackBuilder getIssueIntent(@NonNull Context context, @NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ if (segments == null || segments.size() < 4) return null;
+ String owner;
+ String repo;
+ String number;
+ if ("issues".equals(segments.get(2))) {
+ owner = segments.get(0);
+ repo = segments.get(1);
+ number = segments.get(3);
+ } else if ("issues".equals(segments.get(3))) {//notifications url.
+ owner = segments.get(1);
+ repo = segments.get(2);
+ number = segments.get(4);
+ } else {
+ return null;
+ }
+ if (InputHelper.isEmpty(number))
+ return null;
+ int issueNumber;
+ try {
+ issueNumber = Integer.parseInt(number);
+ } catch (NumberFormatException nfe) {
+ return null;
+ }
+ if (issueNumber < 1) return null;
+ return TaskStackBuilder.create(context)
+ .addNextIntentWithParentStack(RepoPagerView.createIntent(context, repo, owner))
+ .addNextIntent(IssuePagerView.createIntent(context, repo, owner, issueNumber));
+ }
+
+ @Nullable private static TaskStackBuilder getRepo(@NonNull Context context, @NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ if (segments == null || segments.size() < 2 || segments.size() > 2) return null;
+ String owner = segments.get(0);
+ String repoName = segments.get(1);
+ return TaskStackBuilder.create(context)
+ .addParentStack(MainView.class)
+ .addNextIntent(RepoPagerView.createIntent(context, repoName, owner));
+ }
+
+ /**
+ * [[k0shk0sh, FastHub, issues], k0shk0sh/fastHub/(issues,pulls,commits, etc)]
+ */
+ @Nullable private static TaskStackBuilder getGeneralRepo(@NonNull Context context, @NonNull Uri uri) {
+ //TODO parse deeper links to their associate views. meantime fallback to repoPage
+ if (uri.getAuthority().equals(HOST_DEFAULT) || uri.getAuthority().equals(API_AUTHORITY)) {
+ List segments = uri.getPathSegments();
+ if (segments == null || segments.isEmpty()) return null;
+ if (segments.size() == 1) {
+ return getUser(context, uri);
+ } else if (segments.size() > 1) {
+ String owner = segments.get(0);
+ String repoName = segments.get(1);
+ return TaskStackBuilder.create(context)
+ .addParentStack(MainView.class)
+ .addNextIntent(RepoPagerView.createIntent(context, repoName, owner));
+ }
+ }
+ return null;
+ }
+
+ @Nullable private static TaskStackBuilder getCommits(@NonNull Context context, @NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ if (segments == null || segments.isEmpty() || segments.size() < 4) return null;
+ if (segments.get(3).equals("commits")) {
+ String login = segments.get(1);
+ String repoId = segments.get(2);
+ String sha = segments.get(4);
+ return TaskStackBuilder.create(context)
+ .addNextIntentWithParentStack(RepoPagerView.createIntent(context, repoId, login))
+ .addNextIntent(CommitPagerView.createIntent(context, repoId, login, sha));
+ }
+ return null;
+ }
+
+ @Nullable private static TaskStackBuilder getCommit(@NonNull Context context, @NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ if (segments == null || segments.size() < 4 || !"commit".equals(segments.get(2))) return null;
+ String login = segments.get(0);
+ String repoId = segments.get(1);
+ String sha = segments.get(3);
+ return TaskStackBuilder.create(context)
+ .addNextIntentWithParentStack(RepoPagerView.createIntent(context, repoId, login))
+ .addNextIntent(CommitPagerView.createIntent(context, repoId, login, sha));
+ }
+
+ @Nullable private static TaskStackBuilder getUser(@NonNull Context context, @NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ if (segments != null && !segments.isEmpty() && segments.size() == 1) {
+ return TaskStackBuilder.create(context)
+ .addParentStack(MainView.class)
+ .addNextIntent(UserPagerView.createIntent(context, segments.get(0)));
+ }
+ return null;
+ }
+
+ @Nullable private static TaskStackBuilder getBlob(@NonNull Context context, @NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ if (segments == null || segments.size() < 4) return null;
+ String segmentTwo = segments.get(2);
+ if (segmentTwo.equals("blob") || segmentTwo.equals("tree")) {
+ String fullUrl = uri.toString();
+ if (uri.getAuthority().equalsIgnoreCase(HOST_DEFAULT)) {
+ fullUrl = "https://" + RAW_AUTHORITY + "/" + segments.get(0) + "/" + segments.get(1) + "/" +
+ segments.get(segments.size() - 2) + "/" + uri.getLastPathSegment();
+ }
+ if (fullUrl != null) {
+ return TaskStackBuilder.create(context)
+ .addParentStack(MainView.class)
+ .addNextIntent(CodeViewerView.createIntent(context, fullUrl));
+ }
+ } else {
+ String authority = uri.getAuthority();
+ if (TextUtils.equals(authority, RAW_AUTHORITY)) {
+ return TaskStackBuilder.create(context)
+ .addParentStack(MainView.class)
+ .addNextIntent(CodeViewerView.createIntent(context, uri.toString()));
+ }
+ }
+ return null;
+ }
+
+ @SafeVarargs private static Optional returnNonNull(T... t) {
+ return Stream.of(t).filter(value -> value != null).findFirst();
+ }
+
+ @Nullable private static String getGistId(@NonNull Uri uri) {
+ List segments = uri.getPathSegments();
+ return segments != null && !segments.isEmpty() ? segments.get(0) : null;
+ }
+}
diff --git a/app/src/main/java/com/fastaccess/provider/tasks/NotificationJobTask.java b/app/src/main/java/com/fastaccess/provider/tasks/NotificationJobTask.java
index a6fa6d9f..66b043ed 100644
--- a/app/src/main/java/com/fastaccess/provider/tasks/NotificationJobTask.java
+++ b/app/src/main/java/com/fastaccess/provider/tasks/NotificationJobTask.java
@@ -7,6 +7,7 @@ import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.NotificationCompat;
import com.annimon.stream.Stream;
@@ -16,6 +17,7 @@ import com.fastaccess.data.dao.NotificationThreadModel;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.provider.rest.RestProvider;
+import com.fastaccess.ui.modules.main.MainView;
import com.fastaccess.ui.modules.notification.NotificationActivityView;
import com.firebase.jobdispatcher.Constraint;
import com.firebase.jobdispatcher.FirebaseJobDispatcher;
@@ -87,10 +89,12 @@ public class NotificationJobTask extends JobService {
.count();
if (count > 0) {
Context context = getApplicationContext();
+ TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
+ taskStackBuilder.addParentStack(MainView.class);
Intent intent = new Intent(this, NotificationActivityView.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
+ taskStackBuilder.addNextIntent(intent);
+ PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_announcement)
.setContentTitle(context.getString(R.string.notifictions))
diff --git a/app/src/main/java/com/fastaccess/ui/modules/parser/LinksParserActivity.java b/app/src/main/java/com/fastaccess/ui/modules/parser/LinksParserActivity.java
index de20a89a..896e5afb 100644
--- a/app/src/main/java/com/fastaccess/ui/modules/parser/LinksParserActivity.java
+++ b/app/src/main/java/com/fastaccess/ui/modules/parser/LinksParserActivity.java
@@ -8,7 +8,7 @@ import android.widget.Toast;
import com.fastaccess.R;
import com.fastaccess.data.dao.LoginModel;
-import com.fastaccess.provider.scheme.SchemeParser;
+import com.fastaccess.provider.scheme.StackBuilderSchemeParser;
import com.fastaccess.ui.modules.login.LoginView;
/**
@@ -46,7 +46,7 @@ public class LinksParserActivity extends Activity {
}
private void onUriReceived() {
- SchemeParser.launchUri(this, getIntent());
+ StackBuilderSchemeParser.launchUri(this, getIntent());
finish();
}
}
diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerView.java b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerView.java
index ffcc7e1a..495423ae 100644
--- a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerView.java
+++ b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/issue/details/IssuePagerView.java
@@ -242,10 +242,6 @@ public class IssuePagerView extends BaseActivity