├── .github
└── readme-images
│ ├── demo.gif
│ └── ic_launcher-playstore.png
├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── name
│ │ └── lmj001
│ │ └── saveondevice
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-playstore.png
│ ├── java
│ │ └── name
│ │ │ └── lmj001
│ │ │ └── saveondevice
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable
│ │ └── ic_launcher_foreground.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ └── ic_launcher.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── colors.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── name
│ └── lmj001
│ └── saveondevice
│ └── ExampleUnitTest.kt
├── build.gradle
├── fastlane
└── metadata
│ └── android
│ ├── de
│ ├── full_description.txt
│ └── short_description.txt
│ └── en-US
│ ├── full_description.txt
│ ├── images
│ ├── featureGraphic.png
│ ├── icon.png
│ └── phoneScreenshots
│ │ ├── 1.png
│ │ └── 2.png
│ └── short_description.txt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.github/readme-images/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/.github/readme-images/demo.gif
--------------------------------------------------------------------------------
/.github/readme-images/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/.github/readme-images/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /app/release
5 | /.idea
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | .cxx
11 | local.properties
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #
Save On Device
2 |
3 | An Android app that allows you to save files on your device from other apps using the Share or View functionality.
4 |
5 |
6 |
7 | ## Features
8 | - Save files from other apps to local storage
9 | - Save copied text to local storage
10 |
11 | This fork of the [original](https://github.com/lmj0011/save-on-device) by lmj0011 is just about 25KB and is compatible with all versions of Android. It also supports saving files from the View action in addition to the Share one.
12 |
13 | ## License
14 |
15 | Copyright 2023 Landan Jackson
16 |
17 | Licensed under the Apache License, Version 2.0 (the "License");
18 | you may not use this file except in compliance with the License.
19 | You may obtain a copy of the License at
20 |
21 | http://www.apache.org/licenses/LICENSE-2.0
22 |
23 | Unless required by applicable law or agreed to in writing, software
24 | distributed under the License is distributed on an "AS IS" BASIS,
25 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 | See the License for the specific language governing permissions and
27 | limitations under the License.
28 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | compileSdk 35
7 |
8 | defaultConfig {
9 | applicationId "name.lmj001.savetodevice"
10 | minSdk 1
11 | targetSdk 36
12 | versionCode 8
13 | versionName "0.7.1"
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled true
19 | shrinkResources true
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | compileOptions {
24 | sourceCompatibility JavaVersion.VERSION_1_8
25 | targetCompatibility JavaVersion.VERSION_1_8
26 | }
27 | namespace 'name.lmj001.saveondevice'
28 | }
29 |
30 | dependencies {
31 | }
32 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/name/lmj001/saveondevice/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package name.lmj001.saveondevice
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("name.lmj001.saveondevice", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/java/name/lmj001/saveondevice/MainActivity.java:
--------------------------------------------------------------------------------
1 | package name.lmj001.saveondevice;
2 |
3 | import android.Manifest;
4 | import android.app.Activity;
5 | import android.app.Dialog;
6 | import android.content.ContentResolver;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.content.SharedPreferences;
10 | import android.content.pm.PackageManager;
11 | import android.database.Cursor;
12 | import android.graphics.Color;
13 | import android.net.Uri;
14 | import android.os.Build;
15 | import android.os.Bundle;
16 | import android.os.Environment;
17 | import android.os.FileUtils;
18 | import android.provider.DocumentsContract;
19 | import android.provider.OpenableColumns;
20 | import android.text.TextUtils;
21 | import android.view.View;
22 | import android.webkit.MimeTypeMap;
23 | import android.widget.Button;
24 | import android.widget.EditText;
25 | import android.widget.LinearLayout;
26 | import android.widget.TextView;
27 | import android.widget.Toast;
28 | import android.widget.ToggleButton;
29 |
30 | import java.io.File;
31 | import java.io.FileOutputStream;
32 | import java.io.InputStream;
33 | import java.io.OutputStream;
34 | import java.text.Normalizer;
35 | import java.util.ArrayList;
36 | import java.util.Objects;
37 | import java.util.concurrent.Executors;
38 |
39 | public class MainActivity extends Activity {
40 | private static Uri inputUri;
41 | private static ArrayList inputUris;
42 | private static String sharedText;
43 | private static boolean saveIndividually;
44 | private final static boolean supportsBuiltInAndroidFilePicker = Build.VERSION.SDK_INT > 18;
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 |
50 | SharedPreferences settings = getSharedPreferences("set", Context.MODE_PRIVATE);
51 | saveIndividually = settings.getBoolean("saveIndividually", false);
52 | final View protectEyes = new View(this);
53 | protectEyes.setBackgroundColor(Color.BLACK);
54 | setContentView(protectEyes);
55 |
56 | Intent intent = getIntent();
57 | String action = intent.getAction();
58 | if (Intent.ACTION_VIEW.equals(action)) {
59 | inputUri = intent.getData();
60 | callSaveFileResultLauncherForIndividual();
61 | } else if (Intent.ACTION_SEND.equals(action)) {
62 | if (intent.hasExtra(Intent.EXTRA_STREAM)) {
63 | inputUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
64 | callSaveFileResultLauncherForIndividual();
65 | } else if (intent.hasExtra(Intent.EXTRA_TEXT)) {
66 | sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
67 | if (sharedText != null) {
68 | String fileName = sharedText.substring(0, Math.min(sharedText.length(), 20));
69 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
70 | fileName = Normalizer.normalize(fileName, Normalizer.Form.NFD)
71 | .replaceAll("[^\\p{ASCII}]", "")
72 | .replaceAll("[^a-zA-Z0-9\\s]+", "")
73 | .trim()
74 | .replaceAll("\\s+", "-")
75 | .toLowerCase();
76 | } else {
77 | StringBuilder sb = new StringBuilder();
78 | for (char c : fileName.toCharArray()) if ((int) c <= 127) sb.append(c);
79 | fileName = sb.toString()
80 | .replaceAll("[^a-zA-Z0-9\\s]", "")
81 | .trim()
82 | .replaceAll("\\s+", "-")
83 | .toLowerCase();
84 | }
85 | if (supportsBuiltInAndroidFilePicker) {
86 | Intent saveFileIntent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
87 | saveFileIntent.addCategory(Intent.CATEGORY_OPENABLE);
88 | saveFileIntent.setType("text/plain");
89 | saveFileIntent.putExtra(Intent.EXTRA_TITLE, fileName);
90 | startActivityForResult(saveFileIntent, 0);
91 | } else saveFile(new File(
92 | getSharedPreferences("set", Context.MODE_PRIVATE)
93 | .getString("directoryToSaveFiles",
94 | new File(Environment.getExternalStorageDirectory(), "Download").getPath()), fileName));
95 | } else {
96 | Toast.makeText(getApplicationContext(), R.string.nothing, Toast.LENGTH_LONG).show();
97 | finish();
98 | }
99 | }
100 | } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
101 | if (intent.hasExtra(Intent.EXTRA_STREAM)) {
102 | inputUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
103 | if (saveIndividually || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
104 | inputUri = inputUris.get(0);
105 | inputUris.remove(0);
106 | callSaveFileResultLauncherForIndividual();
107 | } else {
108 | for (Uri uri : inputUris) {
109 | final String mimeType = getApplicationContext().getContentResolver().getType(uri);
110 | if (TextUtils.isEmpty(mimeType)) {
111 | Toast.makeText(getApplicationContext(), R.string.unsupported_mimetype, Toast.LENGTH_LONG).show();
112 | finish();
113 | }
114 | }
115 | Intent saveFilesIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
116 | startActivityForResult(saveFilesIntent, 1);
117 | }
118 | }
119 | } else {
120 | setContentView(R.layout.activity_main);
121 | ToggleButton tb = findViewById(R.id.multiSaveSwitch);
122 | if (Build.VERSION.SDK_INT < 21) {
123 | if (supportsBuiltInAndroidFilePicker) {
124 | tb.setChecked(true);
125 | tb.setEnabled(false);
126 | findViewById(R.id.oldAndroidInfo).setVisibility(View.VISIBLE);
127 | } else {
128 | findViewById(R.id.veryOldAndroidInfo).setVisibility(View.VISIBLE);
129 | tb.setVisibility(View.INVISIBLE);
130 | findViewById(R.id.multiSaveInfo).setVisibility(View.INVISIBLE);
131 | findViewById(R.id.multiSaveSwitch).setVisibility(View.INVISIBLE);
132 | EditText outputDirectoryField = findViewById(R.id.directorySaveFiles);
133 | outputDirectoryField.setVisibility(View.VISIBLE);
134 | outputDirectoryField.setText(settings.getString("directoryToSaveFiles", Environment.getExternalStorageDirectory().getPath() + File.separator + "Download"));
135 | Button b = findViewById(R.id.saveDirectorySetting);
136 | b.setVisibility(View.VISIBLE);
137 | b.setOnClickListener(v -> {
138 | final SharedPreferences.Editor editor = settings.edit();
139 | final String userFilePath = outputDirectoryField.getText().toString();
140 | final File newFile = new File(userFilePath);
141 | if (newFile.exists() || newFile.mkdir()) {
142 | editor.putString("directoryToSaveFiles", userFilePath);
143 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) editor.apply();
144 | else editor.commit();
145 | } else
146 | showError(getString(R.string.invalid_filepath));
147 | });
148 | }
149 | } else {
150 | tb.setChecked(saveIndividually);
151 | tb.setOnCheckedChangeListener((buttonView, isChecked) -> settings.edit().putBoolean("saveIndividually", isChecked).apply());
152 | }
153 | }
154 | }
155 |
156 | private void showError(Exception err) {
157 | StringBuilder sb = new StringBuilder(err.toString());
158 | for(StackTraceElement ste : err.getStackTrace()) sb.append('\n').append(ste);
159 | showError(sb);
160 | }
161 |
162 | private void showError(CharSequence err) {
163 | runOnUiThread(() -> {
164 | Toast.makeText(this, err, Toast.LENGTH_SHORT).show();
165 | Dialog dialog = new Dialog(this, android.R.style.Theme_Black);
166 | dialog.setTitle(R.string.err);
167 |
168 | LinearLayout layout = new LinearLayout(this);
169 | layout.setOrientation(LinearLayout.VERTICAL);
170 | layout.setPadding(16, 16, 16, 16);
171 | layout.setBackgroundColor(Color.BLACK);
172 |
173 | TextView errorMessage = new TextView(this);
174 | errorMessage.setText(err);
175 | errorMessage.setTextAppearance(this, android.R.style.TextAppearance_Large);
176 | layout.addView(errorMessage);
177 | errorMessage.setTextColor(0xFF691383);
178 | errorMessage.setBackgroundColor(Color.BLACK);
179 |
180 | Button okButton = new Button(this);
181 | okButton.setText("OK");
182 | okButton.setOnClickListener(view -> finish());
183 | layout.addView(okButton);
184 |
185 | dialog.setContentView(layout);
186 | dialog.show();
187 | });
188 | }
189 |
190 | private void callSaveFileResultLauncherForIndividual() {
191 | String fileName = getOriginalFileName(this, inputUri);
192 | if (supportsBuiltInAndroidFilePicker) {
193 | String mimeType = getApplicationContext().getContentResolver().getType(inputUri);
194 | if (TextUtils.isEmpty(mimeType)) {
195 | if (Build.VERSION.SDK_INT > 22 && Build.VERSION.SDK_INT < 29 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
196 | showError(getString(R.string.need_storage));
197 | requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
198 | if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
199 | final File tempFile = new File(getExternalCacheDir() + File.separator + fileName);
200 | saveFile(tempFile);
201 | inputUri = Uri.fromFile(tempFile); // lol
202 | }
203 | }
204 | String fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1).trim();
205 | mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase());
206 | if (TextUtils.isEmpty(mimeType)) mimeType = "application/octet-stream"; // Default MIME type
207 | }
208 |
209 | Intent saveFileIntent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
210 | saveFileIntent.addCategory(Intent.CATEGORY_OPENABLE);
211 | saveFileIntent.setType(mimeType);
212 | saveFileIntent.putExtra(Intent.EXTRA_TITLE, fileName);
213 | startActivityForResult(saveFileIntent, 0);
214 | } else saveFile(new File(
215 | getSharedPreferences("set", Context.MODE_PRIVATE)
216 | .getString("directoryToSaveFiles",
217 | new File(Environment.getExternalStorageDirectory(), "Download").getPath()), fileName));
218 | }
219 |
220 | @Override
221 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
222 | super.onActivityResult(requestCode, resultCode, data);
223 | Uri outputUri;
224 | if (resultCode == RESULT_OK && data != null && (outputUri = data.getData()) != null)
225 | Executors.newSingleThreadExecutor().submit(() -> {
226 | if (requestCode == 0 || saveIndividually || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
227 | try (OutputStream outputStream = getContentResolver().openOutputStream(outputUri)) {
228 | if (inputUri == null) outputStream.write(sharedText.getBytes());
229 | else try (InputStream inputStream = getContentResolver().openInputStream(inputUri)) {
230 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) inputStream.transferTo(outputStream);
231 | else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) FileUtils.copy(inputStream, outputStream);
232 | else {
233 | byte[] buffer = new byte[4096];
234 | int length;
235 | while ((length = inputStream.read(buffer)) > 0) {
236 | outputStream.write(buffer, 0, length);
237 | }
238 | }
239 | }
240 | } catch (Exception e) {
241 | showError(e);
242 | }
243 | if (inputUris == null || inputUris.isEmpty()) {
244 | runOnUiThread(() -> {
245 | Toast.makeText(this, R.string.success, Toast.LENGTH_SHORT).show();
246 | finish();
247 | });
248 | } else {
249 | inputUri = inputUris.get(0);
250 | inputUris.remove(0);
251 | callSaveFileResultLauncherForIndividual();
252 | }
253 | } else {
254 | ContentResolver resolver = getContentResolver();
255 | try {
256 | Uri docUri = DocumentsContract.buildDocumentUriUsingTree(outputUri, DocumentsContract.getTreeDocumentId(outputUri));
257 | for (Uri inputUri1 : inputUris) {
258 | try (InputStream inputStream = resolver.openInputStream(inputUri1);
259 | OutputStream outputStream = resolver.openOutputStream(DocumentsContract.createDocument(resolver, docUri, "*/*", getOriginalFileName(this, inputUri1)))) {
260 | byte[] buffer = new byte[4096];
261 | int length;
262 | while ((length = inputStream.read(buffer)) > 0) {
263 | outputStream.write(buffer, 0, length);
264 | }
265 | }
266 | }
267 | runOnUiThread(() -> {
268 | Toast.makeText(this, R.string.success, Toast.LENGTH_SHORT).show();
269 | finish();
270 | });
271 | } catch (Exception e) {
272 | showError(e);
273 | }
274 | }
275 | return null;
276 | });
277 | }
278 |
279 | private void saveFile(File outputFile) {
280 | try (OutputStream outputStream = new FileOutputStream(outputFile)) {
281 | if (inputUri == null) outputStream.write(sharedText.getBytes());
282 | else try (InputStream inputStream = getContentResolver().openInputStream(inputUri)) {
283 | byte[] buffer = new byte[4096];
284 | int length;
285 | while ((length = inputStream.read(buffer)) > 0) {
286 | outputStream.write(buffer, 0, length);
287 | }
288 | }
289 | } catch (Exception e) {
290 | showError(e);
291 | }
292 | if (inputUris == null || inputUris.isEmpty()) {
293 | runOnUiThread(() -> {
294 | Toast.makeText(this, R.string.success, Toast.LENGTH_SHORT).show();
295 | finish();
296 | });
297 | } else {
298 | inputUri = inputUris.get(0);
299 | inputUris.remove(0);
300 | callSaveFileResultLauncherForIndividual();
301 | }
302 | }
303 |
304 | private static String getOriginalFileName(Context context, Uri uri) {
305 | String result = null;
306 | try {
307 | if (Objects.equals(uri.getScheme(), "content")) {
308 | try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) {
309 | if (cursor != null && cursor.moveToFirst()) {
310 | result = cursor.getString(cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME));
311 | }
312 | }
313 | }
314 | if (result == null) {
315 | result = uri.getPath();
316 | int cut = Objects.requireNonNull(result).lastIndexOf('/');
317 | if (cut != -1) {
318 | result = result.substring(cut + 1);
319 | }
320 | }
321 | } catch (NullPointerException | IllegalArgumentException ignored) {
322 | result = "filename_not_found";
323 | }
324 | return result;
325 | }
326 | }
327 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
14 |
15 |
17 |
18 |
20 |
21 |
23 |
24 |
26 |
27 |
28 |
30 |
31 |
32 |
34 |
35 |
36 |
38 |
39 |
40 |
42 |
43 |
44 |
46 |
47 |
48 |
50 |
51 |
52 |
54 |
55 |
56 |
58 |
59 |
60 |
61 |
62 |
66 |
70 |
73 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
20 |
21 |
22 |
28 |
29 |
37 |
38 |
47 |
48 |
55 |
56 |
67 |
68 |
74 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #36577F
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Save
3 | Save on device
4 | Unsupported mimeType
5 | If this is enabled, when you share multiple files to the app, it will bring up a dialog for each file allowing you to rename it and select the folder to save it in. Otherwise, you will simply choose a folder to save the files in, and they will all be saved there automatically.
6 | Unfortunately, the version of Android on your device does not support the method used to save all files as once. You will be forced to use this mode.
7 | Save multiple files individually
8 | Your Android version is so old that it does not support the dialog used to select where to save the file. You can enter the path to a folder in the box below, and all the files will be saved there.
9 | Directory to save files
10 | Saved successfully
11 | Nothing detected to save
12 | Storage permission needed because the MIME type of the file could not be found
13 | Error
14 | Invalid file path
15 |
16 |
--------------------------------------------------------------------------------
/app/src/test/java/name/lmj001/saveondevice/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package name.lmj001.saveondevice
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:8.7.3'
9 | // NOTE: Do not place your application dependencies here; they belong
10 | // in the individual module build.gradle files
11 | }
12 | }
13 |
14 | task clean(type: Delete) {
15 | delete rootProject.buildDir
16 | }
17 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/de/full_description.txt:
--------------------------------------------------------------------------------
1 | Save on Device fügt dem Android Sharesheet eine Option hinzu, mit der Du Dateien auf Deinem Gerät speichern kannst.
2 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/de/short_description.txt:
--------------------------------------------------------------------------------
1 | Speichere teilbare Daten auf Deinem Gerät
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/full_description.txt:
--------------------------------------------------------------------------------
1 | Save on Device adds an option to the Android Sharesheet that allows you to save files to your device.
2 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/featureGraphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/fastlane/metadata/android/en-US/images/featureGraphic.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/fastlane/metadata/android/en-US/images/icon.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/short_description.txt:
--------------------------------------------------------------------------------
1 | Save shareable data to your device
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbdurazaaqMohammed/save-on-device/85481a22792850049e269b2af0e4c8037ef99209/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90 | ' "$PWD" ) || exit
91 |
92 | # Use the maximum available, or set MAX_FD != -1 to use that value.
93 | MAX_FD=maximum
94 |
95 | warn () {
96 | echo "$*"
97 | } >&2
98 |
99 | die () {
100 | echo
101 | echo "$*"
102 | echo
103 | exit 1
104 | } >&2
105 |
106 | # OS specific support (must be 'true' or 'false').
107 | cygwin=false
108 | msys=false
109 | darwin=false
110 | nonstop=false
111 | case "$( uname )" in #(
112 | CYGWIN* ) cygwin=true ;; #(
113 | Darwin* ) darwin=true ;; #(
114 | MSYS* | MINGW* ) msys=true ;; #(
115 | NONSTOP* ) nonstop=true ;;
116 | esac
117 |
118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
119 |
120 |
121 | # Determine the Java command to use to start the JVM.
122 | if [ -n "$JAVA_HOME" ] ; then
123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
124 | # IBM's JDK on AIX uses strange locations for the executables
125 | JAVACMD=$JAVA_HOME/jre/sh/java
126 | else
127 | JAVACMD=$JAVA_HOME/bin/java
128 | fi
129 | if [ ! -x "$JAVACMD" ] ; then
130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
131 |
132 | Please set the JAVA_HOME variable in your environment to match the
133 | location of your Java installation."
134 | fi
135 | else
136 | JAVACMD=java
137 | if ! command -v java >/dev/null 2>&1
138 | then
139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
140 |
141 | Please set the JAVA_HOME variable in your environment to match the
142 | location of your Java installation."
143 | fi
144 | fi
145 |
146 | # Increase the maximum file descriptors if we can.
147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
148 | case $MAX_FD in #(
149 | max*)
150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151 | # shellcheck disable=SC2039,SC3045
152 | MAX_FD=$( ulimit -H -n ) ||
153 | warn "Could not query maximum file descriptor limit"
154 | esac
155 | case $MAX_FD in #(
156 | '' | soft) :;; #(
157 | *)
158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159 | # shellcheck disable=SC2039,SC3045
160 | ulimit -n "$MAX_FD" ||
161 | warn "Could not set maximum file descriptor limit to $MAX_FD"
162 | esac
163 | fi
164 |
165 | # Collect all arguments for the java command, stacking in reverse order:
166 | # * args from the command line
167 | # * the main class name
168 | # * -classpath
169 | # * -D...appname settings
170 | # * --module-path (only if needed)
171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
172 |
173 | # For Cygwin or MSYS, switch paths to Windows format before running java
174 | if "$cygwin" || "$msys" ; then
175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
177 |
178 | JAVACMD=$( cygpath --unix "$JAVACMD" )
179 |
180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
181 | for arg do
182 | if
183 | case $arg in #(
184 | -*) false ;; # don't mess with options #(
185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
186 | [ -e "$t" ] ;; #(
187 | *) false ;;
188 | esac
189 | then
190 | arg=$( cygpath --path --ignore --mixed "$arg" )
191 | fi
192 | # Roll the args list around exactly as many times as the number of
193 | # args, so each arg winds up back in the position where it started, but
194 | # possibly modified.
195 | #
196 | # NB: a `for` loop captures its iteration list before it begins, so
197 | # changing the positional parameters here affects neither the number of
198 | # iterations, nor the values presented in `arg`.
199 | shift # remove old arg
200 | set -- "$@" "$arg" # push replacement arg
201 | done
202 | fi
203 |
204 |
205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207 |
208 | # Collect all arguments for the java command:
209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210 | # and any embedded shellness will be escaped.
211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212 | # treated as '${Hostname}' itself on the command line.
213 |
214 | set -- \
215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
216 | -classpath "$CLASSPATH" \
217 | org.gradle.wrapper.GradleWrapperMain \
218 | "$@"
219 |
220 | # Stop when "xargs" is not available.
221 | if ! command -v xargs >/dev/null 2>&1
222 | then
223 | die "xargs is not available"
224 | fi
225 |
226 | # Use "xargs" to parse quoted args.
227 | #
228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
229 | #
230 | # In Bash we could simply go:
231 | #
232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
233 | # set -- "${ARGS[@]}" "$@"
234 | #
235 | # but POSIX shell has neither arrays nor command substitution, so instead we
236 | # post-process each arg (as a line of input to sed) to backslash-escape any
237 | # character that might be a shell metacharacter, then use eval to reverse
238 | # that process (while maintaining the separation between arguments), and wrap
239 | # the whole thing up as a single "set" statement.
240 | #
241 | # This will of course break if any of these variables contains a newline or
242 | # an unmatched quote.
243 | #
244 |
245 | eval "set -- $(
246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
247 | xargs -n1 |
248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
249 | tr '\n' ' '
250 | )" '"$@"'
251 |
252 | exec "$JAVACMD" "$@"
253 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
3 | repositories {
4 | google()
5 | mavenCentral()
6 | jcenter() // Warning: this repository is going to shut down soon
7 | }
8 | }
9 | rootProject.name = "Save"
10 | include ':app'
11 |
--------------------------------------------------------------------------------