aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-03-29 00:11:07 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-03-30 19:32:04 +0200
commit4cec2194e01b7213271fa1fb0d50e5ae386fb16e (patch)
tree665c252d21815ded98c46a36be58d58feb6f5b0f /OpenPGP-Keychain/src/main/java/org
parent224e8a7554a58f98b6ff71cc1a15d14108f98242 (diff)
downloadopen-keychain-4cec2194e01b7213271fa1fb0d50e5ae386fb16e.tar.gz
open-keychain-4cec2194e01b7213271fa1fb0d50e5ae386fb16e.tar.bz2
open-keychain-4cec2194e01b7213271fa1fb0d50e5ae386fb16e.zip
Experiments with fragments in decrypt activity
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java350
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java62
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java78
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java74
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java12
5 files changed, 421 insertions, 155 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
index 9b3b00c19..24a8854af 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
@@ -25,12 +25,17 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
+import android.support.v4.app.Fragment;
+import android.support.v4.view.PagerTabStrip;
+import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.*;
+
import com.beardedhen.androidbootstrap.BootstrapButton;
import com.devspark.appmsg.AppMsg;
+
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.sufficientlysecure.keychain.Constants;
@@ -49,6 +54,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
+import org.sufficientlysecure.keychain.ui.adapter.PageTabStripAdapter;
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
@@ -57,7 +63,7 @@ import org.sufficientlysecure.keychain.util.Log;
import java.io.*;
import java.util.regex.Matcher;
-@SuppressLint("NewApi")
+//@SuppressLint("NewApi")
public class DecryptActivity extends DrawerActivity {
/* Intents */
@@ -67,28 +73,30 @@ public class DecryptActivity extends DrawerActivity {
/* EXTRA keys for input */
public static final String EXTRA_TEXT = "text";
+ public static final String EXTRA_SELECTED_TAB = "selected_tab";
+
private static final int RESULT_CODE_LOOKUP_KEY = 0x00007006;
private static final int RESULT_CODE_FILE = 0x00007003;
private long mSignatureKeyId = 0;
- private boolean mReturnResult = false;
+// private boolean mReturnResult = false;
// TODO: replace signed only checks with something more intelligent
// PgpDecryptVerify should handle all automatically!!!
private boolean mSignedOnly = false;
private boolean mAssumeSymmetricEncryption = false;
- private EditText mMessage = null;
+ // private EditText mMessage = null;
private RelativeLayout mSignatureLayout = null;
private ImageView mSignatureStatusImage = null;
private TextView mUserId = null;
private TextView mUserIdRest = null;
- private ViewFlipper mSource = null;
- private TextView mSourceLabel = null;
- private ImageView mSourcePrevious = null;
- private ImageView mSourceNext = null;
+// private ViewFlipper mSource = null;
+// private TextView mSourceLabel = null;
+// private ImageView mSourcePrevious = null;
+// private ImageView mSourceNext = null;
private int mDecryptTarget;
@@ -107,45 +115,50 @@ public class DecryptActivity extends DrawerActivity {
private FileDialogFragment mFileDialog;
- private boolean mDecryptImmediately = false;
+// private boolean mDecryptImmediately = false;
private BootstrapButton mDecryptButton;
- private void initView() {
- mSource = (ViewFlipper) findViewById(R.id.source);
- mSourceLabel = (TextView) findViewById(R.id.sourceLabel);
- mSourcePrevious = (ImageView) findViewById(R.id.sourcePrevious);
- mSourceNext = (ImageView) findViewById(R.id.sourceNext);
-
- mSourcePrevious.setClickable(true);
- mSourcePrevious.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- mSource.setInAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
- R.anim.push_right_in));
- mSource.setOutAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
- R.anim.push_right_out));
- mSource.showPrevious();
- updateSource();
- }
- });
-
- mSourceNext.setClickable(true);
- OnClickListener nextSourceClickListener = new OnClickListener() {
- public void onClick(View v) {
- mSource.setInAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
- R.anim.push_left_in));
- mSource.setOutAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
- R.anim.push_left_out));
- mSource.showNext();
- updateSource();
- }
- };
- mSourceNext.setOnClickListener(nextSourceClickListener);
+ ViewPager mViewPager;
+ PagerTabStrip mPagerTabStrip;
+ PageTabStripAdapter mTabsAdapter;
+ DecryptMessageFragment mMessageFragment;
+ DecryptFileFragment mFileFragment;
- mSourceLabel.setClickable(true);
- mSourceLabel.setOnClickListener(nextSourceClickListener);
+ private void initView() {
+// mSource = (ViewFlipper) findViewById(R.id.source);
+// mSourceLabel = (TextView) findViewById(R.id.sourceLabel);
+// mSourcePrevious = (ImageView) findViewById(R.id.sourcePrevious);
+// mSourceNext = (ImageView) findViewById(R.id.sourceNext);
+//
+// mSourcePrevious.setClickable(true);
+// mSourcePrevious.setOnClickListener(new OnClickListener() {
+// public void onClick(View v) {
+// mSource.setInAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
+// R.anim.push_right_in));
+// mSource.setOutAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
+// R.anim.push_right_out));
+// mSource.showPrevious();
+// updateSource();
+// }
+// });
+//
+// mSourceNext.setClickable(true);
+// OnClickListener nextSourceClickListener = new OnClickListener() {
+// public void onClick(View v) {
+// mSource.setInAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
+// R.anim.push_left_in));
+// mSource.setOutAnimation(AnimationUtils.loadAnimation(DecryptActivity.this,
+// R.anim.push_left_out));
+// mSource.showNext();
+// updateSource();
+// }
+// };
+// mSourceNext.setOnClickListener(nextSourceClickListener);
+//
+// mSourceLabel.setClickable(true);
+// mSourceLabel.setOnClickListener(nextSourceClickListener);
- mMessage = (EditText) findViewById(R.id.message);
mSignatureLayout = (RelativeLayout) findViewById(R.id.signature);
mSignatureStatusImage = (ImageView) findViewById(R.id.ic_signature_status);
mUserId = (TextView) findViewById(R.id.mainUserId);
@@ -153,10 +166,10 @@ public class DecryptActivity extends DrawerActivity {
// measure the height of the source_file view and set the message view's min height to that,
// so it fills mSource fully... bit of a hack.
- View tmp = findViewById(R.id.sourceFile);
- tmp.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
- int height = tmp.getMeasuredHeight();
- mMessage.setMinimumHeight(height);
+// View tmp = findViewById(R.id.sourceFile);
+// tmp.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
+// int height = tmp.getMeasuredHeight();
+// mMessage.setMinimumHeight(height);
mFilename = (EditText) findViewById(R.id.filename);
mBrowse = (BootstrapButton) findViewById(R.id.btn_browse);
@@ -178,11 +191,11 @@ public class DecryptActivity extends DrawerActivity {
mDeleteAfter = (CheckBox) findViewById(R.id.deleteAfterDecryption);
// default: message source
- mSource.setInAnimation(null);
- mSource.setOutAnimation(null);
- while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
- mSource.showNext();
- }
+// mSource.setInAnimation(null);
+// mSource.setOutAnimation(null);
+// while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
+// mSource.showNext();
+// }
mDecryptButton = (BootstrapButton) findViewById(R.id.action_decrypt);
mDecryptButton.setOnClickListener(new OnClickListener() {
@@ -191,6 +204,49 @@ public class DecryptActivity extends DrawerActivity {
decryptClicked();
}
});
+
+ mViewPager = (ViewPager) findViewById(R.id.decrypt_pager);
+ mPagerTabStrip = (PagerTabStrip) findViewById(R.id.decrypt_pager_tab_strip);
+ initPager();
+ }
+
+ private static final int PAGER_TAB_MESSAGE = 0;
+ private static final int PAGER_TAB_FILE = 1;
+
+ private void initPager() {
+ mTabsAdapter = new PageTabStripAdapter(this);
+ mViewPager.setAdapter(mTabsAdapter);
+
+ Bundle messageBundle = new Bundle();
+ mTabsAdapter.addTab(DecryptMessageFragment.class, messageBundle, getString(R.string.label_message));
+
+ Bundle fileBundle = new Bundle();
+ mTabsAdapter.addTab(DecryptFileFragment.class, fileBundle, getString(R.string.label_file));
+
+// mPagerTabStrip.
+ getSupportFragmentManager().executePendingTransactions();
+// for (Fragment f : getSupportFragmentManager().getFragments()) {
+// Log.d(Constants.TAG, "f: "+f.getTag());
+// }
+
+ DecryptMessageFragment messageFragment = (DecryptMessageFragment) getFragmentByPosition(PAGER_TAB_MESSAGE);
+// mFileFragment = (DecryptFileFragment) getFragmentByPosition(PAGER_TAB_FILE);
+
+// Log.d(Constants.TAG, fr.getTag());
+//
+ }
+
+ /**
+ * find fragment
+ *
+ * @param pos
+ * @return
+ */
+ public Fragment getFragmentByPosition(int pos) {
+ // based on FragmentPagerAdapter.makeFragmentName()
+ String tag = "android:switcher:" + mViewPager.getId() + ":" + pos;
+ Log.d(Constants.TAG, "findFragmentByTag: "+tag);
+ return getSupportFragmentManager().findFragmentByTag(tag);
}
@Override
@@ -209,25 +265,25 @@ public class DecryptActivity extends DrawerActivity {
// Handle intent actions
handleActions(getIntent());
- if (mSource.getCurrentView().getId() == R.id.sourceMessage
- && mMessage.getText().length() == 0) {
-
- CharSequence clipboardText = ClipboardReflection.getClipboardText(this);
-
- String data = "";
- if (clipboardText != null) {
- Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(clipboardText);
- if (!matcher.matches()) {
- matcher = PgpHelper.PGP_SIGNED_MESSAGE.matcher(clipboardText);
- }
- if (matcher.matches()) {
- data = matcher.group(1);
- mMessage.setText(data);
- AppMsg.makeText(this, R.string.using_clipboard_content, AppMsg.STYLE_INFO)
- .show();
- }
- }
- }
+// if (mSource.getCurrentView().getId() == R.id.sourceMessage
+// && mMessage.getText().length() == 0) {
+//
+// CharSequence clipboardText = ClipboardReflection.getClipboardText(this);
+//
+// String data = "";
+// if (clipboardText != null) {
+// Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(clipboardText);
+// if (!matcher.matches()) {
+// matcher = PgpHelper.PGP_SIGNED_MESSAGE.matcher(clipboardText);
+// }
+// if (matcher.matches()) {
+// data = matcher.group(1);
+// mMessage.setText(data);
+// AppMsg.makeText(this, R.string.using_clipboard_content, AppMsg.STYLE_INFO)
+// .show();
+// }
+// }
+// }
mSignatureLayout.setVisibility(View.GONE);
mSignatureLayout.setOnClickListener(new OnClickListener() {
@@ -246,28 +302,29 @@ public class DecryptActivity extends DrawerActivity {
}
});
- if (mReturnResult) {
- mSourcePrevious.setClickable(false);
- mSourcePrevious.setEnabled(false);
- mSourcePrevious.setVisibility(View.INVISIBLE);
-
- mSourceNext.setClickable(false);
- mSourceNext.setEnabled(false);
- mSourceNext.setVisibility(View.INVISIBLE);
-
- mSourceLabel.setClickable(false);
- mSourceLabel.setEnabled(false);
- }
-
- updateSource();
-
- if (mDecryptImmediately
- || (mSource.getCurrentView().getId() == R.id.sourceMessage && (mMessage.getText()
- .length() > 0 || mContentUri != null))) {
- decryptClicked();
- }
+// if (mReturnResult) {
+// mSourcePrevious.setClickable(false);
+// mSourcePrevious.setEnabled(false);
+// mSourcePrevious.setVisibility(View.INVISIBLE);
+//
+// mSourceNext.setClickable(false);
+// mSourceNext.setEnabled(false);
+// mSourceNext.setVisibility(View.INVISIBLE);
+//
+// mSourceLabel.setClickable(false);
+// mSourceLabel.setEnabled(false);
+// }
+//
+// updateSource();
+
+// if (mDecryptImmediately
+// || (mSource.getCurrentView().getId() == R.id.sourceMessage && (mMessage.getText()
+// .length() > 0 || mContentUri != null))) {
+// decryptClicked();
+// }
}
+
/**
* Handles all actions with this intent
*
@@ -316,14 +373,17 @@ public class DecryptActivity extends DrawerActivity {
* Main Actions
*/
if (ACTION_DECRYPT.equals(action) && textData != null) {
- Log.d(Constants.TAG, "textData null, matching text ...");
+ Log.d(Constants.TAG, "textData not null, matching text ...");
Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(textData);
if (matcher.matches()) {
Log.d(Constants.TAG, "PGP_MESSAGE matched");
textData = matcher.group(1);
// replace non breakable spaces
textData = textData.replaceAll("\\xa0", " ");
- mMessage.setText(textData);
+
+ mViewPager.setCurrentItem(PAGER_TAB_MESSAGE, false);
+ mMessageFragment.setText(textData);
+// mMessage.setText(textData);
} else {
matcher = PgpHelper.PGP_SIGNED_MESSAGE.matcher(textData);
if (matcher.matches()) {
@@ -331,7 +391,10 @@ public class DecryptActivity extends DrawerActivity {
textData = matcher.group(1);
// replace non breakable spaces
textData = textData.replaceAll("\\xa0", " ");
- mMessage.setText(textData);
+// mMessage.setText(textData);
+ mViewPager.setCurrentItem(PAGER_TAB_MESSAGE, false);
+ mMessageFragment = (DecryptMessageFragment) getFragmentByPosition(mViewPager.getCurrentItem());
+ mMessageFragment.setText(textData);
} else {
Log.d(Constants.TAG, "Nothing matched!");
}
@@ -344,14 +407,14 @@ public class DecryptActivity extends DrawerActivity {
mInputFilename = path;
mFilename.setText(mInputFilename);
guessOutputFilename();
- mSource.setInAnimation(null);
- mSource.setOutAnimation(null);
- while (mSource.getCurrentView().getId() != R.id.sourceFile) {
- mSource.showNext();
- }
+// mSource.setInAnimation(null);
+// mSource.setOutAnimation(null);
+// while (mSource.getCurrentView().getId() != R.id.sourceFile) {
+// mSource.showNext();
+// }
} else {
Log.e(Constants.TAG,
- "Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!");
+ "Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!");
Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
.show();
// end activity
@@ -373,28 +436,28 @@ public class DecryptActivity extends DrawerActivity {
mOutputFilename = Constants.Path.APP_DIR + "/" + filename;
}
- private void updateSource() {
- switch (mSource.getCurrentView().getId()) {
- case R.id.sourceFile: {
- mSourceLabel.setText(R.string.label_file);
- mDecryptButton.setText(getString(R.string.btn_decrypt));
- break;
- }
-
- case R.id.sourceMessage: {
- mSourceLabel.setText(R.string.label_message);
- mDecryptButton.setText(getString(R.string.btn_decrypt));
- break;
- }
-
- default: {
- break;
- }
- }
- }
+// private void updateSource() {
+// switch (mSource.getCurrentView().getId()) {
+// case R.id.sourceFile: {
+// mSourceLabel.setText(R.string.label_file);
+// mDecryptButton.setText(getString(R.string.btn_decrypt));
+// break;
+// }
+//
+// case R.id.sourceMessage: {
+// mSourceLabel.setText(R.string.label_message);
+// mDecryptButton.setText(getString(R.string.btn_decrypt));
+// break;
+// }
+//
+// default: {
+// break;
+// }
+// }
+// }
private void decryptClicked() {
- if (mSource.getCurrentView().getId() == R.id.sourceFile) {
+ if (mViewPager.getCurrentItem() == PAGER_TAB_FILE) {
mDecryptTarget = Id.target.file;
} else {
mDecryptTarget = Id.target.message;
@@ -428,13 +491,13 @@ public class DecryptActivity extends DrawerActivity {
}
if (mDecryptTarget == Id.target.message) {
- String messageData = mMessage.getText().toString();
- Matcher matcher = PgpHelper.PGP_SIGNED_MESSAGE.matcher(messageData);
- if (matcher.matches()) {
- mSignedOnly = true;
- decryptStart();
- return;
- }
+// String messageData = mMessage.getText().toString();
+// Matcher matcher = PgpHelper.PGP_SIGNED_MESSAGE.matcher(messageData);
+// if (matcher.matches()) {
+// mSignedOnly = true;
+// decryptStart();
+// return;
+// }
}
// else treat it as an decrypted message/file
@@ -519,7 +582,8 @@ public class DecryptActivity extends DrawerActivity {
AppMsg.STYLE_ALERT).show();
}
} else {
- inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes());
+
+// inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes());
}
// get decryption key for this inStream
@@ -551,18 +615,6 @@ public class DecryptActivity extends DrawerActivity {
}
}
- private void replyClicked() {
- Intent intent = new Intent(this, EncryptActivity.class);
- intent.setAction(EncryptActivity.ACTION_ENCRYPT);
- String data = mMessage.getText().toString();
- data = data.replaceAll("(?m)^", "> ");
- data = "\n\n" + data;
- intent.putExtra(EncryptActivity.EXTRA_TEXT, data);
- intent.putExtra(EncryptActivity.EXTRA_SIGNATURE_KEY_ID, mSecretKeyId);
- intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, new long[]{mSignatureKeyId});
- startActivity(intent);
- }
-
private void askForOutputFilename() {
// Message is received after passphrase is cached
Handler returnHandler = new Handler() {
@@ -620,8 +672,8 @@ public class DecryptActivity extends DrawerActivity {
} else {
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES);
- String message = mMessage.getText().toString();
- data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes());
+// String message = mMessage.getText().toString();
+// data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes());
}
data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
@@ -647,20 +699,20 @@ public class DecryptActivity extends DrawerActivity {
AppMsg.makeText(DecryptActivity.this, R.string.decryption_successful,
AppMsg.STYLE_INFO).show();
- if (mReturnResult) {
- Intent intent = new Intent();
- intent.putExtras(returnData);
- setResult(RESULT_OK, intent);
- finish();
- return;
- }
+// if (mReturnResult) {
+// Intent intent = new Intent();
+// intent.putExtras(returnData);
+// setResult(RESULT_OK, intent);
+// finish();
+// return;
+// }
switch (mDecryptTarget) {
case Id.target.message:
String decryptedMessage = returnData
.getString(KeychainIntentService.RESULT_DECRYPTED_STRING);
- mMessage.setText(decryptedMessage);
- mMessage.setHorizontallyScrolling(false);
+// mMessage.setText(decryptedMessage);
+// mMessage.setHorizontallyScrolling(false);
break;
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java
new file mode 100644
index 000000000..0c8fd8c83
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2013 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.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+
+import org.sufficientlysecure.keychain.R;
+
+public class DecryptFileFragment extends Fragment {
+
+ private EditText mMessage;
+
+ /**
+ * Creates new instance of this fragment
+ */
+ public static DecryptFileFragment newInstance() {
+ DecryptFileFragment frag = new DecryptFileFragment();
+
+ Bundle args = new Bundle();
+ frag.setArguments(args);
+
+ return frag;
+ }
+
+ /**
+ * Inflate the layout for this fragment
+ */
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.decrypt_file_fragment, container, false);
+
+ mMessage = (EditText) view.findViewById(R.id.message);
+
+ return view;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ }
+
+}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java
new file mode 100644
index 000000000..3fa7e89ba
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013 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.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.EditText;
+
+import com.beardedhen.androidbootstrap.BootstrapButton;
+
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
+import org.sufficientlysecure.keychain.util.Log;
+
+public class DecryptMessageFragment extends Fragment {
+
+ private EditText mMessage;
+
+ /**
+ * Creates new instance of this fragment
+ */
+ public static DecryptMessageFragment newInstance() {
+ DecryptMessageFragment frag = new DecryptMessageFragment();
+
+ Bundle args = new Bundle();
+ frag.setArguments(args);
+
+ return frag;
+ }
+
+ /**
+ * Inflate the layout for this fragment
+ */
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.decrypt_message_fragment, container, false);
+
+ mMessage = (EditText) view.findViewById(R.id.message);
+
+ return view;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ Log.d(Constants.TAG, "tag: " + getTag());
+ }
+
+ public String getText() {
+ return mMessage.getText().toString();
+ }
+
+ public void setText(String message) {
+ mMessage.setText(message);
+ }
+
+}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java
new file mode 100644
index 000000000..402699623
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java
@@ -0,0 +1,74 @@
+/*
+ * 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.adapter;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.app.FragmentStatePagerAdapter;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
+
+import java.util.ArrayList;
+
+public class PageTabStripAdapter extends FragmentPagerAdapter {
+ private final Context mContext;
+ private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
+
+ static final class TabInfo {
+ private final Class<?> clss;
+ private final Bundle args;
+ private final String title;
+
+ TabInfo(Class<?> clss, Bundle args, String title) {
+ this.clss = clss;
+ this.args = args;
+ this.title = title;
+ }
+ }
+
+ public PageTabStripAdapter(ActionBarActivity activity) {
+ super(activity.getSupportFragmentManager());
+ mContext = activity;
+ }
+
+ public void addTab(Class<?> clss, Bundle args, String title) {
+ TabInfo info = new TabInfo(clss, args, title);
+ mTabs.add(info);
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public int getCount() {
+ return mTabs.size();
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ TabInfo info = mTabs.get(position);
+ return Fragment.instantiate(mContext, info.clss.getName(), info.args);
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ return mTabs.get(position).title;
+ }
+}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java
index f435d46ef..6dbea61dc 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java
@@ -36,12 +36,12 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
static final class TabInfo {
- private final Class<?> mClss;
- private final Bundle mArgs;
+ private final Class<?> clss;
+ private final Bundle args;
- TabInfo(Class<?> mClss, Bundle mArgs) {
- this.mClss = mClss;
- this.mArgs = mArgs;
+ TabInfo(Class<?> clss, Bundle args) {
+ this.clss = clss;
+ this.args = args;
}
}
@@ -71,7 +71,7 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
@Override
public Fragment getItem(int position) {
TabInfo info = mTabs.get(position);
- return Fragment.instantiate(mContext, info.mClss.getName(), info.mArgs);
+ return Fragment.instantiate(mContext, info.clss.getName(), info.args);
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {