Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade slf4j wrapper #1

Open
wants to merge 17 commits into
base: 1.0.3
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
### License information

- This software includes the work that is distributed in the Apache License 2.0.
- [Zip4J 2.2.3](http://www.lingala.net/zip4j.html)
- [Zip4J 2.11.1](http://www.lingala.net/zip4j.html)
- This software includes the work that is distributed in the MOZILLA PUBLIC LICENSE 1.1.
- [juniversalchardet-1.0.3](https://code.google.com/archive/p/juniversalchardet/)
- This software includes the work that is distributed in the MIT License.
Expand Down
32 changes: 21 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
//compileSdkVersion 29
compileSdkVersion 33
//buildToolsVersion "29.0.3"
buildToolsVersion '33.0.0'
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 33
versionCode 2
versionName "1.0.3"
}
Expand All @@ -28,9 +30,9 @@ android {
include 'Utilities*.aar'
}

afterEvaluate {
// afterEvaluate {
assembleDebug.finalizedBy(copy_aar_debug)
}
// }

}
}
Expand All @@ -53,9 +55,9 @@ android {
include 'Utilities*.aar'
}

afterEvaluate {
// afterEvaluate {
assembleRelease.finalizedBy(copy_aar_release)
}
// }

}
}
Expand All @@ -64,11 +66,19 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.0'
// implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.preference:preference:1.2.0'

// implementation 'com.google.android.material:material:1.2.0'
implementation 'com.google.android.material:material:1.6.1'

implementation files('libs/juniversalchardet-1.0.3.jar')

implementation files('libs/zip4j_2.2.3_20191102_04.jar')
implementation files('libs/WrapperForSlf4j-1.0.3.jar')
//implementation files('libs/zip4j_2.2.3_20191102_04.jar')
// zip4j maven: https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j
//implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.11.1'
implementation files('libs/zip4j_2.11.1_20220623.jar')

implementation files('libs/WrapperForSlf4j-1.7.36.jar')
}
Binary file removed app/libs/WrapperForSlf4j-1.0.3.jar
Binary file not shown.
Binary file added app/libs/WrapperForSlf4j-1.7.36.jar
Binary file not shown.
Binary file added app/libs/zip4j_2.11.1_20220623.jar
Binary file not shown.
Binary file removed app/libs/zip4j_2.2.3_20191102_04.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ public void run() {

@SuppressWarnings("deprecation")
public static void setSpinnerBackground(Context c, Spinner spinner, boolean theme_is_light) {
if (theme_is_light) spinner.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.spinner_color_background_light));
else spinner.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.spinner_color_background));
if (theme_is_light) spinner.setBackground(c.getResources().getDrawable(R.drawable.spinner_color_background_light));
else spinner.setBackground(c.getResources().getDrawable(R.drawable.spinner_color_background));
};

private ListView mTreeFileListView=null;
Expand Down Expand Up @@ -831,7 +831,7 @@ public void positiveResponse(Context c, Object[] o) {
mTreeFileListView.setVisibility(TextView.VISIBLE);
mTreeFilelistAdapter.setDataList(tfl);
}
if (mDialogSelectCat==DIALOG_SELECT_CATEGORY_FILE && mDialogFileName.equals("")) {
if (mDialogSelectCat==DIALOG_SELECT_CATEGORY_FILE && et_file_name.getText().toString().equals("")) {
setButtonEnabled(mActivity, btnOk, false);
putDlgMsg(dlg_msg, mContext.getString(R.string.msgs_file_select_edit_dlg_filename_not_specified));
} else {
Expand All @@ -854,7 +854,7 @@ public void negativeResponse(Context c, Object[] o) {
if (mDialogSelectCat==DIALOG_SELECT_CATEGORY_FILE) {
mTreeFilelistAdapter.setDataItemIsSelected(pos);
et_file_name.setText(mTreeFilelistAdapter.getDataItem(pos).getName());
if (mTreeFilelistAdapter.getDataItem(pos).isDir() && mDialogSelectCat==DIALOG_SELECT_CATEGORY_FILE) setButtonEnabled(mActivity, btnOk, false);
if (mTreeFilelistAdapter.getDataItem(pos).isDir()) setButtonEnabled(mActivity, btnOk, false);
else setButtonEnabled(mActivity, btnOk, true);
}
}
Expand Down Expand Up @@ -1285,7 +1285,8 @@ private void createLocalFilelist(final boolean fileOnly, final String dir, final
}

private String getRootFilePath(String fp) {
if (fp.startsWith("/storage/emulated/0")) return "/storage/emulated/0";
String primary_storage_path = SafManager3.getPrimaryStoragePath(); // "/storage/emulated/0"
if (fp.startsWith(primary_storage_path)) return primary_storage_path;
else {
String[] fp_parts=fp.startsWith("/")?fp.substring(1).split("/"):fp.split("/");
String rt_fp="/"+fp_parts[0]+"/"+fp_parts[1];
Expand Down Expand Up @@ -1389,21 +1390,23 @@ public void run() {
th.start();
}

// On browse for files/dirs to select, do not list /Android/data
private boolean canAccessDirectory(String path) {
boolean result=true;
if (path.endsWith(".android_secure")) result=false;
else {
if (Build.VERSION.SDK_INT>=30) {
if (Build.VERSION.SDK_INT >= 30) {
String primary_storage_path = SafManager3.getPrimaryStoragePath(); // "/storage/emulated/0"
String[] fp_array=path.split("/");
if (path.startsWith("/storage/emulated/0")) {
String abs_dir=path.replace("/storage/emulated/0", "");
if (path.startsWith(primary_storage_path)) {
String abs_dir=path.replace(primary_storage_path, "");
if (!abs_dir.equals("")) {
if (abs_dir.startsWith("/Android/data") || abs_dir.startsWith("/Android/obb")) {
result=false;
}
}
} else {
if (fp_array.length>=3) {
if (fp_array.length >= 3) {
String abs_dir=path.replace("/"+fp_array[1]+"/"+fp_array[2], "");
if (!abs_dir.equals("")) {
if (abs_dir.startsWith("/Android/data") || abs_dir.startsWith("/Android/obb")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ this software and associated documentation files (the "Software"), to deal

import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.os.Bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ this software and associated documentation files (the "Software"), to deal

@SuppressLint("SdCardPath")
public class LocalMountPoint {

// legacy code that should be narrowed. Used only by send log as zip file (CommonLogManagementFragment -> sendLogFile())
static public String[] convertFilePathToMountpointFormat(Context c, String fp) {
ArrayList<String> ml=getLocalMountPointList(c);
String ldir="/",lfile="";
Expand All @@ -47,7 +47,7 @@ static public String[] convertFilePathToMountpointFormat(Context c, String fp) {
}
}
File lf=new File(fp);
if (lf.isDirectory()) {
if (lf != null && lf.isDirectory()) {
ldir=fp.replace(lurl, "");
} else {
if (fp.lastIndexOf("/")>=0) {
Expand Down Expand Up @@ -76,10 +76,13 @@ static private boolean isMountPointReadable(String mp) {
else result=false;
return result;
};


// legacy code that should be narrowed. Used only by send log as zip file (CommonLogManagementFragment -> sendLogFile())
// called for send log as zip by convertFilePathToMountpointFormat() and getLocalMountPointList()
static public String getExternalStorageDir() {
String ext_dir= Environment.getExternalStorageDirectory().toString();
if (ext_dir!=null) return ext_dir;
//String ext_dir= Environment.getExternalStorageDirectory().toString();
String ext_dir=Environment.getExternalStorageDirectory().getPath(); // /storage/emulated/0
if (ext_dir != null) return ext_dir; // is never null
else return "/";
// String status = Environment.getExternalStorageState();
// if (!status.equals(Environment.MEDIA_MOUNTED)) {
Expand All @@ -99,6 +102,7 @@ static public String getExternalStorageDir() {
// }
};

// legacy not used
static public boolean isExternalStorageAvailable() {
String status = Environment.getExternalStorageState();
if (!status.equals(Environment.MEDIA_MOUNTED)) return false;
Expand All @@ -115,6 +119,7 @@ static public boolean isExternal2MountPioint(String fp) {
return result;
};

// legacy not used
static public boolean isExternalMountPoint(Context c, String fp) {
boolean result=false;
if (isExternalStorageAvailable()) {
Expand All @@ -128,7 +133,8 @@ static public boolean isExternalMountPoint(Context c, String fp) {
} else result=false;
return result;
};


// legacy not used
@SuppressLint("SdCardPath")
static public boolean isMountPointAvailable(Context c, String fp) {
boolean result=false;
Expand All @@ -149,14 +155,16 @@ static public boolean isMountPointAvailable(Context c, String fp) {
}
return result;
};


// legacy not used
static public boolean isAppSpecificDirectory(Context c, String lmp, String dir) {
String fp="";
if (dir.equals("")) fp=lmp;
else fp=lmp+"/"+dir;
return isAppSpecificDirectory(c,fp);
};

// legacy not used
static public boolean isAppSpecificDirectory(Context c, String fp) {
boolean result=false;
ArrayList<String> ml=getLocalMountPointList(c);
Expand Down Expand Up @@ -234,6 +242,7 @@ static public boolean isAppSpecificDirectory(Context c, String fp) {
// return ml;
// };

// legacy not used
static public boolean isMountPointCanWrite(String mp) {
boolean result=false;
File lf=new File(mp+"/isLocalMountPointWritable_temp.tmp");
Expand All @@ -246,6 +255,7 @@ static public boolean isMountPointCanWrite(String mp) {
return result;
}

// legacy not used
static public ArrayList<String> getLocalMountpointList2(Context c) {
ArrayList<String> ml=LocalMountPoint.getLocalMountPointList(c);
ArrayList<String> new_ml=new ArrayList<String>();
Expand Down Expand Up @@ -281,6 +291,8 @@ static public ArrayList<String> getLocalMountpointList2(Context c) {
return new_ml;
}

// legacy code that should be narrowed. Used only by send log as zip file (CommonLogManagementFragment -> sendLogFile())
// called for send log as zip by convertFilePathToMountpointFormat()
@SuppressLint("SdCardPath")
static public ArrayList<String> getLocalMountPointList(Context c) {
String pkg_name=c.getClass().getPackage().getName();
Expand All @@ -292,8 +304,9 @@ static public ArrayList<String> getLocalMountPointList(Context c) {
if (fl_1!=null) {
for (int i=0;i<fl_1.length;i++) {
if (fl_1[i].getName().equals("emulated")) {
File tlf=new File("/storage/emulated");
File[] tlist=tlf.listFiles();
//File tlf=new File("/storage/emulated");
//File[] tlist=tlf.listFiles();
File[] tlist=fl_1[i].listFiles(); // /storage/emulated
if (tlist!=null) {
for (int j=0;j<tlist.length;j++) {
addMountPointPrimary(tlist[j].getPath(), ml);
Expand Down Expand Up @@ -353,19 +366,20 @@ static public ArrayList<String> getLocalMountPointList(Context c) {
addMountPointPrimaryAndSecondary("/storage/external_SD", ml, pkg_name);

// File[] ext_dirs =ContextCompat.getExternalFilesDirs(c, null);
File[] ext_dirs =c.getExternalFilesDirs(null);
if (ext_dirs!=null) {
for (int i=0;i<ext_dirs.length;i++) {
if (ext_dirs[i]!=null && ext_dirs[i].getPath()!=null) {
if (!ext_dirs[i].getPath().startsWith(primary_esd)) {
boolean found=false;
for(int j=0;j<ml.size();j++) {
if (ext_dirs[i].getPath().equals(ml.get(j))) {
found=true;
File[] ext_dirs = c.getExternalFilesDirs(null);
if (ext_dirs != null) {
for (int i=0; i < ext_dirs.length; i++) {
if (ext_dirs[i] != null) {
String ext_dir_path = ext_dirs[i].getPath();
if (ext_dir_path != null && !ext_dir_path.startsWith(primary_esd)) {
boolean found = false;
for(int j=0; j < ml.size(); j++) {
if (ext_dir_path.equals(ml.get(j))) {
found = true;
break;
}
}
if (!found) ml.add(ext_dirs[i].getPath());
if (!found) ml.add(ext_dir_path);
}
}
}
Expand All @@ -377,7 +391,7 @@ static public ArrayList<String> getLocalMountPointList(Context c) {

private static void addMountPointPrimaryAndSecondary(String mp, ArrayList<String> ml, String pkg_name) {
File lf =new File(mp);
if (lf.canRead()) {
if (lf != null && lf.canRead()) {
ml.add(mp);
ml.add(mp+"/Android/data/"+pkg_name+"/files");
// Log.v("","added p&s="+mp);
Expand Down Expand Up @@ -421,6 +435,7 @@ private static void addMountPointPrimary(String mp, ArrayList<String> ml) {
// };
//

// legacy not used
final public static ArrayList<LocalMountPointListItem> getLocalMountPointListWithLink(Context c) {
ArrayList<LocalMountPointListItem> list=new ArrayList<LocalMountPointListItem>();
ArrayList<String> mp_list=getLocalMountPointList(c);
Expand Down Expand Up @@ -448,6 +463,8 @@ final public static ArrayList<LocalMountPointListItem> getLocalMountPointListWit
}
return list;
};

// legacy not used
static public class LocalMountPointListItem {
public boolean isSynbolicLink=false;
public String mount_point_name=null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ public void negativeResponse(Context c, Object[] o) {
public void run() {
File lf=new File(zip_file_name);
lf.delete();
String[] lmp=LocalMountPoint.convertFilePathToMountpointFormat(mContext, file_name[0]);
String[] lmp=LocalMountPoint.convertFilePathToMountpointFormat(mContext, file_name[0]); // should just use /storage/emulated/0 (SafManager3.getPrimaryStoragePath())
ZipUtil.createZipFile(mContext, tc,pbdf,zip_file_name,lmp[0],file_name);
if (tc.isEnabled()) {
Intent intent=new Intent();
Expand Down Expand Up @@ -1466,9 +1466,14 @@ public void showDialog(Context c, FragmentManager fm, Fragment frag, NotifyEvent
ft.commitAllowingStateLoss();
mNotifyUpdateLogOption=ntfy;
} else {
File lf=c.getExternalFilesDirs(null)[0];
String fp = "";
File[] fl=c.getExternalFilesDirs(null);
if (fl != null) {
File lf=fl[0];
if (lf != null) fp = lf.getPath(); // internal storage app specific dir
}
MessageDialogFragment mdf=MessageDialogFragment.newInstance(false, "E",
c.getString(R.string.msgs_log_can_not_start_log_mgmt), "file="+lf);
c.getString(R.string.msgs_log_can_not_start_log_mgmt), "file="+fp);
mdf.showDialog(fm, mdf, null);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ protected void showDialog(Bundle state) {

@SuppressWarnings("deprecation")
public static void setSpinnerBackground(Context c, Spinner spinner, boolean theme_is_light) {
if (theme_is_light) spinner.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.spinner_color_background_light));
else spinner.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.spinner_color_background));
if (theme_is_light) spinner.setBackground(c.getResources().getDrawable(R.drawable.spinner_color_background_light));
else spinner.setBackground(c.getResources().getDrawable(R.drawable.spinner_color_background));
};

private ListView mTreeFileListView=null;
Expand Down
Loading