changed single_account config into more simple lock_settings

This commit is contained in:
Daniel Gultsch 2016-02-27 10:25:31 +01:00
parent c393e60891
commit 60ab03afb1
8 changed files with 29 additions and 8 deletions

View File

@ -45,7 +45,7 @@ public final class Config {
public static final String CONFERENCE_DOMAIN_LOCK = null; //only allow conference creation for this domain
public static final boolean LOCK_DOMAINS_IN_CONVERSATIONS = false; //only add contacts and conferences for own domains
public static final boolean SINGLE_ACCOUNT = false; //set to true to allow only one account
public static final boolean LOCK_SETTINGS = false; //set to true to disallow account and settings editing
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
public static final boolean ALLOW_NON_TLS_CONNECTIONS = false; //very dangerous. you should have a good reason to set this to true

View File

@ -333,7 +333,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.muc_details, menu);
return true;
return super.onCreateOptionsMenu(menu);
}
@Override

View File

@ -297,7 +297,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
edit.setVisible(false);
delete.setVisible(false);
}
return true;
return super.onCreateOptionsMenu(menu);
}
private void populateView() {

View File

@ -420,7 +420,7 @@ public class ConversationActivity extends XmppActivity
}
}
}
return true;
return super.onCreateOptionsMenu(menu);
}
protected void selectPresenceToAttachFile(final int attachmentChoice, final int encryption) {

View File

@ -499,7 +499,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
clearDevices.setVisible(false);
mamPrefs.setVisible(false);
}
return true;
return super.onCreateOptionsMenu(menu);
}
@Override
@ -621,6 +621,13 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
this.mNamePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
}
mPassword.setEnabled(!Config.LOCK_SETTINGS);
mAccountJid.setEnabled(!Config.LOCK_SETTINGS);
mHostname.setEnabled(!Config.LOCK_SETTINGS);
mPort.setEnabled(!Config.LOCK_SETTINGS);
mPasswordConfirm.setEnabled(!Config.LOCK_SETTINGS);
mRegisterNew.setEnabled(!Config.LOCK_SETTINGS);
if (!mInitMode) {
this.mAvatar.setVisibility(View.VISIBLE);
this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));

View File

@ -155,9 +155,9 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
addAccount.setVisible(false);
addAccountWithCertificate.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
} else {
addAccount.setVisible(!Config.SINGLE_ACCOUNT);
addAccount.setVisible(!Config.LOCK_SETTINGS);
}
addAccountWithCertificate.setVisible(!Config.SINGLE_ACCOUNT);
addAccountWithCertificate.setVisible(!Config.LOCK_SETTINGS);
if (!accountsLeftToEnable()) {
enableAll.setVisible(false);

View File

@ -533,7 +533,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
mSearchEditText.append(mInitialJid);
filter(mInitialJid);
}
return true;
return super.onCreateOptionsMenu(menu);
}
@Override

View File

@ -42,6 +42,7 @@ 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;
@ -377,6 +378,19 @@ public abstract class XmppActivity extends Activity {
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
final MenuItem menuSettings = menu.findItem(R.id.action_settings);
final MenuItem menuManageAccounts = menu.findItem(R.id.action_accounts);
if (menuSettings != null) {
menuSettings.setVisible(!Config.LOCK_SETTINGS);
}
if (menuManageAccounts != null) {
menuManageAccounts.setVisible(!Config.LOCK_SETTINGS);
}
return super.onCreateOptionsMenu(menu);
}
protected boolean showBatteryOptimizationWarning() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);