help activity
This commit is contained in:
@@ -47,7 +47,7 @@ public final class Id {
|
||||
public static final int encrypt = 0x21070013;
|
||||
public static final int encrypt_to_clipboard = 0x21070014;
|
||||
public static final int decrypt = 0x21070015;
|
||||
public static final int decrypt_to_clipboard = 0x21070016;
|
||||
public static final int reply = 0x21070016;
|
||||
public static final int cancel = 0x21070017;
|
||||
public static final int save = 0x21070018;
|
||||
|
||||
|
||||
@@ -117,13 +117,13 @@ public class DecryptActivity extends BaseActivity {
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
if (mDecryptEnabled) {
|
||||
menu.add(1, Id.menu.option.encrypt_to_clipboard, 0, mDecryptString)
|
||||
menu.add(1, Id.menu.option.decrypt, 0, mDecryptString)
|
||||
// .setIcon(R.drawable.ic_menu_encrypt)
|
||||
.setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
}
|
||||
if (mReplyEnabled) {
|
||||
menu.add(1, Id.menu.option.encrypt, 1, mReplyString)
|
||||
menu.add(1, Id.menu.option.reply, 1, mReplyString)
|
||||
// .setIcon(R.drawable.ic_menu_decrypt)
|
||||
.setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
@@ -132,6 +132,26 @@ public class DecryptActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.decrypt: {
|
||||
decryptClicked();
|
||||
|
||||
return true;
|
||||
}
|
||||
case Id.menu.option.reply: {
|
||||
replyClicked();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -171,8 +191,6 @@ public class DecryptActivity extends BaseActivity {
|
||||
mSourceLabel.setOnClickListener(nextSourceClickListener);
|
||||
|
||||
mMessage = (EditText) findViewById(R.id.message);
|
||||
// mDecryptButton = (Button) findViewById(R.id.btn_decrypt);
|
||||
// mReplyButton = (Button) findViewById(R.id.btn_reply);
|
||||
mSignatureLayout = (LinearLayout) findViewById(R.id.signature);
|
||||
mSignatureStatusImage = (ImageView) findViewById(R.id.ic_signature_status);
|
||||
mUserId = (TextView) findViewById(R.id.mainUserId);
|
||||
@@ -258,6 +276,9 @@ public class DecryptActivity extends BaseActivity {
|
||||
mMessage.setText(textData);
|
||||
mDecryptString = getString(R.string.btn_verify);
|
||||
// mDecryptButton.setText(R.string.btn_verify);
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Nothing matched!");
|
||||
}
|
||||
@@ -305,7 +326,8 @@ public class DecryptActivity extends BaseActivity {
|
||||
mMessage.setText(data);
|
||||
mDecryptString = getString(R.string.btn_verify);
|
||||
|
||||
// mDecryptButton.setText(R.string.btn_verify);
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,21 +370,11 @@ public class DecryptActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
// mDecryptButton.setOnClickListener(new OnClickListener() {
|
||||
// public void onClick(View v) {
|
||||
// decryptClicked();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// mReplyButton.setOnClickListener(new OnClickListener() {
|
||||
// public void onClick(View v) {
|
||||
// replyClicked();
|
||||
// }
|
||||
// });
|
||||
// mReplyButton.setVisibility(View.INVISIBLE);
|
||||
|
||||
mReplyEnabled = false;
|
||||
|
||||
// build new actionbar
|
||||
invalidateOptionsMenu();
|
||||
|
||||
if (mReturnResult) {
|
||||
mSourcePrevious.setClickable(false);
|
||||
mSourcePrevious.setEnabled(false);
|
||||
@@ -381,6 +393,7 @@ public class DecryptActivity extends BaseActivity {
|
||||
if (mSource.getCurrentView().getId() == R.id.sourceMessage
|
||||
&& (mMessage.getText().length() > 0 || mData != null || mContentUri != null)) {
|
||||
// mDecryptButton.performClick();
|
||||
// TODO: why was it performClick()???
|
||||
decryptClicked();
|
||||
}
|
||||
}
|
||||
@@ -416,16 +429,19 @@ public class DecryptActivity extends BaseActivity {
|
||||
switch (mSource.getCurrentView().getId()) {
|
||||
case R.id.sourceFile: {
|
||||
mSourceLabel.setText(R.string.label_file);
|
||||
// mDecryptButton.setText(R.string.btn_decrypt);
|
||||
mDecryptString = getString(R.string.btn_decrypt);
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
break;
|
||||
}
|
||||
|
||||
case R.id.sourceMessage: {
|
||||
mSourceLabel.setText(R.string.label_message);
|
||||
// mDecryptButton.setText(R.string.btn_decrypt);
|
||||
mDecryptString = getString(R.string.btn_decrypt);
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -633,9 +649,11 @@ public class DecryptActivity extends BaseActivity {
|
||||
removeDialog(Id.dialog.decrypting);
|
||||
mSignatureKeyId = 0;
|
||||
mSignatureLayout.setVisibility(View.GONE);
|
||||
// mReplyButton.setVisibility(View.INVISIBLE);
|
||||
mReplyEnabled = false;
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
|
||||
String error = data.getString(Apg.EXTRA_ERROR);
|
||||
if (error != null) {
|
||||
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT)
|
||||
@@ -657,8 +675,10 @@ public class DecryptActivity extends BaseActivity {
|
||||
String decryptedMessage = data.getString(Apg.EXTRA_DECRYPTED_MESSAGE);
|
||||
mMessage.setText(decryptedMessage);
|
||||
mMessage.setHorizontallyScrolling(false);
|
||||
// mReplyButton.setVisibility(View.VISIBLE);
|
||||
mReplyEnabled = false;
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
79
org_apg/src/org/apg/ui/HelpActivity.java
Normal file
79
org_apg/src/org/apg/ui/HelpActivity.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apg.ui;
|
||||
|
||||
import org.apg.R;
|
||||
import org.apg.util.Utils;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockActivity;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class HelpActivity extends SherlockActivity {
|
||||
Activity mActivity;
|
||||
TextView mHelpText;
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
case android.R.id.home:
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate View for this Activity
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.help_activity);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mActivity = this;
|
||||
|
||||
mHelpText = (TextView) findViewById(R.id.help_text);
|
||||
|
||||
// load html from html file from /res/raw
|
||||
String helpText = Utils.readContentFromResource(mActivity, R.raw.help);
|
||||
|
||||
// set text from resources with html markup
|
||||
mHelpText.setText(Html.fromHtml(helpText));
|
||||
// make links work
|
||||
mHelpText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,6 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
public void myKeysOnClick(View view) {
|
||||
startActivity(new Intent(this, SecretKeyListActivity.class));
|
||||
|
||||
}
|
||||
|
||||
public void encryptOnClick(View view) {
|
||||
@@ -68,7 +67,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
public void helpOnClick(View view) {
|
||||
// TODO: implement help view
|
||||
startActivity(new Intent(this, HelpActivity.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
54
org_apg/src/org/apg/util/Utils.java
Normal file
54
org_apg/src/org/apg/util/Utils.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apg.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class Utils {
|
||||
|
||||
/**
|
||||
* Reads html files from /res/raw/example.html to output them as string. See
|
||||
* http://www.monocube.com/2011/02/08/android-tutorial-html-file-in-webview/
|
||||
*
|
||||
* @param context
|
||||
* current context
|
||||
* @param resourceID
|
||||
* of html file to read
|
||||
* @return content of html file with formatting
|
||||
*/
|
||||
public static String readContentFromResource(Context context, int resourceID) {
|
||||
InputStream raw = context.getResources().openRawResource(resourceID);
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
int i;
|
||||
try {
|
||||
i = raw.read();
|
||||
while (i != -1) {
|
||||
stream.write(i);
|
||||
i = raw.read();
|
||||
}
|
||||
raw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stream.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user