Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apply plugin: 'com.android.application'

android {

compileSdkVersion 32
compileSdkVersion 33

defaultConfig {
applicationId "be.ppareit.swiftp"
minSdkVersion 23
targetSdkVersion 32
targetSdkVersion 33
versionCode 30100
versionName "3.1"
}
Expand Down Expand Up @@ -45,7 +45,6 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'net.vrallev.android:cat:1.0.5'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import android.content.Context;
import android.preference.MultiSelectListPreference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import net.vrallev.android.cat.Cat;

/**
* This is the same as the sdk MultiSelectListPreference but each time
Expand All @@ -41,7 +41,7 @@ public DynamicMultiSelectListPreference(Context context, AttributeSet attrs) {

@Override
protected View onCreateDialogView() {
Cat.d("Creating dialog view");
Log.d("swiftp", "Creating dialog view");

mPopulateListener.onPopulate(this);

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/be/ppareit/swiftp/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;

import net.vrallev.android.cat.Cat;

import be.ppareit.swiftp.gui.FsWidgetProvider;

Expand Down Expand Up @@ -99,7 +99,7 @@ public static String getVersion() {
PackageManager pm = context.getPackageManager();
return pm.getPackageInfo(packageName, 0).versionName;
} catch (NameNotFoundException e) {
Cat.e("Unable to find the name " + packageName + " in the package");
Log.e("swiftp","Unable to find the name " + packageName + " in the package");
return null;
}
}
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/be/ppareit/swiftp/FsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

import androidx.core.content.ContextCompat;

import net.vrallev.android.cat.Cat;

import java.io.IOException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -148,7 +147,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
//https://developer.android.com/reference/android/app/Service.html
//if there are not any pending start commands to be delivered to the service, it will be called with a null intent object,
if (intent != null && intent.getAction() != null) {
Cat.d("onStartCommand called with action: " + intent.getAction());
Log.d("swiftp","onStartCommand called with action: " + intent.getAction());

switch (intent.getAction()) {
case ACTION_REQUEST_START:
Expand Down Expand Up @@ -365,7 +364,7 @@ public static InetAddress getLocalInetAddress() {
&& !address.isLinkLocalAddress()
&& address instanceof Inet4Address) {
if (returnAddress != null) {
Cat.w("Found more than one valid address local inet address, why???");
Log.w("swiftp","Found more than one valid address local inet address, why???");
}
returnAddress = address;
}
Expand Down Expand Up @@ -465,7 +464,7 @@ public void onTaskRemoved(Intent rootIntent) {
Intent restartService = new Intent(getApplicationContext(), this.getClass());
restartService.setPackage(getPackageName());
PendingIntent restartServicePI = PendingIntent.getService(
getApplicationContext(), 1, restartService, PendingIntent.FLAG_ONE_SHOT);
getApplicationContext(), 1, restartService, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
AlarmManager alarmService = (AlarmManager) getApplicationContext()
.getSystemService(Context.ALARM_SERVICE);
alarmService.set(AlarmManager.ELAPSED_REALTIME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import android.app.AlertDialog;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import net.vrallev.android.cat.Cat;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -77,7 +77,7 @@ private void update() {
try {
mRoot = new File(mRoot.getCanonicalPath());
} catch (IOException e) {
Cat.w("Directory root is incorrect, fixing to external storage.");
Log.w("swiftp","Directory root is incorrect, fixing to external storage.");
mRoot = Environment.getExternalStorageDirectory();
}

Expand All @@ -94,8 +94,8 @@ private void update() {
return (file.isDirectory() && !file.isHidden());
});
if (dirs == null) {
Cat.w("Unable to receive dirs list, no Access rights?");
Cat.d("Unable to fix, continue with empty list");
Log.w("swiftp", "Unable to receive dirs list, no Access rights?");
Log.d("swiftp","Unable to fix, continue with empty list");
dirs = new String[]{};
}
mAdapter.add("..");
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/be/ppareit/swiftp/gui/FsNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;

import androidx.core.app.NotificationCompat;

import net.vrallev.android.cat.Cat;

import java.net.InetAddress;

Expand All @@ -44,7 +44,7 @@ public class FsNotification {
public static final int NOTIFICATION_ID = 7890;

public static Notification setupNotification(Context context) {
Cat.d("Setting up the notification");
Log.d("swiftp","Setting up the notification");
// Get NotificationManager reference
NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

Expand Down Expand Up @@ -96,6 +96,7 @@ public static Notification setupNotification(Context context) {
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(channelId, name, importance);
channel.setDescription(description);
channel.setShowBadge(false);
nm.createNotificationChannel(channel);
}

Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/be/ppareit/swiftp/gui/FsTileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import android.os.Build;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.Log;

import androidx.annotation.RequiresApi;

import net.vrallev.android.cat.Cat;

import java.net.InetAddress;

Expand Down Expand Up @@ -50,7 +51,7 @@ private void updateTileState() {
// Fill in the FTP server address
InetAddress address = FsService.getLocalInetAddress();
if (address == null) {
Cat.v("Unable to retrieve wifi ip address");
Log.v("swiftp","Unable to retrieve wifi ip address");
tile.setLabel(getString(R.string.swiftp_name));
return;
}
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/be/ppareit/swiftp/gui/FsWidgetProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import android.widget.RemoteViews;

import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;

import net.vrallev.android.cat.Cat;

import java.net.InetAddress;

Expand All @@ -52,7 +52,7 @@ public class FsWidgetProvider extends AppWidgetProvider {

@Override
public void onReceive(Context context, Intent intent) {
Cat.v("Received broadcast: " + intent.getAction());
Log.v("swiftp","Received broadcast: " + intent.getAction());
// watch for the broadcasts by the ftp server and update the widget if needed
final String action = intent.getAction();
if (FsService.ACTION_STARTED.equals(action) || FsService.ACTION_STOPPED.equals(action)) {
Expand All @@ -65,7 +65,7 @@ public void onReceive(Context context, Intent intent) {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
Cat.d("onUpdated called");
Log.d("swiftp","onUpdated called");
// let the updating happen by a service
Intent updateIntent = new Intent(context, UpdateService.class);
ContextCompat.startForegroundService(context, updateIntent);
Expand All @@ -75,11 +75,11 @@ public static class UpdateService extends Service {
// all real work is done in a service to avoid ANR messages
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Cat.d("UpdateService start command");
Log.d("swiftp","UpdateService start command");
// We won't take long, but still we need to keep display a notification while updating
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (nm == null) {
Cat.e("We were unable to receive the notification manager.");
Log.e("swiftp","We were unable to receive the notification manager.");
return START_NOT_STICKY;
}
String channelId = "be.ppareit.swiftp.widget_provider.channelId";
Expand Down Expand Up @@ -113,7 +113,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
// get ip address
InetAddress address = FsService.getLocalInetAddress();
if (address == null) {
Cat.w("Unable to retrieve the local ip address");
Log.w("swiftp","Unable to retrieve the local ip address");
text = "ERROR";
} else {
text = address.getHostAddress();
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/be/ppareit/swiftp/gui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand All @@ -37,7 +38,6 @@
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import net.vrallev.android.cat.Cat;

import java.util.Arrays;

Expand All @@ -56,7 +56,7 @@ public class MainActivity extends AppCompatActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
Cat.d("created");
Log.d("swiftp","created");
setTheme(FsSettings.getTheme());
super.onCreate(savedInstanceState);

Expand All @@ -65,7 +65,7 @@ public void onCreate(Bundle savedInstanceState) {
}

if (App.isFreeVersion() && App.isPaidVersionInstalled()) {
Cat.d("Running demo while paid is installed");
Log.d("swiftp","Running demo while paid is installed");
AlertDialog ad = new AlertDialog.Builder(this)
.setTitle(R.string.demo_while_paid_dialog_title)
.setMessage(R.string.demo_while_paid_dialog_message)
Expand Down Expand Up @@ -101,11 +101,11 @@ public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
if (requestCode != PERMISSIONS_REQUEST_CODE) {
Cat.e("Unhandled request code");
Log.e("swiftp","Unhandled request code");
return;
}
Cat.d("permissions: " + Arrays.toString(permissions));
Cat.d("grantResults: " + Arrays.toString(grantResults));
Log.d("swiftp","permissions: " + Arrays.toString(permissions));
Log.d("swiftp","grantResults: " + Arrays.toString(grantResults));
if (grantResults.length > 0) {
// Permissions not granted, close down
for (int result : grantResults) {
Expand Down
34 changes: 23 additions & 11 deletions app/src/main/java/be/ppareit/swiftp/gui/PreferenceFragment.java
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct.

Wish I would have seen this earlier.

The onCreate has just been changed in a little different way. Instead of asking the user to press the hidden option, the app now opens the Scoped storage chooser itself. Does this work for you?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually remove the check too if wanted. The intent of use was its seen in a bad state but technically could just leave that for the user to deal without the extra helpful smoothing out of it :)

Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
import android.preference.PreferenceScreen;
import android.preference.TwoStatePreference;
import android.text.util.Linkify;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

import net.vrallev.android.cat.Cat;

import java.net.InetAddress;
import java.util.List;
Expand Down Expand Up @@ -78,7 +78,19 @@ public void onCreate(Bundle savedInstanceState) {
updateRunningState();
runningPref.setOnPreferenceChangeListener((preference, newValue) -> {
if ((Boolean) newValue) {
FsService.start();
if (FsSettings.getExternalStorageUri() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
FsService.start();
} else {
AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
adb.setTitle("Write External Storage is Required");
adb.setMessage("Please set the starting directory at Advanced Settings->Writing external storage");
adb.setPositiveButton("Ok", (dialog, which) -> {
dialog.dismiss();
runningPref.setChecked(false);
});
adb.show();
FsService.stop();
}
} else {
FsService.stop();
}
Expand Down Expand Up @@ -120,7 +132,7 @@ public void onCreate(Bundle savedInstanceState) {
try {
portNumber = Integer.parseInt(newPortNumberString);
} catch (Exception e) {
Cat.d("Error parsing port number! Moving on...");
Log.d("swiftp","Error parsing port number! Moving on...");
}
if (portNumber <= 0 || 65535 < portNumber) {
Toast.makeText(getActivity(),
Expand Down Expand Up @@ -182,7 +194,7 @@ public void onCreate(Bundle savedInstanceState) {

Preference helpPref = findPref("help");
helpPref.setOnPreferenceClickListener(preference -> {
Cat.v("On preference help clicked");
Log.v("swiftp","On preference help clicked");
Context context = getActivity();
AlertDialog ad = new AlertDialog.Builder(context)
.setTitle(R.string.help_dlg_title)
Expand Down Expand Up @@ -228,7 +240,7 @@ public void onResume() {
updateRunningState();
updateUsersPref();

Cat.d("onResume: Registering the FTP server actions");
Log.d("swiftp","onResume: Registering the FTP server actions");
IntentFilter filter = new IntentFilter();
filter.addAction(FsService.ACTION_STARTED);
filter.addAction(FsService.ACTION_STOPPED);
Expand All @@ -240,17 +252,17 @@ public void onResume() {
public void onPause() {
super.onPause();

Cat.v("onPause: Unregistering the FTPServer actions");
Log.v("swiftp","onPause: Unregistering the FTPServer actions");
getActivity().unregisterReceiver(mFsActionsReceiver);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
Cat.d("onActivityResult called");
Log.d("swiftp","onActivityResult called");
if (requestCode == ACTION_OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK) {
Uri treeUri = resultData.getData();
String path = treeUri.getPath();
Cat.d("Action Open Document Tree on path " + path);
Log.d("swiftp","Action Open Document Tree on path " + path);

final CheckBoxPreference writeExternalStoragePref = findPref("writeExternalStorage");
if (!":".equals(path.substring(path.length() - 1)) || path.contains("primary")) {
Expand Down Expand Up @@ -302,7 +314,7 @@ private void updateRunningState() {
// Fill in the FTP server address
InetAddress address = FsService.getLocalInetAddress();
if (address == null) {
Cat.v("Unable to retrieve wifi ip address");
Log.v("swiftp","Unable to retrieve wifi ip address");
runningPref.setSummary(R.string.running_summary_failed_to_get_ip_address);
return;
}
Expand All @@ -324,7 +336,7 @@ private void updateRunningState() {
BroadcastReceiver mFsActionsReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Cat.v("action received: " + intent.getAction());
Log.v("swiftp","action received: " + intent.getAction());
if (intent.getAction() == null) {
return;
}
Expand Down
Loading