Skip to content

Commit

Permalink
Add is_branded_plus condition for is_branded if statements
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Apr 18, 2024
1 parent 9579e3d commit 8c10a68
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
4 changes: 0 additions & 4 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,6 @@ public static boolean isClientBranded() {
return getAppContext().getResources().getBoolean(R.bool.is_branded_client);
}

public static boolean isClientBrandedOrBrandedPlus() {
return isClientBrandedPlus() || isClientBranded();
}

public static boolean isClientBrandedPlus() {
return (getAppContext().getResources().getBoolean(R.bool.is_branded_plus_client));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,14 @@ protected void onCreate(Bundle savedInstanceState) {
mIsFirstAuthAttempt = savedInstanceState.getBoolean(KEY_AUTH_IS_FIRST_ATTEMPT_TAG);
}

String webloginUrl = null;
boolean webViewLoginMethod;

RestrictionsManager restrictionsManager = (RestrictionsManager) getSystemService(Context.RESTRICTIONS_SERVICE);
AppConfigManager appConfigManager = new AppConfigManager(this, restrictionsManager.getApplicationRestrictions());
String webloginUrl = appConfigManager.getBaseUrl(MainApp.isClientBrandedPlus());

if (getResources().getBoolean(R.bool.is_branded_plus_client)) {
if (webloginUrl != null) {
webViewLoginMethod = true;
webloginUrl = appConfigManager.getBaseUrl(true);
} else if (getIntent().getBooleanExtra(EXTRA_USE_PROVIDER_AS_WEBLOGIN, false)) {
webViewLoginMethod = true;
webloginUrl = getString(R.string.provider_registration_server);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,11 @@ private void setupQuotaElement() {

public void updateHeader() {
int primaryColor = themeColorUtils.unchangedPrimaryColor(getAccount(), this);
boolean isClientBranded = getResources().getBoolean(R.bool.is_branded_client);
boolean isClientBrandedPlus = getResources().getBoolean(R.bool.is_branded_plus_client);

if (getAccount() != null &&
getCapabilities().getServerBackground() != null && !MainApp.isClientBrandedOrBrandedPlus()) {
getCapabilities().getServerBackground() != null && (!isClientBranded || !isClientBrandedPlus)) {

OCCapability capability = getCapabilities();
String logo = capability.getServerLogo();
Expand Down Expand Up @@ -339,7 +341,7 @@ public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {

// hide ecosystem apps according to user preference or in branded client
LinearLayout banner = mNavigationViewHeader.findViewById(R.id.drawer_ecosystem_apps);
boolean shouldHideTopBanner = MainApp.isClientBrandedOrBrandedPlus() || !preferences.isShowEcosystemApps();
boolean shouldHideTopBanner = isClientBrandedPlus || isClientBranded || !preferences.isShowEcosystemApps();

if (shouldHideTopBanner) {
hideTopBanner(banner);
Expand Down Expand Up @@ -470,7 +472,7 @@ private void filterDrawerMenu(final Menu menu, @NonNull final User user) {
DrawerMenuUtil.filterTrashbinMenuItem(menu, capability);
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
DrawerMenuUtil.filterGroupfoldersMenuItem(menu, capability);
DrawerMenuUtil.filterAssistantMenuItem(menu, capability, getResources());
DrawerMenuUtil.filterAssistantMenuItem(menu, capability);
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
DrawerMenuUtil.removeMenuItem(menu, R.id.nav_community, !getResources().getBoolean(R.bool.participate_enabled));
DrawerMenuUtil.removeMenuItem(menu, R.id.nav_shared, !getResources().getBoolean(R.bool.shared_enabled));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ private void setupDetailsCategory(PreferenceScreen preferenceScreen) {
boolean fPassCodeEnabled = getResources().getBoolean(R.bool.passcode_enabled);
boolean fDeviceCredentialsEnabled = getResources().getBoolean(R.bool.device_credentials_enabled);
boolean fShowHiddenFilesEnabled = getResources().getBoolean(R.bool.show_hidden_files_enabled);
boolean fShowEcosystemAppsEnabled = !MainApp.isClientBrandedOrBrandedPlus();
boolean fShowEcosystemAppsEnabled = !MainApp.isClientBrandedPlus() || !MainApp.isClientBranded();
boolean fSyncedFolderLightEnabled = getResources().getBoolean(R.bool.syncedFolder_light);
boolean fShowMediaScanNotifications = preferences.isShowMediaScanNotifications();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class PreviewMediaActivity :
private fun genericThumbnail(): Drawable? {
val result = AppCompatResources.getDrawable(this, R.drawable.logo)
result?.let {
if (!MainApp.isClientBrandedOrBrandedPlus()) {
if (!MainApp.isClientBranded() || !MainApp.isClientBrandedPlus()) {
DrawableCompat.setTint(it, resources.getColor(R.color.primary, this.theme))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private void setThumbnailForAudio(OCFile file) {
private void setGenericThumbnail() {
Drawable logo = AppCompatResources.getDrawable(requireContext(), R.drawable.logo);
if (logo != null) {
if (!MainApp.isClientBrandedOrBrandedPlus()) {
if (!MainApp.isClientBranded() || !MainApp.isClientBrandedPlus()) {
// only colour logo of non-branded client
DrawableCompat.setTint(logo, getResources().getColor(R.color.primary, requireContext().getTheme()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static void filterActivityMenuItem(Menu menu, @Nullable OCCapability capa
}
}

public static void filterAssistantMenuItem(Menu menu, @Nullable OCCapability capability, Resources resources) {
if (MainApp.isClientBrandedOrBrandedPlus()) {
public static void filterAssistantMenuItem(Menu menu, @Nullable OCCapability capability) {
if (MainApp.isClientBranded() || MainApp.isClientBrandedPlus()) {
if (capability != null && capability.getAssistant().isFalse()) {
removeMenuItem(menu, R.id.nav_assistant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class AppConfigManager(private val context: Context, private val appRestrictions

fun getBaseUrl(isBrandedPlus: Boolean): String? {
if (!isBrandedPlus) {
Log_OC.d(tag, "Proxy configuration cannot be set. Client is not branded plus.")
Log_OC.d(tag, "Proxy configuration cannot be set. Client is not branded plus. Default url applied")
return null
}

return if (appRestrictions.containsKey(AppConfigKeys.BaseUrl.key)) {
appRestrictions.getString(AppConfigKeys.BaseUrl.key)
} else {
Log_OC.d(tag, "BaseUrl configuration cannot be found")
Log_OC.d(tag, "BaseUrl configuration cannot be found, default url applied")
null
}
}
Expand Down

0 comments on commit 8c10a68

Please sign in to comment.