add setting for mini-player bottom spacing #1009
4 changed files with 48 additions and 1 deletions
|
@ -76,6 +76,7 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
@ -207,7 +208,7 @@ import lombok.Setter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import okhttp3.OkHttpClient;
|
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 String CHANNEL_ID_PLAYBACK = "io.lbry.browser.LBRY_PLAYBACK_CHANNEL";
|
||||||
private static final int PLAYBACK_NOTIFICATION_ID = 3;
|
private static final int PLAYBACK_NOTIFICATION_ID = 3;
|
||||||
private static final String SPECIAL_URL_PREFIX = "lbry://?";
|
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_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_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_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_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_SUBSCRIPTIONS = "io.lbry.browser.preference.notifications.Subscriptions";
|
||||||
public static final String PREFERENCE_KEY_NOTIFICATION_REWARDS = "io.lbry.browser.preference.notifications.Rewards";
|
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_NEW_INSTALL_DONE = 5;
|
||||||
private static final int STARTUP_STAGE_SUBSCRIPTIONS_LOADED = 6;
|
private static final int STARTUP_STAGE_SUBSCRIPTIONS_LOADED = 6;
|
||||||
private static final int STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED = 7;
|
private static final int STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED = 7;
|
||||||
|
private static final int DEFAULT_MINI_PLAYER_MARGIN = 4;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -436,6 +439,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
updateMiniPlayerMargins();
|
||||||
|
|
||||||
// setup the billing client in main activity (to handle cases where the verification purchase flow may have been interrupted)
|
// setup the billing client in main activity (to handle cases where the verification purchase flow may have been interrupted)
|
||||||
billingClient = BillingClient.newBuilder(this)
|
billingClient = BillingClient.newBuilder(this)
|
||||||
.setListener(new PurchasesUpdatedListener() {
|
.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() {
|
public boolean isDarkMode() {
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
return sp.getBoolean(PREFERENCE_KEY_DARK_MODE, false);
|
return sp.getBoolean(PREFERENCE_KEY_DARK_MODE, false);
|
||||||
|
@ -1143,8 +1159,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
checkPurchases();
|
checkPurchases();
|
||||||
checkWebSocketClient();
|
checkWebSocketClient();
|
||||||
|
updateMiniPlayerMargins();
|
||||||
enteringPIPMode = false;
|
enteringPIPMode = false;
|
||||||
|
|
||||||
applyNavbarSigninPadding();
|
applyNavbarSigninPadding();
|
||||||
|
@ -1221,6 +1240,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
|
||||||
if (!enteringPIPMode && !inPictureInPictureMode && appPlayer != null && !isBackgroundPlaybackEnabled()) {
|
if (!enteringPIPMode && !inPictureInPictureMode && appPlayer != null && !isBackgroundPlaybackEnabled()) {
|
||||||
appPlayer.setPlayWhenReady(false);
|
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 {
|
private class PlayerNotificationDescriptionAdapter implements PlayerNotificationManager.MediaDescriptionAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,9 +4,13 @@ import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
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.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
|
import androidx.preference.EditTextPreference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
|
@ -23,6 +27,15 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
setPreferencesFromResource(R.xml.settings, 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
|
@Override
|
||||||
|
|
|
@ -242,6 +242,7 @@
|
||||||
<string name="notifications">Notifications</string>
|
<string name="notifications">Notifications</string>
|
||||||
<string name="subscriptions">Subscriptions</string>
|
<string name="subscriptions">Subscriptions</string>
|
||||||
<string name="content_interests">Content Interests</string>
|
<string name="content_interests">Content Interests</string>
|
||||||
|
<string name="mini_player_bottom_spacing">Mini-player bottom spacing</string>
|
||||||
|
|
||||||
<string name="keep_sdk_in_background">Keep the LBRY service running in the background for improved wallet and network performance</string>
|
<string name="keep_sdk_in_background">Keep the LBRY service running in the background for improved wallet and network performance</string>
|
||||||
<string name="participate_in_data_network">Participate in the data network (requires app and background service restart)</string>
|
<string name="participate_in_data_network">Participate in the data network (requires app and background service restart)</string>
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
app:title="@string/show_url_suggestions"
|
app:title="@string/show_url_suggestions"
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:inputType="numberDecimal|numberSigned"
|
||||||
|
app:key="io.lbry.browser.preference.userinterface.MiniPlayerBottomMargin"
|
||||||
|
app:title="@string/mini_player_bottom_spacing"
|
||||||
|
app:defaultValue="4"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|
Loading…
Reference in a new issue