From 5c1ecd4b48f45811fc85276e49cebd38db592f5c Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Wed, 15 Nov 2017 19:21:38 +0100 Subject: [PATCH] Add about --- .../java/com/keepassdroid/AboutActivity.java | 76 +++++++++ .../java/com/keepassdroid/AboutDialog.java | 72 -------- app/src/main/res/layout/about.xml | 159 ++++++++++++------ 3 files changed, 179 insertions(+), 128 deletions(-) create mode 100644 app/src/main/java/com/keepassdroid/AboutActivity.java delete mode 100644 app/src/main/java/com/keepassdroid/AboutDialog.java diff --git a/app/src/main/java/com/keepassdroid/AboutActivity.java b/app/src/main/java/com/keepassdroid/AboutActivity.java new file mode 100644 index 000000000..dda3c8af8 --- /dev/null +++ b/app/src/main/java/com/keepassdroid/AboutActivity.java @@ -0,0 +1,76 @@ +/* + * 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.keepassdroid; + +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.MenuItem; +import android.widget.TextView; + +import com.android.keepass.R; + +public class AboutActivity extends AppCompatActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.about); + + Toolbar 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; + try { + PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); + version = packageInfo.versionName; + } catch (NameNotFoundException e) { + Log.w(getClass().getSimpleName(), "Unable to get application version", e); + version = "Unable to get application version."; + } + version = getString(R.string.version_label) + " " + version; + TextView versionText = (TextView) findViewById(R.id.activity_about_version); + versionText.setText(version); + } + + @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/keepassdroid/AboutDialog.java b/app/src/main/java/com/keepassdroid/AboutDialog.java deleted file mode 100644 index 80cc00cf7..000000000 --- a/app/src/main/java/com/keepassdroid/AboutDialog.java +++ /dev/null @@ -1,72 +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 2 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.keepassdroid; - -import android.app.Dialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Bundle; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AlertDialog; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; - -import com.android.keepass.R; - -public class AboutDialog extends DialogFragment { - - private View root; - - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - LayoutInflater inflater = getActivity().getLayoutInflater(); - - root = inflater.inflate(R.layout.about, null); - - setVersion(); - - builder.setView(root) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - dismiss(); - } - }); - return builder.create(); - } - - private void setVersion() { - Context ctx = getContext(); - String version; - try { - PackageInfo packageInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0); - version = packageInfo.versionName; - } catch (NameNotFoundException e) { - e.printStackTrace(); - version = ""; - } - TextView tv = (TextView) root.findViewById(R.id.version); - tv.setText(version); - } -} diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml index 9f1013365..684762e6f 100644 --- a/app/src/main/res/layout/about.xml +++ b/app/src/main/res/layout/about.xml @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -17,64 +17,111 @@ You should have received a copy of the GNU General Public License along with KeePass DX. If not, see . --> - + android:layout_height="wrap_content" + android:orientation="vertical"> - + + + android:layout_height="match_parent"> - - - - - - - - - - - - - \ No newline at end of file + android:isScrollContainer="true" + android:orientation="vertical" + android:paddingBottom="16dp" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:paddingTop="16dp" + android:scrollbars="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file