diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java
index 266b55d3..b5d8f93d 100644
--- a/app/src/main/java/io/lbry/browser/MainActivity.java
+++ b/app/src/main/java/io/lbry/browser/MainActivity.java
@@ -76,6 +76,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatDelegate;
+import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
@@ -207,7 +208,7 @@ import lombok.Setter;
import lombok.SneakyThrows;
import okhttp3.OkHttpClient;
-public class MainActivity extends AppCompatActivity implements SdkStatusListener {
+public class MainActivity extends AppCompatActivity implements SdkStatusListener, SharedPreferences.OnSharedPreferenceChangeListener {
private static final String CHANNEL_ID_PLAYBACK = "io.lbry.browser.LBRY_PLAYBACK_CHANNEL";
private static final int PLAYBACK_NOTIFICATION_ID = 3;
private static final String SPECIAL_URL_PREFIX = "lbry://?";
@@ -313,6 +314,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public static final String PREFERENCE_KEY_DARK_MODE = "io.lbry.browser.preference.userinterface.DarkMode";
public static final String PREFERENCE_KEY_SHOW_MATURE_CONTENT = "io.lbry.browser.preference.userinterface.ShowMatureContent";
public static final String PREFERENCE_KEY_SHOW_URL_SUGGESTIONS = "io.lbry.browser.preference.userinterface.UrlSuggestions";
+ public static final String PREFERENCE_KEY_MINI_PLAYER_BOTTOM_MARGIN = "io.lbry.browser.preference.userinterface.MiniPlayerBottomMargin";
public static final String PREFERENCE_KEY_NOTIFICATION_COMMENTS = "io.lbry.browser.preference.notifications.Comments";
public static final String PREFERENCE_KEY_NOTIFICATION_SUBSCRIPTIONS = "io.lbry.browser.preference.notifications.Subscriptions";
public static final String PREFERENCE_KEY_NOTIFICATION_REWARDS = "io.lbry.browser.preference.notifications.Rewards";
@@ -393,6 +395,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
private static final int STARTUP_STAGE_NEW_INSTALL_DONE = 5;
private static final int STARTUP_STAGE_SUBSCRIPTIONS_LOADED = 6;
private static final int STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED = 7;
+ private static final int DEFAULT_MINI_PLAYER_MARGIN = 4;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -436,6 +439,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
+ updateMiniPlayerMargins();
+
// setup the billing client in main activity (to handle cases where the verification purchase flow may have been interrupted)
billingClient = BillingClient.newBuilder(this)
.setListener(new PurchasesUpdatedListener() {
@@ -612,6 +617,17 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
});
}
+ private void updateMiniPlayerMargins() {
+ // mini-player bottom margin setting
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
+ int miniPlayerBottomMargin = Helper.parseInt(
+ sp.getString(PREFERENCE_KEY_MINI_PLAYER_BOTTOM_MARGIN, String.valueOf(DEFAULT_MINI_PLAYER_MARGIN)), DEFAULT_MINI_PLAYER_MARGIN);
+ ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) findViewById(R.id.global_now_playing_card).getLayoutParams();
+ int scaledMiniPlayerMargin = getScaledValue(DEFAULT_MINI_PLAYER_MARGIN);
+ int scaledMiniPlayerBottomMargin = getScaledValue(miniPlayerBottomMargin);
+ lp.setMargins(scaledMiniPlayerMargin, 0, scaledMiniPlayerMargin, scaledMiniPlayerBottomMargin);
+ }
+
public boolean isDarkMode() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
return sp.getBoolean(PREFERENCE_KEY_DARK_MODE, false);
@@ -1143,8 +1159,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
@Override
protected void onResume() {
super.onResume();
+ PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
+
checkPurchases();
checkWebSocketClient();
+ updateMiniPlayerMargins();
enteringPIPMode = false;
applyNavbarSigninPadding();
@@ -1221,6 +1240,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
@Override
protected void onPause() {
+ PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
if (!enteringPIPMode && !inPictureInPictureMode && appPlayer != null && !isBackgroundPlaybackEnabled()) {
appPlayer.setPlayWhenReady(false);
}
@@ -1833,6 +1853,13 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
}
}
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (PREFERENCE_KEY_MINI_PLAYER_BOTTOM_MARGIN.equalsIgnoreCase(key)) {
+ updateMiniPlayerMargins();
+ }
+ }
+
private class PlayerNotificationDescriptionAdapter implements PlayerNotificationManager.MediaDescriptionAdapter {
@Override
diff --git a/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java b/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java
index 7e93b6ca..d23c12a5 100644
--- a/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java
+++ b/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java
@@ -4,9 +4,13 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.text.InputType;
+import android.widget.EditText;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatDelegate;
+import androidx.preference.EditTextPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
@@ -23,6 +27,15 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.settings, rootKey);
+ PreferenceManager manager = getPreferenceManager();
+
+ EditTextPreference miniPlayerBottomMarginPreference = manager.findPreference(MainActivity.PREFERENCE_KEY_MINI_PLAYER_BOTTOM_MARGIN);
+ miniPlayerBottomMarginPreference.setOnBindEditTextListener(new EditTextPreference.OnBindEditTextListener() {
+ @Override
+ public void onBindEditText(@NonNull EditText editText) {
+ editText.setInputType(InputType.TYPE_CLASS_NUMBER);
+ }
+ });
}
@Override
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4f45dd59..41915992 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -242,6 +242,7 @@
Notifications
Subscriptions
Content Interests
+ Mini-player bottom spacing
Keep the LBRY service running in the background for improved wallet and network performance
Participate in the data network (requires app and background service restart)
diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml
index 25af5cb7..6348a2d9 100644
--- a/app/src/main/res/xml/settings.xml
+++ b/app/src/main/res/xml/settings.xml
@@ -23,6 +23,12 @@
app:title="@string/show_url_suggestions"
app:defaultValue="true"
app:iconSpaceReserved="false" />
+