cache useTor information in activity

This commit is contained in:
Daniel Gultsch 2020-04-19 08:04:36 +02:00
parent 72c551d128
commit 31dfb0c704
3 changed files with 11 additions and 6 deletions

View File

@ -1252,7 +1252,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
private void checkPermissionAndTriggerAudioCall() { private void checkPermissionAndTriggerAudioCall() {
if (activity.xmppConnectionService.useTorToConnect() || conversation.getAccount().isOnion()) { if (activity.mUseTor || conversation.getAccount().isOnion()) {
Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show();
return; return;
} }
@ -1262,7 +1262,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
private void checkPermissionAndTriggerVideoCall() { private void checkPermissionAndTriggerVideoCall() {
if (activity.xmppConnectionService.useTorToConnect() || conversation.getAccount().isOnion()) { if (activity.mUseTor || conversation.getAccount().isOnion()) {
Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show();
return; return;
} }

View File

@ -383,7 +383,6 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (isCameraFeatureAvailable()) { if (isCameraFeatureAvailable()) {
Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment); Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment);
boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan) boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan)
&& fragment != null
&& fragment instanceof ConversationsOverviewFragment; && fragment instanceof ConversationsOverviewFragment;
qrCodeScanMenuItem.setVisible(visible); qrCodeScanMenuItem.setVisible(visible);
} else { } else {

View File

@ -67,6 +67,7 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.services.BarcodeProvider; import eu.siacs.conversations.services.BarcodeProvider;
import eu.siacs.conversations.services.QuickConversationsService;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder; import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
import eu.siacs.conversations.ui.service.EmojiService; import eu.siacs.conversations.ui.service.EmojiService;
@ -96,6 +97,7 @@ public abstract class XmppActivity extends ActionBarActivity {
protected int mTheme; protected int mTheme;
protected boolean mUsingEnterKey = false; protected boolean mUsingEnterKey = false;
protected boolean mUseTor = false;
protected Toast mToast; protected Toast mToast;
public Runnable onOpenPGPKeyPublished = () -> Toast.makeText(XmppActivity.this, R.string.openpgp_has_been_published, Toast.LENGTH_SHORT).show(); public Runnable onOpenPGPKeyPublished = () -> Toast.makeText(XmppActivity.this, R.string.openpgp_has_been_published, Toast.LENGTH_SHORT).show();
protected ConferenceInvite mPendingConferenceInvite = null; protected ConferenceInvite mPendingConferenceInvite = null;
@ -211,6 +213,8 @@ public abstract class XmppActivity extends ActionBarActivity {
this.registerListeners(); this.registerListeners();
this.onBackendConnected(); this.onBackendConnected();
} }
this.mUsingEnterKey = usingEnterKey();
this.mUseTor = useTor();
} }
public void connectToBackend() { public void connectToBackend() {
@ -408,8 +412,6 @@ public abstract class XmppActivity extends ActionBarActivity {
} }
this.mTheme = findTheme(); this.mTheme = findTheme();
setTheme(this.mTheme); setTheme(this.mTheme);
this.mUsingEnterKey = usingEnterKey();
} }
protected boolean isCameraFeatureAvailable() { protected boolean isCameraFeatureAvailable() {
@ -451,10 +453,14 @@ public abstract class XmppActivity extends ActionBarActivity {
} }
} }
protected boolean usingEnterKey() { private boolean usingEnterKey() {
return getBooleanPreference("display_enter_key", R.bool.display_enter_key); return getBooleanPreference("display_enter_key", R.bool.display_enter_key);
} }
private boolean useTor() {
return QuickConversationsService.isConversations() && getBooleanPreference("use_tor", R.bool.use_tor);
}
protected SharedPreferences getPreferences() { protected SharedPreferences getPreferences() {
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
} }