enable check for update

This commit is contained in:
Yuriy Liskov
2020-09-24 22:49:26 +03:00
parent 01d1c8b83a
commit d44dfc12cb
38 changed files with 112 additions and 156 deletions
@@ -1,4 +1,4 @@
package com.liskovsoft.smartyoutubetv2.common.app.models.auth;
package com.liskovsoft.smartyoutubetv2.common.app.models.signin;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Header;
@@ -1,4 +1,4 @@
package com.liskovsoft.smartyoutubetv2.common.app.models.auth;
package com.liskovsoft.smartyoutubetv2.common.app.models.signin;
import android.content.Context;
import com.liskovsoft.smartyoutubetv2.common.R;
@@ -10,7 +10,7 @@ import com.liskovsoft.mediaserviceinterfaces.data.MediaGroup;
import com.liskovsoft.sharedutils.mylogger.Log;
import com.liskovsoft.sharedutils.prefs.GlobalPreferences;
import com.liskovsoft.smartyoutubetv2.common.R;
import com.liskovsoft.smartyoutubetv2.common.app.models.auth.SignInData;
import com.liskovsoft.smartyoutubetv2.common.app.models.signin.SignInData;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Header;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.VideoGroup;
@@ -1,5 +1,6 @@
package com.liskovsoft.smartyoutubetv2.common.app.presenters;
import android.annotation.SuppressLint;
import android.content.Context;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.interfaces.Presenter;
import com.liskovsoft.smartyoutubetv2.common.app.views.ViewManager;
@@ -7,6 +8,7 @@ import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.common.app.views.DetailsView;
public class DetailsPresenter implements Presenter<DetailsView> {
@SuppressLint("StaticFieldLeak")
private static DetailsPresenter sInstance;
private final Context mContext;
private final ViewManager mViewManager;
@@ -1,5 +1,6 @@
package com.liskovsoft.smartyoutubetv2.common.app.presenters;
import android.annotation.SuppressLint;
import android.content.Context;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.interfaces.Presenter;
import com.liskovsoft.smartyoutubetv2.common.app.views.ViewManager;
@@ -9,6 +10,7 @@ import com.liskovsoft.smartyoutubetv2.common.app.views.PlaybackView;
public class PlaybackPresenter implements Presenter<PlaybackView> {
private static final String TAG = PlaybackPresenter.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
private static PlaybackPresenter sInstance;
private final Context mContext;
private final ViewManager mViewManager;
@@ -1,5 +1,6 @@
package com.liskovsoft.smartyoutubetv2.common.app.presenters;
import android.annotation.SuppressLint;
import android.content.Context;
import com.liskovsoft.mediaserviceinterfaces.MediaGroupManager;
import com.liskovsoft.mediaserviceinterfaces.MediaService;
@@ -17,6 +18,7 @@ import io.reactivex.schedulers.Schedulers;
public class SearchPresenter implements VideoGroupPresenter<SearchView> {
private static final String TAG = SearchPresenter.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
private static SearchPresenter sInstance;
private final Context mContext;
private final MediaService mMediaService;
@@ -1,5 +1,6 @@
package com.liskovsoft.smartyoutubetv2.common.app.presenters;
import android.annotation.SuppressLint;
import android.content.Context;
import com.liskovsoft.mediaserviceinterfaces.MediaService;
import com.liskovsoft.sharedutils.mylogger.Log;
@@ -12,6 +13,7 @@ import io.reactivex.schedulers.Schedulers;
public class SignInPresenter implements Presenter<SignInView> {
private static final String TAG = SignInPresenter.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
private static SignInPresenter sInstance;
private final MediaService mMediaService;
private final Context mContext;
@@ -1,5 +1,6 @@
package com.liskovsoft.smartyoutubetv2.common.app.presenters;
import android.annotation.SuppressLint;
import android.content.Context;
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.ui.OptionItem;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.interfaces.Presenter;
@@ -10,6 +11,7 @@ import java.util.ArrayList;
import java.util.List;
public class VideoSettingsPresenter implements Presenter<VideoSettingsView> {
@SuppressLint("StaticFieldLeak")
private static VideoSettingsPresenter sInstance;
private final Context mContext;
private VideoSettingsView mView;
@@ -0,0 +1,4 @@
package com.liskovsoft.smartyoutubetv2.common.app.views;
public interface AppUpdateView {
}
@@ -1,6 +1,6 @@
package com.liskovsoft.smartyoutubetv2.common.app.views;
import com.liskovsoft.smartyoutubetv2.common.app.models.auth.ErrorFragmentData;
import com.liskovsoft.smartyoutubetv2.common.app.models.signin.ErrorFragmentData;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Header;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.VideoGroup;
@@ -7,11 +7,11 @@ import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import com.liskovsoft.smartyoutubetv2.tv.data.old.FetchVideoService;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract.VideoEntry;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoDbBuilder;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoDbHelper;
import com.liskovsoft.smartyoutubetv2.tv.old.data.FetchVideoService;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract.VideoEntry;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoDbBuilder;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoDbHelper;
import org.json.JSONArray;
import org.json.JSONException;
+8 -8
View File
@@ -123,19 +123,19 @@
<!-- Begin Old activities -->
<activity
android:name="com.liskovsoft.smartyoutubetv2.tv.ui.old.VerticalGridActivity"
android:name="com.liskovsoft.smartyoutubetv2.tv.old.ui.VerticalGridActivity"
android:exported="true"
android:parentActivityName="com.liskovsoft.smartyoutubetv2.tv.ui.browse.BrowseActivity"
android:screenOrientation="landscape"
android:theme="@style/Theme.Leanback.VerticalGrid" />
<activity
android:name="com.liskovsoft.smartyoutubetv2.tv.ui.old.GuidedStepActivity"
android:name="com.liskovsoft.smartyoutubetv2.tv.old.ui.GuidedStepActivity"
android:screenOrientation="landscape"
android:theme="@style/Theme.Example.Leanback.GuidedStep" />
<!-- Provides search suggestions for keywords against video metadata. -->
<provider
android:name="com.liskovsoft.smartyoutubetv2.tv.data.old.VideoProvider"
android:name=".old.data.VideoProvider"
android:authorities="${packageName}"
android:permission="${applicationId}.ACCESS_VIDEO_DATA"
android:exported="true">
@@ -145,7 +145,7 @@
</provider>
<receiver
android:name="com.liskovsoft.smartyoutubetv2.tv.recommendation.old.RecommendationReceiver"
android:name=".old.recommendation.RecommendationReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
@@ -154,20 +154,20 @@
</receiver>
<service
android:name="com.liskovsoft.smartyoutubetv2.tv.data.old.FetchVideoService"
android:name=".old.data.FetchVideoService"
android:exported="false" />
<service
android:name="com.liskovsoft.smartyoutubetv2.tv.recommendation.old.UpdateRecommendationsService"
android:name=".old.recommendation.UpdateRecommendationsService"
android:enabled="true" />
<activity android:name="com.liskovsoft.smartyoutubetv2.tv.ui.old.SettingsActivity"
<activity android:name="com.liskovsoft.smartyoutubetv2.tv.old.ui.SettingsActivity"
android:exported="true"
android:screenOrientation="landscape"
android:theme="@style/LeanbackPreferences"
/>
<activity
android:name="com.liskovsoft.smartyoutubetv2.tv.ui.old.AuthenticationActivity"
android:name="com.liskovsoft.smartyoutubetv2.tv.old.ui.AuthenticationActivity"
android:screenOrientation="landscape"
android:theme="@style/Theme.Example.Leanback.GuidedStep" />
@@ -1,98 +0,0 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.model;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import java.util.ArrayList;
import java.util.List;
/**
* Manages a playlist of videos.
*/
public class Playlist {
private List<Video> playlist;
private int currentPosition;
public Playlist() {
playlist = new ArrayList<>();
currentPosition = 0;
}
/**
* Clears the videos from the playlist.
*/
public void clear() {
playlist.clear();
}
/**
* Adds a video to the end of the playlist.
*
* @param video to be added to the playlist.
*/
public void add(Video video) {
playlist.add(video);
}
/**
* Sets current position in the playlist.
*
* @param currentPosition
*/
public void setCurrentPosition(int currentPosition) {
this.currentPosition = currentPosition;
}
/**
* Returns the size of the playlist.
*
* @return The size of the playlist.
*/
public int size() {
return playlist.size();
}
/**
* Moves to the next video in the playlist. If already at the end of the playlist, null will
* be returned and the position will not change.
*
* @return The next video in the playlist.
*/
public Video next() {
if ((currentPosition + 1) < size()) {
currentPosition++;
return playlist.get(currentPosition);
}
return null;
}
/**
* Moves to the previous video in the playlist. If the playlist is already at the beginning,
* null will be returned and the position will not change.
*
* @return The previous video in the playlist.
*/
public Video previous() {
if (currentPosition - 1 >= 0) {
currentPosition--;
return playlist.get(currentPosition);
}
return null;
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.data.old;
package com.liskovsoft.smartyoutubetv2.tv.old.data;
import android.app.IntentService;
import android.content.ContentValues;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.data.old;
package com.liskovsoft.smartyoutubetv2.tv.old.data;
import android.app.SearchManager;
import android.content.ContentResolver;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.data.old;
package com.liskovsoft.smartyoutubetv2.tv.old.data;
import android.content.ContentValues;
import android.content.Context;
@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.data.old;
package com.liskovsoft.smartyoutubetv2.tv.old.data;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract.VideoEntry;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract.VideoEntry;
/**
* VideoDbHelper manages the creation and upgrade of the database used in this sample.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.data.old;
package com.liskovsoft.smartyoutubetv2.tv.old.data;
import android.app.SearchManager;
import android.content.ContentProvider;
@@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.model.old;
package com.liskovsoft.smartyoutubetv2.tv.old.model;
import android.database.Cursor;
import androidx.leanback.database.CursorMapper;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract;
/**
* VideoCursorMapper maps a database Cursor to a Video object.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.recommendation.old;
package com.liskovsoft.smartyoutubetv2.tv.old.recommendation;
import android.app.AlarmManager;
import android.app.PendingIntent;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.recommendation.old;
package com.liskovsoft.smartyoutubetv2.tv.old.recommendation;
import android.app.IntentService;
import android.app.Notification;
@@ -33,9 +33,9 @@ import android.util.Log;
import com.bumptech.glide.Glide;
import com.liskovsoft.smartyoutubetv2.tv.BuildConfig;
import com.liskovsoft.smartyoutubetv2.tv.R;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.tv.model.old.VideoCursorMapper;
import com.liskovsoft.smartyoutubetv2.tv.old.model.VideoCursorMapper;
import com.liskovsoft.smartyoutubetv2.tv.ui.details.VideoDetailsActivity;
import java.util.concurrent.ExecutionException;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.ui.old;
package com.liskovsoft.smartyoutubetv2.tv.old.ui;
import android.app.Activity;
import android.graphics.drawable.Drawable;
@@ -14,13 +14,11 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.ui.old;
package com.liskovsoft.smartyoutubetv2.tv.old.ui;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import androidx.leanback.app.BrowseSupportFragment;
import androidx.leanback.app.BrowseSupportFragment.MainFragmentAdapter;
import androidx.leanback.app.ErrorSupportFragment;
import androidx.fragment.app.Fragment;
import android.view.Gravity;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.ui.old;
package com.liskovsoft.smartyoutubetv2.tv.old.ui;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.ui.old;
package com.liskovsoft.smartyoutubetv2.tv.old.ui;
import android.app.Activity;
import android.os.Bundle;
@@ -12,7 +12,7 @@
* the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.ui.old;
package com.liskovsoft.smartyoutubetv2.tv.old.ui;
import android.content.Intent;
import android.os.Bundle;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.ui.old;
package com.liskovsoft.smartyoutubetv2.tv.old.ui;
import android.os.Bundle;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.smartyoutubetv2.tv.ui.old;
package com.liskovsoft.smartyoutubetv2.tv.old.ui;
import android.content.Intent;
import android.database.Cursor;
@@ -36,9 +36,9 @@ import androidx.loader.content.Loader;
import android.view.View;
import com.liskovsoft.smartyoutubetv2.tv.R;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.tv.model.old.VideoCursorMapper;
import com.liskovsoft.smartyoutubetv2.tv.old.model.VideoCursorMapper;
import com.liskovsoft.smartyoutubetv2.tv.presenter.CardPresenter;
import com.liskovsoft.smartyoutubetv2.tv.ui.details.VideoDetailsActivity;
import com.liskovsoft.smartyoutubetv2.tv.ui.search.SearchActivity;
@@ -7,7 +7,7 @@ import androidx.fragment.app.Fragment;
import androidx.leanback.app.BrowseSupportFragment;
import androidx.leanback.app.BrowseSupportFragment.MainFragmentAdapter;
import androidx.leanback.app.ErrorSupportFragment;
import com.liskovsoft.smartyoutubetv2.common.app.models.auth.ErrorFragmentData;
import com.liskovsoft.smartyoutubetv2.common.app.models.signin.ErrorFragmentData;
import com.liskovsoft.smartyoutubetv2.tv.R;
public class BrowseDialogFragment extends ErrorSupportFragment implements BrowseSupportFragment.MainFragmentAdapterProvider {
@@ -17,7 +17,7 @@ import androidx.leanback.widget.PresenterSelector;
import androidx.leanback.widget.Row;
import androidx.leanback.widget.RowHeaderPresenter.ViewHolder;
import com.liskovsoft.sharedutils.helpers.Helpers;
import com.liskovsoft.smartyoutubetv2.common.app.models.auth.ErrorFragmentData;
import com.liskovsoft.smartyoutubetv2.common.app.models.signin.ErrorFragmentData;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Header;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.VideoGroup;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.BrowsePresenter;
@@ -44,9 +44,9 @@ import com.bumptech.glide.request.transition.Transition;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.DetailsPresenter;
import com.liskovsoft.smartyoutubetv2.common.app.views.DetailsView;
import com.liskovsoft.smartyoutubetv2.tv.R;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.tv.model.old.VideoCursorMapper;
import com.liskovsoft.smartyoutubetv2.tv.old.model.VideoCursorMapper;
import com.liskovsoft.smartyoutubetv2.tv.presenter.DetailsDescriptionPresenter;
import com.liskovsoft.smartyoutubetv2.tv.ui.playback.PlaybackActivity;
@@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.liskovsoft.sharedutils.mylogger.Log;
import com.liskovsoft.smartyoutubetv2.tv.update.AppUpdateManager;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.PlaybackPresenter;
import com.liskovsoft.smartyoutubetv2.common.app.views.ViewManager;
import com.liskovsoft.smartyoutubetv2.common.utils.IntentExtractor;
@@ -19,6 +20,7 @@ public class SplashActivity extends Activity {
applyNewIntent(getIntent());
updateChannels();
checkForUpdates();
finish();
}
@@ -30,6 +32,16 @@ public class SplashActivity extends Activity {
applyNewIntent(intent);
}
private void applyNewIntent(Intent intent) {
if (IntentExtractor.isVideo(intent)) {
PlaybackPresenter playbackPresenter = PlaybackPresenter.instance(this);
playbackPresenter.openVideo(IntentExtractor.getVideoId(intent));
} else {
ViewManager viewManager = ViewManager.instance(this);
viewManager.startDefaultView(this);
}
}
private void updateChannels() {
Class<?> clazz = null;
@@ -48,13 +60,9 @@ public class SplashActivity extends Activity {
}
}
private void applyNewIntent(Intent intent) {
if (IntentExtractor.isVideo(intent)) {
PlaybackPresenter playbackPresenter = PlaybackPresenter.instance(this);
playbackPresenter.openVideo(IntentExtractor.getVideoId(intent));
} else {
ViewManager viewManager = ViewManager.instance(this);
viewManager.startDefaultView(this);
}
private void checkForUpdates() {
AppUpdateManager updatePresenter = AppUpdateManager.instance(this);
updatePresenter.checkForUpdates();
updatePresenter.unhold();
}
}
@@ -0,0 +1,34 @@
package com.liskovsoft.smartyoutubetv2.tv.update;
import android.annotation.SuppressLint;
import android.content.Context;
import com.liskovsoft.appupdatechecker2.AppUpdateChecker;
public class AppUpdateManager {
private static final String UPDATE_MANIFEST_URL = "https://github.com/yuliskov/SmartYouTubeTV/releases/download/stable/smartyoutubetv.json";
@SuppressLint("StaticFieldLeak")
private static AppUpdateManager sInstance;
private final Context mContext;
private final AppUpdateChecker mUpdateChecker;
public AppUpdateManager(Context context) {
mContext = context;
mUpdateChecker = new AppUpdateChecker(mContext);
}
public static AppUpdateManager instance(Context context) {
if (sInstance == null) {
sInstance = new AppUpdateManager(context.getApplicationContext());
}
return sInstance;
}
public void checkForUpdates() {
mUpdateChecker.forceCheckForUpdates(UPDATE_MANIFEST_URL);
}
public void unhold() {
sInstance = null;
}
}
@@ -4,7 +4,7 @@
android:layout_height="match_parent">
<fragment
android:id="@+id/settingsFragment"
android:name="com.liskovsoft.smartyoutubetv2.tv.ui.old.SettingsFragment"
android:name="com.liskovsoft.smartyoutubetv2.tv.old.ui.SettingsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"></fragment>
</RelativeLayout>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vertical_grid_fragment"
android:name="com.liskovsoft.smartyoutubetv2.tv.ui.old.VerticalGridFragment"
android:name="com.liskovsoft.smartyoutubetv2.tv.old.ui.VerticalGridFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -2,8 +2,8 @@ package com.liskovsoft.smartyoutubetv2.tv;
import android.content.ContentValues;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.data.old.VideoDbBuilder;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoContract;
import com.liskovsoft.smartyoutubetv2.tv.old.data.VideoDbBuilder;
import org.json.JSONArray;
import org.json.JSONException;