renamed music to media settings + some settings refactoring

This commit is contained in:
gdlbo
2022-07-09 19:48:06 +03:00
parent ba216cb06b
commit d3840bf9fd
12 changed files with 108 additions and 99 deletions
@@ -1,8 +1,6 @@
package ru.vtosters.lite.downloaders;
import static com.vtosters.lite.R.*;
import static com.vtosters.lite.R.string;
import static ru.vtosters.lite.downloaders.VideoDownloader.downloadVideo;
import static ru.vtosters.lite.utils.Globals.getIdentifier;
import static ru.vtosters.lite.utils.Globals.getString;
import android.app.DownloadManager;
import android.content.Context;
@@ -16,11 +14,11 @@ import com.vk.dto.stories.model.StoryEntry;
import java.util.List;
public class StoryDownloader{
public static void injectAction(AlertDialogs.b dialogBuilder, StoryEntry story) {
public static void injectAction(AlertDialogs.b dialogBuilder, StoryEntry story){
Context ctx = dialogBuilder.a().show().getContext();
dialogBuilder.a(string.download, () -> {
// if story is a pic
if (story.T1()) {
if(story.T1()){
List<ImageSize> imageSizes = story.E.Q.t1();
String url = imageSizes.get(imageSizes.size() - 1).url;
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
@@ -31,7 +29,7 @@ public class StoryDownloader{
return;
}
// if story is a video
if (story.M1() && story.F != null) {
if(story.M1() && story.F != null){
downloadVideo(story.F, ctx); // dead
}
});
@@ -6,10 +6,10 @@ import android.os.Bundle;
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
public class MusicFragment extends MaterialPreferenceToolbarFragment{
public class MediaFragment extends MaterialPreferenceToolbarFragment{
@Override
public void onCreate(Bundle bundle){
super.onCreate(bundle);
addPreferencesFromResource(getIdentifier("preferences_music", "xml"));
addPreferencesFromResource(getIdentifier("preferences_media", "xml"));
}
}
@@ -71,6 +71,7 @@ import ru.vtosters.lite.utils.VKUIwrapper;
public class VTSettings extends MaterialPreferenceToolbarFragment{
public static int hideitems = 0;
public static String getValAsString(String stringid, Boolean value){
if(disableSettingsSumms()) return null;
@@ -134,7 +135,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
String feedsumm = getValAsString("vtlfeedsumm", ads());
String docksumm = getDocksumm();
String musicsumm = getValAsString("vtlmusicsumm", isIntegrationEnabled());
String musicsumm = getValAsString("vtlmediasumm", isIntegrationEnabled());
String msgsumm = getValAsString("vtlmsgsumm", vkme());
String activitysumm = getValAsString("vtlactivitysumm", offline());
String themessumm = getValAsString("vtlthemessumm", navbar());
@@ -314,17 +315,16 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
context.startActivity(a2);
return false;
});
if(isValidSignature())
PreferencesUtil.addPreference(this, "", Globals.getString("vtlmusic"), musicsumm, !DoNotUseOldIcons() ? "ic_music_24" : "ic_music_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(MusicFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
}
PreferencesUtil.addPreference(this, "", Globals.getString("vtlmedia"), musicsumm, "ic_media_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(MediaFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
return false;
});
PreferencesUtil.addPreference(this, "", Globals.getString("vtlmessages"), msgsumm, !DoNotUseOldIcons() ? "ic_message_24" : "ic_message_outline_28", preference -> {
Context context = getContext();
Intent a2 = new Navigator(MessagesFragment.class).b(context);
@@ -365,7 +365,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{
return false;
});
if(milkshake()) {
if(milkshake()){
PreferencesUtil.addPreference(this, "", "Настроить Superapp", superapp, "ic_explore_outline_28", (preference) -> {
callEditorPopup();
return true;
@@ -200,7 +200,7 @@ public class Preferences{
}
public static boolean milkshake(){
return getBoolValue("milkshake", true);
return getBoolValue("milkshake", false);
}
public static boolean musicnewcatalog(){