Ver Fonte

use grey theme if no theming of elements is possible

tobiasKaminsky há 8 anos atrás
pai
commit
911c6459ff

+ 5 - 0
src/main/java/com/owncloud/android/ui/activity/Preferences.java

@@ -135,6 +135,11 @@ public class Preferences extends PreferenceActivity
     @SuppressWarnings("deprecation")
     @Override
     public void onCreate(Bundle savedInstanceState) {
+
+        if (DisplayUtils.themingEnabled()) {
+            setTheme(R.style.FallbackThemingTheme);
+        }
+
         getDelegate().installViewFactory();
         getDelegate().onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);

+ 3 - 6
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java

@@ -105,6 +105,9 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
     @Override
     public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
+        if (DisplayUtils.themingEnabled()) {
+            getContext().getTheme().applyStyle(R.style.FallbackThemingTheme, true);
+        }
         View view = inflater.inflate(R.layout.contacts_backup_fragment, null);
         ButterKnife.bind(this, view);
 
@@ -412,9 +415,6 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
             datePickerDialog.getDatePicker().setMaxDate(backupFiles.lastElement().getModificationTimestamp());
             datePickerDialog.getDatePicker().setMinDate(backupFiles.firstElement().getModificationTimestamp());
 
-            int accentColor = DisplayUtils.primaryAccentColor();
-
-
             datePickerDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                 @Override
                 public void onDismiss(DialogInterface dialog) {
@@ -423,9 +423,6 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
             });
 
             datePickerDialog.show();
-
-            datePickerDialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(accentColor);
-            datePickerDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(accentColor);
         } else {
             Toast.makeText(contactsPreferenceActivity, R.string.contacts_preferences_something_strange_happened,
                     Toast.LENGTH_SHORT).show();

+ 8 - 4
src/main/java/com/owncloud/android/utils/DisplayUtils.java

@@ -1,4 +1,4 @@
-/**
+/*
  * Nextcloud Android client application
  *
  * @author Andy Scherzinger
@@ -7,17 +7,17 @@
  * Copyright (C) 2011  Bartek Przybylski
  * Copyright (C) 2015 ownCloud Inc.
  * Copyright (C) 2016 Andy Scherzinger
- * <p>
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  * License as published by the Free Software Foundation; either
  * version 3 of the License, or any later version.
- * <p>
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- * <p>
+ *
  * You should have received a copy of the GNU Affero General Public
  * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -835,6 +835,10 @@ public class DisplayUtils {
         }
     }
 
+    public static boolean themingEnabled() {
+        return getCapability().getServerColor() != null && !getCapability().getServerColor().isEmpty();
+    }
+
     /**
      * Set color of title to white/black depending on background color
      *

+ 6 - 0
src/main/res/values/styles.xml

@@ -35,6 +35,12 @@
 		<item name="searchViewStyle">@style/ownCloud.SearchView</item>
 	</style>
 
+	<style name="FallbackThemingTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+		<item name="colorPrimary">#616161</item>
+		<item name="colorPrimaryDark">#424242</item>
+		<item name="colorAccent">#757575</item>
+	</style>
+
 	<!-- seperate action bar style for activities without an action bar -->
 	<style name="Theme.ownCloud.Toolbar" parent="Theme.AppCompat.Light.NoActionBar">
 		<item name="windowNoTitle">true</item>