From 9cc108827f932387ca6ebeb59c01d857b1e05fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schu=CC=88ller?= Date: Mon, 31 Dec 2018 20:32:22 +0100 Subject: [PATCH] wip --- .../peertube/activity/VideoListActivity.java | 5 +++-- .../network/AuthorizationInterceptor.java | 7 +++++-- app/src/main/res/layout/activity_login.xml | 16 ++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index ed8b3d4..4fdaa84 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -421,6 +421,7 @@ public class VideoListActivity extends AppCompatActivity { if (!Session.getInstance().isLoggedIn()) { Intent intent = new Intent(this, LoginActivity.class); this.startActivity(intent); + return false; } else { if (!isLoading) { @@ -430,9 +431,9 @@ public class VideoListActivity extends AppCompatActivity { subscriptions = true; loadVideos(currentStart, count, sort, filter); } + return true; } - return true; case R.id.navigation_account: //Log.v(TAG, "navigation_account"); @@ -446,7 +447,7 @@ public class VideoListActivity extends AppCompatActivity { this.startActivity(intent); } - return true; + return false; } return false; }); diff --git a/app/src/main/java/net/schueller/peertube/network/AuthorizationInterceptor.java b/app/src/main/java/net/schueller/peertube/network/AuthorizationInterceptor.java index 5329b7b..438797e 100644 --- a/app/src/main/java/net/schueller/peertube/network/AuthorizationInterceptor.java +++ b/app/src/main/java/net/schueller/peertube/network/AuthorizationInterceptor.java @@ -41,11 +41,14 @@ public class AuthorizationInterceptor implements Interceptor { if (session.isLoggedIn()) { -// if (mainResponse.code() == 401 || mainResponse.code() == 403) { + if (mainResponse.code() == 401 || mainResponse.code() == 403) { // session.invalidate(); // return mainResponse; -// } + Log.v("Authorization", "Intercept code: " + mainResponse.code()); + } + + // add authentication header to each request if we are logged in Request.Builder builder = mainRequest.newBuilder().header("Authorization", session.getToken()). method(mainRequest.method(), mainRequest.body()); mainResponse = chain.proceed(builder.build()); diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 82d760d..9187735 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -10,26 +10,26 @@ android:paddingTop="@dimen/activity_vertical_margin" tools:context="net.schueller.peertube.activity.LoginActivity"> - - + + + + +