Add branding support for

- hide provider
- hide auth
- multi account support
- enforce domain

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-10-09 10:42:23 +02:00
parent 0a49c9dc40
commit d7400c3f76
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
4 changed files with 91 additions and 41 deletions

View file

@ -25,6 +25,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.view.ViewGroup import android.view.ViewGroup
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import autodagger.AutoInjector import autodagger.AutoInjector
@ -38,10 +39,7 @@ import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.appbar.MaterialToolbar
import com.nextcloud.talk.R import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.CallNotificationController import com.nextcloud.talk.controllers.*
import com.nextcloud.talk.controllers.ConversationsListController
import com.nextcloud.talk.controllers.LockedController
import com.nextcloud.talk.controllers.ServerSelectionController
import com.nextcloud.talk.controllers.base.providers.ActionBarProvider import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
import com.nextcloud.talk.utils.ConductorRemapping import com.nextcloud.talk.utils.ConductorRemapping
import com.nextcloud.talk.utils.SecurityUtils import com.nextcloud.talk.utils.SecurityUtils
@ -102,16 +100,29 @@ class MainActivity : BaseActivity(), ActionBarProvider {
router!!.setRoot(RouterTransaction.with(ConversationsListController()) router!!.setRoot(RouterTransaction.with(ConversationsListController())
.pushChangeHandler(HorizontalChangeHandler()) .pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())) .popChangeHandler(HorizontalChangeHandler()))
} else {
if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) {
router!!.pushController(RouterTransaction.with(
WebViewLoginController(resources.getString(R.string.weblogin_url), false))
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler()))
} else {
router!!.setRoot(RouterTransaction.with(ServerSelectionController())
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler()))
}
}
} else {
if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) {
router!!.pushController(RouterTransaction.with(
WebViewLoginController(resources.getString(R.string.weblogin_url), false))
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler()))
} else { } else {
router!!.setRoot(RouterTransaction.with(ServerSelectionController()) router!!.setRoot(RouterTransaction.with(ServerSelectionController())
.pushChangeHandler(HorizontalChangeHandler()) .pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())) .popChangeHandler(HorizontalChangeHandler()))
} }
} else {
router!!.setRoot(RouterTransaction.with(ServerSelectionController())
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler()))
} }
} }
} }

View file

@ -35,10 +35,7 @@ import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import autodagger.AutoInjector;
import butterknife.BindView;
import butterknife.OnClick;
import com.bluelinelabs.conductor.RouterTransaction; import com.bluelinelabs.conductor.RouterTransaction;
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler; import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
import com.nextcloud.talk.R; import com.nextcloud.talk.R;
@ -51,15 +48,21 @@ import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.utils.database.user.UserUtils;
import com.nextcloud.talk.utils.preferences.AppPreferences; import com.nextcloud.talk.utils.preferences.AppPreferences;
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder; import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
import java.security.cert.CertificateException;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import autodagger.AutoInjector;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText; import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import studio.carbonylgroup.textfieldboxes.TextFieldBoxes; import studio.carbonylgroup.textfieldboxes.TextFieldBoxes;
import javax.inject.Inject;
import java.security.cert.CertificateException;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class ServerSelectionController extends BaseController { public class ServerSelectionController extends BaseController {
@ -128,8 +131,13 @@ public class ServerSelectionController extends BaseController {
textFieldBoxes.getEndIconImageButton().setVisibility(View.VISIBLE); textFieldBoxes.getEndIconImageButton().setVisibility(View.VISIBLE);
textFieldBoxes.getEndIconImageButton().setOnClickListener(view1 -> checkServerAndProceed()); textFieldBoxes.getEndIconImageButton().setOnClickListener(view1 -> checkServerAndProceed());
if (TextUtils.isEmpty(getResources().getString(R.string.nc_providers_url)) && (TextUtils.isEmpty(getResources if (getResources().getBoolean(R.bool.hide_auth_cert)) {
().getString(R.string.nc_import_account_type)))) { certTextView.setVisibility(View.GONE);
}
if (getResources().getBoolean(R.bool.hide_provider) ||
TextUtils.isEmpty(getResources().getString(R.string.nc_providers_url)) &&
(TextUtils.isEmpty(getResources().getString(R.string.nc_import_account_type)))) {
providersTextView.setVisibility(View.INVISIBLE); providersTextView.setVisibility(View.INVISIBLE);
} else { } else {
if ((TextUtils.isEmpty(getResources if ((TextUtils.isEmpty(getResources
@ -179,6 +187,11 @@ public class ServerSelectionController extends BaseController {
serverEntry.requestFocus(); serverEntry.requestFocus();
if (!TextUtils.isEmpty(getResources().getString(R.string.weblogin_url))) {
serverEntry.setText(getResources().getString(R.string.weblogin_url));
checkServerAndProceed();
}
serverEntry.addTextChangedListener(new TextWatcher() { serverEntry.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

View file

@ -37,15 +37,7 @@ import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Checkable; import android.widget.Checkable;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.emoji.widget.EmojiTextView;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import autodagger.AutoInjector;
import butterknife.BindView;
import butterknife.OnClick;
import com.bluelinelabs.conductor.RouterTransaction; import com.bluelinelabs.conductor.RouterTransaction;
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler; import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler; import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler;
@ -61,7 +53,11 @@ import com.nextcloud.talk.controllers.base.BaseController;
import com.nextcloud.talk.jobs.AccountRemovalWorker; import com.nextcloud.talk.jobs.AccountRemovalWorker;
import com.nextcloud.talk.models.RingtoneSettings; import com.nextcloud.talk.models.RingtoneSettings;
import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.database.UserEntity;
import com.nextcloud.talk.utils.*; import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.DisplayUtils;
import com.nextcloud.talk.utils.DoNotDisturbUtils;
import com.nextcloud.talk.utils.LoggingUtils;
import com.nextcloud.talk.utils.SecurityUtils;
import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.utils.database.user.UserUtils;
import com.nextcloud.talk.utils.preferences.AppPreferences; import com.nextcloud.talk.utils.preferences.AppPreferences;
@ -69,18 +65,38 @@ import com.nextcloud.talk.utils.preferences.MagicUserInputModule;
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder; import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
import com.yarolegovich.lovelydialog.LovelySaveStateHandler; import com.yarolegovich.lovelydialog.LovelySaveStateHandler;
import com.yarolegovich.lovelydialog.LovelyStandardDialog; import com.yarolegovich.lovelydialog.LovelyStandardDialog;
import com.yarolegovich.mp.*; import com.yarolegovich.mp.MaterialChoicePreference;
import io.reactivex.android.schedulers.AndroidSchedulers; import com.yarolegovich.mp.MaterialEditTextPreference;
import io.reactivex.disposables.Disposable; import com.yarolegovich.mp.MaterialPreferenceCategory;
import io.reactivex.schedulers.Schedulers; import com.yarolegovich.mp.MaterialPreferenceScreen;
import net.orange_box.storebox.listeners.OnPreferenceValueChangedListener; import com.yarolegovich.mp.MaterialStandardPreference;
import org.greenrobot.eventbus.EventBus; import com.yarolegovich.mp.MaterialSwitchPreference;
import net.orange_box.storebox.listeners.OnPreferenceValueChangedListener;
import javax.inject.Inject;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.emoji.widget.EmojiTextView;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import autodagger.AutoInjector;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class SettingsController extends BaseController { public class SettingsController extends BaseController {
@ -264,11 +280,15 @@ public class SettingsController extends BaseController {
.popChangeHandler(new HorizontalChangeHandler())); .popChangeHandler(new HorizontalChangeHandler()));
}); });
addAccountButton.addPreferenceClickListener(view15 -> { if (getResources().getBoolean(R.bool.multiaccount_support)) {
getRouter().pushController(RouterTransaction.with(new addAccountButton.addPreferenceClickListener(view15 -> {
ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler()) getRouter().pushController(RouterTransaction.with(new
.popChangeHandler(new VerticalChangeHandler())); ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler())
}); .popChangeHandler(new VerticalChangeHandler()));
});
} else {
addAccountButton.setVisibility(View.GONE);
}
switchAccountButton.addPreferenceClickListener(view16 -> { switchAccountButton.addPreferenceClickListener(view16 -> {
getRouter().pushController(RouterTransaction.with(new getRouter().pushController(RouterTransaction.with(new

View file

@ -30,6 +30,12 @@
<string name="nc_push_server_url" translatable="false">https://push-notifications.nextcloud.com</string> <string name="nc_push_server_url" translatable="false">https://push-notifications.nextcloud.com</string>
<!-- Branding -->
<bool name="hide_provider">false</bool>
<bool name="hide_auth_cert">false</bool>
<bool name="multiaccount_support">true</bool>
<string name="weblogin_url" translatable="false"></string>
<!-- Will not be shown if empty --> <!-- Will not be shown if empty -->
<string name="nc_privacy_url" translatable="false">https://nextcloud.com/privacy/</string> <string name="nc_privacy_url" translatable="false">https://nextcloud.com/privacy/</string>
<string name="nc_gpl3_url" translatable="false">https://www.gnu.org/licenses/gpl-3.0.en.html</string> <string name="nc_gpl3_url" translatable="false">https://www.gnu.org/licenses/gpl-3.0.en.html</string>