/** * Try to fetch string resource id from key * This only works if the key is only defined once and value=key */ protected int keyToStringResId(String keyAsString) { return _cu.getResId(ContextUtils.ResType.STRING, keyAsString); }
public static String mayUseTranslationServices(final RepositoryResources resources) { for (File file : resources.readme) { int i = FileUtils.fileContains(file, STR_TRANSLATION_SERVICES); if (i != -1) return STR_TRANSLATION_SERVICES[i]; } return ""; }
/** * Get a BuildConfig string value */ public String bcstr(String fieldName, String defaultValue) { Object field = getBuildConfigValue(fieldName); if (field != null && field instanceof String) { return (String) field; } return defaultValue; }
public void run() { // Returns a simple result, handleable without json parser {"key":"feediyujiq"} String ret = NetworkUtils.performCall(server + "/documents", NetworkUtils.POST, text); final String key = (ret.length() > 15) ? ret.split("\"")[3] : ""; handler.post(() -> callback.callback(!key.isEmpty(), server + "/" + key)); } }.start();
public static boolean downloadFile(final String url, final File out) { return downloadFile(url, out, null); }
private static String performCall(final URL url, final String method, final String data) { return performCall(url, method, data, null); }
public static boolean unzip(final File zipFile, final File destRootFolder, boolean flatten) { return unzip(zipFile, destRootFolder, flatten, null); }
/** * Check if this is a gplay build (requires BuildConfig field) */ public boolean isGooglePlayBuild() { return bcbool("IS_GPLAY_BUILD", true); }
/** * Share the given bitmap with given format * * @param bitmap Image * @param format A {@link Bitmap.CompressFormat}, supporting JPEG,PNG,WEBP * @return if success, true */ public boolean shareImage(Bitmap bitmap, Bitmap.CompressFormat format) { return shareImage(bitmap, format, 95, "SharedImage"); }
/** * Write the given {@link Bitmap} to {@code imageFile}, in {@link CompressFormat#JPEG} format */ public boolean writeImageToFileJpeg(File imageFile, Bitmap image) { return writeImageToFile(imageFile, image, Bitmap.CompressFormat.JPEG, 95); }
/** * See {@link #print(WebView, String) print method} */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) @SuppressWarnings("deprecation") public PrintJob createPdf(WebView webview, String jobName) { return print(webview, jobName); }
/** * Convert a {@link File} to an {@link Uri} * * @param file the file * @return Uri for this file */ public Uri getUriByFileProviderAuthority(File file) { return FileProvider.getUriForFile(_context, getFileProviderAuthority(), file); }
public static boolean downloadFile(final URL url, final File outFile, final Callback.a1<Float> progressCallback) { return downloadFile(url, outFile, null, progressCallback); }
public static String performCall(final String url, final JSONObject json) { return performCall(url, POST, json); }
/** * Get a BuildConfig bool value */ public Boolean bcbool(String fieldName, Boolean defaultValue) { Object field = getBuildConfigValue(fieldName); if (field != null && field instanceof Boolean) { return (Boolean) field; } return defaultValue; }
/** * Checks if all given (textual) ressource ids are available * * @param resType A {@link ResType} * @param resIdsTextual A (textual) identifier to be awaited at R.restype.resIdsTextual * @return True if all given ids are available */ public boolean areRessourcesAvailable(final ResType resType, final String... resIdsTextual) { for (String name : resIdsTextual) { if (getResId(resType, name) == 0) { return false; } } return true; }
public static ArrayList<File> searchAndroidResources(final RepositoryResources resources) { ArrayList<File> result = new ArrayList<>(); for (File file : resources.xml) if (FileUtils.fileContains(file, STR_STRING, STR_PLURALS) != -1) result.add(file); return result; }
/** * Check if this is a foss build (requires BuildConfig field) */ public boolean isFossBuild() { return bcbool("IS_FOSS_BUILD", false); }
/** * Get a BuildConfig string value */ public Integer bcint(String fieldName, int defaultValue) { Object field = getBuildConfigValue(fieldName); if (field != null && field instanceof Integer) { return (Integer) field; } return defaultValue; }