Cleanups
This commit is contained in:
@@ -12,6 +12,7 @@ import android.content.res.Configuration;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
@@ -180,6 +181,7 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
final int message = boteNotStartedMessage;
|
||||
DialogFragment df = new DialogFragment() {
|
||||
@Override
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(message)
|
||||
|
||||
@@ -69,6 +69,7 @@ public class NetworkInfoFragment extends Fragment {
|
||||
((TextView) view.findViewById(R.id.error)).setText(mConnectError.toString());
|
||||
|
||||
view.findViewById(R.id.copy_error).setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String fullError = joinStackTrace(mConnectError);
|
||||
@@ -227,8 +228,7 @@ public class NetworkInfoFragment extends Fragment {
|
||||
|
||||
printer.println(e);
|
||||
StackTraceElement[] trace = e.getStackTrace();
|
||||
for (int i = 0; i < trace.length; i++)
|
||||
printer.println("\tat " + trace[i]);
|
||||
for (StackTraceElement aTrace : trace) printer.println("\tat " + aTrace);
|
||||
|
||||
e = e.getCause();
|
||||
if (e != null)
|
||||
|
||||
@@ -388,6 +388,9 @@ public class NewEmailFragment extends Fragment {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
mCallbacks.onBackPressAllowed();
|
||||
else
|
||||
getActivity().onNavigateUp();
|
||||
}
|
||||
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ViewContactActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onResume() {
|
||||
@@ -70,6 +71,7 @@ public class ViewContactActivity extends ActionBarActivity {
|
||||
return f.createNdefMessage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class EditIdentityFragment extends EditPictureFragment {
|
||||
public void onTaskFinished();
|
||||
}
|
||||
private static Callbacks sDummyCallbacks = new Callbacks() {
|
||||
public void onTaskFinished() {};
|
||||
public void onTaskFinished() {}
|
||||
};
|
||||
|
||||
@Override
|
||||
@@ -195,7 +195,7 @@ public class EditIdentityFragment extends EditPictureFragment {
|
||||
mError.setText("");
|
||||
|
||||
IdentityWaiterFrag f = IdentityWaiterFrag.newInstance(
|
||||
(mKey == null ? true : false),
|
||||
(mKey == null),
|
||||
cryptoImplId,
|
||||
null,
|
||||
mKey,
|
||||
@@ -320,15 +320,15 @@ public class EditIdentityFragment extends EditPictureFragment {
|
||||
public Object[] getParams() {
|
||||
Bundle args = getArguments();
|
||||
return new Object[] {
|
||||
Boolean.valueOf(args.getBoolean(CREATE_NEW)),
|
||||
Integer.valueOf(args.getInt(CRYPTO_IMPL_ID)),
|
||||
args.getBoolean(CREATE_NEW),
|
||||
args.getInt(CRYPTO_IMPL_ID),
|
||||
args.getString(VANITY_PREFIX),
|
||||
args.getString(KEY),
|
||||
args.getString(PUBLIC_NAME),
|
||||
args.getString(DESCRIPTION),
|
||||
args.getString(PICTURE_BASE64),
|
||||
args.getString(EMAIL_ADDRESS),
|
||||
Boolean.valueOf(args.getBoolean(SET_DEFAULT)),
|
||||
args.getBoolean(SET_DEFAULT),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class SetPasswordFragment extends Fragment {
|
||||
public void onTaskFinished();
|
||||
}
|
||||
private static Callbacks sDummyCallbacks = new Callbacks() {
|
||||
public void onTaskFinished() {};
|
||||
public void onTaskFinished() {}
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
@@ -116,12 +116,8 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
Map<String, ?> all = prefs.getAll();
|
||||
Iterator<String> iterator = all.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String x = iterator.next();
|
||||
if (x.startsWith("i2pbote.")) // Skip over Android-specific settings
|
||||
continue;
|
||||
else if ("autoMailCheckEnabled".equals(x))
|
||||
for (String x : all.keySet()) {
|
||||
if ("autoMailCheckEnabled".equals(x))
|
||||
config.setAutoMailCheckEnabled(prefs.getBoolean(x, true));
|
||||
else if ("mailCheckInterval".equals(x))
|
||||
config.setMailCheckInterval(prefs.getInt(x, 30));
|
||||
@@ -527,6 +523,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void showLegacyHeaders(Object[] result) {
|
||||
mLegacyIdentityListHeaders = (Preference[]) result[0];
|
||||
getPreferenceScreen().removeAll();
|
||||
@@ -554,9 +551,8 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
if (adapter == null) {
|
||||
super.setListAdapter(null);
|
||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
super.setListAdapter(adapter); // TODO: implement legacy headers styling
|
||||
super.setListAdapter(adapter);
|
||||
} else {
|
||||
// TODO: Fix NPE when rotating screen
|
||||
super.setListAdapter(new HeaderAdapter(this, adapter));
|
||||
}
|
||||
}
|
||||
@@ -635,7 +631,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
HeaderViewHolder holder;
|
||||
Header header = getItem(position);
|
||||
int headerType = getHeaderType(header);
|
||||
View view = null;
|
||||
View view;
|
||||
|
||||
if (convertView == null) {
|
||||
holder = new HeaderViewHolder();
|
||||
@@ -647,6 +643,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
break;
|
||||
|
||||
case HEADER_TYPE_NORMAL:
|
||||
default:
|
||||
view = mInflater.inflate(
|
||||
R.layout.preference_header_item, parent,
|
||||
false);
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ViewIdentityActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onResume() {
|
||||
@@ -70,6 +71,7 @@ public class ViewIdentityActivity extends ActionBarActivity {
|
||||
return f.createNdefMessage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
@@ -57,7 +57,6 @@ public class BoteHelper extends GeneralHelper {
|
||||
* @param ctx Android Context to get strings from.
|
||||
* @param folder The folder.
|
||||
* @return The name of the folder.
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public static String getFolderDisplayName(Context ctx, EmailFolder folder) {
|
||||
String name = folder.getName();
|
||||
@@ -118,7 +117,7 @@ public class BoteHelper extends GeneralHelper {
|
||||
/**
|
||||
* Get a Bitmap containing the picture for the contact or identity
|
||||
* corresponding to the given address.
|
||||
* @param address
|
||||
* @param address the address to get a picture for.
|
||||
* @return a Bitmap, or null if no picture was found.
|
||||
* @throws PasswordException
|
||||
* @throws IOException
|
||||
@@ -138,7 +137,7 @@ public class BoteHelper extends GeneralHelper {
|
||||
/**
|
||||
* Get a Bitmap containing the picture for the contact or identity
|
||||
* corresponding to the given Destination.
|
||||
* @param base64dest
|
||||
* @param base64dest the Destination to get a picture for.
|
||||
* @return a Bitmap, or null if no picture was found.
|
||||
* @throws PasswordException
|
||||
* @throws IOException
|
||||
@@ -207,8 +206,8 @@ public class BoteHelper extends GeneralHelper {
|
||||
// Is the sender anonymous and we are not the recipient?
|
||||
if (email.isAnonymous()) {
|
||||
Address[] recipients = email.getAllRecipients();
|
||||
for (int i = 0; i < recipients.length; i++) {
|
||||
String toDest = EmailDestination.extractBase64Dest(recipients[i].toString());
|
||||
for (Address recipient : recipients) {
|
||||
String toDest = EmailDestination.extractBase64Dest(recipient.toString());
|
||||
if (toDest != null && getIdentity(toDest) != null)
|
||||
// We are a recipient
|
||||
return false;
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
public class MoveToDialogFragment extends DialogFragment {
|
||||
@@ -63,6 +64,7 @@ public class MoveToDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.action_move_to)
|
||||
|
||||
@@ -21,9 +21,7 @@ public class Person implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof Person))
|
||||
return false;
|
||||
return address.equals(((Person)other).address);
|
||||
return other instanceof Person && address.equals(((Person) other).address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,8 +43,8 @@ public class QrCodeUtils {
|
||||
/**
|
||||
* Generate Bitmap with QR Code based on input.
|
||||
*
|
||||
* @param input
|
||||
* @param size
|
||||
* @param input The data to render as a QR code.
|
||||
* @param size The preferred width and height of the QR code in pixels.
|
||||
* @return QR Code as Bitmap
|
||||
*/
|
||||
public static Bitmap getQRCodeBitmap(final String input, final int size) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.nfc.NdefRecord;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
@@ -94,6 +95,7 @@ public abstract class ViewAddressFragment extends Fragment {
|
||||
mExpandedQrCode = (ImageView) view.findViewById(R.id.expanded_qr_code);
|
||||
|
||||
view.findViewById(R.id.copy_key).setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Object clipboardService = getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
@@ -173,6 +175,7 @@ public abstract class ViewAddressFragment extends Fragment {
|
||||
case R.id.action_delete_identity:
|
||||
DialogFragment df = new DialogFragment() {
|
||||
@Override
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(getDeleteAddressMessage())
|
||||
@@ -198,11 +201,10 @@ public abstract class ViewAddressFragment extends Fragment {
|
||||
}
|
||||
|
||||
public NdefMessage createNdefMessage() {
|
||||
NdefMessage msg = new NdefMessage(new NdefRecord[]{
|
||||
return new NdefMessage(new NdefRecord[]{
|
||||
createNameRecord(),
|
||||
createDestinationRecord()
|
||||
});
|
||||
return msg;
|
||||
}
|
||||
|
||||
private NdefRecord createNameRecord() {
|
||||
|
||||
Reference in New Issue
Block a user