mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
Added sync settings in preferences
This commit is contained in:
parent
26ba9467f1
commit
a68f45e7dc
8 changed files with 114 additions and 35 deletions
|
|
@ -226,6 +226,13 @@ public class MainActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
public void goFromSettingsToSync(Bundle bundle) {
|
||||
setBottomNavigationBarVisibility(false);
|
||||
setBottomSheetVisibility(false);
|
||||
|
||||
navController.navigate(R.id.action_settingsFragment_to_syncFragment, bundle);
|
||||
}
|
||||
|
||||
public void goToHome() {
|
||||
bottomNavigationView.setVisibility(View.VISIBLE);
|
||||
|
||||
|
|
|
|||
|
|
@ -98,19 +98,6 @@ public class HomeFragment extends Fragment {
|
|||
bundle.putString(Song.IS_FAVORITE, Song.IS_FAVORITE);
|
||||
activity.navController.navigate(R.id.action_homeFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
||||
bind.syncMusicButton.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
|
||||
builder.setMessage("Force reload your entire music library")
|
||||
.setTitle("Force sync")
|
||||
.setNegativeButton(R.string.ignore, null)
|
||||
.setPositiveButton("Sync", (dialog, id) -> {
|
||||
PreferenceUtil.getInstance(requireContext()).setSync(false);
|
||||
PreferenceUtil.getInstance(requireContext()).setSongGenreSync(false);
|
||||
activity.goToSync();
|
||||
})
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
private void initDiscoverSongSlideView() {
|
||||
|
|
|
|||
|
|
@ -122,12 +122,8 @@ public class LibraryFragment extends Fragment {
|
|||
builder.setMessage("Sync song's genres otherwise nothing will be shown in each genre category")
|
||||
.setTitle("Song's genres not synchronized")
|
||||
.setNegativeButton(R.string.ignore, null)
|
||||
.setPositiveButton("Sync", (dialog, id) -> syncSongsPerGenre())
|
||||
.setPositiveButton("Sync", (dialog, id) -> activity.goToSync())
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void syncSongsPerGenre() {
|
||||
activity.goToSync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,35 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.helper.ThemeHelper;
|
||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.SyncUtil;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
private static final String TAG = "SettingsFragment";
|
||||
|
||||
private MainActivity activity;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
activity = (MainActivity) getActivity();
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.global_preferences, rootKey);
|
||||
|
|
@ -24,5 +43,37 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
Preference music_sync_button = findPreference(getString(R.string.music_sync));
|
||||
music_sync_button.setOnPreferenceClickListener(preference -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
|
||||
builder.setMessage("Force reload your entire music library")
|
||||
.setTitle("Force sync")
|
||||
.setNegativeButton(R.string.ignore, null)
|
||||
.setPositiveButton("Sync", (dialog, id) -> {
|
||||
PreferenceUtil.getInstance(requireContext()).setSync(false);
|
||||
PreferenceUtil.getInstance(requireContext()).setSongGenreSync(false);
|
||||
|
||||
Bundle bundle = SyncUtil.getSyncBundle(true, true, true, true, true, false);
|
||||
activity.goFromSettingsToSync(bundle);
|
||||
})
|
||||
.show();
|
||||
return true;
|
||||
});
|
||||
|
||||
Preference cross_sync_button = findPreference(getString(R.string.genres_music_cross_sync));
|
||||
cross_sync_button.setOnPreferenceClickListener(preference -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
|
||||
builder.setMessage("Sync song's genres otherwise nothing will be shown in each genre category")
|
||||
.setTitle("Song's genres not synchronized")
|
||||
.setNegativeButton(R.string.ignore, null)
|
||||
.setPositiveButton("Sync", (dialog, id) -> {
|
||||
Bundle bundle = SyncUtil.getSyncBundle(false, false, true, false, false, true);
|
||||
activity.goFromSettingsToSync(bundle);
|
||||
})
|
||||
.show();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue