Skip to content

Commit

Permalink
use AppConfigKeys as parameter instead of String
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 5, 2024
1 parent 12db066 commit 1f2d28f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class ChooseAccountDialogFragment :

private fun checkAppRestrictions() {
val disableMultiAccount = requireContext().getRestriction(
AppConfigKeys.DisableMultiAccount.key,
AppConfigKeys.DisableMultiAccount,
context?.resources?.getBoolean(R.bool.disable_multiaccount) ?: false
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import android.widget.Toast
import com.google.common.io.Resources
import com.owncloud.android.R
import com.owncloud.android.datamodel.ReceiverFlag
import com.owncloud.android.utils.appConfig.AppConfigKeys

fun <T : Any> Context.getRestriction(key: String, defaultValue: T): T {
fun <T : Any> Context.getRestriction(appConfigKey: AppConfigKeys, defaultValue: T): T {
val restrictionsManager = getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
return restrictionsManager.getRestriction(key, defaultValue)
return restrictionsManager.getRestriction(appConfigKey.key, defaultValue)
}

@Suppress("UNCHECKED_CAST")
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ private void setProxyConfig() {
return;
}

String host = ContextExtensionsKt.getRestriction(this, AppConfigKeys.ProxyHost.getKey(), getString(R.string.proxy_host));
int port = ContextExtensionsKt.getRestriction(this, AppConfigKeys.ProxyPort.getKey(), getResources().getInteger(R.integer.proxy_port));
String host = ContextExtensionsKt.getRestriction(this, AppConfigKeys.ProxyHost, getString(R.string.proxy_host));
int port = ContextExtensionsKt.getRestriction(this, AppConfigKeys.ProxyPort, getResources().getInteger(R.integer.proxy_port));

if (TextUtils.isEmpty(host) || port == -1) {
Log_OC.d(TAG, "Proxy configuration cannot be found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ protected void onCreate(Bundle savedInstanceState) {
String webloginUrl = null;

if (MainApp.isClientBrandedPlus()) {
String baseUrl = ContextExtensionsKt.getRestriction(this, AppConfigKeys.BaseUrl.getKey(), "");
String baseUrl = ContextExtensionsKt.getRestriction(this, AppConfigKeys.BaseUrl, "");
if (!TextUtils.isEmpty(baseUrl)) {
webloginUrl = baseUrl + WEB_LOGIN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SendShareDialog : BottomSheetDialogFragment(R.layout.send_share_fragment),
@Suppress("MagicNumber")
private fun setupSendButtonRecyclerView() {
val disableSharing = requireContext().getRestriction(
AppConfigKeys.DisableSharing.key,
AppConfigKeys.DisableSharing,
context?.resources?.getBoolean(R.bool.disable_sharing) ?: false
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object ClipboardUtil {
@Suppress("TooGenericExceptionCaught")
fun copyToClipboard(activity: Activity, text: String?, showToast: Boolean = true) {
val disableClipboard = activity.getRestriction(
AppConfigKeys.DisableClipboard.key,
AppConfigKeys.DisableClipboard,
activity.resources.getBoolean(R.bool.disable_clipboard)
)
if (disableClipboard) {
Expand Down

0 comments on commit 1f2d28f

Please sign in to comment.