Skip to content

Commit

Permalink
Add Uri-AbsolutePath converter for Android,
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 61a68df15246531a6539d59e30d753724d4eed55
Author: 孙娇 <[email protected]>
Date:   Fri Mar 29 11:44:50 2024 +0800

    Update files_page.dart

commit 1de022bc565841c986cceefe4536abc81021796c
Author: 孙娇 <[email protected]>
Date:   Fri Mar 29 11:43:01 2024 +0800

    完成

commit 142a65aaca86b9355d5a73cffdb32e4f8c2a4e6f
Author: 孙娇 <[email protected]>
Date:   Fri Mar 29 11:07:00 2024 +0800

    Update settings.gradle

commit 0c84db64a282ead743fdfc545bda49ad1b70dc97
Author: 孙娇 <[email protected]>
Date:   Fri Mar 29 10:50:48 2024 +0800

    Update MainActivity.kt
  • Loading branch information
sun-jiao committed Mar 29, 2024
1 parent 02b9e4f commit 3271361
Show file tree
Hide file tree
Showing 32 changed files with 167 additions and 39 deletions.
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

# Flut Renamer

**Flut Renamer** is a powerful yet easy-to-use tool designed to help users manage and rename files and directories. No more manually renaming one by one – our app offers various features including inserting text, inserting file metadata and Exif data, replacing text, deleting text, rearranging, and more, allowing you to quickly batch rename files according to your needs.
**Flut Renamer** is a powerful yet easy-to-use tool designed to help users manage and rename files and directories. No more manually renaming one by one – our app offers various features including inserting text, file metadata, and Exif data, replacing text, deleting text, rearranging, and more, allowing you to quickly batch rename files according to your needs.

"**Flut**" is derived from "**Flutter**", meaning the app is built using Flutter, but does not use the full name to avoid any possible trademark infringement. And "Flut" means flood in German, which implies that this app can batch rename files as fast as a flood.
"**Flut**" is derived from "**Flutter**," indicating that the app is built using the Flutter framework, but it does not use the full name to avoid any possible trademark infringement. Additionally, "Flut" means "flood" in German, which implies that this app can batch rename files as swiftly as a flood.

* Multiple renaming options: Easily achieve batch file renaming by inserting, replacing, deleting text, and rearranging.
* Insert file metadata and Exif data: Extract information from file metadata and Exif data and insert it into the file name.
* Insert file metadata and Exif data: Extract information from file metadata and Exif data to insert it into the file name.
* Completely open-source and free: Flut Renamer is entirely open-source and contains no advertisements or in-app purchases, allowing you to use it freely at any time.
* Cross-platform compatibility: Built on the Flutter framework, Flut Renamer can run on multiple operating systems, enabling you to use it anytime, anywhere.

## Install
### Android
<a href="https://play.google.com/store/apps/details?id=net.sunjiao.renamer"><img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" height=60px /></a>
Install from the Google Play Store or download the *.apk from [releases].

Install from Google Play Store or download *.apk from [releases].
Android provides drag-and-drop files as content URIs, which cannot be renamed, so we need to convert them to absolute paths.

Drag-and-dropped files from the [AOSP Files app](https://www.androidpolice.com/2017/03/22/android-o-feature-spotlight-downloads-app-now-files-new-features/) and [Files by Google](https://play.google.com/store/apps/details?id=com.google.android.apps.nbu.files) are not allowed to get an absolute path, so drag-and-drop from them is not supported.

Drag-and-drop works fine with Solid Explorer and OnePlus File Explorer.

### Linux
Download *.AppImage or *.tar.gz from [releases].
Download the *.AppImage or *.tar.gz from [releases].

For Arch Linux users, just run:
```shell
Expand All @@ -27,22 +31,22 @@ yay -S flut-renamer-bin # binary version
```

### Windows
Download *.exe from [releases].
Download the *.exe from [releases].

### macOS
Download *.dmg from [releases].
Download the *.dmg from [releases].

### iOS
Download *.ipa from [releases] and install by AltStore or other tools.
Download the *.ipa from [releases] and install it using AltStore or other tools.

In fact, I have no Apple development experience at all, and I don’t even know the Swift language. The iOS and macOS native code was completed with the following links as references: [Writing custom platform-specific code](https://docs.flutter.dev/platform-integration/platform-channels?tab=type-mappings-swift-tab#type-mappings-swift-tab), [Providing access to directories](https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories), [juanmartin/renamerApp-ios](https://github.com/juanmartin/renamerApp-ios). Therefore, if there are any errors in the swift code, please fell free to point them out by opening an issue or a pull request. I'll be very grateful to you.
In fact, I have no Apple development experience at all, and I don’t even know the Swift language. The iOS and macOS native code were completed with the following links as references: [Writing custom platform-specific code](https://docs.flutter.dev/platform-integration/platform-channels?tab=type-mappings-swift-tab#type-mappings-swift-tab), [Providing access to directories](https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories), [juanmartin/renamerApp-ios](https://github.com/juanmartin/renamerApp-ios). Therefore, if there are any errors in the Swift code, please feel free to point them out by opening an issue or a pull request. I'll be very grateful to you.

## todo:
- ~~Duplicate name check~~.(Done.)
- ~~Convert, including case convert, Chinese simp/trad/pinyin convert, Latin/Cyrillic script transliteration~~.(Done.)
- ~~Incremental renaming: for example, RenamerFile-1, RenamerFile-2, RenamerFile-3, RenamerFile-4, ...~~.(Done.)
- ~~Rules re-editing~~.(Done.)
- ~~Implement iOS renamer with specific code and Platform channel~~.(Done.)
- ~~Duplicate name check.~~ (Done.)
- ~~Convert, including case conversion, Chinese simp/trad/pinyin conversion, and Latin/Cyrillic script transliteration.~~ (Done.)
- ~~Incremental renaming: for example, RenamerFile-1, RenamerFile-2, RenamerFile-3, RenamerFile-4, ...~~ (Done.)
- ~~Rules re-editing.~~ (Done.)
- ~~Implement iOS renamer with specific code and Platform channel.~~ (Done.)

# Screenshots
## Desktop
Expand Down
49 changes: 49 additions & 0 deletions android/app/src/main/kotlin/net/sunjiao/renamer/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
package net.sunjiao.renamer

import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.provider.MediaStore
import android.util.Log
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel

class MainActivity: FlutterActivity() {
private val CHANNEL = "net.sunjiao.renamer/picker"

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
call, result ->
if (call.method == "getRealPathFromURI") {
val uriArg = call.argument<String>("uri")

getRealPathFromURI(this, Uri.parse(uriArg), result)
} else {
result.notImplemented()
}
}
}

private fun getRealPathFromURI(context: Context, contentUri: Uri, result: MethodChannel.Result) {
var cursor: Cursor? = null
try {
val proj = arrayOf(MediaStore.Images.Media.DATA)
cursor = context.contentResolver.query(contentUri, proj, null, null, null)
val columnIndex: Int? = cursor?.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
if (columnIndex == null) {
result.error("Cannot get column index", null, null)
return
}

cursor?.moveToFirst()
val absolute = cursor?.getString(columnIndex)
if (!absolute.isNullOrEmpty()) {
result.success(absolute)
return
}

result.error("Cannot get absolute path", null, null)
} catch (e: Exception) {
Log.e("net.sunjiao.renamer", "getRealPathFromURI Exception : $e")
result.error(e.message.toString(), e.localizedMessage, null)
} finally {
cursor?.close()
}
}
}
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.3.0' apply false
id "com.android.application" version '8.3.1' apply false
}

include ":app"
4 changes: 3 additions & 1 deletion lib/arb/intl_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"iosRemindTitle": "حول تحديد الملفات على iOS",
"iosRemindContent": "لتحديد الملفات على iOS، اختر أولاً مجلدًا يحتوي على الملفات الخاصة بك. ثم، في المجلد المحدد، حدد الملفات التي ترغب في إعادة تسميتها. بسبب قيود iOS، يتعين علينا اتباع هذين الخطوتين، مما يضمن الوصول الآمن إلى الملفات. دعنا نبدأ!",
"androidRemindTitle": "إعادة تسمية الدلائل",
"androidRemindContent": "باستخدام Flut Renamer ، يمكنك إعادة تسمية الملفات والمجلدات. اضغط مع الاستمرار على مجلد لتحديده ، ثم حدد 'الملفات والمجلدات' من الزر المنسدل في الزاوية اليسرى العليا لتمكين إعادة تسمية المجلد. لأسباب أمنية ، بعض المجلدات المحجوزة للنظام غير قابلة للتحديد.", "doNotRemindAgain": "لا تذكر مرة أخرى",
"androidRemindContent": "باستخدام Flut Renamer ، يمكنك إعادة تسمية الملفات والمجلدات. اضغط مع الاستمرار على مجلد لتحديده ، ثم حدد 'الملفات والمجلدات' من الزر المنسدل في الزاوية اليسرى العليا لتمكين إعادة تسمية المجلد. لأسباب أمنية ، بعض المجلدات المحجوزة للنظام غير قابلة للتحديد.",
"doNotRemindAgain": "لا تذكر مرة أخرى",
"rename": "إعادة التسمية",
"appInfo": "معلومات التطبيق",
"aboutContent": "هذا التطبيق مصمم لمساعدة المستخدمين في إعادة تسمية الملفات. تم تطويره باستخدام إطار العمل Flutter، لذا فهو متوافق أيضًا مع أنظمة التشغيل الأخرى. إنه مفتوح المصدر بالكامل، ويمكن مراجعته والمساهمة فيه.",
Expand Down Expand Up @@ -53,6 +54,7 @@
"addFiles": "الرجاء إضافة ملفات.",
"dragToAdd": "اسحب وأسقط الملفات للإضافة.",
"dropToAdd": "أفلت الملفات هنا للإضافة.",
"dragNotSupported": "بسبب قيود أمان النظام، لا يُدعم سحب وإسقاط الملفات من هذا التطبيق.",
"fileAlreadyExists": "اسم الملف موجود بالفعل",
"renameFailed": "فشلت عملية إعادة التسمية",
"rulesSequentially": "تُنفذ القواعد بترتيب متسلسل. انقر على قاعدة لتحريرها. اسحب زر \"=\" على اليسار واسحبه لترتيب القواعد.",
Expand Down
4 changes: 3 additions & 1 deletion lib/arb/intl_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"iosRemindTitle": "Dateiauswahl auf iOS",
"iosRemindContent": "Um Dateien auf iOS auszuwählen, wählen Sie zunächst einen Ordner aus, der Ihre Dateien enthält. Wählen Sie dann in dem ausgewählten Ordner die Dateien aus, die Sie umbenennen möchten. Aufgrund von iOS-Beschränkungen müssen wir diese beiden Schritte durchführen, um einen sicheren Dateizugriff zu gewährleisten. Lass uns anfangen!",
"androidRemindTitle": "Verzeichnis umbenennen",
"androidRemindContent": "Mit dem Flut Renamer können Sie nicht nur Dateien, sondern auch Verzeichnisse umbenennen. Drücken Sie lange auf ein Verzeichnis, um es auszuwählen, und wählen Sie dann 'Dateien & Verzeichnisse' aus dem Dropdown-Button in der oberen linken Ecke, um die Umbenennung von Verzeichnissen zu aktivieren. Aus Sicherheitsgründen sind einige systemreservierte Verzeichnisse nicht auswählbar.", "doNotRemindAgain": "Nicht mehr erinnern",
"androidRemindContent": "Mit dem Flut Renamer können Sie nicht nur Dateien, sondern auch Verzeichnisse umbenennen. Drücken Sie lange auf ein Verzeichnis, um es auszuwählen, und wählen Sie dann 'Dateien & Verzeichnisse' aus dem Dropdown-Button in der oberen linken Ecke, um die Umbenennung von Verzeichnissen zu aktivieren. Aus Sicherheitsgründen sind einige systemreservierte Verzeichnisse nicht auswählbar.",
"doNotRemindAgain": "Nicht mehr erinnern",
"rename": "Umbenennen",
"appInfo": "App-Information",
"aboutContent": "Diese App soll Benutzern beim Umbenennen von Dateien helfen. Sie wurde mit dem Flutter-Framework entwickelt und ist daher auch für andere Betriebssysteme geeignet. Sie ist vollständig Open Source und kann überprüft und verbessert werden.",
Expand Down Expand Up @@ -53,6 +54,7 @@
"addFiles": "Bitte fügen Sie Dateien hinzu.",
"dragToAdd": "Ziehen Sie Dateien hierhin, um sie hinzuzufügen.",
"dropToAdd": "Legen Sie Dateien hier ab, um sie hinzuzufügen.",
"dragNotSupported": "Aufgrund von Systemsicherheitsbeschränkungen wird das Ziehen und Ablegen von Dateien aus dieser App nicht unterstützt.",
"fileAlreadyExists": "Dateiname wird bereits verwendet",
"renameFailed": "Umbenennen fehlgeschlagen",
"rulesSequentially": "Regeln werden nacheinander ausgeführt. Klicken Sie auf eine Regel, um sie zu bearbeiten. Halten Sie die '='-Taste auf der linken Seite gedrückt und ziehen Sie sie, um die Regeln zu sortieren.",
Expand Down
1 change: 1 addition & 0 deletions lib/arb/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"addFiles": "Add files",
"dragToAdd": "Drag and drop to add files.",
"dropToAdd": "Drop to add files.",
"dragNotSupported": "Dur to system security restriction, drag-drop files from this app is not supported.",
"fileAlreadyExists": "Filename already used by another file",
"renameFailed": "Rename failed",
"rulesSequentially": "Rules are executed sequentially. Click a rule to edit it. Hold the '=' button on the left and drag it to sort rules.",
Expand Down
4 changes: 3 additions & 1 deletion lib/arb/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"iosRemindTitle": "Sobre la selección de archivos en iOS",
"iosRemindContent": "Para seleccionar archivos en iOS, primero elige una carpeta que contenga tus archivos. Luego, dentro de la carpeta seleccionada, elige los archivos que deseas renombrar. Debido a las limitaciones de iOS, debemos seguir estos dos pasos para garantizar el acceso seguro a los archivos. ¡Comencemos!",
"androidRemindTitle": "Renombrar directorios",
"androidRemindContent": "Con el Flut Renamer, puede cambiar el nombre no solo de los archivos, sino también de los directorios. Mantenga presionado un directorio para seleccionarlo y luego seleccione 'Archivos y directorios' en el botón desplegable de la esquina superior izquierda para habilitar el cambio de nombre de directorios. Por razones de seguridad, algunos directorios reservados por el sistema no se pueden seleccionar.", "doNotRemindAgain": "Aceptar, no volver a recordar",
"androidRemindContent": "Con el Flut Renamer, puede cambiar el nombre no solo de los archivos, sino también de los directorios. Mantenga presionado un directorio para seleccionarlo y luego seleccione 'Archivos y directorios' en el botón desplegable de la esquina superior izquierda para habilitar el cambio de nombre de directorios. Por razones de seguridad, algunos directorios reservados por el sistema no se pueden seleccionar.",
"doNotRemindAgain": "Aceptar, no volver a recordar",
"rename": "Renombrar",
"appInfo": "Información de la aplicación",
"aboutContent": "Esta aplicación está diseñada para ayudar a los usuarios a renombrar archivos. Está desarrollada con el framework Flutter, por lo que también es compatible con otros sistemas operativos. Es completamente de código abierto y puede ser revisada y contribuida por cualquiera.",
Expand Down Expand Up @@ -53,6 +54,7 @@
"addFiles": "Por favor, agrega archivos.",
"dragToAdd": "Arrastra y suelta archivos para agregarlos.",
"dropToAdd": "Suelta archivos aquí para agregarlos.",
"dragNotSupported": "Debido a restricciones de seguridad del sistema, no se admite arrastrar y soltar archivos desde esta aplicación.",
"fileAlreadyExists": "El nombre de archivo ya está en uso",
"renameFailed": "Error al renombrar",
"rulesSequentially": "Las reglas se ejecutan secuencialmente. Haga clic en una regla para editarla. Mantenga presionado el botón '=' a la izquierda y arrástrelo para ordenar las reglas.",
Expand Down
1 change: 1 addition & 0 deletions lib/arb/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"addFiles": "Veuillez ajouter des fichiers.",
"dragToAdd": "Glissez et déposez des fichiers pour les ajouter.",
"dropToAdd": "Déposez des fichiers ici.",
"dragNotSupported": "En raison des restrictions de sécurité du système, le glisser-déposer de fichiers depuis cette application n'est pas pris en charge.",
"fileAlreadyExists": "Le nom de fichier est déjà utilisé",
"renameFailed": "Échec du renommage",
"rulesSequentially": "Les règles sont exécutées séquentiellement. Cliquez sur une règle pour la modifier. Maintenez le bouton '=' à gauche enfoncé et faites-le glisser pour trier les règles.",
Expand Down
1 change: 1 addition & 0 deletions lib/arb/intl_it.arb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"addFiles": "Si prega di aggiungere dei file.",
"dragToAdd": "Trascina i file per aggiungerli.",
"dropToAdd": "Rilascia i file qui per aggiungerli.",
"dragNotSupported": "A causa delle restrizioni di sicurezza del sistema, il trascinamento di file da questa app non è supportato.",
"fileAlreadyExists": "Il nome del file è già in uso",
"renameFailed": "Rinomina non riuscita",
"rulesSequentially": "Le regole vengono eseguite sequenzialmente. Fare clic su una regola per modificarla. Tenere premuto il pulsante '=' a sinistra e trascinarlo per ordinare le regole.",
Expand Down
1 change: 1 addition & 0 deletions lib/arb/intl_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"addFiles": "ファイルを追加してください。",
"dragToAdd": "追加するためにファイルをドラッグ&ドロップしてください。",
"dropToAdd": "ここにファイルをドロップして追加してください。",
"dragNotSupported": "システムのセキュリティ制限により、このアプリからのファイルのドラッグ&ドロップはサポートされていません。",
"fileAlreadyExists": "ファイル名がすでに存在します",
"renameFailed": "リネームに失敗しました",
"rulesSequentially": "ルールは順次実行されます。ルールを編集するにはクリックします。左側の「=」ボタンを押しながらドラッグしてルールを並べ替えることができます。",
Expand Down
1 change: 1 addition & 0 deletions lib/arb/intl_ko.arb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"addFiles": "파일을 추가하세요.",
"dragToAdd": "추가하려면 파일을 여기로 끌어다 놓으세요.",
"dropToAdd": "파일을 여기에 놓아 추가하세요.",
"dragNotSupported": "시스템 보안 제한으로 인해 이 앱에서 파일을 드래그 앤 드롭하는 것은 지원되지 않습니다.",
"fileAlreadyExists": "파일 이름이 이미 사용 중입니다",
"renameFailed": "이름 변경 실패",
"rulesSequentially": "규칙은 순차적으로 실행됩니다. 규칙을 편집하려면 클릭하십시오. 왼쪽에있는 '=' 버튼을 누른 상태에서 드래그하여 규칙을 정렬하십시오.",
Expand Down
Loading

0 comments on commit 3271361

Please sign in to comment.