Skip to content

Commit

Permalink
Remove dot-nomedia creation, (by @gsantner, closes #229)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Mar 20, 2023
1 parent 77433f4 commit 6a9f63a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@
import net.gsantner.memetastic.service.AssetUpdater;
import net.gsantner.memetastic.service.ThumbnailCleanupTask;
import net.gsantner.memetastic.util.AppSettings;
import net.gsantner.memetastic.util.MediaStoreUtils;
import net.gsantner.memetastic.util.PermissionChecker;
import net.gsantner.opoc.preference.GsPreferenceFragmentCompat;
import net.gsantner.opoc.preference.SharedPreferencesPropertyBackend;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import butterknife.BindView;
Expand Down Expand Up @@ -173,27 +170,6 @@ public Boolean onPreferenceClicked(Preference preference, String key, int keyRes
getActivity().finish();
}
}
if (eq(key, R.string.pref_key__is_show_in_gallery)) {
boolean showInGallery = settings.getDefaultPreferences().getBoolean(key, true);
File memeDirectory = AssetUpdater.getMemesDir(AppSettings.get());
File noMediaFile = new File(memeDirectory, ".nomedia");
if (showInGallery) {
noMediaFile.delete();
MediaStoreUtils.deleteFileFromMediaStore(context, noMediaFile);
File[] files = memeDirectory.listFiles();
for (int i = 0; i < files.length; i++) {
MediaStoreUtils.deleteFileFromMediaStore(context, files[i]);
MediaStoreUtils.addFileToMediaStore(context, files[i]);
}
} else {
try {
noMediaFile.createNewFile();
MediaStoreUtils.addFileToMediaStore(context, noMediaFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#########################################################*/
package net.gsantner.memetastic.data;

import static net.gsantner.memetastic.data.MemeConfig.Point;

import android.graphics.Bitmap;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import static net.gsantner.memetastic.data.MemeConfig.Point;

/**
* A memes settings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ private void loadConfigFromFolder(File folder, List<MemeData.Font> dataFonts, Li

MemeConfig.Config conf = null;
File configFile = new File(folder, MEMETASTIC_CONFIG_FILE);
FileUtils.touch(new File(folder, ".nomedia"));
if (configFile.exists()) {
try {
String contents = FileUtils.readTextFile(configFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Snackbar showSnackBar(@StringRes int stringResId, boolean showLong) {

public void showSnackBar(@StringRes int stringResId, boolean showLong, @StringRes int actionResId, View.OnClickListener listener) {
Snackbar.make(_activity.findViewById(android.R.id.content), stringResId,
showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT)
showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT)
.setAction(actionResId, listener)
.show();
}
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/net/gsantner/opoc/util/ContextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#########################################################*/
package net.gsantner.opoc.util;

import static android.content.Context.VIBRATOR_SERVICE;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.graphics.Bitmap.CompressFormat;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -88,10 +91,6 @@
import java.util.List;
import java.util.Locale;

import static android.content.Context.VIBRATOR_SERVICE;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.graphics.Bitmap.CompressFormat;

@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "ObsoleteSdkInt", "deprecation", "SpellCheckingInspection", "TryFinallyCanBeTryWithResources", "UnusedAssignment", "UnusedReturnValue"})
public class ContextUtils {
//
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/net/gsantner/opoc/util/ShareUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#########################################################*/
package net.gsantner.opoc.util;

import static android.app.Activity.RESULT_OK;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
Expand Down Expand Up @@ -70,8 +72,6 @@
import java.util.Locale;
import java.util.Random;

import static android.app.Activity.RESULT_OK;

/**
* A utility class to ease information sharing on Android.
* Also allows to parse/fetch information out of shared information.
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings-not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="pref_key__is_migrated" translatable="false">pref_key__is_migrated</string>
<string name="pref_key__download_assets_try" translatable="false">pref_key__download_assets_try</string>
<string name="pref_key__memelist_view_type" translatable="false">pref_key__memelist_view_type</string>
<string name="pref_key__is_show_in_gallery" translatable="false">pref_key__is_show_in_gallery</string>
<string name="pref_key__hidden_meme_templates" translatable="false">pref_key__hidden_meme_templates</string>

<string name="pref_key__more_info__settings" translatable="false">pref_key__more_info__settings</string>
Expand Down
28 changes: 16 additions & 12 deletions app/src/main/res/xml/preferences_master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/settings">


<PreferenceScreen android:icon="@drawable/ic_grid_on_black_24dp" android:title="@string/overview" android:summary="@string/main_view">


<PreferenceScreen
android:icon="@drawable/ic_grid_on_black_24dp"
android:summary="@string/main_view"
android:title="@string/overview">

<ListPreference
android:defaultValue="0"
Expand Down Expand Up @@ -76,7 +79,10 @@

</PreferenceScreen>

<PreferenceScreen android:title="@string/editor" android:summary="@string/edit_picture" android:icon="@drawable/ic_edit_black_24dp">
<PreferenceScreen
android:icon="@drawable/ic_edit_black_24dp"
android:summary="@string/edit_picture"
android:title="@string/editor">

<CheckBoxPreference
android:defaultValue="false"
Expand All @@ -103,13 +109,11 @@
</PreferenceScreen>


<PreferenceScreen android:title="@string/picture_viewer" android:icon="@drawable/ic_image_black_24dp" android:summary="@string/pictures_shown_in_gallery_and_this_app">
<CheckBoxPreference
android:defaultValue="true"
android:icon="@drawable/ic_photo_library_black_24dp"
android:key="@string/pref_key__is_show_in_gallery"
android:title="@string/show_in_device_gallery" />

<PreferenceScreen
android:icon="@drawable/ic_image_black_24dp"
android:summary="@string/pictures_shown_in_gallery_and_this_app"
android:title="@string/picture_viewer">

<Preference
android:icon="@drawable/ic_delete_sweep_black_24dp"
android:key="@string/pref_key__cleanup_thumbnails"
Expand All @@ -133,4 +137,4 @@
android:title="@string/language" />
</PreferenceCategory>

</PreferenceScreen>
</PreferenceScreen>

0 comments on commit 6a9f63a

Please sign in to comment.