mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Add ability to open equalizer from SettingsFragment
This commit is contained in:
parent
1f50638a5e
commit
a024010fef
3 changed files with 38 additions and 2 deletions
|
|
@ -1,11 +1,20 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.media.audiofx.AudioEffect;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.activity.result.ActivityResult;
|
||||
import androidx.activity.result.ActivityResultCallback;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContract;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
|
@ -23,6 +32,21 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
private MainActivity activity;
|
||||
private SettingViewModel settingViewModel;
|
||||
|
||||
private ActivityResultLauncher<Intent> someActivityResultLauncher;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
someActivityResultLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() != Activity.RESULT_OK) {
|
||||
findPreference("equalizer").setSummary("No equalizer available");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
activity = (MainActivity) getActivity();
|
||||
|
|
@ -70,10 +94,16 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
@Override
|
||||
public void onSuccess(boolean isScanning, long count) {
|
||||
if (isScanning) getScanStatus();
|
||||
else
|
||||
findPreference("scan_library").setSummary("Scanning: counting " + count + " tracks");
|
||||
else findPreference("scan_library").setSummary("Scanning: counting " + count + " tracks");
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("equalizer").setOnPreferenceClickListener(preference -> {
|
||||
Intent intent = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
|
||||
someActivityResultLauncher.launch(intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.cappielloantonio.play.subsonic.models.Genre;
|
|||
import com.cappielloantonio.play.subsonic.models.SimilarArtistID3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MappingUtil {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@
|
|||
app:title="@string/theme_selection"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<Preference
|
||||
android:key="equalizer"
|
||||
android:title="Equalizer"
|
||||
app:summary="Adjust audio settings" />
|
||||
|
||||
<Preference
|
||||
android:key="scan_library"
|
||||
android:title="Scan library" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue