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

Bugfix/display name recently used database #319 #333

Open
wants to merge 3 commits into
base: master
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
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion = 27
Expand Down Expand Up @@ -56,6 +58,10 @@ dependencies {
implementation 'com.madgag.spongycastle:prov:1.58.0.0'
implementation 'joda-time:joda-time:2.9.4'
implementation 'com.android.support:support-compat:27.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}

buildscript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@

public class FileSelectActivity extends Activity {

private static final int MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE = 111;
private ListView mList;
private ListAdapter mAdapter;
private RecentFileAdapter mAdapter;

private static final int CMENU_CLEAR = Menu.FIRST;

Expand Down Expand Up @@ -331,10 +330,10 @@ public void run() {

private void fillData() {
// Set the initial value of the filename
EditText filename = (EditText) findViewById(R.id.file_filename);
EditText filename = findViewById(R.id.file_filename);
filename.setText(Environment.getExternalStorageDirectory().getAbsolutePath() + getString(R.string.default_file_path));

mAdapter = new ArrayAdapter<String>(this, R.layout.file_row, R.id.file_filename, fileHistory.getDbList());
mAdapter = new RecentFileAdapter(this, fileHistory.getDbList());
mList.setAdapter(mAdapter);
}

Expand Down
28 changes: 28 additions & 0 deletions app/src/main/java/com/keepassdroid/fileselect/RecentFileAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.keepassdroid.fileselect

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import com.android.keepass.R
import kotlinx.android.synthetic.main.file_row.view.filename
import kotlinx.android.synthetic.main.file_row.view.filepath
import android.view.LayoutInflater



class RecentFileAdapter(context: Context, val items: List<String>)
: ArrayAdapter<String>(context, R.layout.file_row, R.id.file_filename, items) {

override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View? {
var itemView = convertView
if( itemView == null ){
val vi = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
itemView = vi.inflate(R.layout.file_row, null)
}
itemView?.filename?.text = items.get(position).substringAfterLast('/')
itemView?.filepath?.text = items.get(position)

return itemView
}
}
35 changes: 30 additions & 5 deletions app/src/main/res/layout/file_row.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2009-2011 Brian Pellin.

This file is part of KeePassDroid.
Expand All @@ -17,8 +16,34 @@
You should have received a copy of the GNU General Public License
along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
-->
<TextView android:id="@+id/file_filename" xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="4sp"
style="@style/GroupText"/>
android:orientation="vertical">

<TextView
android:id="@+id/filename"
style="@style/ElementTextTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/margin_tiny"
android:paddingBottom="@dimen/margin_tiny"
android:paddingStart="@dimen/margin_small"
android:paddingEnd="@dimen/margin_small"
tools:text="short filename" />

<TextView
android:id="@+id/filepath"
style="@style/ElementTextSmall"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:paddingTop="@dimen/margin_tiny"
android:paddingBottom="@dimen/margin_tiny"
android:paddingStart="@dimen/margin_small"
android:paddingEnd="@dimen/margin_small"
tools:text="example full file path" />

</LinearLayout>
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
Expand All @@ -9,7 +10,8 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down