Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Replace "Blacklist" with "Blocklist" #831

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/assets/phonograph-changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ <h3>Version 0.16.0</h3>
However, if you want to support the development and receive updates through the Play Store,
consider buying Phonograph Pro. Thank you!
<li><b>NEW:</b> Full Android Oreo support</li>
<li><b>NEW:</b> Folder blacklist</li>
<li><b>NEW:</b> Folder blocklist</li>
<li><b>NEW:</b> Manually set custom artist images</li>
<li><b>NEW:</b> Tap to hide toolbar in now playing screen</li>
<li><b>NEW:</b> Option to select the old notification style</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @author Aidan Follestad (afollestad), modified by Karim Abou Zeid
*/
public class BlacklistFolderChooserDialog extends DialogFragment implements MaterialDialog.ListCallback {
public class BlocklistFolderChooserDialog extends DialogFragment implements MaterialDialog.ListCallback {

private File parentFolder;
private File[] parentContents;
Expand Down Expand Up @@ -65,8 +65,8 @@ private File[] listFiles() {
return null;
}

public static BlacklistFolderChooserDialog create() {
return new BlacklistFolderChooserDialog();
public static BlocklistFolderChooserDialog create() {
return new BlocklistFolderChooserDialog();
}

@NonNull
Expand Down Expand Up @@ -99,7 +99,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
.autoDismiss(false)
.onPositive((dialog, which) -> {
dismiss();
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
callback.onFolderSelection(BlocklistFolderChooserDialog.this, parentFolder);
})
.onNegative((materialDialog, dialogAction) -> dismiss())
.positiveText(R.string.add_action)
Expand Down Expand Up @@ -147,7 +147,7 @@ public void setCallback(FolderCallback callback) {
}

public interface FolderCallback {
void onFolderSelection(@NonNull BlacklistFolderChooserDialog dialog, @NonNull File folder);
void onFolderSelection(@NonNull BlocklistFolderChooserDialog dialog, @NonNull File folder);
}

private static class FolderSorter implements Comparator<File> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import androidx.annotation.Nullable;

import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.provider.BlacklistStore;
import com.kabouzeid.gramophone.provider.BlocklistStore;
import com.kabouzeid.gramophone.util.PreferenceUtil;

import java.util.ArrayList;
Expand Down Expand Up @@ -110,11 +110,11 @@ public static Cursor makeSongCursor(@NonNull final Context context, @Nullable St
selection = BASE_SELECTION;
}

// Blacklist
List<String> paths = BlacklistStore.getInstance(context).getPaths();
// Blocklist
List<String> paths = BlocklistStore.getInstance(context).getPaths();
if (!paths.isEmpty()) {
selection = generateBlacklistSelection(selection, paths.size());
selectionValues = addBlacklistSelectionValues(selectionValues, paths);
selection = generateBlocklistSelection(selection, paths.size());
selectionValues = addBlocklistSelectionValues(selectionValues, paths);
}

try {
Expand All @@ -125,7 +125,7 @@ public static Cursor makeSongCursor(@NonNull final Context context, @Nullable St
}
}

private static String generateBlacklistSelection(String selection, int pathCount) {
private static String generateBlocklistSelection(String selection, int pathCount) {
String newSelection = selection != null && !selection.trim().equals("") ? selection + " AND " : "";
newSelection += AudioColumns.DATA + " NOT LIKE ?";
for (int i = 0; i < pathCount - 1; i++) {
Expand All @@ -134,7 +134,7 @@ private static String generateBlacklistSelection(String selection, int pathCount
return newSelection;
}

private static String[] addBlacklistSelectionValues(String[] selectionValues, List<String> paths) {
private static String[] addBlocklistSelectionValues(String[] selectionValues, List<String> paths) {
if (selectionValues == null) selectionValues = new String[0];
String[] newSelectionValues = new String[selectionValues.length + paths.size()];
System.arraycopy(selectionValues, 0, newSelectionValues, 0, selectionValues.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class BlacklistPreference extends ATEDialogPreference {
public BlacklistPreference(Context context) {
public class BlocklistPreference extends ATEDialogPreference {
public BlocklistPreference(Context context) {
super(context);
}

public BlacklistPreference(Context context, AttributeSet attrs) {
public BlocklistPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}

public BlacklistPreference(Context context, AttributeSet attrs, int defStyleAttr) {
public BlocklistPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

public BlacklistPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
public BlocklistPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import com.afollestad.materialdialogs.MaterialDialog;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.dialogs.BlacklistFolderChooserDialog;
import com.kabouzeid.gramophone.provider.BlacklistStore;
import com.kabouzeid.gramophone.dialogs.BlocklistFolderChooserDialog;
import com.kabouzeid.gramophone.provider.BlocklistStore;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -18,61 +18,61 @@
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class BlacklistPreferenceDialog extends DialogFragment implements BlacklistFolderChooserDialog.FolderCallback {
public class BlocklistPreferenceDialog extends DialogFragment implements BlocklistFolderChooserDialog.FolderCallback {

private List<String> paths;

public static BlacklistPreferenceDialog newInstance() {
return new BlacklistPreferenceDialog();
public static BlocklistPreferenceDialog newInstance() {
return new BlocklistPreferenceDialog();
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BlacklistFolderChooserDialog blacklistFolderChooserDialog = (BlacklistFolderChooserDialog) getChildFragmentManager().findFragmentByTag("FOLDER_CHOOSER");
if (blacklistFolderChooserDialog != null) {
blacklistFolderChooserDialog.setCallback(this);
BlocklistFolderChooserDialog blocklistFolderChooserDialog = (BlocklistFolderChooserDialog) getChildFragmentManager().findFragmentByTag("FOLDER_CHOOSER");
if (blocklistFolderChooserDialog != null) {
blocklistFolderChooserDialog.setCallback(this);
}

refreshBlacklistData();
refreshBlocklistData();
return new MaterialDialog.Builder(getContext())
.title(R.string.blacklist)
.title(R.string.blocklist)
.positiveText(android.R.string.ok)
.neutralText(R.string.clear_action)
.negativeText(R.string.add_action)
.items(paths)
.autoDismiss(false)
.itemsCallback((materialDialog, view, i, charSequence) -> new MaterialDialog.Builder(getContext())
.title(R.string.remove_from_blacklist)
.content(Html.fromHtml(getString(R.string.do_you_want_to_remove_from_the_blacklist, charSequence)))
.title(R.string.remove_from_blocklist)
.content(Html.fromHtml(getString(R.string.do_you_want_to_remove_from_the_blocklist, charSequence)))
.positiveText(R.string.remove_action)
.negativeText(android.R.string.cancel)
.onPositive((materialDialog12, dialogAction) -> {
BlacklistStore.getInstance(getContext()).removePath(new File(charSequence.toString()));
refreshBlacklistData();
BlocklistStore.getInstance(getContext()).removePath(new File(charSequence.toString()));
refreshBlocklistData();
}).show())
// clear
.onNeutral((materialDialog, dialogAction) -> new MaterialDialog.Builder(getContext())
.title(R.string.clear_blacklist)
.content(R.string.do_you_want_to_clear_the_blacklist)
.title(R.string.clear_blocklist)
.content(R.string.do_you_want_to_clear_the_blocklist)
.positiveText(R.string.clear_action)
.negativeText(android.R.string.cancel)
.onPositive((materialDialog1, dialogAction1) -> {
BlacklistStore.getInstance(getContext()).clear();
refreshBlacklistData();
BlocklistStore.getInstance(getContext()).clear();
refreshBlocklistData();
}).show())
// add
.onNegative((materialDialog, dialogAction) -> {
BlacklistFolderChooserDialog dialog = BlacklistFolderChooserDialog.create();
dialog.setCallback(BlacklistPreferenceDialog.this);
BlocklistFolderChooserDialog dialog = BlocklistFolderChooserDialog.create();
dialog.setCallback(BlocklistPreferenceDialog.this);
dialog.show(getChildFragmentManager(), "FOLDER_CHOOSER");
})
.onPositive((materialDialog, dialogAction) -> dismiss())
.build();
}

private void refreshBlacklistData() {
paths = BlacklistStore.getInstance(getContext()).getPaths();
private void refreshBlocklistData() {
paths = BlocklistStore.getInstance(getContext()).getPaths();

MaterialDialog dialog = (MaterialDialog) getDialog();
if (dialog != null) {
Expand All @@ -83,8 +83,8 @@ private void refreshBlacklistData() {
}

@Override
public void onFolderSelection(@NonNull BlacklistFolderChooserDialog folderChooserDialog, @NonNull File file) {
BlacklistStore.getInstance(getContext()).addPath(file);
refreshBlacklistData();
public void onFolderSelection(@NonNull BlocklistFolderChooserDialog folderChooserDialog, @NonNull File file) {
BlocklistStore.getInstance(getContext()).addPath(file);
refreshBlocklistData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,46 @@
import java.util.ArrayList;
import java.util.List;

public class BlacklistStore extends SQLiteOpenHelper {
private static BlacklistStore sInstance = null;
public static final String DATABASE_NAME = "blacklist.db";
public class BlocklistStore extends SQLiteOpenHelper {
private static BlocklistStore sInstance = null;
public static final String DATABASE_NAME = "blocklist.db";
private static final int VERSION = 1;
private Context context;

public BlacklistStore(final Context context) {
public BlocklistStore(final Context context) {
super(context, DATABASE_NAME, null, VERSION);
this.context = context;
}

@Override
public void onCreate(@NonNull final SQLiteDatabase db) {
db.execSQL("CREATE TABLE IF NOT EXISTS " + BlacklistStoreColumns.NAME + " ("
+ BlacklistStoreColumns.PATH + " STRING NOT NULL);");
db.execSQL("CREATE TABLE IF NOT EXISTS " + BlocklistStoreColumns.NAME + " ("
+ BlocklistStoreColumns.PATH + " STRING NOT NULL);");
}

@Override
public void onUpgrade(@NonNull final SQLiteDatabase db, final int oldVersion, final int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + BlacklistStoreColumns.NAME);
db.execSQL("DROP TABLE IF EXISTS " + BlocklistStoreColumns.NAME);
onCreate(db);
}

@Override
public void onDowngrade(@NonNull SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + BlacklistStoreColumns.NAME);
db.execSQL("DROP TABLE IF EXISTS " + BlocklistStoreColumns.NAME);
onCreate(db);
}

@NonNull
public static synchronized BlacklistStore getInstance(@NonNull final Context context) {
public static synchronized BlocklistStore getInstance(@NonNull final Context context) {
if (sInstance == null) {
sInstance = new BlacklistStore(context.getApplicationContext());
if (!PreferenceUtil.getInstance(context).initializedBlacklist()) {
// blacklisted by default
sInstance = new BlocklistStore(context.getApplicationContext());
if (!PreferenceUtil.getInstance(context).initializedBlocklist()) {
// blocklisted by default
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS));
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS));
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES));

PreferenceUtil.getInstance(context).setInitializedBlacklist();
PreferenceUtil.getInstance(context).setInitializedBlocklist();
}
}
return sInstance;
Expand All @@ -79,8 +79,8 @@ private void addPathImpl(File file) {
try {
// add the entry
final ContentValues values = new ContentValues(1);
values.put(BlacklistStoreColumns.PATH, path);
database.insert(BlacklistStoreColumns.NAME, null, values);
values.put(BlocklistStoreColumns.PATH, path);
database.insert(BlocklistStoreColumns.NAME, null, values);

database.setTransactionSuccessful();
} finally {
Expand All @@ -95,9 +95,9 @@ public boolean contains(File file) {
String path = FileUtil.safeGetCanonicalPath(file);

final SQLiteDatabase database = getReadableDatabase();
Cursor cursor = database.query(BlacklistStoreColumns.NAME,
new String[]{BlacklistStoreColumns.PATH},
BlacklistStoreColumns.PATH + "=?",
Cursor cursor = database.query(BlocklistStoreColumns.NAME,
new String[]{BlocklistStoreColumns.PATH},
BlocklistStoreColumns.PATH + "=?",
new String[]{path},
null, null, null, null);

Expand All @@ -112,16 +112,16 @@ public void removePath(File file) {
final SQLiteDatabase database = getWritableDatabase();
String path = FileUtil.safeGetCanonicalPath(file);

database.delete(BlacklistStoreColumns.NAME,
BlacklistStoreColumns.PATH + "=?",
database.delete(BlocklistStoreColumns.NAME,
BlocklistStoreColumns.PATH + "=?",
new String[]{path});

notifyMediaStoreChanged();
}

public void clear() {
final SQLiteDatabase database = getWritableDatabase();
database.delete(BlacklistStoreColumns.NAME, null, null);
database.delete(BlocklistStoreColumns.NAME, null, null);

notifyMediaStoreChanged();
}
Expand All @@ -132,8 +132,8 @@ private void notifyMediaStoreChanged() {

@NonNull
public List<String> getPaths() {
Cursor cursor = getReadableDatabase().query(BlacklistStoreColumns.NAME,
new String[]{BlacklistStoreColumns.PATH},
Cursor cursor = getReadableDatabase().query(BlocklistStoreColumns.NAME,
new String[]{BlocklistStoreColumns.PATH},
null, null, null, null, null);

List<String> paths = new ArrayList<>();
Expand All @@ -148,8 +148,8 @@ public List<String> getPaths() {
return paths;
}

public interface BlacklistStoreColumns {
String NAME = "blacklist";
public interface BlocklistStoreColumns {
String NAME = "blocklist";

String PATH = "path";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager;
import com.kabouzeid.gramophone.misc.NonProAllowedColors;
import com.kabouzeid.gramophone.preferences.BlacklistPreference;
import com.kabouzeid.gramophone.preferences.BlacklistPreferenceDialog;
import com.kabouzeid.gramophone.preferences.BlocklistPreference;
import com.kabouzeid.gramophone.preferences.BlocklistPreferenceDialog;
import com.kabouzeid.gramophone.preferences.LibraryPreference;
import com.kabouzeid.gramophone.preferences.LibraryPreferenceDialog;
import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreference;
Expand Down Expand Up @@ -158,16 +158,16 @@ public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.pref_lockscreen);
addPreferencesFromResource(R.xml.pref_audio);
addPreferencesFromResource(R.xml.pref_playlists);
addPreferencesFromResource(R.xml.pref_blacklist);
addPreferencesFromResource(R.xml.pref_blocklist);
}

@Nullable
@Override
public DialogFragment onCreatePreferenceDialog(Preference preference) {
if (preference instanceof NowPlayingScreenPreference) {
return NowPlayingScreenPreferenceDialog.newInstance();
} else if (preference instanceof BlacklistPreference) {
return BlacklistPreferenceDialog.newInstance();
} else if (preference instanceof BlocklistPreference) {
return BlocklistPreferenceDialog.newInstance();
} else if (preference instanceof LibraryPreference) {
return LibraryPreferenceDialog.newInstance();
}
Expand Down
Loading