diff --git a/app/src/main/java/io/github/gsantner/memetastic/App.java b/app/src/main/java/io/github/gsantner/memetastic/App.java index e57340827..8712bd1c0 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/App.java +++ b/app/src/main/java/io/github/gsantner/memetastic/App.java @@ -18,7 +18,7 @@ import io.github.gsantner.memetastic.data.MemeFont; import io.github.gsantner.memetastic.data.MemeLibConfig; import io.github.gsantner.memetastic.util.AppSettings; -import io.github.gsantner.memetastic.util.Helpers; +import io.github.gsantner.memetastic.util.ContextUtils; /** * The apps application object @@ -96,7 +96,7 @@ public MemeCategory getMemeCategory(String category) { } public void shareBitmapToOtherApp(Bitmap bitmap, Activity activity) { - File imageFile = Helpers.get().saveBitmapToFile(getCacheDir().getAbsolutePath(), getString(R.string.cached_picture_filename), bitmap); + File imageFile = ContextUtils.get().writeImageToFileJpeg(getCacheDir().getAbsolutePath(), getString(R.string.cached_picture_filename), bitmap); if (imageFile != null) { Uri imageUri = FileProvider.getUriForFile(this, getString(R.string.app_fileprovider), imageFile); if (imageUri != null) { diff --git a/app/src/main/java/io/github/gsantner/memetastic/activity/AboutActivity.java b/app/src/main/java/io/github/gsantner/memetastic/activity/AboutActivity.java index a5e7d622c..1b7313c2a 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/activity/AboutActivity.java +++ b/app/src/main/java/io/github/gsantner/memetastic/activity/AboutActivity.java @@ -17,9 +17,9 @@ import butterknife.ButterKnife; import butterknife.OnClick; import io.github.gsantner.memetastic.R; -import io.github.gsantner.memetastic.util.Helpers; -import io.github.gsantner.memetastic.util.HelpersA; -import io.github.gsantner.opoc.util.SimpleMarkdownParser; +import io.github.gsantner.memetastic.util.ContextUtils; +import io.github.gsantner.memetastic.util.ActivityUtils; +import net.gsantner.opoc.util.SimpleMarkdownParser; @SuppressWarnings("unused") public class AboutActivity extends AppCompatActivity { @@ -60,18 +60,18 @@ protected void onCreate(Bundle savedInstanceState) { textLicense.setMovementMethod(LinkMovementMethod.getInstance()); textContributors.setMovementMethod(LinkMovementMethod.getInstance()); - Helpers helpers = Helpers.get(); - helpers.setHtmlToTextView(textTeam, - Helpers.get().loadMarkdownForTextViewFromRaw(R.raw.maintainers, "") + ContextUtils cu = ContextUtils.get(); + cu.setHtmlToTextView(textTeam, + ContextUtils.get().loadMarkdownForTextViewFromRaw(R.raw.maintainers, "") ); - helpers.setHtmlToTextView(textContributors, - Helpers.get().loadMarkdownForTextViewFromRaw(R.raw.contributors, "") + cu.setHtmlToTextView(textContributors, + cu.loadMarkdownForTextViewFromRaw(R.raw.contributors, "") ); // License text MUST be shown try { - helpers.setHtmlToTextView(textLicense, + cu.setHtmlToTextView(textLicense, SimpleMarkdownParser.get().parse(getString(R.string.copyright_license_text_official).replace("\n", " \n"), "", SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW).getHtml() ); @@ -96,7 +96,7 @@ public void onButtonClicked(View v) { switch (v.getId()) { case R.id.about__activity__text_app_version: { try { - HelpersA.get(this).showDialogWithHtmlTextView(R.string.changelog, new SimpleMarkdownParser().parse( + ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.changelog, new SimpleMarkdownParser().parse( getResources().openRawResource(R.raw.changelog), "", SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW, SimpleMarkdownParser.FILTER_CHANGELOG ).getHtml() @@ -107,12 +107,12 @@ public void onButtonClicked(View v) { break; } case R.id.about__activity__button_app_license: { - HelpersA.get(this).showDialogWithHtmlTextView(R.string.licenses, Helpers.get().readTextfileFromRawRes(R.raw.license, "", ""), false, null); + ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.licenses, ContextUtils.get().readTextfileFromRawRes(R.raw.license, "", ""), false, null); break; } case R.id.about__activity__button_third_party_licenses: { try { - HelpersA.get(this).showDialogWithHtmlTextView(R.string.licenses, new SimpleMarkdownParser().parse( + ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.licenses, new SimpleMarkdownParser().parse( getResources().openRawResource(R.raw.licenses_3rd_party), "", SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW).getHtml() ); diff --git a/app/src/main/java/io/github/gsantner/memetastic/activity/ImageViewActivity.java b/app/src/main/java/io/github/gsantner/memetastic/activity/ImageViewActivity.java index d7c06cfda..87ee9638d 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/activity/ImageViewActivity.java +++ b/app/src/main/java/io/github/gsantner/memetastic/activity/ImageViewActivity.java @@ -18,7 +18,7 @@ import io.github.gsantner.memetastic.App; import io.github.gsantner.memetastic.R; import io.github.gsantner.memetastic.util.AppSettings; -import io.github.gsantner.memetastic.util.Helpers; +import io.github.gsantner.memetastic.util.ContextUtils; public class ImageViewActivity extends AppCompatActivity { //######################## @@ -49,7 +49,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.imageview__activity); ButterKnife.bind(this); app = (App) getApplication(); - //Helpers.get().enableImmersiveMode(getWindow().getDecorView()); + //ContextUtils.get().enableImmersiveMode(getWindow().getDecorView()); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { @@ -66,7 +66,7 @@ protected void onCreate(Bundle savedInstanceState) { ".thumbnails" + File.separator + getString(R.string.app_name) + "_"); } - mBitmap = Helpers.get().loadImageFromFilesystem(imagePath); + mBitmap = ContextUtils.get().loadImageFromFilesystem(imagePath); expandedImageView.setImageBitmap(mBitmap); } diff --git a/app/src/main/java/io/github/gsantner/memetastic/activity/MainActivity.java b/app/src/main/java/io/github/gsantner/memetastic/activity/MainActivity.java index 8cf0834de..ca0840824 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/activity/MainActivity.java +++ b/app/src/main/java/io/github/gsantner/memetastic/activity/MainActivity.java @@ -48,10 +48,10 @@ import io.github.gsantner.memetastic.ui.GridDecoration; import io.github.gsantner.memetastic.ui.GridRecycleAdapter; import io.github.gsantner.memetastic.util.AppSettings; -import io.github.gsantner.memetastic.util.Helpers; -import io.github.gsantner.memetastic.util.HelpersA; +import io.github.gsantner.memetastic.util.ContextUtils; +import io.github.gsantner.memetastic.util.ActivityUtils; import io.github.gsantner.memetastic.util.ThumbnailCleanupTask; -import io.github.gsantner.opoc.util.SimpleMarkdownParser; +import net.gsantner.opoc.util.SimpleMarkdownParser; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, TabLayout.OnTabSelectedListener { @@ -89,7 +89,7 @@ public class MainActivity extends AppCompatActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Helpers.get().setAppLanguage(AppSettings.get().getLanguage()); + ContextUtils.get().setAppLanguage(AppSettings.get().getLanguage()); if (AppSettings.get().isOverviewStatusBarHidden()) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } @@ -108,7 +108,7 @@ protected void onCreate(Bundle savedInstanceState) { tabLayout.setOnTabSelectedListener(this); // Setup Floating Action Button - int gridColumns = Helpers.get().isInPortraitMode() + int gridColumns = ContextUtils.get().isInPortraitMode() ? app.settings.getGridColumnCountPortrait() : app.settings.getGridColumnCountLandscape(); @@ -141,12 +141,12 @@ protected void onCreate(Bundle savedInstanceState) { String html = mdParser.parse(getString(R.string.copyright_license_text_official).replace("\n", " \n"), "").getHtml(); html += mdParser.parse(getResources().openRawResource(R.raw.licenses_3rd_party), "").getHtml(); - HelpersA.get(this).showDialogWithHtmlTextView(R.string.licenses, html); + ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.licenses, html); } else if (app.settings.isAppCurrentVersionFirstStart()) { mdParser.parse( getResources().openRawResource(R.raw.changelog), "", SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW, SimpleMarkdownParser.FILTER_CHANGELOG); - HelpersA.get(this).showDialogWithHtmlTextView(R.string.changelog, mdParser.getHtml()); + ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.changelog, mdParser.getHtml()); } } catch (IOException e) { @@ -222,11 +222,11 @@ public boolean handleBarClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_about: { - HelpersA.get(this).animateToActivity(AboutActivity.class, false, null); + ActivityUtils.get(this).animateToActivity(AboutActivity.class, false, null); return true; } case R.id.action_settings: { - HelpersA.get(this).animateToActivity(SettingsActivity.class, false, SettingsActivity.ACTIVITY_ID); + ActivityUtils.get(this).animateToActivity(SettingsActivity.class, false, SettingsActivity.ACTIVITY_ID); return true; } case R.id.action_exit: { @@ -242,16 +242,16 @@ public boolean handleBarClick(MenuItem item) { return true; } case R.id.action_donate_bitcoin: { - Helpers.get().showDonateBitcoinRequest(R.string.donate__bitcoin_id, R.string.donate__bitcoin_amount, R.string.donate__bitcoin_message, R.string.donate__bitcoin_url); + ContextUtils.get().showDonateBitcoinRequest(R.string.donate__bitcoin_id, R.string.donate__bitcoin_amount, R.string.donate__bitcoin_message, R.string.donate__bitcoin_url); return true; } case R.id.action_homepage_code: { - Helpers.get().openWebpageInExternalBrowser(getString(R.string.app_www_source)); + ContextUtils.get().openWebpageInExternalBrowser(getString(R.string.app_www_source)); return true; } case R.id.action_picture_from_gallery: { Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); - HelpersA.get(this).animateToActivity(i, false, REQUEST_LOAD_GALLERY_IMAGE); + ActivityUtils.get(this).animateToActivity(i, false, REQUEST_LOAD_GALLERY_IMAGE); return true; } case R.id.action_picture_from_camera: { @@ -273,7 +273,7 @@ public boolean handleBarClick(MenuItem item) { } case R.id.action_mode_saved: { emptylistText.setText(R.string.main__nodata__saved); - File filePath = Helpers.get().getPicturesMemetasticFolder(); + File filePath = ContextUtils.get().getPicturesMemetasticFolder(); filePath.mkdirs(); memeOriginObject = new MemeOriginStorage(filePath, getString(R.string.dot_thumbnails)); toolbar.setTitle(R.string.main__mode__saved); @@ -322,7 +322,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { onImageTemplateWasChosen(picturePath, false); } } else { - HelpersA.get(this).showSnackBar(R.string.main__error_no_picture_selected, false); + ActivityUtils.get(this).showSnackBar(R.string.main__error_no_picture_selected, false); } } @@ -330,7 +330,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { onImageTemplateWasChosen(cameraPictureFilepath, false); } else { - HelpersA.get(this).showSnackBar(R.string.main__error_no_picture_selected, false); + ActivityUtils.get(this).showSnackBar(R.string.main__error_no_picture_selected, false); } } } @@ -354,7 +354,7 @@ public void showCameraDialog() { cameraPictureFilepath = photoFile.getAbsolutePath(); } catch (IOException ex) { - HelpersA.get(this).showSnackBar(R.string.main__error_camera_cannot_start, false); + ActivityUtils.get(this).showSnackBar(R.string.main__error_camera_cannot_start, false); } // Continue only if the File was successfully created @@ -365,7 +365,7 @@ public void showCameraDialog() { } else { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } - HelpersA.get(this).animateToActivity(takePictureIntent, false, REQUEST_TAKE_CAMERA_PICTURE); + ActivityUtils.get(this).animateToActivity(takePictureIntent, false, REQUEST_TAKE_CAMERA_PICTURE); } } } @@ -374,7 +374,7 @@ public void onImageTemplateWasChosen(String filePath, boolean bIsAsset) { final Intent intent = new Intent(this, MemeCreateActivity.class); intent.putExtra(MemeCreateActivity.EXTRA_IMAGE_PATH, filePath); intent.putExtra(MemeCreateActivity.ASSET_IMAGE, bIsAsset); - HelpersA.get(this).animateToActivity(intent, false, MemeCreateActivity.RESULT_MEME_EDITING_FINISHED); + ActivityUtils.get(this).animateToActivity(intent, false, MemeCreateActivity.RESULT_MEME_EDITING_FINISHED); } public void openImageViewActivityWithImage(String imagePath) { @@ -383,7 +383,7 @@ public void openImageViewActivityWithImage(String imagePath) { Intent intent = new Intent(this, ImageViewActivity.class); intent.putExtra(IMAGE_PATH, imagePath); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); - HelpersA.get(this).animateToActivity(intent, false, null); + ActivityUtils.get(this).animateToActivity(intent, false, null); } @Override @@ -399,7 +399,7 @@ public void onTabSelected(TabLayout.Tab tab) { // Custom tab if (tabPos >= 0 && tabPos == MemeLibConfig.MEME_CATEGORIES.ALL.length) { - File customFolder = Helpers.get().getPicturesMemetasticTemplatesCustomFolder(); + File customFolder = ContextUtils.get().getPicturesMemetasticTemplatesCustomFolder(); emptylistText.setText(getString(R.string.main__nodata__custom_templates, getString(R.string.custom_templates_visual))); memeOriginObject = new MemeOriginStorage(customFolder, getString(R.string.dot_thumbnails)); ((MemeOriginStorage) memeOriginObject).setIsTemplate(true); diff --git a/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java b/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java index 0d92350dc..cb4fd81c7 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java +++ b/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java @@ -60,8 +60,8 @@ import io.github.gsantner.memetastic.ui.FontAdapter; import io.github.gsantner.memetastic.util.AndroidBug5497Workaround; import io.github.gsantner.memetastic.util.AppSettings; -import io.github.gsantner.memetastic.util.Helpers; -import io.github.gsantner.memetastic.util.HelpersA; +import io.github.gsantner.memetastic.util.ContextUtils; +import io.github.gsantner.memetastic.util.ActivityUtils; import uz.shift.colorpicker.LineColorPicker; /** @@ -245,7 +245,7 @@ private Bitmap extractBitmapFromIntent(final Intent intent) { //Scale big images down to avoid "out of memory" InputStream inputStream = getAssets().open(imagePath); BitmapFactory.decodeStream(inputStream, new Rect(0, 0, 0, 0), options); - options.inSampleSize = Helpers.get().calculateInSampleSize(options, app.settings.getRenderQualityReal()); + options.inSampleSize = ContextUtils.get().calculateInSampleSize(options, app.settings.getRenderQualityReal()); options.inJustDecodeBounds = false; inputStream.close(); inputStream = getAssets().open(imagePath); @@ -257,7 +257,7 @@ private Bitmap extractBitmapFromIntent(final Intent intent) { } else { //Scale big images down to avoid "out of memory" BitmapFactory.decodeFile(imagePath, options); - options.inSampleSize = Helpers.get().calculateInSampleSize(options, app.settings.getRenderQualityReal()); + options.inSampleSize = ContextUtils.get().calculateInSampleSize(options, app.settings.getRenderQualityReal()); options.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeFile(imagePath, options); } @@ -308,7 +308,7 @@ public boolean onImageTouched(View view) { textEditBottomCaption.clearFocus(); textEditTopCaption.clearFocus(); imageEditView.requestFocus(); - HelpersA.get(this).hideSoftKeyboard(); + ActivityUtils.get(this).hideSoftKeyboard(); if (moarControlsContainerVisible) { toggleMoarControls(true, false); } @@ -357,7 +357,7 @@ private boolean saveMemeToFilesystem(boolean showDialog) { } String filename = String.format(Locale.getDefault(), "%s_%d.jpg", getString(R.string.app_name), memeSavetime); - boolean wasSaved = Helpers.get().saveBitmapToFile(filepath, filename, lastBitmap) != null && Helpers.get().saveBitmapToFile(thumbnailPath, filename, Helpers.get().createThumbnail(lastBitmap)) != null; + boolean wasSaved = ContextUtils.get().writeImageToFileJpeg(filepath, filename, lastBitmap) != null && ContextUtils.get().writeImageToFileJpeg(thumbnailPath, filename, ContextUtils.get().scaleBitmap(lastBitmap)) != null; if (wasSaved && showDialog) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); @@ -411,7 +411,7 @@ public void toggleMoarControls(boolean forceVisibile, boolean visible) { @OnClick(R.id.fab) public void onFloatingButtonClicked(View view) { toggleMoarControls(false, false); - HelpersA.get(this).hideSoftKeyboard(); + ActivityUtils.get(this).hideSoftKeyboard(); View focusedView = this.getCurrentFocus(); if (focusedView != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); @@ -536,7 +536,7 @@ public Bitmap drawMultilineTextToBitmap(Context c, MemeSetting memeSetting) { bitmap = workBmp; } - float scale = Helpers.get().getScalingFactorInPixelsForWritingOnPicture(bitmap.getWidth(), bitmap.getHeight()); + float scale = ContextUtils.get().getScalingFactorInPixelsForWritingOnPicture(bitmap.getWidth(), bitmap.getHeight()); float borderScale = scale * memeSetting.getCaptionTop().getFontSize() / MemeLibConfig.FONT_SIZES.DEFAULT; Bitmap.Config bitmapConfig = bitmap.getConfig(); // set default bitmap config if none diff --git a/app/src/main/java/io/github/gsantner/memetastic/activity/SplashActivity.java b/app/src/main/java/io/github/gsantner/memetastic/activity/SplashActivity.java index 86cee087b..0f10fa21c 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/activity/SplashActivity.java +++ b/app/src/main/java/io/github/gsantner/memetastic/activity/SplashActivity.java @@ -15,8 +15,8 @@ import io.github.gsantner.memetastic.BuildConfig; import io.github.gsantner.memetastic.R; -import io.github.gsantner.memetastic.util.Helpers; -import io.github.gsantner.memetastic.util.HelpersA; +import io.github.gsantner.memetastic.util.ContextUtils; +import io.github.gsantner.memetastic.util.ActivityUtils; public class SplashActivity extends AppCompatActivity { @@ -70,8 +70,8 @@ public void onRequestPermissionsResult(int req, String[] perm, int[] grantResult private void startMemeCreator(boolean skipDelay) { // Create MemeCreator directories int delay = (skipDelay || BuildConfig.DEBUG) ? 1000 : getResources().getInteger(R.integer.splash_delay); - new File(Helpers.get().getPicturesMemetasticFolder(), getString(R.string.dot_thumbnails)).mkdirs(); - new File(Helpers.get().getPicturesMemetasticTemplatesCustomFolder(), getString(R.string.dot_thumbnails)).mkdirs(); + new File(ContextUtils.get().getPicturesMemetasticFolder(), getString(R.string.dot_thumbnails)).mkdirs(); + new File(ContextUtils.get().getPicturesMemetasticTemplatesCustomFolder(), getString(R.string.dot_thumbnails)).mkdirs(); // Start activity and exit splash @@ -80,7 +80,7 @@ private void startMemeCreator(boolean skipDelay) { handler.postDelayed(new Runnable() { @Override public void run() { - HelpersA.get(SplashActivity.this).animateToActivity(MainActivity.class, true, null); + ActivityUtils.get(SplashActivity.this).animateToActivity(MainActivity.class, true, null); } }, delay); } diff --git a/app/src/main/java/io/github/gsantner/memetastic/ui/GridRecycleAdapter.java b/app/src/main/java/io/github/gsantner/memetastic/ui/GridRecycleAdapter.java index 68acb85de..6d9db68de 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/ui/GridRecycleAdapter.java +++ b/app/src/main/java/io/github/gsantner/memetastic/ui/GridRecycleAdapter.java @@ -20,7 +20,7 @@ import io.github.gsantner.memetastic.data.MemeOriginAssets; import io.github.gsantner.memetastic.data.MemeOriginFavorite; import io.github.gsantner.memetastic.data.MemeOriginInterface; -import io.github.gsantner.memetastic.util.Helpers; +import io.github.gsantner.memetastic.util.ContextUtils; import io.github.gsantner.memetastic.util.ImageLoaderTask; /** @@ -114,7 +114,7 @@ public void onClick(View v) { } private void tintFavourite(ImageView iv, boolean isFav) { - Helpers.get().setDrawableWithColorToImageView(iv, + ContextUtils.get().setDrawableWithColorToImageView(iv, isFav ? R.drawable.ic_star_black_32dp : R.drawable.ic_star_border_black_32dp, isFav ? R.color.comic_yellow : R.color.comic_blue); } diff --git a/app/src/main/java/io/github/gsantner/memetastic/util/ActivityUtils.java b/app/src/main/java/io/github/gsantner/memetastic/util/ActivityUtils.java new file mode 100644 index 000000000..2cf651394 --- /dev/null +++ b/app/src/main/java/io/github/gsantner/memetastic/util/ActivityUtils.java @@ -0,0 +1,13 @@ +package io.github.gsantner.memetastic.util; + +import android.app.Activity; + +public class ActivityUtils extends net.gsantner.opoc.util.ActivityUtils { + private ActivityUtils(Activity activity) { + super(activity); + } + + public static ActivityUtils get(Activity activity) { + return new ActivityUtils(activity); + } +} diff --git a/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java b/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java index 5815f6e44..184b37c9e 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java +++ b/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java @@ -9,7 +9,7 @@ import io.github.gsantner.memetastic.App; import io.github.gsantner.memetastic.BuildConfig; import io.github.gsantner.memetastic.R; -import io.github.gsantner.opoc.util.AppSettingsBase; +import net.gsantner.opoc.util.AppSettingsBase; public class AppSettings extends AppSettingsBase { private static final int MAX_FAVS = 50; @@ -146,7 +146,7 @@ public int getLastSelectedTab() { public int getGridColumnCountPortrait() { int count = getInt(R.string.pref_key__grid_column_count_portrait, -1); if (count == -1) { - count = 3 + (int) Math.max(0, 0.5 * (Helpers.get().getEstimatedScreenSizeInches() - 5.0)); + count = 3 + (int) Math.max(0, 0.5 * (ContextUtils.get().getEstimatedScreenSizeInches() - 5.0)); setGridColumnCountPortrait(count); } return count; diff --git a/app/src/main/java/io/github/gsantner/memetastic/util/Helpers.java b/app/src/main/java/io/github/gsantner/memetastic/util/ContextUtils.java similarity index 53% rename from app/src/main/java/io/github/gsantner/memetastic/util/Helpers.java rename to app/src/main/java/io/github/gsantner/memetastic/util/ContextUtils.java index 7add41588..a6c370447 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/util/Helpers.java +++ b/app/src/main/java/io/github/gsantner/memetastic/util/ContextUtils.java @@ -21,75 +21,25 @@ import io.github.gsantner.memetastic.R; import io.github.gsantner.memetastic.data.MemeLibConfig; -public class Helpers extends io.github.gsantner.opoc.util.Helpers { - public Helpers(Context context) { +public class ContextUtils extends net.gsantner.opoc.util.ContextUtils { + public ContextUtils(Context context) { super(context); } - public static Helpers get() { - return new Helpers(App.get()); + public static ContextUtils get() { + return new ContextUtils(App.get()); } - /** - * Calculates the scaling factor so the bitmap is maximal as big as the reqSize - * - * @param options Bitmap-options that contain the current dimensions of the bitmap - * @param reqSize the maximal size of the Bitmap - * @return the scaling factor that needs to be applied to the bitmap - */ - public int calculateInSampleSize(BitmapFactory.Options options, int reqSize) { - // Raw height and width of image - final int height = options.outHeight; - final int width = options.outWidth; - int inSampleSize = 1; - - if (Math.max(height, width) > reqSize) { - inSampleSize = Math.round(1f * Math.max(height, width) / reqSize); - } - //Log.i("MEME", "scaleBy::" + inSampleSize); - return inSampleSize; - } - - public Bitmap createThumbnail(Bitmap bitmap) { - int thumbnailSize = 300; - int picSize = Math.min(bitmap.getHeight(), bitmap.getWidth()); - float scale = 1.f * thumbnailSize / picSize; - Matrix matrix = new Matrix(); - matrix.postScale(scale, scale); - return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); - } - public File saveBitmapToFile(String pathToFile, String filename, Bitmap bitmapToSave) { - new File(pathToFile).mkdirs(); - File imageFile = new File(pathToFile, filename); - - FileOutputStream stream = null; - try { - stream = new FileOutputStream(imageFile); // overwrites this image every time - bitmapToSave.compress(Bitmap.CompressFormat.JPEG, 95, stream); - return imageFile; - } catch (FileNotFoundException ignored) { - } finally { - try { - if (stream != null) - stream.close(); - } catch (IOException ignored) { - } - } - return null; + public Bitmap scaleBitmap(Bitmap bitmap) { + return scaleBitmap(bitmap, 300); } public Bitmap loadImageFromFilesystem(String imagePath) { - BitmapFactory.Options options = new BitmapFactory.Options(); - options.inJustDecodeBounds = true; - BitmapFactory.decodeFile(imagePath, options); - options.inSampleSize = calculateInSampleSize(options, MemeLibConfig.MEME_FULLSCREEN_MAX_IMAGESIZE); - options.inJustDecodeBounds = false; - return BitmapFactory.decodeFile(imagePath, options); + return loadImageFromFilesystem(imagePath, MemeLibConfig.MEME_FULLSCREEN_MAX_IMAGESIZE); } - public int getImmersiveUiVisibility() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { int statusBarFlag = View.SYSTEM_UI_FLAG_FULLSCREEN; @@ -137,11 +87,6 @@ public float getScalingFactorInPixelsForWritingOnPicture(int w, int h) { return (size + addl) / (fontScaler); } - public static void setDrawableWithColorToImageView(ImageView imageView, @DrawableRes int drawableResId, @ColorRes int colorResId) { - imageView.setImageResource(drawableResId); - imageView.setColorFilter(ContextCompat.getColor(imageView.getContext(), colorResId)); - } - public File getPicturesMemetasticFolder() { return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), _context.getString(R.string.app_name)); } diff --git a/app/src/main/java/io/github/gsantner/memetastic/util/HelpersA.java b/app/src/main/java/io/github/gsantner/memetastic/util/HelpersA.java deleted file mode 100644 index 24def07a2..000000000 --- a/app/src/main/java/io/github/gsantner/memetastic/util/HelpersA.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.github.gsantner.memetastic.util; - -import android.app.Activity; - -public class HelpersA extends io.github.gsantner.opoc.util.HelpersA { - private HelpersA(Activity activity) { - super(activity); - } - - public static HelpersA get(Activity activity) { - return new HelpersA(activity); - } -} diff --git a/app/src/main/java/io/github/gsantner/memetastic/util/ImageLoaderTask.java b/app/src/main/java/io/github/gsantner/memetastic/util/ImageLoaderTask.java index d1d626c73..fef7e7857 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/util/ImageLoaderTask.java +++ b/app/src/main/java/io/github/gsantner/memetastic/util/ImageLoaderTask.java @@ -41,9 +41,9 @@ private Bitmap loadStorageImage(String imagePath) { BitmapFactory.decodeFile(imagePath, options); if (_isThumbnail) - options.inSampleSize = Helpers.get().calculateInSampleSize(options, _sampleSizeThumbnails); + options.inSampleSize = ContextUtils.get().calculateInSampleSize(options, _sampleSizeThumbnails); else - options.inSampleSize = Helpers.get().calculateInSampleSize(options, MemeLibConfig.MEME_FULLSCREEN_MAX_IMAGESIZE); + options.inSampleSize = ContextUtils.get().calculateInSampleSize(options, MemeLibConfig.MEME_FULLSCREEN_MAX_IMAGESIZE); options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(imagePath, options); } @@ -56,9 +56,9 @@ private Bitmap loadAssetImage(String imagePath) { inputStream = _assetManager.open(imagePath); BitmapFactory.decodeStream(inputStream, new Rect(0, 0, 0, 0), options); if (_isThumbnail) { - options.inSampleSize = Helpers.get().calculateInSampleSize(options, _sampleSizeThumbnails); + options.inSampleSize = ContextUtils.get().calculateInSampleSize(options, _sampleSizeThumbnails); } else { - options.inSampleSize = Helpers.get().calculateInSampleSize(options, MemeLibConfig.MEME_FULLSCREEN_MAX_IMAGESIZE); + options.inSampleSize = ContextUtils.get().calculateInSampleSize(options, MemeLibConfig.MEME_FULLSCREEN_MAX_IMAGESIZE); } if (inputStream != null) { inputStream.close(); diff --git a/app/src/main/java/io/github/gsantner/memetastic/util/ThumbnailCleanupTask.java b/app/src/main/java/io/github/gsantner/memetastic/util/ThumbnailCleanupTask.java index b63bef6d7..6799c5cb3 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/util/ThumbnailCleanupTask.java +++ b/app/src/main/java/io/github/gsantner/memetastic/util/ThumbnailCleanupTask.java @@ -21,14 +21,14 @@ public ThumbnailCleanupTask(Context context) { } public void run() { - Helpers helpers = Helpers.get(); + ContextUtils cu = ContextUtils.get(); - File picPath = helpers.getPicturesMemetasticFolder(); + File picPath = cu.getPicturesMemetasticFolder(); File thumbPath = new File(picPath, strres_dotThumbnails); cleanupThumbnails(picPath, thumbPath); - picPath = helpers.getPicturesMemetasticTemplatesCustomFolder(); + picPath = cu.getPicturesMemetasticTemplatesCustomFolder(); thumbPath = new File(picPath, strres_dotThumbnails); cleanupThumbnails(picPath, thumbPath); } @@ -60,11 +60,11 @@ private void cleanupThumbnails(File picPath, File thumbPath) { MemeOriginStorage memeOriginStorage = new MemeOriginStorage(picPath, strres_dotThumbnails); Map missing = memeOriginStorage.getMissingThumbnails(); for (Map.Entry entry : missing.entrySet()) { - Bitmap bitmap = Helpers.get().loadImageFromFilesystem(entry.getKey()); + Bitmap bitmap = ContextUtils.get().loadImageFromFilesystem(entry.getKey()); if (bitmap != null) { File thumbFp = new File(entry.getValue()); - bitmap = Helpers.get().createThumbnail(bitmap); - Helpers.get().saveBitmapToFile(thumbFp.getParent(), thumbFp.getName(), bitmap); + bitmap = ContextUtils.get().scaleBitmap(bitmap); + ContextUtils.get().writeImageToFileJpeg(thumbFp.getParent(), thumbFp.getName(), bitmap); } } } diff --git a/app/src/main/java/io/github/gsantner/opoc/ui/LanguagePreference.java b/app/src/main/java/net/gsantner/opoc/ui/LanguagePreference.java similarity index 81% rename from app/src/main/java/io/github/gsantner/opoc/ui/LanguagePreference.java rename to app/src/main/java/net/gsantner/opoc/ui/LanguagePreference.java index b5e2ef89b..cfe4de86e 100644 --- a/app/src/main/java/io/github/gsantner/opoc/ui/LanguagePreference.java +++ b/app/src/main/java/net/gsantner/opoc/ui/LanguagePreference.java @@ -14,7 +14,7 @@ * A ListPreference that displays a list of available languages * Requires: * The BuildConfig field "APPLICATION_LANGUAGES" which is a array of all available languages - * opoc/Helpers + * opoc/ContextUtils * BuildConfig field can be defined by using the method below buildConfigField("String[]", "APPLICATION_LANGUAGES", '{' + getUsedAndroidLanguages().collect {"\"${it}\""}.join(",") + '}') @@ -39,15 +39,13 @@ static String[] getUsedAndroidLanguages() { * Summary: Change language of this app. Restart app for changes to take effect * Define element in Preferences-XML: - - */ -package io.github.gsantner.opoc.ui; +package net.gsantner.opoc.ui; import android.annotation.TargetApi; import android.content.Context; @@ -55,18 +53,25 @@ static String[] getUsedAndroidLanguages() { import android.preference.ListPreference; import android.util.AttributeSet; +import net.gsantner.opoc.util.ContextUtils; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; -import io.github.gsantner.opoc.util.Helpers; - /** * A {@link android.preference.ListPreference} that displays a list of languages to select from */ -@SuppressWarnings({"unused", "SpellCheckingInspection"}) +@SuppressWarnings({"unused", "SpellCheckingInspection", "WeakerAccess"}) public class LanguagePreference extends ListPreference { + private static final String SYSTEM_LANGUAGE_CODE = ""; + public static String SYSTEM_LANGUAGE_NAME = "System"; + + // The language of res/values/ -> (usually English) + public static String DEFAULT_LANGUAGE_NAME = "English"; + public static String DEFAULT_LANGUAGE_CODE = "en"; + public LanguagePreference(Context context) { super(context); init(context, null); @@ -93,19 +98,21 @@ public LanguagePreference(Context context, AttributeSet attrs, int defStyleAttr, protected boolean callChangeListener(Object newValue) { if (newValue instanceof String) { // Does not apply to existing UI, use recreate() - new Helpers(getContext()).setAppLanguage((String) newValue); + new ContextUtils(getContext()).setAppLanguage((String) newValue); } return super.callChangeListener(newValue); } private void init(Context context, AttributeSet attrs) { + setDefaultValue(SYSTEM_LANGUAGE_CODE); + // Fetch readable details - Helpers helpers = new Helpers(context); + ContextUtils contextUtils = new ContextUtils(context); List languages = new ArrayList<>(); - Object bcof = helpers.getBuildConfigValue("APPLICATION_LANGUAGES"); + Object bcof = contextUtils.getBuildConfigValue("APPLICATION_LANGUAGES"); if (bcof instanceof String[]) { for (String langId : (String[]) bcof) { - Locale locale = helpers.getLocaleByAndroidCode(langId); + Locale locale = contextUtils.getLocaleByAndroidCode(langId); languages.add(summarizeLocale(locale) + ";" + langId); } } @@ -120,10 +127,10 @@ private void init(Context context, AttributeSet attrs) { entries[i + 2] = languages.get(i).split(";")[0]; entryval[i + 2] = languages.get(i).split(";")[1]; } - entries[0] = "System"; - entryval[0] = ""; - entries[1] = "English"; - entryval[1] = "en"; + entries[0] = SYSTEM_LANGUAGE_NAME; + entryval[0] = SYSTEM_LANGUAGE_CODE; + entries[1] = DEFAULT_LANGUAGE_NAME; + entryval[1] = DEFAULT_LANGUAGE_CODE; setEntries(entries); setEntryValues(entryval); @@ -143,7 +150,7 @@ private String summarizeLocale(Locale locale) { // Add current language to summary @Override public CharSequence getSummary() { - Locale locale = new Helpers(getContext()).getLocaleByAndroidCode(getValue()); + Locale locale = new ContextUtils(getContext()).getLocaleByAndroidCode(getValue()); return super.getSummary() + "\n\n" + summarizeLocale(locale); } } diff --git a/app/src/main/java/io/github/gsantner/opoc/util/HelpersA.java b/app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java similarity index 84% rename from app/src/main/java/io/github/gsantner/opoc/util/HelpersA.java rename to app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java index 95ac1ca62..9d5850d74 100644 --- a/app/src/main/java/io/github/gsantner/opoc/util/HelpersA.java +++ b/app/src/main/java/net/gsantner/opoc/util/ActivityUtils.java @@ -9,7 +9,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/ * ---------------------------------------------------------------------------- */ -package io.github.gsantner.opoc.util; +package net.gsantner.opoc.util; import android.app.Activity; import android.content.DialogInterface; @@ -22,17 +22,18 @@ import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.util.TypedValue; +import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; @SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection"}) -public class HelpersA extends Helpers { +public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils { //######################## //## Members, Constructors //######################## protected Activity _activity; - public HelpersA(final Activity activity) { + public ActivityUtils(final Activity activity) { super(activity); _activity = activity; } @@ -106,4 +107,18 @@ public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, b .setView(textView); dialog.show(); } + + // Toggle with no param, else set visibility according to first bool + public void toggleStatusbarVisibility(boolean... optionalForceVisible) { + WindowManager.LayoutParams attrs = _activity.getWindow().getAttributes(); + int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN; + if (optionalForceVisible.length == 0) { + attrs.flags ^= flag; + } else if (optionalForceVisible.length == 1 && optionalForceVisible[0]) { + attrs.flags &= ~flag; + } else { + attrs.flags |= flag; + } + _activity.getWindow().setAttributes(attrs); + } } diff --git a/app/src/main/java/io/github/gsantner/opoc/util/AppSettingsBase.java b/app/src/main/java/net/gsantner/opoc/util/AppSettingsBase.java similarity index 99% rename from app/src/main/java/io/github/gsantner/opoc/util/AppSettingsBase.java rename to app/src/main/java/net/gsantner/opoc/util/AppSettingsBase.java index 8a3477e7a..46c3b6ba5 100644 --- a/app/src/main/java/io/github/gsantner/opoc/util/AppSettingsBase.java +++ b/app/src/main/java/net/gsantner/opoc/util/AppSettingsBase.java @@ -11,8 +11,6 @@ */ /* - * Get updates: - * https://github.com/gsantner/onePieceOfCode/blob/master/java/AppSettingsBase.java * This is a wrapper for settings based on SharedPreferences * with keys in resources. Extend from this class and add * getters/setters for the app's settings. @@ -44,7 +42,7 @@ public static AppSettings get() { } */ -package io.github.gsantner.opoc.util; +package net.gsantner.opoc.util; import android.annotation.SuppressLint; import android.content.Context; @@ -73,9 +71,9 @@ public class AppSettingsBase { //######################## //## Members, Constructors //######################## - protected final Context _context; protected final SharedPreferences _prefApp; protected final String _prefAppName; + protected final Context _context; public AppSettingsBase(final Context context) { this(context, SHARED_PREF_APP); diff --git a/app/src/main/java/io/github/gsantner/opoc/util/Helpers.java b/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java similarity index 70% rename from app/src/main/java/io/github/gsantner/opoc/util/Helpers.java rename to app/src/main/java/net/gsantner/opoc/util/ContextUtils.java index 043797e60..b03b58686 100644 --- a/app/src/main/java/io/github/gsantner/opoc/util/Helpers.java +++ b/app/src/main/java/net/gsantner/opoc/util/ContextUtils.java @@ -9,7 +9,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/ * ---------------------------------------------------------------------------- */ -package io.github.gsantner.opoc.util; +package net.gsantner.opoc.util; import android.annotation.SuppressLint; import android.app.AlarmManager; @@ -22,16 +22,26 @@ import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Matrix; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.VectorDrawable; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; +import android.os.Build; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; +import android.support.annotation.Nullable; import android.support.annotation.RawRes; import android.support.annotation.StringRes; +import android.support.graphics.drawable.VectorDrawableCompat; import android.support.v4.content.ContextCompat; +import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.app.AlertDialog; import android.support.v7.widget.AppCompatButton; import android.text.Html; @@ -40,22 +50,31 @@ import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.DisplayMetrics; +import android.view.View; +import android.view.inputmethod.InputMethodManager; import android.webkit.WebView; +import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Locale; +import static android.graphics.Bitmap.CompressFormat; + @SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection", "deprecation"}) -public class Helpers { +public class ContextUtils { //######################## //## Members, Constructors //######################## protected Context _context; - public Helpers(Context context) { + public ContextUtils(Context context) { _context = context; } @@ -231,6 +250,14 @@ public boolean isConnectedToInternet() { return activeNetInfo != null && activeNetInfo.isConnectedOrConnecting(); } + public boolean isConnectedToInternet(@Nullable @StringRes Integer warnMessageStringRes) { + final boolean result = isConnectedToInternet(); + if (!result && warnMessageStringRes != null) + Toast.makeText(_context, _context.getString(warnMessageStringRes), Toast.LENGTH_SHORT).show(); + + return result; + } + public void restartApp(Class classToStartupWith) { Intent restartIntent = new Intent(_context, classToStartupWith); PendingIntent restartIntentP = PendingIntent.getActivity(_context, 555, @@ -317,4 +344,94 @@ public float px2dp(final float px) { public float dp2px(final float dp) { return dp * _context.getResources().getDisplayMetrics().density; } + + public void setViewVisible(View view, boolean visible) { + view.setVisibility(visible ? View.VISIBLE : View.GONE); + } + + public static void setDrawableWithColorToImageView(ImageView imageView, @DrawableRes int drawableResId, @ColorRes int colorResId) { + imageView.setImageResource(drawableResId); + imageView.setColorFilter(ContextCompat.getColor(imageView.getContext(), colorResId)); + } + + public Bitmap drawableToBitmap(Drawable drawable) { + Bitmap bitmap = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && (drawable instanceof VectorDrawable || drawable instanceof VectorDrawableCompat)) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + drawable = (DrawableCompat.wrap(drawable)).mutate(); + } + + bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), + drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + } else if (drawable instanceof BitmapDrawable) { + bitmap = ((BitmapDrawable) drawable).getBitmap(); + } + return bitmap; + } + + public Bitmap loadImageFromFilesystem(String imagePath, int maxDimen) { + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + BitmapFactory.decodeFile(imagePath, options); + options.inSampleSize = calculateInSampleSize(options, maxDimen); + options.inJustDecodeBounds = false; + return BitmapFactory.decodeFile(imagePath, options); + } + + /** + * Calculates the scaling factor so the bitmap is maximal as big as the maxDimen + * + * @param options Bitmap-options that contain the current dimensions of the bitmap + * @param maxDimen Max size of the Bitmap (width or height) + * @return the scaling factor that needs to be applied to the bitmap + */ + public int calculateInSampleSize(BitmapFactory.Options options, int maxDimen) { + // Raw height and width of image + int height = options.outHeight; + int width = options.outWidth; + int inSampleSize = 1; + + if (Math.max(height, width) > maxDimen) { + inSampleSize = Math.round(1f * Math.max(height, width) / maxDimen); + } + return inSampleSize; + } + + public Bitmap scaleBitmap(Bitmap bitmap, int maxDimen) { + int picSize = Math.min(bitmap.getHeight(), bitmap.getWidth()); + float scale = 1.f * maxDimen / picSize; + Matrix matrix = new Matrix(); + matrix.postScale(scale, scale); + return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); + } + + public File writeImageToFileJpeg(String path, String filename, Bitmap image) { + return writeImageToFile(path, filename, image, Bitmap.CompressFormat.JPEG, 95); + } + + public File writeImageToFile(String path, String filename, Bitmap image, CompressFormat format, int quality) { + File imageFile = new File(path); + if (imageFile.exists() || imageFile.mkdirs()) { + imageFile = new File(path, filename); + + FileOutputStream stream = null; + try { + stream = new FileOutputStream(imageFile); // overwrites this image every time + image.compress(format, quality, stream); + return imageFile; + } catch (FileNotFoundException ignored) { + } finally { + try { + if (stream != null) { + stream.close(); + } + } catch (IOException ignored) { + } + } + } + return null; + } } diff --git a/app/src/main/java/io/github/gsantner/opoc/util/SimpleMarkdownParser.java b/app/src/main/java/net/gsantner/opoc/util/SimpleMarkdownParser.java similarity index 96% rename from app/src/main/java/io/github/gsantner/opoc/util/SimpleMarkdownParser.java rename to app/src/main/java/net/gsantner/opoc/util/SimpleMarkdownParser.java index 0895f98d3..72a220bb7 100644 --- a/app/src/main/java/io/github/gsantner/opoc/util/SimpleMarkdownParser.java +++ b/app/src/main/java/net/gsantner/opoc/util/SimpleMarkdownParser.java @@ -14,7 +14,7 @@ * Get updates: * https://github.com/gsantner/onePieceOfCode/blob/master/java/SimpleMarkdownParser.java * Apply to TextView: - * See https://github.com/gsantner/onePieceOfCode/blob/master/android/Helpers.get().java + * See https://github.com/gsantner/onePieceOfCode/blob/master/android/ContextUtils.java * Parses most common markdown tags. Only inline tags are supported, multiline/block syntax * is not supported (citation, multiline code, ..). This is intended to stay as easy as possible. * @@ -27,7 +27,7 @@ * FILTER_WEB is intended to be used at engines understanding most common HTML tags. */ -package io.github.gsantner.opoc.util; +package net.gsantner.opoc.util; import java.io.BufferedReader; import java.io.FileInputStream; @@ -130,13 +130,13 @@ public String filter(String text) { //######################## //## Singleton //######################## - private static SimpleMarkdownParser instance; + private static SimpleMarkdownParser __instance; public static SimpleMarkdownParser get() { - if (instance == null) { - instance = new SimpleMarkdownParser(); + if (__instance == null) { + __instance = new SimpleMarkdownParser(); } - return instance; + return __instance; } //######################## @@ -152,8 +152,8 @@ public SimpleMarkdownParser() { //######################## //## Methods //######################## - public SimpleMarkdownParser setDefaultSmpFilter(SmpFilter _defaultSmpFilter) { - this._defaultSmpFilter = _defaultSmpFilter; + public SimpleMarkdownParser setDefaultSmpFilter(SmpFilter defaultSmpFilter) { + _defaultSmpFilter = defaultSmpFilter; return this; } diff --git a/app/src/main/res/xml/preferences_master.xml b/app/src/main/res/xml/preferences_master.xml index b24288896..53ae02d08 100644 --- a/app/src/main/res/xml/preferences_master.xml +++ b/app/src/main/res/xml/preferences_master.xml @@ -84,7 +84,7 @@ -