hedzr / android-file-chooser

a lightweight file/folder chooser or picker
Apache License 2.0
284 stars 62 forks source link

Not compatible with D-pad #47

Closed zipswich closed 2 years ago

zipswich commented 5 years ago

Unable to use D-pad to click the OK or Cancel button. The focus will not stay on them. Very strange. This has been confirmed on both physical devices and emulators.

hedzr commented 5 years ago

you're so kind. i'll review it asap.

Guiorgy commented 5 years ago

@zipswich, if the problem is still there, would you mind trying my implementation of D-pad? It's a bit different. (you do need to enable it though .enableDpad(true))

hedzr commented 5 years ago

I had already fixed at commit 84b825d but wrong issue number. :(

Guiorgy commented 5 years ago

oh

zipswich commented 5 years ago

I am sorry but I missed the fix. Thanks a lot for the effort. Anyway, I have just tried it. There seems to be no more "OK" button. It has only Cancel button: image

Guiorgy commented 5 years ago

@zipswich, what setting/filters are you using? Depending on that, the button will/will not be visible.

zipswich commented 5 years ago

@Guiorgy Here is my code:

                        new ChooserDialog(SettingsActivity.this)
                                .titleFollowsDir(true)
                                .withResources(R.string.choose_folder, R.string.ok, R.string.cancel)
                                .withStartFile(dirDefault.getAbsolutePath())
                                // to handle the result(s)
                                .withChosenListener((path, pathFile) -> {
Guiorgy commented 5 years ago

@zipswich, sorry for the late relpy.

if (_dirOnly || _enableMultiple) {
    // choosing folder, or multiple files picker
    builder.setPositiveButton(_okRes, (dialog, which) -> {
        if (_result != null) {
             _result.onChoosePath(_currentDir.getAbsolutePath(), _currentDir);
        }
    });
}

In other words, your code is for choosing a single file, which you can select by clicking on it in the list. The button apears if you either want to choose a directory/folder or choose several files.

for example, selecting directory:

.withFilter(/*choose directory*/ true, /*allow hidden files/folders*/ false);
zipswich commented 5 years ago

@Guiorgy Thank you for the elucidation.
Yes, I can confirm that that both OK and Cancel buttons are displayed for selecting a directory, and either can be selected with D-pad. The remaining problem for D-pad operation is the center (enter) button does not work for OK or Cancel. In other words, neither button works with D-pad.

hedzr commented 5 years ago

I hope it works now

zipswich commented 5 years ago

Thank you. Should I still use the following? implementation 'com.obsez.android.lib.filechooser:filechooser:1.1.16' I have just built an app, D-pad still does not work.

hedzr commented 5 years ago

Temporarily, you might need to switch to jitpack.io for the patch d7b831b. Try this one: https://jitpack.io/#hedzr/android-file-chooser/d7b831bf0a

    dependencies {
            implementation 'com.github.hedzr:android-file-chooser:d7b831bf0a'
    }
zipswich commented 5 years ago

Thank you. I got the following error in Android Studio:

ERROR: Failed to resolve: com.github.hedzr:android-file-chooser:d7b831bf0a

hedzr commented 5 years ago

Try again and you'll find it. jitpack.io need a while for building at first request.

You could check that page. It had been built successfully. see also: https://jitpack.io/com/github/hedzr/android-file-chooser/master-v1.1.10-gd7b831b-149/build.log

zipswich commented 5 years ago

Not sure why I still get the following error:

Could not find com.github.hedzr:android-file-chooser:d7b831bf0a.
  Searched in the following locations:
    - https://dl.google.com/dl/android/maven2/com/github/hedzr/android-file-chooser/d7b831bf0a/android-file-chooser-d7b831bf0a.pom
    - https://dl.google.com/dl/android/maven2/com/github/hedzr/android-file-chooser/d7b831bf0a/android-file-chooser-d7b831bf0a.jar
    - https://jcenter.bintray.com/com/github/hedzr/android-file-chooser/d7b831bf0a/android-file-chooser-d7b831bf0a.pom
    - https://jcenter.bintray.com/com/github/hedzr/android-file-chooser/d7b831bf0a/android-file-chooser-d7b831bf0a.jar
    - https://repo.maven.apache.org/maven2/com/github/hedzr/android-file-chooser/d7b831bf0a/android-file-chooser-d7b831bf0a.pom
    - https://repo.maven.apache.org/maven2/com/github/hedzr/android-file-chooser/d7b831bf0a/android-file-chooser-d7b831bf0a.jar
hedzr commented 5 years ago

did you put jitpack ref to your top-level build.gradle, like the README?

it looks like:

allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

take a look about README or https://jitpack.io/#hedzr/android-file-chooser/d7b831bf0a.

zipswich commented 5 years ago

Yes, I copied the code from the page: image

hedzr commented 5 years ago

How about moving these lines up to your TOP-LEVEL build.gradle?

zipswich commented 5 years ago

Now, I am getting:

Task :app:transformDexArchiveWithExternalLibsDexMergerForOfficialDebug FAILED AGPBI: {"kind":"error","text":"Program type already present: com.obsez.android.lib.filechooser.ChooserDialog$Result","sources":[{}],"tool":"D8"}

Perhaps I should just wait for the fix to reach the normal channel.

hedzr commented 5 years ago

:). I could be not publish a release in these days and it seems be fast.

About the error, it looks like you have multiple implements of this library with multiple version. Anyway, you could rebuild since the duplicated symbols; and try add java 8 declares at your app/build.gradle.

zipswich commented 5 years ago

The problem is probably related to AFC used in a library. The library can be built, but the app including the library cannot be built. I will try a few things to get back here to report the outcome.

zipswich commented 5 years ago

I have finally got it to work. I need to apologize for forgetting that the app's gradle file must have the same script as the library's grade file to use AFC even though the app does not have any code using AFC.

The Cancel button works exactly as expected - it can be focused with D-pad arrow keys and selected with the center key. However, the OK button is selected automatically as soon as it gets the focus without using the center button. I think the OK button should behave exactly the same way as the OK button.

hedzr commented 5 years ago

Sorry for late to reply. I have not any dpad simulate device or emulator currently, so this case is hard to reproduced. But here is a slight patch because it looks like the basic reason.

Guiorgy commented 5 years ago

dpad_demo

if you are still having problems, you can try the experimental branch

Guiorgy commented 5 years ago

are you still having issues with the new release? If not, then please consider closing this issue

zipswich commented 2 years ago

@Guiorgy Very sorry but I have just realized that I somehow missed the Github notification. It works fine now.