From 77c397e0d110b776d7dfa6d81a78d17c60d594ca Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 4 Jul 2019 19:10:33 +0200 Subject: [PATCH] Fix small bugs --- .../keepass/activities/AboutActivity.java | 88 ------------------- .../keepass/activities/AboutActivity.kt | 82 +++++++++++++++++ .../FileDatabaseSelectActivity.java | 2 +- 3 files changed, 83 insertions(+), 89 deletions(-) delete mode 100644 app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.java create mode 100644 app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.kt diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.java b/app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.java deleted file mode 100644 index 2a2d41516..000000000 --- a/app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft. - * - * This file is part of KeePass DX. - * - * KeePass DX is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * KeePass DX is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KeePass DX. If not, see . - * - */ -package com.kunzisoft.keepass.activities; - -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Bundle; -import android.support.v7.widget.Toolbar; -import android.util.Log; -import android.view.MenuItem; -import android.widget.TextView; - -import com.kunzisoft.keepass.BuildConfig; -import com.kunzisoft.keepass.R; -import com.kunzisoft.keepass.stylish.StylishActivity; - -import org.joda.time.DateTime; - -public class AboutActivity extends StylishActivity { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.about); - - Toolbar toolbar = findViewById(R.id.toolbar); - toolbar.setTitle(getString(R.string.menu_about)); - setSupportActionBar(toolbar); - assert getSupportActionBar() != null; - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setDisplayShowHomeEnabled(true); - - String version; - String build; - try { - version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; - build = BuildConfig.BUILD_VERSION; - } catch (NameNotFoundException e) { - Log.w(getClass().getSimpleName(), "Unable to get the app or the build version", e); - version = "Unable to get the app version"; - build = "Unable to get the build version"; - } - version = getString(R.string.version_label, version); - TextView versionTextView = findViewById(R.id.activity_about_version); - versionTextView.setText(version); - - build = getString(R.string.build_label, build); - TextView buildTextView = findViewById(R.id.activity_about_build); - buildTextView.setText(build); - - - TextView disclaimerText = findViewById(R.id.disclaimer); - disclaimerText.setText(getString(R.string.disclaimer_formal, new DateTime().getYear())); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - - //noinspection SimplifiableIfStatement - switch (id) { - case android.R.id.home: - finish(); - break; - } - return super.onOptionsItemSelected(item); - } -} diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.kt new file mode 100644 index 000000000..c2018c06c --- /dev/null +++ b/app/src/main/java/com/kunzisoft/keepass/activities/AboutActivity.kt @@ -0,0 +1,82 @@ +/* + * Copyright 2019 Jeremy Jamet / Kunzisoft. + * + * This file is part of KeePass DX. + * + * KeePass DX is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * KeePass DX is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KeePass DX. If not, see . + * + */ +package com.kunzisoft.keepass.activities + +import android.content.pm.PackageManager.NameNotFoundException +import android.os.Bundle +import android.support.v7.widget.Toolbar +import android.util.Log +import android.view.MenuItem +import android.widget.TextView + +import com.kunzisoft.keepass.BuildConfig +import com.kunzisoft.keepass.R +import com.kunzisoft.keepass.stylish.StylishActivity + +import org.joda.time.DateTime + +class AboutActivity : StylishActivity() { + + public override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.about) + + val toolbar = findViewById(R.id.toolbar) + toolbar.title = getString(R.string.menu_about) + setSupportActionBar(toolbar) + assert(supportActionBar != null) + supportActionBar!!.setDisplayHomeAsUpEnabled(true) + supportActionBar!!.setDisplayShowHomeEnabled(true) + + var version: String + var build: String + try { + version = packageManager.getPackageInfo(packageName, 0).versionName + build = BuildConfig.BUILD_VERSION + } catch (e: NameNotFoundException) { + Log.w(javaClass.simpleName, "Unable to get the app or the build version", e) + version = "Unable to get the app version" + build = "Unable to get the build version" + } + + version = getString(R.string.version_label, version) + val versionTextView = findViewById(R.id.activity_about_version) + versionTextView.text = version + + build = getString(R.string.build_label, build) + val buildTextView = findViewById(R.id.activity_about_build) + buildTextView.text = build + + + val disclaimerText = findViewById(R.id.disclaimer) + disclaimerText.text = getString(R.string.disclaimer_formal, DateTime().year) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + when (item.itemId) { + android.R.id.home -> finish() + } + return super.onOptionsItemSelected(item) + } +} diff --git a/app/src/main/java/com/kunzisoft/keepass/fileselect/FileDatabaseSelectActivity.java b/app/src/main/java/com/kunzisoft/keepass/fileselect/FileDatabaseSelectActivity.java index 80f0b323a..1ee943508 100644 --- a/app/src/main/java/com/kunzisoft/keepass/fileselect/FileDatabaseSelectActivity.java +++ b/app/src/main/java/com/kunzisoft/keepass/fileselect/FileDatabaseSelectActivity.java @@ -91,7 +91,7 @@ public class FileDatabaseSelectActivity extends StylishActivity implements FileDatabaseHistoryAdapter.FileSelectClearListener, FileDatabaseHistoryAdapter.FileInformationShowListener { - private static final String TAG = "FileDatabaseSelectActivity"; + private static final String TAG = "FileDbSelectActivity"; private static final String EXTRA_STAY = "EXTRA_STAY";