mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-29 21:33:07 -08:00
Add toolbar in layouts
This commit is contained in:
1 parent
73a3bafc57
commit
2d4d5fc9b0
19 files changed
+327
-315
No files matched your search
@@ -36,6 +36,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
@@ -109,7 +110,7 @@ public class EntryActivity extends LockCloseHideActivity {
|
||||
}
|
||||
|
||||
protected void setupEditButtons() {
|
||||
Button edit = (Button) findViewById(R.id.entry_edit);
|
||||
View edit = findViewById(R.id.entry_edit);
|
||||
edit.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
@@ -120,9 +121,6 @@ public class EntryActivity extends LockCloseHideActivity {
|
||||
|
||||
if (readOnly) {
|
||||
edit.setVisibility(View.GONE);
|
||||
|
||||
View divider = findViewById(R.id.entry_divider2);
|
||||
divider.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +131,12 @@ public class EntryActivity extends LockCloseHideActivity {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setEntryView();
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
assert getSupportActionBar() != null;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
||||
Context appCtx = getApplicationContext();
|
||||
dateFormat = android.text.format.DateFormat.getDateFormat(appCtx);
|
||||
@@ -372,58 +376,60 @@ public class EntryActivity extends LockCloseHideActivity {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
case R.id.menu_donate:
|
||||
try {
|
||||
Util.gotoUrl(this, R.string.donate_url);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
case R.id.menu_toggle_pass:
|
||||
if ( mShowPassword ) {
|
||||
item.setTitle(R.string.menu_showpass);
|
||||
mShowPassword = false;
|
||||
} else {
|
||||
item.setTitle(R.string.menu_hide_password);
|
||||
mShowPassword = true;
|
||||
}
|
||||
setPasswordStyle();
|
||||
case R.id.menu_donate:
|
||||
try {
|
||||
Util.gotoUrl(this, R.string.donate_url);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return true;
|
||||
case R.id.menu_toggle_pass:
|
||||
if ( mShowPassword ) {
|
||||
item.setTitle(R.string.menu_showpass);
|
||||
mShowPassword = false;
|
||||
} else {
|
||||
item.setTitle(R.string.menu_hide_password);
|
||||
mShowPassword = true;
|
||||
}
|
||||
setPasswordStyle();
|
||||
return true;
|
||||
|
||||
case R.id.menu_goto_url:
|
||||
String url;
|
||||
url = mEntry.getUrl();
|
||||
case R.id.menu_goto_url:
|
||||
String url;
|
||||
url = mEntry.getUrl();
|
||||
|
||||
// Default http:// if no protocol specified
|
||||
if ( ! url.contains("://") ) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
|
||||
try {
|
||||
Util.gotoUrl(this, url);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_url_handler, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
|
||||
// Default http:// if no protocol specified
|
||||
if ( ! url.contains("://") ) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
case R.id.menu_copy_user:
|
||||
timeoutCopyToClipboard(mEntry.getUsername(true, App.getDB().pm));
|
||||
return true;
|
||||
|
||||
try {
|
||||
Util.gotoUrl(this, url);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_url_handler, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.menu_copy_pass:
|
||||
timeoutCopyToClipboard(new String(mEntry.getPassword(true, App.getDB().pm)));
|
||||
return true;
|
||||
|
||||
case R.id.menu_copy_user:
|
||||
timeoutCopyToClipboard(mEntry.getUsername(true, App.getDB().pm));
|
||||
return true;
|
||||
|
||||
case R.id.menu_copy_pass:
|
||||
timeoutCopyToClipboard(new String(mEntry.getPassword(true, App.getDB().pm)));
|
||||
return true;
|
||||
|
||||
case R.id.menu_lock:
|
||||
App.setShutdown();
|
||||
setResult(KeePass.EXIT_LOCK);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
case R.id.menu_lock:
|
||||
App.setShutdown();
|
||||
setResult(KeePass.EXIT_LOCK);
|
||||
finish();
|
||||
return true;
|
||||
|
||||
case android.R.id.home :
|
||||
finish(); // close this activity and return to preview activity (if there is any)
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class EntryActivityV4 extends EntryActivity {
|
||||
|
||||
@Override
|
||||
protected void setEntryView() {
|
||||
setContentView(R.layout.entry_view_v4);
|
||||
setContentView(R.layout.entry_view);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.InputType;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -117,6 +118,13 @@ public abstract class EntryEditActivity extends LockCloseHideActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.entry_edit);
|
||||
setResult(KeePass.EXIT_NORMAL);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getString(R.string.app_name));
|
||||
setSupportActionBar(toolbar);
|
||||
assert getSupportActionBar() != null;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
||||
// Likely the app has been killed exit the activity
|
||||
Database db = App.getDB();
|
||||
@@ -157,7 +165,7 @@ public abstract class EntryEditActivity extends LockCloseHideActivity {
|
||||
});
|
||||
|
||||
// Generate password button
|
||||
Button generatePassword = (Button) findViewById(R.id.generate_button);
|
||||
View generatePassword = findViewById(R.id.generate_button);
|
||||
generatePassword.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
@@ -166,7 +174,7 @@ public abstract class EntryEditActivity extends LockCloseHideActivity {
|
||||
});
|
||||
|
||||
// Save button
|
||||
Button save = (Button) findViewById(R.id.entry_save);
|
||||
View save = findViewById(R.id.entry_save);
|
||||
save.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
@@ -198,17 +206,6 @@ public abstract class EntryEditActivity extends LockCloseHideActivity {
|
||||
|
||||
});
|
||||
|
||||
// Cancel button
|
||||
Button cancel = (Button) findViewById(R.id.entry_cancel);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Respect mask password setting
|
||||
if (mShowPassword) {
|
||||
EditText pass = (EditText) findViewById(R.id.entry_password);
|
||||
@@ -219,6 +216,8 @@ public abstract class EntryEditActivity extends LockCloseHideActivity {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected boolean validateBeforeSaving() {
|
||||
// Require title
|
||||
@@ -313,25 +312,28 @@ public abstract class EntryEditActivity extends LockCloseHideActivity {
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
case R.id.menu_donate:
|
||||
try {
|
||||
Util.gotoUrl(this, R.string.donate_url);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
case R.id.menu_toggle_pass:
|
||||
if ( mShowPassword ) {
|
||||
item.setTitle(R.string.menu_showpass);
|
||||
mShowPassword = false;
|
||||
} else {
|
||||
item.setTitle(R.string.menu_hide_password);
|
||||
mShowPassword = true;
|
||||
}
|
||||
setPasswordStyle();
|
||||
return true;
|
||||
case R.id.menu_donate:
|
||||
try {
|
||||
Util.gotoUrl(this, R.string.donate_url);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
case R.id.menu_toggle_pass:
|
||||
if ( mShowPassword ) {
|
||||
item.setTitle(R.string.menu_showpass);
|
||||
mShowPassword = false;
|
||||
} else {
|
||||
item.setTitle(R.string.menu_hide_password);
|
||||
mShowPassword = true;
|
||||
}
|
||||
setPasswordStyle();
|
||||
return true;
|
||||
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
@@ -144,6 +145,14 @@ public abstract class GroupActivity extends GroupBaseActivity {
|
||||
} else {
|
||||
setContentView(new GroupViewOnlyView(this));
|
||||
}
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getString(R.string.app_name));
|
||||
setSupportActionBar(toolbar);
|
||||
assert getSupportActionBar() != null;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
||||
Log.w(TAG, "Set view");
|
||||
|
||||
if ( addGroupEnabled ) {
|
||||
@@ -230,4 +239,6 @@ public abstract class GroupActivity extends GroupBaseActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public abstract class GroupBaseActivity extends LockCloseListActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void setGroupIcon() {
|
||||
if (mGroup != null) {
|
||||
ImageView iv = (ImageView) findViewById(R.id.icon);
|
||||
|
||||
Reference in new issue
Block a user