mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-03-13 15:20:26 +08:00
slideable: move init to topmost activity; upd MediaServiceCore
This commit is contained in:
Submodule MediaServiceCore updated: 9364d97660...a5a6dc7722
@@ -95,4 +95,6 @@ dependencies {
|
||||
implementation project(':leanbackassistant')
|
||||
|
||||
implementation project(':appupdatechecker2')
|
||||
|
||||
implementation project(':slidableactivity') // https://github.com/r0adkll/Slidr
|
||||
}
|
||||
|
||||
@@ -27,7 +27,12 @@ import com.liskovsoft.smartyoutubetv2.common.prefs.GeneralData;
|
||||
import com.liskovsoft.smartyoutubetv2.common.prefs.MainUIData;
|
||||
import com.liskovsoft.smartyoutubetv2.common.prefs.PlayerData;
|
||||
import com.liskovsoft.smartyoutubetv2.common.prefs.PlayerTweaksData;
|
||||
import com.liskovsoft.smartyoutubetv2.common.utils.Utils;
|
||||
import com.liskovsoft.youtubeapi.service.internal.MediaServiceData;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrConfig;
|
||||
import com.r0adkll.slidr.model.SlidrListener;
|
||||
import com.r0adkll.slidr.model.SlidrPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -92,6 +97,8 @@ public class MotherActivity extends FragmentActivity {
|
||||
mScreensaverManager = new ScreensaverManager(this); // moved below the theme to fix side effects
|
||||
|
||||
//Helpers.addFullscreenListener(this);
|
||||
|
||||
initEdgeSlide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -435,4 +442,39 @@ public class MotherActivity extends FragmentActivity {
|
||||
protected MediaServiceData getMediaServiceData() {
|
||||
return MediaServiceData.instance();
|
||||
}
|
||||
|
||||
private void initEdgeSlide() {
|
||||
if (VERSION.SDK_INT < 21 || !Helpers.isTouchSupported(this) || Utils.isSystemGestureArrowEnabled(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SlidrConfig config = new SlidrConfig.Builder()
|
||||
.position(SlidrPosition.LEFT) // Swipe from the left
|
||||
.edge(true) // Only trigger from the screen edge
|
||||
.edgeSize(0.18f) // Grab 18% of the screen (good for cars)
|
||||
.scrimStartAlpha(0f) // Don't dim the background screen
|
||||
.scrimEndAlpha(0f) // Background clear when finished
|
||||
.distanceThreshold(0.1f) // Set drag distance to minimum
|
||||
.listener(new SlidrListener() {
|
||||
@Override
|
||||
public void onSlideStateChanged(int state) {}
|
||||
|
||||
@Override
|
||||
public void onSlideChange(float percent) {}
|
||||
|
||||
@Override
|
||||
public void onSlideOpened() {}
|
||||
|
||||
@Override
|
||||
public boolean onSlideClosed() {
|
||||
// This replaces the default finish() with your back logic
|
||||
onBackPressed();
|
||||
return true; // Tells the library we handled the close
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
// Attach to this activity
|
||||
Slidr.attach(this, config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1208,6 +1208,23 @@ public class Utils {
|
||||
return original.equals(typed);
|
||||
}
|
||||
|
||||
@SuppressLint("DiscouragedApi")
|
||||
public static boolean isSystemGestureArrowEnabled(Context context) {
|
||||
Resources res = context.getResources();
|
||||
// This is the internal Android constant for navigation mode
|
||||
int resourceId = res.getIdentifier("config_navBarInteractionMode", "integer", "android");
|
||||
|
||||
if (resourceId > 0) {
|
||||
int navMode = res.getInteger(resourceId);
|
||||
// 0: 3-button navigation (Back, Home, Recents)
|
||||
// 1: 2-button navigation (Android P style)
|
||||
// 2: Full Gesture Navigation (Android 10+ Arrow)
|
||||
return navMode == 2;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void persistData(Context context) {
|
||||
VideoStateService.instance(context).persistNow();
|
||||
PlayerData.instance(context).persistNow();
|
||||
|
||||
@@ -180,7 +180,7 @@ public class SliderPanel extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
// MOD: don't full slide (remove whole if block to revert original)
|
||||
// MOD: do partial slide (remove this block to revert original)
|
||||
if (settleLeft == screenWidth) {
|
||||
settleLeft = left;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,6 @@ dependencies {
|
||||
implementation project(':youtubeapi')
|
||||
implementation project(':chatkit')
|
||||
implementation project(':doubletapplayerview')
|
||||
implementation project(':slidableactivity') // https://github.com/r0adkll/Slidr
|
||||
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:' + rxAndroidVersion
|
||||
implementation 'io.reactivex.rxjava2:rxjava:' + rxJavaVersion
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.liskovsoft.smartyoutubetv2.tv.ui.common;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build.VERSION;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.liskovsoft.sharedutils.helpers.Helpers;
|
||||
import com.liskovsoft.sharedutils.mylogger.Log;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.SearchPresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.autoframerate.ModeSyncManager;
|
||||
@@ -19,10 +16,6 @@ import com.liskovsoft.smartyoutubetv2.common.utils.Utils;
|
||||
import com.liskovsoft.smartyoutubetv2.tv.ui.common.keyhandler.DoubleBackManager2;
|
||||
import com.liskovsoft.smartyoutubetv2.tv.ui.playback.PlaybackActivity;
|
||||
import com.liskovsoft.smartyoutubetv2.tv.ui.search.tags.SearchTagsActivity;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
import com.r0adkll.slidr.model.SlidrConfig;
|
||||
import com.r0adkll.slidr.model.SlidrListener;
|
||||
import com.r0adkll.slidr.model.SlidrPosition;
|
||||
|
||||
/**
|
||||
* This parent class contains common methods that run in every activity such as search.
|
||||
@@ -45,44 +38,6 @@ public abstract class LeanbackActivity extends MotherActivity {
|
||||
new PlayerKeyTranslator(this) :
|
||||
new GlobalKeyTranslator(this);
|
||||
mGlobalKeyTranslator.apply();
|
||||
|
||||
initBackSlide();
|
||||
}
|
||||
|
||||
private void initBackSlide() {
|
||||
if (VERSION.SDK_INT < 21 || !Helpers.isTouchSupported(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SlidrConfig config = new SlidrConfig.Builder()
|
||||
.position(SlidrPosition.LEFT) // Swipe from the left
|
||||
.edge(true) // Only trigger from the screen edge
|
||||
.edgeSize(0.18f) // Grab 18% of the screen (good for cars)
|
||||
.scrimColor(Color.BLACK) // Shadow color
|
||||
.scrimStartAlpha(0.8f) // Dim the background screen
|
||||
.scrimEndAlpha(0f) // Background clear when finished
|
||||
.distanceThreshold(0.1f)
|
||||
.listener(new SlidrListener() {
|
||||
@Override
|
||||
public void onSlideStateChanged(int state) {}
|
||||
|
||||
@Override
|
||||
public void onSlideChange(float percent) {}
|
||||
|
||||
@Override
|
||||
public void onSlideOpened() {}
|
||||
|
||||
@Override
|
||||
public boolean onSlideClosed() {
|
||||
// This replaces the default finish() with your back logic
|
||||
onBackPressed();
|
||||
return true; // Tells the library we handled the close
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
// Attach to this activity
|
||||
Slidr.attach(this, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user