Merge pull request #2313 from nextcloud/chore/noid/conversationslistcontroller-kotlin

Convert ConversationsListController to Kotlin, and get rid of ButterKnife
This commit is contained in:
Andy Scherzinger 2022-08-19 00:08:59 +02:00 committed by GitHub
commit 5c6d001750
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1346 additions and 1766 deletions

View file

@ -158,7 +158,6 @@ android {
ext {
androidxCameraVersion = "1.1.0"
butterknifeVersion = "10.2.3"
coilKtVersion = "2.1.0"
daggerVersion = "2.43.2"
lifecycleVersion = '2.5.1'
@ -256,8 +255,6 @@ dependencies {
implementation "org.parceler:parceler-api:$parcelerVersion"
implementation 'net.orange-box.storebox:storebox-lib:1.4.0'
implementation "com.jakewharton:butterknife:${butterknifeVersion}"
kapt "com.jakewharton:butterknife-compiler:${butterknifeVersion}"
implementation 'eu.davidea:flexible-adapter:5.1.0'
implementation 'eu.davidea:flexible-adapter-ui:1.0.0'
implementation fileTree(downloadWebRtc.libFile.path)

View file

@ -32,7 +32,6 @@
<issue id="ObsoleteLintCustomCheck" severity="warning">
<ignore path="**/jetified-annotation-experimental-1.**/**/lint.jar" />
<ignore path="**/butterknife-runtime-10.2.**/**/lint.jar" />
<ignore path="**/jetified-conductor-2.**/**/lint.jar" />
</issue>
</lint>

View file

@ -38,7 +38,7 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ControllerAccountVerificationBinding
@ -73,7 +73,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class AccountVerificationController(args: Bundle? = null) :
NewBaseController(
BaseController(
R.layout.controller_account_verification,
args
) {

View file

@ -125,7 +125,7 @@ import com.nextcloud.talk.adapters.messages.VoiceMessageInterface
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.callbacks.MentionAutocompleteCallback
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ControllerChatBinding
@ -211,7 +211,7 @@ import kotlin.math.roundToInt
@AutoInjector(NextcloudTalkApplication::class)
class ChatController(args: Bundle) :
NewBaseController(
BaseController(
R.layout.controller_chat,
args
),

View file

@ -49,7 +49,7 @@ import com.nextcloud.talk.adapters.items.GenericTextHeaderItem
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.data.user.model.User
@ -89,7 +89,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class ContactsController(args: Bundle) :
NewBaseController(R.layout.controller_contacts_rv),
BaseController(R.layout.controller_contacts_rv),
SearchView.OnQueryTextListener,
FlexibleAdapter.OnItemClickListener {
private val binding: ControllerContactsRvBinding by viewBinding(ControllerContactsRvBinding::bind)

View file

@ -55,7 +55,7 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.adapters.items.ParticipantItem
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.bottomsheet.items.BasicListItemWithImage
import com.nextcloud.talk.controllers.bottomsheet.items.listItemsWithImage
import com.nextcloud.talk.controllers.util.viewBinding
@ -99,7 +99,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class ConversationInfoController(args: Bundle) :
NewBaseController(
BaseController(
R.layout.controller_conversation_info,
args
),

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,7 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.adapters.GeocodingAdapter
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.databinding.ControllerGeocodingBinding
import com.nextcloud.talk.utils.bundle.BundleKeys
@ -58,7 +58,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class GeocodingController(args: Bundle) :
NewBaseController(
BaseController(
R.layout.controller_geocoding,
args
),

View file

@ -49,7 +49,7 @@ import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
import com.nextcloud.talk.R
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.databinding.ControllerLocationBinding
import com.nextcloud.talk.models.json.generic.GenericOverall
@ -83,7 +83,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class LocationPickerController(args: Bundle) :
NewBaseController(
BaseController(
R.layout.controller_location,
args
),

View file

@ -39,7 +39,7 @@ import autodagger.AutoInjector
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.databinding.ControllerLockedBinding
import com.nextcloud.talk.utils.DisplayUtils
@ -48,7 +48,7 @@ import java.util.concurrent.Executor
import java.util.concurrent.Executors
@AutoInjector(NextcloudTalkApplication::class)
class LockedController : NewBaseController(R.layout.controller_locked) {
class LockedController : BaseController(R.layout.controller_locked) {
private val binding: ControllerLockedBinding by viewBinding(ControllerLockedBinding::bind)
override val appBarLayoutType: AppBarLayoutType

View file

@ -52,7 +52,7 @@ import com.nextcloud.talk.activities.TakePhotoActivity
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ControllerProfileBinding
@ -94,7 +94,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
@Suppress("Detekt.TooManyFunctions")
class ProfileController : NewBaseController(R.layout.controller_profile) {
class ProfileController : BaseController(R.layout.controller_profile) {
private val binding: ControllerProfileBinding by viewBinding(ControllerProfileBinding::bind)
@Inject

View file

@ -38,7 +38,7 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.adapters.items.NotificationSoundItem
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.databinding.ControllerGenericRvBinding
import com.nextcloud.talk.models.RingtoneSettings
@ -52,7 +52,7 @@ import java.io.IOException
@AutoInjector(NextcloudTalkApplication::class)
class RingtoneSelectionController(args: Bundle) :
NewBaseController(
BaseController(
R.layout.controller_generic_rv,
args
),

View file

@ -41,7 +41,7 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.databinding.ControllerServerSelectionBinding
import com.nextcloud.talk.models.json.generic.Status
@ -61,7 +61,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class ServerSelectionController :
NewBaseController(R.layout.controller_server_selection) {
BaseController(R.layout.controller_server_selection) {
private val binding: ControllerServerSelectionBinding by viewBinding(ControllerServerSelectionBinding::bind)

View file

@ -68,7 +68,7 @@ import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.setAppTheme
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ControllerSettingsBinding
@ -105,7 +105,7 @@ import java.util.Locale
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class SettingsController : NewBaseController(R.layout.controller_settings) {
class SettingsController : BaseController(R.layout.controller_settings) {
private val binding: ControllerSettingsBinding by viewBinding(ControllerSettingsBinding::bind)
@Inject

View file

@ -37,7 +37,7 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.adapters.items.AdvancedUserItem
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ControllerGenericRvBinding
@ -59,7 +59,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class SwitchAccountController(args: Bundle? = null) :
NewBaseController(
BaseController(
R.layout.controller_generic_rv,
args
) {

View file

@ -51,7 +51,7 @@ import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.databinding.ControllerWebViewLoginBinding
import com.nextcloud.talk.events.CertificateEvent
@ -78,7 +78,7 @@ import java.util.Locale
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class WebViewLoginController(args: Bundle? = null) : NewBaseController(
class WebViewLoginController(args: Bundle? = null) : BaseController(
R.layout.controller_web_view_login,
args
) {

View file

@ -1,271 +0,0 @@
/*
* Nextcloud Talk application
*
* @author Andy Scherzinger
* @author BlueLine Labs, Inc.
* @author Mario Danic
* Copyright (C) 2021 Andy Scherzinger (info@andy-scherzinger.de)
* Copyright (C) 2020 Mario Danic (mario@lovelyhq.com)
* Copyright (C) 2016 BlueLine Labs, Inc.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nextcloud.talk.controllers.base;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.ActionBar;
import androidx.core.content.res.ResourcesCompat;
import com.bluelinelabs.conductor.Controller;
import com.google.android.material.appbar.AppBarLayout;
import com.nextcloud.talk.R;
import com.nextcloud.talk.activities.MainActivity;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.controllers.AccountVerificationController;
import com.nextcloud.talk.controllers.ServerSelectionController;
import com.nextcloud.talk.controllers.SwitchAccountController;
import com.nextcloud.talk.controllers.WebViewLoginController;
import com.nextcloud.talk.controllers.base.providers.ActionBarProvider;
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
import com.nextcloud.talk.utils.DisplayUtils;
import com.nextcloud.talk.utils.preferences.AppPreferences;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import autodagger.AutoInjector;
@AutoInjector(NextcloudTalkApplication.class)
public abstract class BaseController extends ButterKnifeController {
public enum AppBarLayoutType {
TOOLBAR,
SEARCH_BAR,
EMPTY
}
private static final String TAG = "BaseController";
@Inject
AppPreferences appPreferences;
@Inject
Context context;
@Inject
ViewThemeUtils viewThemeUtils;
protected BaseController() {
cleanTempCertPreference();
}
protected BaseController(Bundle args) {
super(args);
cleanTempCertPreference();
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
getRouter().popCurrentController();
return true;
}
return super.onOptionsItemSelected(item);
}
private void cleanTempCertPreference() {
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
List<String> temporaryClassNames = new ArrayList<>();
temporaryClassNames.add(ServerSelectionController.class.getName());
temporaryClassNames.add(AccountVerificationController.class.getName());
temporaryClassNames.add(WebViewLoginController.class.getName());
temporaryClassNames.add(SwitchAccountController.class.getName());
if (!temporaryClassNames.contains(getClass().getName())) {
appPreferences.removeTemporaryClientCertAlias();
}
}
@Override
protected void onViewBound(@NonNull View view) {
super.onViewBound(view);
MainActivity activity = null;
if (getActivity() != null && getActivity() instanceof MainActivity) {
activity = (MainActivity) getActivity();
viewThemeUtils.themeCardView(activity.binding.searchToolbar);
viewThemeUtils.themeToolbar(activity.binding.toolbar);
viewThemeUtils.themeSearchBarText(activity.binding.searchText);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.getIsKeyboardIncognito()) {
disableKeyboardPersonalisedLearning((ViewGroup) view);
if (activity != null) {
disableKeyboardPersonalisedLearning(activity.binding.appBar);
}
}
}
// Note: This is just a quick demo of how an ActionBar *can* be accessed, not necessarily how it *should*
// be accessed. In a production app, this would use Dagger instead.
protected ActionBar getActionBar() {
ActionBarProvider actionBarProvider = null;
try {
actionBarProvider = ((ActionBarProvider) getActivity());
} catch (Exception exception) {
Log.d(TAG, "Failed to fetch the action bar provider");
}
return actionBarProvider != null ? actionBarProvider.getSupportActionBar() : null;
}
@Override
protected void onAttach(@NonNull View view) {
showSearchOrToolbar();
setTitle();
if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(getParentController() != null || getRouter().getBackstackSize() > 1);
}
super.onAttach(view);
}
protected void showSearchOrToolbar() {
if (getActivity() != null && getActivity() instanceof MainActivity) {
boolean showSearchBar = getAppBarLayoutType() == AppBarLayoutType.SEARCH_BAR;
MainActivity activity = (MainActivity) getActivity();
if (getAppBarLayoutType() == AppBarLayoutType.EMPTY) {
activity.binding.toolbar.setVisibility(View.GONE);
activity.binding.searchToolbar.setVisibility(View.GONE);
} else {
AppBarLayout.LayoutParams layoutParams =
(AppBarLayout.LayoutParams) activity.binding.searchToolbar.getLayoutParams();
if (showSearchBar) {
activity.binding.searchToolbar.setVisibility(View.VISIBLE);
activity.binding.searchText.setHint(getSearchHint());
activity.binding.toolbar.setVisibility(View.GONE);
//layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
layoutParams.setScrollFlags(0);
activity.binding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
activity.binding.appBar.getContext(),
R.animator.appbar_elevation_off)
);
} else {
hideSearchBar();
}
activity.binding.searchToolbar.setLayoutParams(layoutParams);
if ((getResources() != null)) {
if (showSearchBar) {
viewThemeUtils.resetStatusBar(activity, activity.binding.searchToolbar);
} else {
viewThemeUtils.themeStatusBar(activity, activity.binding.searchToolbar);
}
}
}
if ((getResources() != null)) {
DisplayUtils.applyColorToNavigationBar(
activity.getWindow(),
ResourcesCompat.getColor(getResources(), R.color.bg_default, null)
);
}
}
}
protected void hideSearchBar() {
MainActivity activity = (MainActivity) getActivity();
AppBarLayout.LayoutParams layoutParams =
(AppBarLayout.LayoutParams) activity.binding.searchToolbar.getLayoutParams();
activity.binding.searchToolbar.setVisibility(View.GONE);
activity.binding.toolbar.setVisibility(View.VISIBLE);
layoutParams.setScrollFlags(0);
activity.binding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
activity.binding.appBar.getContext(),
R.animator.appbar_elevation_on)
);
}
@Override
protected void onDetach(@NonNull View view) {
super.onDetach(view);
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
protected void setTitle() {
Controller parentController = getParentController();
while (parentController != null) {
if (parentController instanceof BaseController && ((BaseController) parentController).getTitle() != null) {
return;
}
parentController = parentController.getParentController();
}
String title = getTitle();
ActionBar actionBar = getActionBar();
if (title != null && actionBar != null) {
actionBar.setTitle(title);
}
}
protected String getTitle() {
return null;
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void disableKeyboardPersonalisedLearning(final ViewGroup viewGroup) {
View view;
EditText editText;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
view = viewGroup.getChildAt(i);
if (view instanceof EditText) {
editText = (EditText) view;
editText.setImeOptions(editText.getImeOptions() | EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING);
} else if (view instanceof ViewGroup) {
disableKeyboardPersonalisedLearning((ViewGroup) view);
}
}
}
public AppBarLayoutType getAppBarLayoutType() {
return AppBarLayoutType.TOOLBAR;
}
public String getSearchHint() {
return context.getString(R.string.appbar_search_in, context.getString(R.string.nc_app_product_name));
}
}

View file

@ -63,7 +63,7 @@ import javax.inject.Inject
import kotlin.jvm.internal.Intrinsics
@AutoInjector(NextcloudTalkApplication::class)
abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? = null) : Controller(args) {
abstract class BaseController(@LayoutRes var layoutRes: Int, args: Bundle? = null) : Controller(args) {
enum class AppBarLayoutType {
TOOLBAR, SEARCH_BAR, EMPTY
}
@ -145,7 +145,7 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
super.onAttach(view)
}
protected fun showSearchOrToolbar() {
open fun showSearchOrToolbar() {
if (isValidActivity(activity)) {
val showSearchBar = appBarLayoutType == AppBarLayoutType.SEARCH_BAR
val activity = activity as MainActivity
@ -202,6 +202,18 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
binding.searchToolbar.visibility = View.GONE
}
fun hideSearchBar() {
val activity = activity as MainActivity?
val layoutParams = activity!!.binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
activity.binding.searchToolbar.visibility = View.GONE
activity.binding.toolbar.visibility = View.VISIBLE
layoutParams.scrollFlags = 0
activity.binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
activity.binding.appBar.context,
R.animator.appbar_elevation_on
)
}
private fun colorizeStatusBar(showSearchBar: Boolean, activity: Activity?, resources: Resources?) {
if (activity != null && resources != null) {
if (showSearchBar) {
@ -223,7 +235,7 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
override fun onDetach(view: View) {
super.onDetach(view)
val imm = context!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
@ -239,17 +251,10 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
private fun calculateValidParentController() {
var parentController = parentController
while (parentController != null) {
if (isValidController(parentController)) {
return
}
parentController = parentController.parentController
}
}
private fun isValidController(parentController: Controller): Boolean {
return parentController is BaseController && parentController.title != null
}
private fun isTitleSetable(): Boolean {
return title != null && actionBar != null
}
@ -280,7 +285,7 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
temporaryClassNames.add(WebViewLoginController::class.java.name)
temporaryClassNames.add(SwitchAccountController::class.java.name)
if (!temporaryClassNames.contains(javaClass.name)) {
appPreferences!!.removeTemporaryClientCertAlias()
appPreferences.removeTemporaryClientCertAlias()
}
}
@ -323,7 +328,7 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
open val appBarLayoutType: AppBarLayoutType
get() = AppBarLayoutType.TOOLBAR
val searchHint: String
get() = context!!.getString(R.string.appbar_search_in, context!!.getString(R.string.nc_app_product_name))
get() = context.getString(R.string.appbar_search_in, context.getString(R.string.nc_app_product_name))
companion object {
private val TAG = BaseController::class.java.simpleName

View file

@ -1,58 +0,0 @@
/**
* Nextcloud Talk application
*
* @author BlueLine Labs, Inc.
* Copyright (C) 2016 BlueLine Labs, Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nextcloud.talk.controllers.base
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import butterknife.ButterKnife
import butterknife.Unbinder
import com.bluelinelabs.conductor.Controller
abstract class ButterKnifeController : Controller {
private var unbinder: Unbinder? = null
constructor()
constructor(args: Bundle) : super(args)
protected abstract fun inflateView(inflater: LayoutInflater, container: ViewGroup): View
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedViewState: Bundle?): View {
val view = inflateView(inflater, container)
unbinder = ButterKnife.bind(this, view)
onViewBound(view)
return view
}
protected open fun onViewBound(view: View) {
// unused atm
}
override fun onDestroyView(view: View) {
super.onDestroyView(view)
unbinder!!.unbind()
unbinder = null
}
}

View file

@ -42,7 +42,7 @@ import com.google.android.material.textfield.TextInputLayout
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.databinding.ControllerEntryMenuBinding
import com.nextcloud.talk.models.json.conversations.Conversation
@ -60,7 +60,7 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class EntryMenuController(args: Bundle) :
NewBaseController(
BaseController(
R.layout.controller_entry_menu,
args
) {

View file

@ -34,7 +34,7 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.base.NewBaseController
import com.nextcloud.talk.controllers.base.BaseController
import com.nextcloud.talk.controllers.util.viewBinding
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ControllerOperationsMenuBinding
@ -79,7 +79,7 @@ import java.util.Collections
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class OperationsMenuController(args: Bundle) : NewBaseController(
class OperationsMenuController(args: Bundle) : BaseController(
R.layout.controller_operations_menu,
args
) {

View file

@ -310,8 +310,4 @@ class ConversationsListBottomDialog(
val behavior = BottomSheetBehavior.from(bottomSheet as View)
behavior.state = BottomSheetBehavior.STATE_COLLAPSED
}
companion object {
private const val TAG = "ConversationOperationDialog"
}
}

View file

@ -1,5 +1,5 @@
build:
maxIssues: 77
maxIssues: 94
weights:
# complexity: 2
# LongParameterList: 1