Przeglądaj źródła

fix for the progress bar on pre lollipop devices via manipulating windowFrame, windowBackground and windowTitleBackgroundStyle

Andy Scherzinger 9 lat temu
rodzic
commit
dbed65610b

+ 11 - 0
res/drawable/process_dialog_background.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@color/white"/>
+    <padding
+        android:left="@dimen/standard_padding"
+        android:top="4dp"
+        android:right="@dimen/standard_padding"
+        android:bottom="4dp"/>
+    <corners
+        android:radius="2dp"/>
+</shape>

+ 23 - 0
res/values-v21/styles.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ownCloud Android client application
+
+  Copyright (C) 2012  Bartek Przybylski
+  Copyright (C) 2015 ownCloud Inc.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License version 2,
+  as published by the Free Software Foundation.
+
+  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 General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+	<style name="ProgressDialogTheme" parent="ownCloud.Dialog">
+	</style>
+</resources>

+ 1 - 0
res/values/colors.xml

@@ -35,6 +35,7 @@
     <color name="login_text_hint_color">#757575</color>
     <color name="primary_button_color">@color/owncloud_blue_accent</color>
     <color name="secondary_button_color">#D6D7D7</color>
+    <color name="transparent">#00000000</color>
 
     <!-- Colors -->
     <color name="color_accent">@color/owncloud_blue_accent</color>

+ 5 - 2
res/values/styles.xml

@@ -62,8 +62,11 @@
 	<style name="ownCloud.Dialog" parent="Theme.AppCompat.Light.Dialog" />
 
 	<style name="ProgressDialogTheme" parent="ownCloud.Dialog">
-		<item name="android:windowFrame">@null</item>
-		<item name="android:windowBackground">@null</item>
+		<item name="colorAccent">@color/color_accent</item>
+		<item name="android:textColorPrimary">@color/primary</item>
+		<item name="android:windowFrame">@color/transparent</item>
+		<item name="android:windowBackground">@color/transparent</item>
+		<item name="android:windowTitleBackgroundStyle">@drawable/process_dialog_background</item>
 	</style>
 
 	<style name="ownCloud.Button" parent="Widget.AppCompat.Button">

+ 11 - 1
src/com/owncloud/android/ui/activity/Uploader.java

@@ -64,6 +64,7 @@ import android.widget.AdapterView.OnItemClickListener;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ListView;
+import android.widget.ProgressBar;
 import android.widget.SimpleAdapter;
 import android.widget.Toast;
 
@@ -201,10 +202,19 @@ public class Uploader extends FileActivity
         final AlertDialog.Builder builder = new Builder(this);
         switch (id) {
         case DIALOG_WAITING:
-            ProgressDialog pDialog = new ProgressDialog(this);
+            final ProgressDialog pDialog = new ProgressDialog(this, R.style.ProgressDialogTheme);
             pDialog.setIndeterminate(false);
             pDialog.setCancelable(false);
             pDialog.setMessage(getResources().getString(R.string.uploader_info_uploading));
+            pDialog.setOnShowListener(new DialogInterface.OnShowListener() {
+                @Override
+                public void onShow(DialogInterface dialog) {
+                    ProgressBar v = (ProgressBar) pDialog.findViewById(android.R.id.progress);
+                    v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.color_accent),
+                            android.graphics.PorterDuff.Mode.MULTIPLY);
+
+                }
+            });
             return pDialog;
         case DIALOG_NO_ACCOUNT:
             builder.setIcon(android.R.drawable.ic_dialog_alert);

+ 12 - 2
src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java

@@ -26,6 +26,7 @@ import android.content.DialogInterface.OnKeyListener;
 import android.os.Bundle;
 import android.support.v4.app.DialogFragment;
 import android.view.KeyEvent;
+import android.widget.ProgressBar;
 
 import com.owncloud.android.R;
 
@@ -62,11 +63,20 @@ public class IndeterminateProgressDialog extends DialogFragment {
         /// create indeterminate progress dialog
         final ProgressDialog dialog = new ProgressDialog(getActivity(), R.style.ProgressDialogTheme);
         dialog.setIndeterminate(true);
+        dialog.setOnShowListener(new DialogInterface.OnShowListener() {
+            @Override
+            public void onShow(DialogInterface dialog) {
+                ProgressBar v = (ProgressBar) getDialog().findViewById(android.R.id.progress);
+                v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.color_accent),
+                        android.graphics.PorterDuff.Mode.MULTIPLY);
+
+            }
+        });
         
         /// set message
         int messageId = getArguments().getInt(ARG_MESSAGE_ID, R.string.placeholder_sentence);
         dialog.setMessage(getString(messageId));
-        
+
         /// set cancellation behavior
         boolean cancelable = getArguments().getBoolean(ARG_CANCELABLE, false);
         if (!cancelable) {
@@ -77,7 +87,7 @@ public class IndeterminateProgressDialog extends DialogFragment {
                 public boolean onKey(DialogInterface dialog, int keyCode,
                         KeyEvent event) {
 
-                    if( keyCode == KeyEvent.KEYCODE_BACK){                  
+                    if( keyCode == KeyEvent.KEYCODE_BACK) {
                         return true;
                     }
                     return false;