aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/XmppActivity.java')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java142
1 files changed, 39 insertions, 103 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 858806e3..28405537 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -41,7 +41,7 @@ import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.util.DisplayMetrics;
-import android.util.Log;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -49,6 +49,7 @@ import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
@@ -68,6 +69,11 @@ import java.util.Hashtable;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
+import de.thedevstack.android.logcat.Logging;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
+import de.thedevstack.conversationsplus.utils.ImageUtil;
+
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
@@ -77,10 +83,8 @@ import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences;
-import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
-import eu.siacs.conversations.ui.widget.Switch;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
@@ -101,21 +105,8 @@ public abstract class XmppActivity extends Activity {
public boolean xmppConnectionServiceBound = false;
protected boolean registeredListeners = false;
- protected int mPrimaryTextColor;
- protected int mSecondaryTextColor;
- protected int mTertiaryTextColor;
- protected int mPrimaryBackgroundColor;
- protected int mSecondaryBackgroundColor;
- protected int mColorRed;
- protected int mColorOrange;
- protected int mColorGreen;
- protected int mPrimaryColor;
-
- protected boolean mUseSubject = true;
-
private DisplayMetrics metrics;
protected int mTheme;
- protected boolean mUsingEnterKey = false;
protected Runnable onOpenPGPKeyPublished = new Runnable() {
@Override
@@ -365,19 +356,8 @@ public abstract class XmppActivity extends Activity {
super.onCreate(savedInstanceState);
metrics = getResources().getDisplayMetrics();
ExceptionHelper.init(getApplicationContext());
- mPrimaryTextColor = getResources().getColor(R.color.black87);
- mSecondaryTextColor = getResources().getColor(R.color.black54);
- mTertiaryTextColor = getResources().getColor(R.color.black12);
- mColorRed = getResources().getColor(R.color.red800);
- mColorOrange = getResources().getColor(R.color.orange500);
- mColorGreen = getResources().getColor(R.color.green500);
- mPrimaryColor = getResources().getColor(R.color.primary);
- mPrimaryBackgroundColor = getResources().getColor(R.color.grey50);
- mSecondaryBackgroundColor = getResources().getColor(R.color.grey200);
this.mTheme = findTheme();
setTheme(this.mTheme);
- this.mUsingEnterKey = usingEnterKey();
- mUseSubject = getPreferences().getBoolean("use_subject", true);
final ActionBar ab = getActionBar();
if (ab!=null) {
ab.setDisplayHomeAsUpEnabled(true);
@@ -393,19 +373,6 @@ public abstract class XmppActivity extends Activity {
}
}
- protected boolean usingEnterKey() {
- return getPreferences().getBoolean("display_enter_key", false);
- }
-
- protected SharedPreferences getPreferences() {
- return PreferenceManager
- .getDefaultSharedPreferences(getApplicationContext());
- }
-
- public boolean useSubjectToIdentifyConference() {
- return mUseSubject;
- }
-
public void switchToConversation(Conversation conversation) {
switchToConversation(conversation, null, false);
}
@@ -767,35 +734,35 @@ public abstract class XmppActivity extends Activity {
case UNTRUSTED:
case TRUSTED:
case TRUSTED_X509:
- trustToggle.setChecked(trust.trusted(), false);
+ trustToggle.setChecked(trust.trusted());
trustToggle.setEnabled(!Config.X509_VERIFICATION || trust != XmppAxolotlSession.Trust.TRUSTED_X509);
if (Config.X509_VERIFICATION && trust == XmppAxolotlSession.Trust.TRUSTED_X509) {
trustToggle.setOnClickListener(null);
}
- key.setTextColor(getPrimaryTextColor());
- keyType.setTextColor(getSecondaryTextColor());
+ key.setTextColor(ConversationsPlusColors.primaryText());
+ keyType.setTextColor(ConversationsPlusColors.secondaryText());
break;
case UNDECIDED:
- trustToggle.setChecked(false, false);
+ trustToggle.setChecked(false);
trustToggle.setEnabled(false);
- key.setTextColor(getPrimaryTextColor());
- keyType.setTextColor(getSecondaryTextColor());
+ key.setTextColor(ConversationsPlusColors.primaryText());
+ keyType.setTextColor(ConversationsPlusColors.secondaryText());
break;
case INACTIVE_UNTRUSTED:
case INACTIVE_UNDECIDED:
trustToggle.setOnClickListener(null);
- trustToggle.setChecked(false, false);
+ trustToggle.setChecked(false);
trustToggle.setEnabled(false);
- key.setTextColor(getTertiaryTextColor());
- keyType.setTextColor(getTertiaryTextColor());
+ key.setTextColor(ConversationsPlusColors.tertiaryText());
+ keyType.setTextColor(ConversationsPlusColors.tertiaryText());
break;
case INACTIVE_TRUSTED:
case INACTIVE_TRUSTED_X509:
trustToggle.setOnClickListener(null);
- trustToggle.setChecked(true, false);
+ trustToggle.setChecked(true);
trustToggle.setEnabled(false);
- key.setTextColor(getTertiaryTextColor());
- keyType.setTextColor(getTertiaryTextColor());
+ key.setTextColor(ConversationsPlusColors.tertiaryText());
+ keyType.setTextColor(ConversationsPlusColors.tertiaryText());
break;
}
@@ -805,7 +772,7 @@ public abstract class XmppActivity extends Activity {
keyType.setVisibility(View.GONE);
}
if (highlight) {
- keyType.setTextColor(getResources().getColor(R.color.accent));
+ keyType.setTextColor(ConversationsPlusColors.accent());
keyType.setText(getString(x509 ? R.string.omemo_fingerprint_x509_selected_message : R.string.omemo_fingerprint_selected_message));
} else {
keyType.setText(getString(x509 ? R.string.omemo_fingerprint_x509 : R.string.omemo_fingerprint));
@@ -967,34 +934,6 @@ public abstract class XmppActivity extends Activity {
}
};
- public int getTertiaryTextColor() {
- return this.mTertiaryTextColor;
- }
-
- public int getSecondaryTextColor() {
- return this.mSecondaryTextColor;
- }
-
- public int getPrimaryTextColor() {
- return this.mPrimaryTextColor;
- }
-
- public int getWarningTextColor() {
- return this.mColorRed;
- }
-
- public int getOnlineColor() {
- return this.mColorGreen;
- }
-
- public int getPrimaryBackgroundColor() {
- return this.mPrimaryBackgroundColor;
- }
-
- public int getSecondaryBackgroundColor() {
- return this.mSecondaryBackgroundColor;
- }
-
public int getPixel(int dp) {
DisplayMetrics metrics = getResources().getDisplayMetrics();
return ((int) (dp * metrics.density));
@@ -1026,14 +965,6 @@ public abstract class XmppActivity extends Activity {
}
}
- protected boolean neverCompressPictures() {
- return getPreferences().getString("picture_compression", "auto").equals("never");
- }
-
- protected boolean manuallyChangePresence() {
- return getPreferences().getBoolean("manually_change_presence", false);
- }
-
protected void unregisterNdefPushMessageCallback() {
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (nfcAdapter != null && nfcAdapter.isEnabled()) {
@@ -1054,7 +985,7 @@ public abstract class XmppActivity extends Activity {
}
protected int findTheme() {
- if (getPreferences().getBoolean("use_larger_font", false)) {
+ if (ConversationsPlusPreferences.useLargerFont()) {
return R.style.ConversationsTheme_LargerText;
} else {
return R.style.ConversationsTheme;
@@ -1083,7 +1014,7 @@ public abstract class XmppActivity extends Activity {
}
protected Bitmap createQrCodeBitmap(String input, int size) {
- Log.d(Config.LOGTAG,"qr code requested size: "+size);
+ Logging.d(Config.LOGTAG,"qr code requested size: "+size);
try {
final QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
@@ -1099,7 +1030,7 @@ public abstract class XmppActivity extends Activity {
}
}
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- Log.d(Config.LOGTAG,"output size: "+width+"x"+height);
+ Logging.d(Config.LOGTAG,"output size: "+width+"x"+height);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
} catch (final WriterException e) {
@@ -1158,16 +1089,14 @@ public abstract class XmppActivity extends Activity {
}
}
- public AvatarService avatarService() {
- return xmppConnectionService.getAvatarService();
- }
-
class BitmapWorkerTask extends AsyncTask<Message, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
- private Message message = null;
+ private final boolean setSize;
+ private Message message = null;
public BitmapWorkerTask(ImageView imageView) {
imageViewReference = new WeakReference<>(imageView);
+ this.setSize = setSize;
}
@Override
@@ -1177,8 +1106,7 @@ public abstract class XmppActivity extends Activity {
}
message = params[0];
try {
- return xmppConnectionService.getFileBackend().getThumbnail(
- message, (int) (metrics.density * 288), false);
+ return ImageUtil.getThumbnail(message, (int) (metrics.density * 288), false);
} catch (FileNotFoundException e) {
return null;
}
@@ -1191,28 +1119,36 @@ public abstract class XmppActivity extends Activity {
if (imageView != null) {
imageView.setImageBitmap(bitmap);
imageView.setBackgroundColor(0x00000000);
+ if (setSize) {
+ imageView.setLayoutParams(new LinearLayout.LayoutParams(
+ bitmap.getWidth(), bitmap.getHeight()));
+ }
}
}
}
}
- public void loadBitmap(Message message, ImageView imageView) {
+ public void loadBitmap(Message message, ImageView imageView, boolean setSize) {
Bitmap bm;
try {
- bm = xmppConnectionService.getFileBackend().getThumbnail(message,
- (int) (metrics.density * 288), true);
+ bm = ImageUtil.getThumbnail(message,(int) (metrics.density * 288), true);
} catch (FileNotFoundException e) {
bm = null;
}
+
if (bm != null) {
cancelPotentialWork(message, imageView);
imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000);
+ if (setSize) {
+ imageView.setLayoutParams(new LinearLayout.LayoutParams(
+ bm.getWidth(), bm.getHeight()));
+ }
} else {
if (cancelPotentialWork(message, imageView)) {
imageView.setBackgroundColor(0xff333333);
imageView.setImageDrawable(null);
- final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
+ final BitmapWorkerTask task = new BitmapWorkerTask(imageView, setSize);
final AsyncDrawable asyncDrawable = new AsyncDrawable(
getResources(), null, task);
imageView.setImageDrawable(asyncDrawable);