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

Add a scroll bar when searching for a media file #91

Merged
merged 3 commits into from
Jun 4, 2018
Merged
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ script:
- python2 app/src/test/shell/test.py

after_failure:
- adb logcat -d -b main,system,events,crash
- cat app/build/reports/findbugs/findbugs.html
- cat app/build/reports/tests/debug/index.html
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies {
compile 'commons-io:commons-io:2.5'
compile group: 'com.google.guava', name: 'guava', version: '20.0'
compile 'com.nononsenseapps:filepicker:4.2.1'
implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.9'
implementation group: 'org.javatuples', name: 'javatuples', version: '1.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.11.1'

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</intent-filter>
</activity>
<activity
android:name="com.nononsenseapps.filepicker.FilePickerActivity"
android:name=".picker.FastScrollerFilePickerActivity"
android:label="@string/app_name"
android:theme="@style/FilePickerTheme">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import protect.videotranscoder.media.MediaContainer;
import protect.videotranscoder.media.MediaInfo;
import protect.videotranscoder.media.VideoCodec;
import protect.videotranscoder.picker.FastScrollerFilePickerActivity;
import protect.videotranscoder.service.FFmpegProcessService;
import protect.videotranscoder.service.MessageId;

Expand Down Expand Up @@ -497,7 +498,7 @@ public void onClick(DialogInterface dialog, int which)
*/
private void selectVideo()
{
Intent i = new Intent(this, FilePickerActivity.class);
Intent i = new Intent(this, FastScrollerFilePickerActivity.class);

i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
Expand Down Expand Up @@ -1433,6 +1434,7 @@ private void displayAboutDialog()
.put("javatuples", "https://www.javatuples.org/")
.put("jackson-databind", "https://github.com/FasterXML/jackson-databind")
.put("ACRA", "https://github.com/ACRA/acra")
.put("RecyclerView-FastScroll", "https://github.com/timusus/RecyclerView-FastScroll")
.build();

final Map<String, String> USED_ASSETS = ImmutableMap.of
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package protect.videotranscoder.picker;

import android.os.Environment;
import android.support.annotation.Nullable;

import com.nononsenseapps.filepicker.AbstractFilePickerActivity;
import com.nononsenseapps.filepicker.AbstractFilePickerFragment;

import java.io.File;

/**
* All this class does is return a suitable fragment.
*/
public class FastScrollerFilePickerActivity extends AbstractFilePickerActivity {

public FastScrollerFilePickerActivity() {
super();
}

@Override
protected AbstractFilePickerFragment getFragment(@Nullable String startPath, int mode, boolean allowMultiple, boolean allowCreateDir, boolean allowExistingFile, boolean singleClick)
{
return getFragment(startPath, mode, allowMultiple, allowCreateDir);
}

protected AbstractFilePickerFragment<File> getFragment(
@Nullable final String startPath, final int mode, final boolean allowMultiple,
final boolean allowCreateDir) {
AbstractFilePickerFragment<File> fragment = new FastScrollerFilePickerFragment();
// startPath is allowed to be null. In that case, default folder should be SD-card and not "/"
fragment.setArgs(startPath != null ? startPath : Environment.getExternalStorageDirectory().getPath(),
mode, allowMultiple, allowCreateDir, true, false);
return fragment;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package protect.videotranscoder.picker;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.nononsenseapps.filepicker.FilePickerFragment;

import protect.videotranscoder.R;

public class FastScrollerFilePickerFragment extends FilePickerFragment {
@Override
protected View inflateRootView(LayoutInflater inflater, ViewGroup container) {
return inflater.inflate(R.layout.fragment_fastscrollerfilepicker, container, false);
}
}
111 changes: 111 additions & 0 deletions app/src/main/res/layout/fragment_fastscrollerfilepicker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ This Source Code Form is subject to the terms of the Mozilla Public
~ License, v. 2.0. If a copy of the MPL was not distributed with this
~ file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<RelativeLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.v7.widget.Toolbar
android:id="@+id/nnf_picker_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?nnf_toolbarTheme">

<TextView
android:id="@+id/nnf_current_dir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="start"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"/>
</android.support.v7.widget.Toolbar>

<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/nnf_buttons_container"
android:layout_below="@+id/nnf_picker_toolbar"
android:descendantFocusability="afterDescendants"
android:focusable="true"
app:fastScrollAutoHide="true"
app:fastScrollAutoHideDelay="1500"
app:fastScrollPopupBgColor="?colorAccent"
app:fastScrollPopupTextColor="@android:color/primary_text_dark"
app:fastScrollThumbColor="?colorAccent" />

<FrameLayout
android:id="@+id/nnf_buttons_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">

<LinearLayout
android:id="@+id/nnf_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/nnf_button_cancel"
style="?attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:text="@string/nnf_list_cancel"/>

<Button
android:id="@+id/nnf_button_ok"
style="?attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:text="@string/nnf_list_ok"/>

</LinearLayout>

<LinearLayout
android:id="@+id/nnf_newfile_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<EditText
android:id="@+id/nnf_text_filename"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:hint="@string/nnf_filename"
android:maxLines="1"
android:paddingLeft="8dp"
android:paddingRight="8dp"/>

<ImageButton
android:id="@+id/nnf_button_ok_newfile"
style="?attr/borderlessButtonStyle"
android:layout_width="48dp"
android:layout_height="48dp"
android:hint="@string/nnf_list_ok"
app:srcCompat="@drawable/nnf_ic_save_black_24dp"
android:tint="?attr/nnf_save_icon_color"/>

</LinearLayout>
</FrameLayout>

<FrameLayout
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_above="@id/nnf_buttons_container"
android:background="?nnf_separator_color"/>
</RelativeLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<string name="about">About</string>
<string name="app_copyright_fmt">Copyright 2018-<xliff:g>%d</xliff:g> Branden Archer</string>
<string name="app_license">Licensed under the GPLv2.</string>
<string name="app_license">Licensed under the GPLv3.</string>
<string name="about_title_fmt">About <xliff:g id="app_name">%s</xliff:g></string>
<string name="debug_version_fmt">Version: <xliff:g id="version">%s</xliff:g></string>
<string name="app_revision_fmt">Revision Information: <xliff:g id="app_revision_url">%s</xliff:g></string>
Expand Down