Redesign of encrypt activites finished

This commit is contained in:
Dominik Schürmann
2015-03-09 16:03:58 +01:00
parent c50dceab32
commit 72c18734ad
17 changed files with 140 additions and 171 deletions

View File

@@ -88,12 +88,20 @@ public abstract class BaseActivity extends ActionBarActivity {
/**
* Close button only
*/
protected void setFullScreenDialogClose(View.OnClickListener cancelOnClickListener) {
setActionBarIcon(R.drawable.ic_close_white_24dp);
protected void setFullScreenDialogClose(View.OnClickListener cancelOnClickListener, boolean white) {
if (white) {
setActionBarIcon(R.drawable.ic_close_white_24dp);
} else {
setActionBarIcon(R.drawable.ic_close_black_24dp);
}
getSupportActionBar().setDisplayShowTitleEnabled(true);
mToolbar.setNavigationOnClickListener(cancelOnClickListener);
}
protected void setFullScreenDialogClose(View.OnClickListener cancelOnClickListener) {
setFullScreenDialogClose(cancelOnClickListener, true);
}
/**
* Inflate custom design with two buttons using drawables.
* This does not conform to the Material Design Guidelines, but we deviate here as this is used

View File

@@ -17,9 +17,12 @@
package org.sufficientlysecure.keychain.ui;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
@@ -40,6 +43,14 @@ public class DecryptFilesActivity extends BaseActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setFullScreenDialogClose(new View.OnClickListener() {
@Override
public void onClick(View v) {
setResult(Activity.RESULT_CANCELED);
finish();
}
}, false);
// Handle intent actions
handleActions(savedInstanceState, getIntent());
}

View File

@@ -18,9 +18,11 @@
package org.sufficientlysecure.keychain.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
@@ -49,6 +51,14 @@ public class DecryptTextActivity extends BaseActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setFullScreenDialogClose(new View.OnClickListener() {
@Override
public void onClick(View v) {
setResult(Activity.RESULT_CANCELED);
finish();
}
}, false);
// Handle intent actions
handleActions(savedInstanceState, getIntent());
}

View File

@@ -1,10 +1,30 @@
/*
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sufficientlysecure.keychain.ui;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
import android.os.PersistableBundle;
import android.view.View;
import org.openintents.openpgp.util.OpenPgpApi;
import org.sufficientlysecure.keychain.R;
@@ -26,6 +46,19 @@ public abstract class EncryptActivity extends BaseActivity {
protected Date mNfcTimestamp = null;
protected byte[] mNfcHash = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setFullScreenDialogClose(new View.OnClickListener() {
@Override
public void onClick(View v) {
setResult(Activity.RESULT_CANCELED);
finish();
}
}, false);
}
protected void startPassphraseDialog(long subkeyId) {
Intent intent = new Intent(this, PassphraseDialogActivity.class);
intent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID, subkeyId);

View File

@@ -314,15 +314,6 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// if called with an intent action, do not init drawer navigation
if (ACTION_ENCRYPT_DATA.equals(getIntent().getAction())) {
// lock drawer
// deactivateDrawerNavigation();
// TODO: back button to key?
} else {
// activateDrawerNavigation(savedInstanceState);
}
// Handle intent actions
handleActions(getIntent());
updateModeFragment();
@@ -339,17 +330,6 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
return super.onCreateOptionsMenu(menu);
}
private void updateModeFragment() {
getSupportFragmentManager().beginTransaction()
.replace(R.id.encrypt_pager_mode,
mCurrentMode == MODE_SYMMETRIC
? new EncryptSymmetricFragment()
: new EncryptAsymmetricFragment()
)
.commitAllowingStateLoss();
getSupportFragmentManager().executePendingTransactions();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.isCheckable()) {
@@ -384,6 +364,17 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
return true;
}
private void updateModeFragment() {
getSupportFragmentManager().beginTransaction()
.replace(R.id.encrypt_pager_mode,
mCurrentMode == MODE_SYMMETRIC
? new EncryptSymmetricFragment()
: new EncryptAsymmetricFragment()
)
.commitAllowingStateLoss();
getSupportFragmentManager().executePendingTransactions();
}
/**
* Handles all actions with this intent
*
@@ -428,7 +419,6 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
// Save uris
mInputUris = uris;
}
}

View File

@@ -27,6 +27,7 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
@@ -56,7 +57,6 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
// view
private View mAddView;
private View mShareFile;
private ListView mSelectedFiles;
private SelectedFilesAdapter mAdapter = new SelectedFilesAdapter();
private final Map<Uri, Bitmap> thumbnailCache = new HashMap<>();
@@ -78,21 +78,6 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.encrypt_files_fragment, container, false);
View vEncryptFile = view.findViewById(R.id.action_encrypt_file);
vEncryptFile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
encryptClicked(false);
}
});
mShareFile = view.findViewById(R.id.action_encrypt_share);
mShareFile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
encryptClicked(true);
}
});
mAddView = inflater.inflate(R.layout.file_list_entry_add, null);
mAddView.setOnClickListener(new View.OnClickListener() {
@Override
@@ -108,8 +93,10 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
private void addInputUri() {
@@ -191,6 +178,24 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.encrypt_save: {
encryptClicked(false);
break;
}
case R.id.encrypt_share: {
encryptClicked(true);
break;
}
default: {
return super.onOptionsItemSelected(item);
}
}
return true;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {

View File

@@ -23,6 +23,7 @@ import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -33,8 +34,6 @@ public class EncryptTextFragment extends Fragment {
public static final String ARG_TEXT = "text";
private TextView mText;
private View mEncryptShare;
private View mEncryptClipboard;
private EncryptActivityInterface mEncryptInterface;
@@ -72,24 +71,16 @@ public class EncryptTextFragment extends Fragment {
mEncryptInterface.setMessage(s.toString());
}
});
mEncryptClipboard = view.findViewById(R.id.action_encrypt_clipboard);
mEncryptShare = view.findViewById(R.id.action_encrypt_share);
mEncryptClipboard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mEncryptInterface.startEncrypt(false);
}
});
mEncryptShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mEncryptInterface.startEncrypt(true);
}
});
return view;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -100,4 +91,22 @@ public class EncryptTextFragment extends Fragment {
mText.setText(text);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.encrypt_copy: {
mEncryptInterface.startEncrypt(false);
break;
}
case R.id.encrypt_share: {
mEncryptInterface.startEncrypt(true);
break;
}
default: {
return super.onOptionsItemSelected(item);
}
}
return true;
}
}