Skip to content

Commit

Permalink
重新提交
Browse files Browse the repository at this point in the history
  • Loading branch information
molihuan committed Jun 7, 2022
1 parent 0ec00a7 commit 94539b2
Show file tree
Hide file tree
Showing 49 changed files with 1,401 additions and 560 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
.externalNativeBuild
.cxx
local.properties
gradles
gradle.properties
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(path: ':fileselectorlib')
implementation project(path: ':fileselectorlib2')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'


}
40 changes: 34 additions & 6 deletions app/src/main/java/com/molihuan/demo01/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@
import android.widget.Button;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.ToastUtils;
import com.molihuan.demo01.R;
import com.molihuan.demo01.utils.PermissionsTools;
import com.z.fileselectorlib.FileSelectorSettings;
import com.z.fileselectorlib.Objects.BasicParams;
import com.z.fileselectorlib.Objects.FileInfo;
import com.zlylib.mlhfileselectorlib.FileSelector;
import com.zlylib.mlhfileselectorlib.utils.Const;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
/**
* SelectCreator
* Created by zhangliyang on 2020/6/20.
* Updata by molihuan on 2022/6/7
*/
public class MainActivity extends Activity implements View.OnClickListener {
private Button btn_openFileChoose1;
private Button btn_openFileChoose2;
private Button btn_openFileChoose3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PermissionsTools.generalPermissionsOfStorage(this);
//PermissionsTools.generalPermissionsOfStorage(this);
//PermissionsTools.getAllNeedPermissions(this,getContentResolver());
getComponent();
setListener();
Expand Down Expand Up @@ -101,7 +103,6 @@ private void openFileChoose1() {
* 设置 onlyShowFolder() 只显示文件夹 后 默认设置了onlySelectFolder()
* 设置 onlySelectFolder() 只能选择文件夹 后 默认设置了isSingle()
* 设置 isSingle() 只能选择一个 后 再设置了setMaxCount() 不生效
*
*/
FileSelector.from(this)
//.onlyShowFolder() //只显示文件夹
Expand All @@ -115,6 +116,33 @@ private void openFileChoose1() {
//.setSortType(FileSelector.BY_EXTENSION_DESC) //设置类型排序
.requestCode(100) //设置返回码
.setTargetPath("/storage/emulated/0/") //设置默认目录
//.setToolbar(new EmptyFragment())
// .setMoreOPtions(new String[]{"选择","删除"},
// new boolean[]{true,false},
// new SelectOptions.IToolbarOptionsListener() {
// @Override
// public void onOptionClick(Context context, int position, String currentPath, ArrayList<FileBean> selectedFileList, ArrayList<String> selectedFilePathList, FileListAdapter adapter) {
// ToastUtils.make().show("选择"+currentPath);
// }
// },
// new SelectOptions.IToolbarOptionsListener() {
// @Override
// public void onOptionClick(Context context, int position, String currentPath, ArrayList<FileBean> selectedFileList, ArrayList<String> selectedFilePathList, FileListAdapter adapter) {
// ToastUtils.make().show("删除"+currentPath);
// }
// }
// )
// .setFileItemDispose(new SelectOptions.IOnFileItemListener() {
// @Override
// public void onFileItemClick(Context context, int position, String fileAbsolutePath, ArrayList<FileBean> selectedFileList, ArrayList<String> selectedFilePathList, FileListAdapter adapter) {
// ToastUtils.make().show("点击"+fileAbsolutePath);
// }
//
// @Override
// public void onLongFileItemClick(Context context, int position, String fileAbsolutePath, ArrayList<FileBean> selectedFileList, ArrayList<String> selectedFilePathList, FileListAdapter adapter) {
// ToastUtils.make().show("长按"+fileAbsolutePath);
// }
// })
.start();
}

Expand Down
89 changes: 89 additions & 0 deletions app/src/main/java/com/molihuan/demo01/fragments/BaseFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.molihuan.demo01.fragments;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.zlylib.mlhfileselectorlib.interfaces.IActivityAndFragment;


public abstract class BaseFragment extends Fragment implements View.OnClickListener {

private int mFragmentViewId;
private View mFragmentView;
public Activity mActivity;
public IActivityAndFragment mIActivityAndFragment;//定义activity与fragment通信接口

public BaseFragment() {
// Required empty public constructor
}
public BaseFragment(@LayoutRes int fragmentViewId) {
mFragmentViewId=fragmentViewId;
}


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (mFragmentView==null){
mFragmentView = inflater.inflate(mFragmentViewId, container, false);
getComponents(mFragmentView);//获取组件
setListeners(mFragmentView);//设置监听
initData(mFragmentView);//初始化数据
}
return mFragmentView;
}

public abstract void initData(View view);

public abstract void setListeners(View view);

public abstract void getComponents(View view);

@Override
public abstract void onClick(View v);



/**
* 当Activity和Fragment产生关系时调用
* context可以强转为Activity
* @param context
*/
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (mActivity==null){
mActivity= getActivity();
}

try {
//获取通信接口实例
mIActivityAndFragment= (IActivityAndFragment) context;
} catch (Exception e) {
e.printStackTrace();
Log.e("interfaceError","IActivityAndFragment错误,Activity必须实现IActivityAndFragment接口");
}
}

/**
* 当Activity和Fragment脱离时调用
*/
@Override
public void onDetach() {
super.onDetach();
}
}
42 changes: 42 additions & 0 deletions app/src/main/java/com/molihuan/demo01/fragments/EmptyFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.molihuan.demo01.fragments;

import android.view.View;
import android.widget.TextView;

import com.molihuan.demo01.R;

public class EmptyFragment extends BaseFragment {

private TextView tv1;

public EmptyFragment() {
super(R.layout.fragment_empty);
}

@Override
public void initData(View view) {

}

@Override
public void setListeners(View view) {
tv1.setOnClickListener(this);
}

@Override
public void getComponents(View view) {
tv1=view.findViewById(R.id.tv1);
}

@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.tv1:
tv1.setVisibility(View.INVISIBLE);

break;
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.molihuan.demo01.interfaces;
/**
* author: molihuan
* 2022.6.1
* Activity与Fragment通信接口
*/
public interface IActivityAndFragment {
Object invokeFuncAiF(int functionCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class PermissionsTools {

public static void getAllNeedPermissions(Activity context, ContentResolver contentResolver){
generalPermissionsOfStorage(context);//普通存储访问权限
getAndroidDataPermissionDialog(context,contentResolver);

if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager())) {
//表明已经有这个权限了
Expand All @@ -42,7 +43,7 @@ public static void getAllNeedPermissions(Activity context, ContentResolver conte
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
specialPermissionsOfStorage(context);//特殊存储访问权限
getAndroidDataPermissionDialog(context,contentResolver);

}
})
.negativeText("就不给")
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_empty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.BaseFragment">

<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_blank_fragment" />

</FrameLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<resources>
<string name="app_name">demo01</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"

classpath 'com.github.kezong:fat-aar:1.3.8'//打包嵌套aar工具
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -16,8 +17,12 @@ allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://www.jitpack.io' }
maven { url 'https://jitpack.io' }
flatDir {
dirs 'libs' //this way we can find the .aar file in libs folder
}
}
}

Expand Down
21 changes: 11 additions & 10 deletions fileselectorlib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
apply plugin: 'com.android.library'
apply plugin: 'com.kezong.fat-aar'

android {
compileSdkVersion 27
buildToolsVersion "29.0.3"
compileSdkVersion 30
buildToolsVersion '30.0.3'

defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
targetSdkVersion 30
versionCode 3
versionName "1.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
Expand All @@ -23,16 +24,16 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

//implementation fileTree(dir: 'libs', include: ['*.jar',"*.aar"])
embed(name: 'XXPermissions-13.5', ext: 'aar')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'


//Android 自定义性ActionBar
// implementation 'androidx.recyclerview:recyclerview:1.2.1'
// Android 自定义性ActionBar
// implementation 'com.github.ZLYang110:TitleBar:1.0.1'
// implementation 'com.github.bumptech.glide:glide:4.8.0'
// implementation 'org.greenrobot:eventbus:3.1.1'
// implementation 'com.android.support:design:27.1.0'
}
apply from: "${getRootDir().absolutePath}/gradles/publish-maven.gradle"
Binary file added fileselectorlib/libs/XXPermissions-13.5.aar
Binary file not shown.
12 changes: 9 additions & 3 deletions fileselectorlib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.zlylib.mlhfileselectorlib">
<!-- 外部存储的写权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- 安卓11额外权限 -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<application>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />

<activity android:name="com.zlylib.mlhfileselectorlib.ui.FileSelectorActivity" />
<application
android:preserveLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true"
>

<activity android:name="com.zlylib.mlhfileselectorlib.activity.FileSelectorActivity" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.ess.file.provider"
Expand Down
Loading

0 comments on commit 94539b2

Please sign in to comment.