Skip to content

Commit

Permalink
update FileBrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirosakiMio committed Mar 22, 2024
1 parent b18134d commit 2774ae6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;

import com.tungsten.fcllibrary.R;
import com.tungsten.fcllibrary.browser.adapter.FileBrowserAdapter;
Expand Down Expand Up @@ -41,6 +42,7 @@ public class FileBrowserActivity extends FCLActivity implements View.OnClickList

private FCLButton sharedDir;
private FCLButton privateDir;
private FCLButton openExternal;
private FCLButton confirm;

private Path currentPath;
Expand Down Expand Up @@ -70,9 +72,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

sharedDir = findViewById(R.id.shared_dir);
privateDir = findViewById(R.id.private_dir);
openExternal = findViewById(R.id.open_external);
confirm = findViewById(R.id.confirm);
sharedDir.setOnClickListener(this);
privateDir.setOnClickListener(this);
openExternal.setOnClickListener(this);
confirm.setOnClickListener(this);

selectedFiles = new ArrayList<>();
Expand Down Expand Up @@ -164,6 +168,12 @@ public void onClick(View view) {
Toast.makeText(this, getString(R.string.file_browser_private_alert), Toast.LENGTH_SHORT).show();
}
}
if (view == openExternal) {
Uri uri = FileProvider.getUriForFile(this, getString(R.string.file_browser_provider), currentPath.toFile());
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setDataAndType(uri, "*/*");
startActivity(intent);
}
if (view == confirm) {
if (selectedFiles.size() == 0 && fileBrowser.getLibMode() != LibMode.FILE_BROWSER) {
Toast.makeText(this, getString(R.string.file_browser_positive_alert), Toast.LENGTH_SHORT).show();
Expand Down
12 changes: 12 additions & 0 deletions FCLLibrary/src/main/res/layout/activity_file_browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/file_browser_private"/>

<com.tungsten.fcllibrary.component.view.FCLButton
android:id="@+id/open_external"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:layout_constraintTop_toBottomOf="@+id/private_dir"
app:layout_constraintStart_toEndOf="@+id/split"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/file_browser_open_external"/>

<com.tungsten.fcllibrary.component.view.FCLTextView
android:id="@+id/mode_hint"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions FCLLibrary/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<string name="file_browser_close">退出</string>
<string name="file_browser_shared">共有目录</string>
<string name="file_browser_private">私有目录</string>
<string name="file_browser_open_external">使用外部应用打开</string>
<string name="file_browser_private_alert">无法进入私有目录,请检查应用权限</string>
<string name="file_browser_mode">模式:</string>
<string name="file_browser_mode_browse">浏览文件</string>
Expand Down
1 change: 1 addition & 0 deletions FCLLibrary/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<string name="file_browser_close">Exit</string>
<string name="file_browser_shared">Shared directory</string>
<string name="file_browser_private">Private directory</string>
<string name="file_browser_open_external">Open in external APP</string>
<string name="file_browser_private_alert">Cannot access to private directory, please check the permission.</string>
<string name="file_browser_mode">Mode:</string>
<string name="file_browser_mode_browse">Browse File</string>
Expand Down

0 comments on commit 2774ae6

Please sign in to comment.