-Subproject commit 30acd4875dda3fd0bec83daaad522f3d5a02ead6
+Subproject commit 25c53f3bf978f53cceed125edfb9a37eecfa15a8
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ownCloud Android client application
+ Copyright (C) 2014 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/>.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+ <ImageView android:id="@+id/icon"
+ android:layout_width="@android:dimen/notification_large_icon_width"
+ android:layout_height="@android:dimen/notification_large_icon_height"
+ android:scaleType="center"
+ />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:minHeight="64dp"
+ android:orientation="vertical"
+ android:paddingRight="12dp"
+ android:paddingLeft="12dp"
+ >
+ <TextView android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal"
+ style="@style/Theme.ownCloud.NotificationText.Title"
+ />
+ <TextView android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="-2dp"
+ android:layout_marginBottom="-2dp"
+ android:singleLine="true"
+ android:fadingEdge="horizontal"
+ android:ellipsize="marquee"
+ style="@style/Theme.ownCloud.NotificationText.Content"
+ />
+ <FrameLayout android:id="@+id/progressHolder"
+ android:layout_width="match_parent"
+ android:layout_height="12dp"
+ >
+ <!-- the FrameLayout is needed to change visibility of the
+ progress bar in Android 2.2, even though
+ https://code.google.com/p/android/issues/detail?id=11040 -->
+ <ProgressBar
+ android:id="@+id/progress"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ style="?android:attr/progressBarStyleHorizontal"
+ />
+ </FrameLayout>
+ </LinearLayout>
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ownCloud Android client application
+ Copyright (C) 2014 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/>.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingTop="5dp"
+ android:paddingLeft="5dp"
+ >
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="3dp"
+ >
+ <ImageView android:id="@+id/icon"
+ android:layout_width="25dp"
+ android:layout_height="25dp"
+ android:scaleType="centerInside"
+ />
+ <TextView android:id="@+id/title"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal"
+ android:paddingLeft="4dp"
+ style="@style/Theme.ownCloud.NotificationText.Title"
+ />
+ </LinearLayout>
+ <TextView android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal"
+ style="@style/Theme.ownCloud.NotificationText.Content"
+ />
+ <FrameLayout android:id="@+id/progressHolder"
+ android:layout_width="match_parent"
+ android:layout_height="10dp"
+ android:paddingTop="2dp"
+ android:paddingBottom="2dp"
+ >
+ <!-- the FrameLayout is needed to change visibility of the
+ progress bar in Android 2.2, even though
+ https://code.google.com/p/android/issues/detail?id=11040 -->
+ <ProgressBar
+ android:id="@+id/progress"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ style="?android:attr/progressBarStyleHorizontal"
+ />
+ </FrameLayout>
+</LinearLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ownCloud Android client application
-
- Copyright (C) 2012 Bartek Przybylski
- Copyright (C) 2012-2013 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/>.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:padding="5dp">
- <ImageView android:id="@+id/status_icon"
- android:layout_width="wrap_content" android:layout_height="fill_parent"
- android:layout_alignParentLeft="true" />
-
- <RelativeLayout android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:layout_toRightOf="@id/status_icon">
-
- <TextView android:id="@+id/status_text" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:layout_alignParentTop="true" />
- <ProgressBar android:id="@+id/status_progress"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:layout_below="@id/status_text"
- android:progressDrawable="@android:drawable/progress_horizontal"
- android:indeterminate="false" android:indeterminateOnly="false" />
-
- </RelativeLayout>
-
-</RelativeLayout>
\ No newline at end of file
<string name="actionbar_upload_from_apps">محتويات من تطبيقات أخرى</string>
<string name="actionbar_upload_files">الملفات</string>
<string name="actionbar_open_with">فتح باستخدام</string>
- <string name="actionbar_mkdir">إنشاء دليل</string>
+ <string name="actionbar_mkdir">إنشاء مجلد</string>
<string name="actionbar_settings">إعدادات</string>
<string name="actionbar_see_details">تفاصيل</string>
<string name="actionbar_send_file">أرسل</string>
<string name="prefs_category_general">عام</string>
<string name="prefs_category_more">المزيد</string>
<string name="prefs_accounts">حسابات</string>
- <string name="prefs_manage_accounts">ادارة الحسابات</string>
- <string name="prefs_pincode">كلمه السر للتطبيق</string>
- <string name="prefs_pincode_summary">حمايه العميل</string>
+ <string name="prefs_manage_accounts">Ø¥دارة الحسابات</string>
+ <string name="prefs_pincode">كلمة سر التطبيق</string>
+ <string name="prefs_pincode_summary">حماية العميل</string>
<string name="prefs_instant_upload">تفعيل الرفع الفوري</string>
- <string name="prefs_instant_upload_summary">رفع الصور الماخوذة عن طريق الكاميرا تلقائياً</string>
+ <string name="prefs_instant_upload_summary">رفع الصور فور التقاطها بالكاميرا </string>
<string name="prefs_log_title">تفعيل الدخول</string>
<string name="prefs_log_summary">يستخدم هذا لتسجيل المشاكل</string>
<string name="prefs_log_title_history">تاريخ الدخول</string>
<string name="auth_host_url">عنوان الخادم https://…</string>
<string name="auth_username">إسم المستخدم</string>
<string name="auth_password">كلمة السر</string>
- <string name="auth_register">جدÙ\8aد Ù\84Ù\80 %1$s ؟</string>
+ <string name="auth_register">جدÙ\8aد Ù\81Ù\8a %1$s ؟</string>
<string name="sync_string_files">الملفات</string>
<string name="setup_btn_connect">اتصال</string>
- <string name="uploader_btn_upload_text">إرÙ\81ع</string>
- <string name="uploader_top_message">اختر مجلد الرفع:</string>
+ <string name="uploader_btn_upload_text">رفع</string>
+ <string name="uploader_top_message">اختر مجلد الرفع :</string>
<string name="uploader_wrn_no_account_title">لم يتم العثور على أي حساب</string>
- <string name="uploader_wrn_no_account_text">لا يوجد جسابات للـ %1$s في جهازك. يرجى إعداد حساب أولاَ.</string>
- <string name="uploader_wrn_no_account_setup_btn_text">إعداد</string>
+ <string name="uploader_wrn_no_account_text">لا توجد حسابات %1$s على جهازك. يرجى تهيئة حساب أولاً.</string>
+ <string name="uploader_wrn_no_account_setup_btn_text">تÙ\87Ù\8aئة</string>
<string name="uploader_wrn_no_account_quit_btn_text">خروج</string>
- <string name="uploader_wrn_no_content_title">Ù\84ا Ù\8aÙ\88جد Ù\85ØØªÙ\88Ù\8aات للرفع</string>
- <string name="uploader_wrn_no_content_text">Ù\84Ù\85 Ù\8aتÙ\85 استÙ\84اÙ\85 Ø£Ù\8a Ù\85ØØªÙ\88Ù\8aات.</string>
- <string name="uploader_error_forbidden_content">%1$s غÙ\8aر Ù\85سÙ\85Ù\88Ø Ù\84Ù\87 باÙ\84Ù\88صÙ\88Ù\84 Ù\84Ù\84Ù\85ØØªÙ\88Ù\89 اÙ\84Ù\85شترك</string>
+ <string name="uploader_wrn_no_content_title">Ù\84ا Ù\8aÙ\88جد Ù\85ØØªÙ\88Ù\89 للرفع</string>
+ <string name="uploader_wrn_no_content_text">Ù\84Ù\85 Ù\8aتÙ\85 استÙ\84اÙ\85 Ø£Ù\8a Ù\85ØØªÙ\88Ù\89. Ù\84ا Ø´Ù\8aØ¡ Ù\84Ù\84رÙ\81ع.</string>
+ <string name="uploader_error_forbidden_content">%1$s غÙ\8aر Ù\85سÙ\85Ù\88Ø Ù\84Ù\87 باÙ\84Ù\88صÙ\88Ù\84 Ù\84Ù\84Ù\85ØØªÙ\88Ù\89 اÙ\84Ù\85شارك</string>
<string name="uploader_info_uploading">يتم الرفع</string>
- <string name="file_list_empty">لا يوجد ملفات في هذا المجلد.\nيمكن انشاء ملف جديد عن طريق خيارات قائمة \"رفع\". </string>
+ <string name="file_list_empty">لا توجد ملفات في هذا المجلد.\nيمكن إنشاء ملف جديد باختيار \"رفع\" القائمة.</string>
<string name="filedetails_select_file">اضغظ على الملف ليتم عرض خيارات أكثر</string>
- <string name="filedetails_size">الحجم:</string>
- <string name="filedetails_type">النوع:</string>
- <string name="filedetails_created">انشئ:</string>
- <string name="filedetails_modified">عُدل:</string>
- <string name="filedetails_download">اÙ\86زال</string>
- <string name="filedetails_sync_file">تحديث ملف</string>
+ <string name="filedetails_size">الحجم :</string>
+ <string name="filedetails_type">النوع :</string>
+ <string name="filedetails_created">انشئ في :</string>
+ <string name="filedetails_modified">عُدل في :</string>
+ <string name="filedetails_download">تØÙ\85Ù\8aل</string>
+ <string name="filedetails_sync_file">تحديث الملف</string>
<string name="filedetails_renamed_in_upload_msg">تم تغيير اسم الملف إلى %1$s أثناء الرفع</string>
<string name="action_share_file">شارك الرابط</string>
<string name="action_unshare_file">الغاء مشاركة الرابط</string>
<string name="common_yes">نعم</string>
<string name="common_no">لا</string>
<string name="common_ok">تم</string>
- <string name="common_cancel_download">إلغاء تحميل</string>
- <string name="common_cancel_upload">Ø¥Ù\84غاء رÙ\81ع اÙ\84Ù\85Ù\84Ù\81ات</string>
- <string name="common_cancel">الغاء</string>
- <string name="common_save_exit">اØÙ\81ظ & خروج</string>
+ <string name="common_cancel_download">Ø¥Ù\84غاء اÙ\84تØÙ\85Ù\8aÙ\84</string>
+ <string name="common_cancel_upload">Ø¥Ù\84غاء اÙ\84رÙ\81ع</string>
+ <string name="common_cancel">Ø¥لغاء</string>
+ <string name="common_save_exit">ØÙ\81ظ + خروج</string>
<string name="common_error">خطأ</string>
<string name="common_loading">تحميل ...</string>
- <string name="common_error_unknown">ØØ¯Ø« خطأ غÙ\8aر Ù\85عرÙ\88Ù\81. </string>
+ <string name="common_error_unknown">خطأ غير معروف. </string>
<string name="about_title">حول</string>
<string name="change_password">عدل كلمة السر</string>
<string name="delete_account">حذف الحساب</string>
<string name="create_account">حساب جديد</string>
- <string name="upload_chooser_title">رÙ\81ع Ù\85Ù\86</string>
+ <string name="upload_chooser_title">اÙ\84رÙ\81ع Ù\85Ù\86 ...</string>
<string name="uploader_info_dirname">اسم المجلد</string>
<string name="uploader_upload_in_progress_ticker">يتم الرفع ...</string>
<string name="uploader_upload_in_progress_content">%1$d%% رفع %2$s</string>
<string name="uploader_upload_succeeded_ticker">تم الرفع بنجاح</string>
<string name="uploader_upload_succeeded_content_single">تم رفع %1$s بنجاح </string>
- <string name="uploader_upload_failed_ticker">عملية الرفع فشلت</string>
- <string name="uploader_upload_failed_content_single">رفع %1$s قد لا يكون كاملاً</string>
- <string name="downloader_download_in_progress_ticker">يتم التحميل</string>
- <string name="downloader_download_in_progress_content">%1$d%% تنزيل %2$s</string>
+ <string name="uploader_upload_failed_ticker">فشل الرفع</string>
+ <string name="uploader_upload_failed_content_single">لم يكتمل رفع %1$s </string>
+ <string name="downloader_download_in_progress_ticker">يتم التحميل ...</string>
+ <string name="downloader_download_in_progress_content">%1$d%% تحميل %2$s</string>
<string name="downloader_download_succeeded_ticker">تم التحميل بنجاح</string>
<string name="downloader_download_succeeded_content">تم تحميل %1$s بنجاح </string>
<string name="downloader_download_failed_ticker">فشل التحميل</string>
- <string name="downloader_download_failed_content"> تحميل %1$s قد لا يكون كاملاَ</string>
+ <string name="downloader_download_failed_content"> لم يكتمل تحميل %1$s</string>
<string name="downloader_not_downloaded_yet">لم يتم تحميلها بعد</string>
- <string name="common_choose_account">اختر حساب</string>
- <string name="sync_fail_ticker">فشل في المزامنة</string>
- <string name="sync_fail_content">تعذر إكمال التزامن لـ %1$s </string>
+ <string name="common_choose_account">اختر حسابا</string>
+ <string name="sync_fail_ticker">فشلت المزامنة.</string>
+ <string name="sync_fail_content">لم تكتمل مزامنة %1$s </string>
<string name="sync_fail_content_unauthorized">كلمة السر غير صالحة لـ %1$s</string>
- <string name="sync_conflicts_in_favourites_ticker">يوجد تعارض</string>
- <string name="sync_fail_in_favourites_content"> جهات الاتصال لـ %1$d لا يمكن مزامنتها ( %2$d تعارض) </string>
+ <string name="sync_conflicts_in_favourites_ticker">هناك تعارض</string>
+ <string name="sync_conflicts_in_favourites_content">لم تنجح المزامنة الدائمة لـ %1$d ملفات</string>
+ <string name="sync_fail_in_favourites_ticker">لم تنجح المزامنة التلقائية للملفات</string>
+ <string name="sync_fail_in_favourites_content"> لا يمكن مزامنة جهات اتصال %1$d ( %2$d تعارض) </string>
+ <string name="sync_foreign_files_forgotten_ticker">تم نسيان بعض الملفات المحلية</string>
+ <string name="sync_foreign_files_forgotten_content">لم ينجح نقل %1$d ملفات إلى المجلد %2$s</string>
+ <string name="sync_foreign_files_forgotten_explanation">اعتبارا من اﻹصدار 1.3.16, الملفات المرفوعة من هذا الجهاز يتم نسخها إلى المجلد المحلي %1$s تفاديا لفقدان البيانات حينما تتم مزامنة ملف واحد مع عدة حسابات.\n\nنظرا لهذا التغيير، تم نسخ كل الملفات المرفوعة في اﻹصدارات السابقة إلى المجلد %2$s. لكن خطأً ما حال دون إتمام العملية أثناء مزامنة الحسابات. يمكنك إما ترك هذه الملفات و حذف الرابط إلى %3$s، و إما نقل الملفات إلى المجلد %1$s و الاحتفاظ بالرابط إلى %4$s \n\nفيما يلي الملفات المحلية، و المفات الخارجية المرتبطة بها في %5$s</string>
<string name="sync_current_folder_was_removed">لا يوجد مجلد %1$s بعد الان</string>
<string name="foreign_files_move">نقل الكل</string>
<string name="foreign_files_success">تم نقل جميع الملفات</string>
- <string name="foreign_files_fail">بعض الملفات لا يمكن نقلها</string>
- <string name="foreign_files_local_text">محلي:%1$s</string>
- <string name="upload_query_move_foreign_files">لا يوجد مساحة كافية لنسخ الملفات المحددة لمجلد %1$s . هل ترغب بنقلهم للمجلد بدلاَ من ذلك؟</string>
- <string name="pincode_enter_pin_code">فضلا, ادخل كلمة السر</string>
- <string name="pincode_configure_your_pin">فضلا, ادخل كلمة السر</string>
+ <string name="foreign_files_fail">لم ينجح نقل بعض الملفات</string>
+ <string name="foreign_files_local_text">محلي :%1$s</string>
+ <string name="foreign_files_remote_text">خارجي : %1$s</string>
+ <string name="upload_query_move_foreign_files">لا يوجد مساحة كافية لنسخ الملفات المحددة إلى مجلد %1$s . هل ترغب بنقلها بدلاَ من ذلك؟</string>
+ <string name="pincode_enter_pin_code">يرجى إدخال كلمة السر</string>
+ <string name="pincode_configure_your_pin">أدخل كلمة السر</string>
<string name="pincode_configure_your_pin_explanation">سيتم طلب PIN في كل مرة يتم فيها تشغيل التطبيق</string>
- <string name="pincode_reenter_your_pincode">Ù\81ضÙ\84ا, ادخÙ\84 Ù\83Ù\84Ù\85Ø© اÙ\84سر Ù\85رÙ\87 اخرÙ\8a</string>
- <string name="pincode_remove_your_pincode">ازاÙ\84Ù\87 كلمة السر</string>
- <string name="pincode_mismatch">Ù\83Ù\84Ù\85ات اÙ\84سر غÙ\8aر Ù\85تطابÙ\82Ù\87</string>
- <string name="pincode_wrong">كلمه السر غير صحيحه</string>
- <string name="pincode_removed">تم ازاله كلمه السر</string>
- <string name="pincode_stored">تم تسجيل كلمه السر</string>
- <string name="media_notif_ticker">%1$s مشغل الموسيقى</string>
- <string name="media_state_playing">%1$s (عرض)</string>
- <string name="media_state_loading">%1$s (تحميل)</string>
- <string name="media_event_done">تÙ\85 اÙ\84اÙ\86تÙ\87اء Ù\85Ù\86 تشغيل %1$s </string>
+ <string name="pincode_reenter_your_pincode">Ù\8aرجÙ\89 إدخاÙ\84 Ù\83Ù\84Ù\85Ø© اÙ\84سر Ù\85رة أخرÙ\89</string>
+ <string name="pincode_remove_your_pincode">إزاÙ\84Ø© كلمة السر</string>
+ <string name="pincode_mismatch">Ù\83Ù\84Ù\85تا اÙ\84سر غÙ\8aر Ù\85تطابÙ\82تÙ\8aÙ\86</string>
+ <string name="pincode_wrong">كلمه السر غير صحيحة</string>
+ <string name="pincode_removed">تمت إزالة كلمه السر</string>
+ <string name="pincode_stored">تم تسجيل كلمت السر</string>
+ <string name="media_notif_ticker">مشغل الموسيقى %1$s </string>
+ <string name="media_state_playing">%1$s (يتم التشغيل)</string>
+ <string name="media_state_loading">%1$s (يتم التحميل)</string>
+ <string name="media_event_done">اÙ\86تÙ\87Ù\89 تشغيل %1$s </string>
<string name="media_err_nothing_to_play">لا يوجد ملف وسائط</string>
- <string name="media_err_no_account">Ù\84Ù\85 Ù\8aتÙ\85 تÙ\82دÙ\8aÙ\85 اي حساب</string>
- <string name="media_err_not_in_owncloud">الملف ليس في حساب فعال</string>
- <string name="media_err_unsupported">ترÙ\85Ù\8aز غÙ\8aر Ù\85دعÙ\88م</string>
+ <string name="media_err_no_account">Ù\84Ù\85 Ù\8aتÙ\85 تÙ\82دÙ\8aÙ\85 Ø£ي حساب</string>
+ <string name="media_err_not_in_owncloud">الملف ليس في حساب صحيح</string>
+ <string name="media_err_unsupported">ترÙ\85Ù\8aز غÙ\8aر Ù\85دعÙ\91م</string>
<string name="media_err_io">لا يمكن قراءة ملف الوسائط</string>
- <string name="media_err_malformed">لم يتم فك ترميز ملف الوسائط بشكل صحيح</string>
+ <string name="media_err_malformed">الملف غير مرمز بشكل صحيح</string>
<string name="media_err_timeout">انتهت المهلة أثناء محاولة العرض</string>
+ <string name="media_err_invalid_progressive_playback">لا يمكن بث ملف الوسائط</string>
<string name="media_err_unknown">لا يمكن عرض ملف الوسائط مع عارض الوسائط المستعمل</string>
<string name="media_err_security_ex">خطا امني اثناء محاولة عرض %1$s</string>
<string name="media_err_io_ex">خطا في المدخلات اثناء محاولة عرض %1$s</string>
<string name="media_err_unexpected">خطا غير متوقع اثناء محاولة عرض %1$s</string>
+ <string name="media_rewind_description">زر الترجيع</string>
+ <string name="media_play_pause_description">زر التشغيل أو الإيقاف</string>
+ <string name="media_forward_description">زر التقدم للأمام</string>
<string name="auth_trying_to_login">محاولة الدخول ...</string>
<string name="auth_no_net_conn_title">لا يتوفر اتصال</string>
<string name="auth_nossl_plain_ok_title">الاتصال الآمن غير متاح</string>
- <string name="auth_connection_established">يتم إنشاء الاتصال</string>
+ <string name="auth_connection_established">تم الاتصال</string>
<string name="auth_testing_connection">اختبار الاتصال ...</string>
- <string name="auth_not_configured_title">اعدادات اÙ\84خاد تاÙ\84Ù\81Ø© </string>
+ <string name="auth_not_configured_title">إعداد اÙ\84خادÙ\85 غÙ\8aر صØÙ\8aØØ©</string>
<string name="auth_account_not_new">الحساب لنفس المستخدم والخادم موجود مسبقا على الجهاز </string>
<string name="auth_account_not_the_same">المستخدم المدخل لا يتوافق مع المستخدم الموجود في الحساب </string>
- <string name="auth_unknown_error_title">حدث خطأ غير معروف!</string>
+ <string name="auth_unknown_error_title">حدث خطأ غير معروف !</string>
<string name="auth_unknown_host_title">فشل في العثور على المضيف</string>
- <string name="auth_incorrect_path_title">تعذر إيجاد جهة الاتصال للسيرفر.</string>
- <string name="auth_timeout_title">الخادم اخذ الكثير من الوقت للرد</string>
- <string name="auth_incorrect_address_title">رابط تالف</string>
- <string name="auth_ssl_general_error_title">فشل في انشاء SSL</string>
- <string name="auth_bad_oc_version_title">لم يتم التعرف على اصدار الخادم</string>
- <string name="auth_wrong_connection_title">لا يمكن إنشاء اتصال</string>
- <string name="auth_secure_connection">تم إنشاء اتصال آمن</string>
- <string name="auth_unauthorized">خطا في الاسم او كلمة المرور</string>
+ <string name="auth_incorrect_path_title">لم يتم إيجاد الخادم</string>
+ <string name="auth_timeout_title">الخادم أخذ كثيرا من الوقت للرد</string>
+ <string name="auth_incorrect_address_title">رابط غير سليم</string>
+ <string name="auth_ssl_general_error_title">فشل في تهيئة SSL</string>
+ <string name="auth_ssl_unverified_server_title">لا يمكن التحقق من هوية خادم SSL</string>
+ <string name="auth_bad_oc_version_title">إصدار الخادم غير معروف</string>
+ <string name="auth_wrong_connection_title">لم ينجح الاتصال</string>
+ <string name="auth_secure_connection">نجح الاتصال آمن</string>
+ <string name="auth_unauthorized">اسم المستخدم أو كلمة المرور خاطئة</string>
<string name="auth_oauth_error">فشل في التحقق</string>
<string name="auth_oauth_error_access_denied">تم رفض الوصول من قبل الخادم المرخص</string>
<string name="auth_wtf_reenter_URL">حالة غير متوقعة: الرجاء, ادخال عنوان الخادم مرة اخرى</string>
<string name="auth_connecting_auth_server">يتم الاتصال بالخادم للتحقق</string>
<string name="auth_unsupported_auth_method">الخادم لا يدعم طريقة التحقق هذه</string>
<string name="auth_unsupported_multiaccount">%1$s لا يدعم الحسابات المتعددة </string>
- <string name="fd_keep_in_sync">اجعل الملف محدث</string>
- <string name="common_rename">إعادة تسميه</string>
- <string name="common_remove">الغى</string>
+ <string name="auth_fail_get_user_name">الخادم لا يجيب بمعرف صحيح للمستخدم، الرجاء الاتصال بالمدير</string>
+ <string name="fd_keep_in_sync"> جعل الملف محدثا</string>
+ <string name="common_rename">إعادة التسمية</string>
+ <string name="common_remove">حذف</string>
<string name="confirmation_remove_alert">هل تود حقاَ إزالة %1$s ؟ </string>
- <string name="confirmation_remove_folder_alert">هل ترغب في إزالة %1$s و جهات الاتصال التابعة له؟ </string>
- <string name="confirmation_remove_local">محلي فقط</string>
+ <string name="confirmation_remove_folder_alert">هل ترغب حقا في إزالة %1$s و محتوياته ؟</string>
+ <string name="confirmation_remove_local">محليا فقط</string>
<string name="confirmation_remove_folder_local">المحتويات المحلية فقط</string>
- <string name="confirmation_remove_remote">حذف من الخادم</string>
- <string name="confirmation_remove_remote_and_local">شبكي و محلي</string>
- <string name="remove_success_msg">يتم الحذف بنجاح</string>
- <string name="remove_fail_msg">Ù\84Ù\82د Ù\81Ø´Ù\84 اÙ\84ØØ°Ù\81</string>
+ <string name="confirmation_remove_remote">اÙ\84ØØ°Ù\81 Ù\85Ù\86 اÙ\84خادÙ\85</string>
+ <string name="confirmation_remove_remote_and_local">محليا و عن بعد</string>
+ <string name="remove_success_msg">تم الحذف بنجاح</string>
+ <string name="remove_fail_msg">فشل الحذف</string>
<string name="rename_dialog_title">أدخل اسما جديدا</string>
- <string name="rename_local_fail_msg">لايمكن اعادة تسمية النسخ المحلي ,حاول باسم آخر </string>
- <string name="rename_server_fail_msg">اعادة التسمية لم تكتمل</string>
- <string name="sync_file_nothing_to_do_msg">محتويات الملفات متزامنة سابقا</string>
- <string name="create_dir_fail_msg">لم يتمكن من انشاء المجلد</string>
+ <string name="rename_local_fail_msg">لم تنجح إعادة تسمية النسخة المحلية، جرب اسما آخر</string>
+ <string name="rename_server_fail_msg">لم تكتمل إعادة التسمية</string>
+ <string name="sync_file_fail_msg">لا يمكن التحقق من الملف الخارجي</string>
+ <string name="sync_file_nothing_to_do_msg">تمت مزامنة محتويات الملفات من قبل</string>
+ <string name="create_dir_fail_msg">لم ينجح إنشاء المجلد</string>
<string name="filename_forbidden_characters">رموز ممنوعة: / \\ < > : \" | ? *</string>
- <string name="wait_a_moment">فضلاً, انتظر</string>
- <string name="filedisplay_unexpected_bad_get_content">خطا غÙ\8aر Ù\85تÙ\88Ù\82ع : اÙ\84رجاء اختÙ\8aار اÙ\84Ù\85Ù\84Ù\81 Ù\85Ù\86 برÙ\86اÙ\85ج آخر</string>
+ <string name="wait_a_moment">انتظر للحظة</string>
+ <string name="filedisplay_unexpected_bad_get_content">خطا غÙ\8aر Ù\85تÙ\88Ù\82ع : اÙ\84رجاء اختÙ\8aار اÙ\84Ù\85Ù\84Ù\81 Ù\85Ù\86 تطبÙ\8aÙ\82 آخر</string>
<string name="filedisplay_no_file_selected">لم يتم اختيار أي ملف</string>
<string name="activity_chooser_title">ارسل الرابط الى ...</string>
<string name="oauth_check_onoff">تسجيل الدخول باستخدام oAuth2</string>
<string name="oauth_login_connection">الاتصال مع خادم oAuth2</string>
- <string name="ssl_validator_header">تعذر التحقق من هوية الموقع</string>
+ <string name="ssl_validator_header">لا يمكن التحقق من هوية الموقع</string>
<string name="ssl_validator_reason_cert_not_trusted">شهادة الخادم غير موثوقة</string>
- <string name="ssl_validator_reason_cert_expired">شهادة الخادم منتهية</string>
- <string name="ssl_validator_reason_cert_not_yet_valid">تاريخ صلاحية شهادة الخادم في المستقبل</string>
- <string name="ssl_validator_reason_hostname_not_verified">هذه الوصله غير متطابقه مع السيرفر فى شهاده الحمايه </string>
- <string name="ssl_validator_question">Ù\87Ù\84 ترÙ\8aد ان تثق في هذه الشهادة على اي حال ؟</string>
- <string name="ssl_validator_not_saved">لم يتمكن من حفظ الشهادة </string>
+ <string name="ssl_validator_reason_cert_expired">شهادة الخادم منتهية الصلاحية</string>
+ <string name="ssl_validator_reason_cert_not_yet_valid">وقت صلاحية شهادة الخادم لم يحن بعد</string>
+ <string name="ssl_validator_reason_hostname_not_verified">الرابط لا يوافق اسم المضيف فى شهاده الحماية </string>
+ <string name="ssl_validator_question">Ù\87Ù\84 ترÙ\8aد Ø£ن تثق في هذه الشهادة على اي حال ؟</string>
+ <string name="ssl_validator_not_saved">لم ينجح حفظ الشهادة </string>
<string name="ssl_validator_btn_details_see">تفاصيل</string>
<string name="ssl_validator_btn_details_hide">إخفاء</string>
- <string name="ssl_validator_label_subject">أصدرت ل:</string>
- <string name="ssl_validator_label_CN">الاسم الشائع:</string>
- <string name="ssl_validator_label_O">منظمة:</string>
- <string name="ssl_validator_label_OU">الوحدة التنظيمية:</string>
- <string name="ssl_validator_label_C">البلد:</string>
- <string name="ssl_validator_label_ST">حالة:</string>
- <string name="ssl_validator_label_L">المكان:</string>
- <string name="ssl_validator_label_validity_from">من:</string>
- <string name="ssl_validator_label_validity_to">إلى:</string>
- <string name="ssl_validator_label_signature">التوقيع:</string>
- <string name="ssl_validator_label_signature_algorithm">الخوارزمية:</string>
+ <string name="ssl_validator_label_subject">أصدرت لـ :</string>
+ <string name="ssl_validator_label_issuer">أصدرت بواسطة</string>
+ <string name="ssl_validator_label_CN">الاسم الشائع :</string>
+ <string name="ssl_validator_label_O">منظمة :</string>
+ <string name="ssl_validator_label_OU">الوحدة التنظيمية :</string>
+ <string name="ssl_validator_label_C">البلد :</string>
+ <string name="ssl_validator_label_ST">الحالة :</string>
+ <string name="ssl_validator_label_L">المكان :</string>
+ <string name="ssl_validator_label_validity">الصلاحية :</string>
+ <string name="ssl_validator_label_validity_from">من :</string>
+ <string name="ssl_validator_label_validity_to">إلى :</string>
+ <string name="ssl_validator_label_signature">التوقيع :</string>
+ <string name="ssl_validator_label_signature_algorithm">الخوارزمية :</string>
+ <string name="ssl_validator_null_cert">لا يمكن إظهار الشهادة</string>
+ <string name="ssl_validator_no_info_about_error">- لا معلومات عن الخطأ.</string>
+ <string name="placeholder_sentence">هذه مساحة محجوزة</string>
+ <string name="placeholder_filename">placeholder.txt</string>
<string name="placeholder_filetype">صورة PNG</string>
<string name="placeholder_filesize">389 KB</string>
+ <string name="placeholder_timestamp">2012/05/18 12:23 مساء</string>
<string name="placeholder_media_time">12:23:45</string>
- <string name="instant_upload_on_wifi">رفع الصور من خلال الواي فاي فقط</string>
+ <string name="instant_upload_on_wifi">رفع الصور من خلال الـ WiFi فقط</string>
+ <string name="instant_upload_path">/InstantUpload</string>
<string name="conflict_title">تعارض في التحديث </string>
+ <string name="conflict_message">الملف %s غير </string>
+ <string name="conflict_keep_both">الاحتفاظ بالنسختين</string>
+ <string name="conflict_overwrite">استبدال</string>
<string name="conflict_dont_upload">عدم الرفع</string>
<string name="preview_image_description">معاينة الصورة</string>
<string name="preview_image_error_unknown_format">هذه الصورة لا يمكن أن تظهر</string>
- <string name="error__upload__local_file_not_copied">%1$s لم يتمكن من النسخ الى %2$s في المجلد المحلي</string>
+ <string name="error__upload__local_file_not_copied">لم ينجح نسخ %1$s إلى المجلد المحلي %2$s </string>
<string name="actionbar_failed_instant_upload">فشل في محاولة الرفع الفوري</string>
<string name="failed_upload_headline_text">فشل في الرفع الفوري</string>
<string name="failed_upload_headline_hint">ملخص لكل الاخطاء في عملية الرفع الفوري</string>
<string name="failed_upload_headline_delete_all_btn">حذف كل المختارات من قائمة انتظار الرفع</string>
<string name="failed_upload_retry_text">اعادة المحاولة لرفع الصورة:</string>
<string name="failed_upload_load_more_images">تحميل المزيد من الصور</string>
+ <string name="failed_upload_retry_do_nothing_text">do nothing you are not online for instant upload</string>
<string name="failed_upload_failure_text">رسالة خطا:</string>
<string name="failed_upload_quota_exceeded_text">الرجاء التاكد من اعدادات الخادم, من الممكن انك تعديت الحد في quota</string>
<string name="share_link_no_support_share_api">عذرا , المشاركة غير مفعلة في الخادم. الرجاء التواصل مع المدير</string>
<string name="unshare_link_file_no_exist">غير قادر على إلغاء مشاركة هذا الملف أو المجلد.لا وجود له</string>
<string name="unshare_link_file_error">حدث خطأ ما أثناء محاولة إلغاء مشاركة هذا الملف أو المجلد</string>
<string name="activity_chooser_send_file_title">أرسل</string>
+ <string name="copy_link">نسخ الرابط</string>
+ <string name="clipboard_text_copied">تم النسخ للحافظة</string>
</resources>
<string name="auth_connecting_auth_server">S\'està connectant a un servidor d\'autenticació...</string>
<string name="auth_unsupported_auth_method">El serivdor no permet aquest mètode d\'autenticació</string>
<string name="auth_unsupported_multiaccount">%1$s no permet comptes múltiples</string>
+ <string name="auth_fail_get_user_name">El servidor no retorna una id d\'usuari correcta, contacteu amb l\'administrador.</string>
<string name="fd_keep_in_sync">Mantén el fitxer actualitzat</string>
<string name="common_rename">Reanomena</string>
<string name="common_remove">Elimina</string>
<string name="ssl_validator_label_validity_to">A:</string>
<string name="ssl_validator_label_signature">Signatura:</string>
<string name="ssl_validator_label_signature_algorithm">Algoritme:</string>
+ <string name="ssl_validator_null_cert">No s\'ha pogut mostrar el certificat.</string>
+ <string name="ssl_validator_no_info_about_error">- No hi ha informació de l\'error</string>
<string name="placeholder_sentence">Això és un text variable</string>
<string name="placeholder_filename">placeholder.txt</string>
<string name="placeholder_filetype">Imatge PNG</string>
<string name="sync_fail_in_favourites_content">Obsah %1$d souborů nemohl být synchronizován (počet konfliktů: %2$d)</string>
<string name="sync_foreign_files_forgotten_ticker">Některé místní soubory byly zapomenuty</string>
<string name="sync_foreign_files_forgotten_content">%1$d souborů z adresáře %2$s nelze zkopírovat do</string>
- <string name="sync_foreign_files_forgotten_explanation">Od verze 1.3.16 jsou soubory nahrané z tohoto zařízení kopírovány do místní %1$s složky, aby se zabránilo ztrátě dat při synchronizaci jednoho souboru s více účty.\n\nVšechny soubory nahrané předchozími verzemi aplikace byly z tohoto důvodu překopírovány do složky %2$s. Přesto se objevila chyba zabraňující dokončení této operace v průběhu synchronizace účtu. Buď můžete soubor(y) ponechat jak jsou a odebrat odkaz do složky %3$s nebo přesunout soubor(y) do složky %1$s a zachovat odkaz na %4$s.\n\nNíže je seznam místních a vzdálených souborů ve složce %5$s, do které byly odkázány.</string>
+ <string name="sync_foreign_files_forgotten_explanation">Od verze 1.3.16 jsou soubory nahrané z tohoto zařízení kopírovány do místní %1$s složky, aby se zabránilo ztrátě dat při synchronizaci jednoho souboru s více účty.\n\nVšechny soubory nahrané předchozími verzemi aplikace byly z tohoto důvodu překopírovány do složky %2$s. Bohužel se objevila chyba zabraňující dokončení této operace v průběhu synchronizace účtu. Buď můžete soubor(y) ponechat jak jsou a odebrat odkaz do složky %3$s nebo přesunout soubor(y) do složky %1$s a zachovat odkaz na %4$s.\n\nNíže je seznam místních a vzdálených souborů ve složce %5$s, do které byly odkázány.</string>
<string name="sync_current_folder_was_removed">Složka %1$s již neexistuje</string>
<string name="foreign_files_move">Přesunout vše</string>
<string name="foreign_files_success">Všechny soubory byly přesunuty</string>
<string name="auth_connecting_auth_server">Připojuji se k přihlašovacímu serveru...</string>
<string name="auth_unsupported_auth_method">Server nepodporuje tuto přihlašovací metodu</string>
<string name="auth_unsupported_multiaccount">%1$s nepodporuje více účtů</string>
+ <string name="auth_fail_get_user_name">Váš server nevrací správné přihlašovací ID, kontaktujte vašeho administrátora</string>
<string name="fd_keep_in_sync">Udržovat soubor aktuální</string>
<string name="common_rename">Přejmenovat</string>
<string name="common_remove">Odstranit</string>
<string name="ssl_validator_label_validity_to">Pro:</string>
<string name="ssl_validator_label_signature">Podpis:</string>
<string name="ssl_validator_label_signature_algorithm">Alogritmus:</string>
+ <string name="ssl_validator_null_cert">Certifikát nemohl být zobrazen.</string>
+ <string name="ssl_validator_no_info_about_error">- Žádné informace o této chybě</string>
<string name="placeholder_sentence">Zástupný text</string>
<string name="placeholder_filename">placeholder.txt</string>
<string name="placeholder_filetype">Obrázek PNG</string>
<string name="sync_fail_in_favourites_content">Indholdet af %1$d filer ikke kunne synkroniseres (%2$d konflikter)</string>
<string name="sync_foreign_files_forgotten_ticker">Visse lokale filer blev glemt</string>
<string name="sync_foreign_files_forgotten_content">%1$d filer ud af %2$s mappe kunne ikke kopieres ind i</string>
+ <string name="sync_foreign_files_forgotten_explanation">Fra version 1.3.16 bliver filer uploadet fra denne enhed kopieret til mappen %1$s for at forhindre datatab når en enkelt fil synkroniseres med flere konti.\n\nPå grund af denne ændring er alle filer som var uploadet i tidligere versioner af denne app kopieret til mappen %2$s. Imidlertid forhindrede en fejl færdiggørelsen af denne operation under konto-synkronisering. Du kan enten lade filerne være som de er og fjerne linket til %3$s eller flytte filerne til mappen %1$s og beholde linket til %4$s.\n\nHerunder er en liste med de lokale og eksterne filer i %5$s, som de var knyttet til.</string>
<string name="sync_current_folder_was_removed">Mappen %1$s eksistere ikke længere</string>
<string name="foreign_files_move">Flyt alle</string>
<string name="foreign_files_success">Alle filer blev flyttet</string>
<string name="auth_connecting_auth_server">Forbinder til godkendelsesserver ...</string>
<string name="auth_unsupported_auth_method">Serveren understøtter ikke denne godkendelsesmetode</string>
<string name="auth_unsupported_multiaccount">%1$s understøtter ikke multiple konti</string>
+ <string name="auth_fail_get_user_name">Din server retunere ikke et korrekt bruger-id. Kontakt venligst din administrator</string>
<string name="fd_keep_in_sync">Hold fil opdateret</string>
<string name="common_rename">Omdøb</string>
<string name="common_remove">Fjern</string>
<string name="ssl_validator_label_validity_to">Til:</string>
<string name="ssl_validator_label_signature">Signatur:</string>
<string name="ssl_validator_label_signature_algorithm">Algoritme:</string>
+ <string name="ssl_validator_null_cert">Certifikatet kunne ikke vises.</string>
+ <string name="ssl_validator_no_info_about_error">- Ingen information om fejlen</string>
<string name="placeholder_sentence">Dette er en pladsholder</string>
<string name="placeholder_filename">stedfortræder.txt</string>
<string name="placeholder_filetype">PNG Billede</string>
<string name="share_link_no_support_share_api">Beklager, deling er ikke slået til på din server. Kontakt venligst din administrator.</string>
<string name="share_link_file_no_exist">Kan ikke dele denne fil eller mappe. Find venligst ud af om den eksisterer</string>
<string name="share_link_file_error">Der opstod en fejl ved deling af denne fil eller mappe</string>
+ <string name="unshare_link_file_no_exist">Kan ikke fjerne delingen af denne fil eller mappe. Den findes ikke.</string>
<string name="unshare_link_file_error">Der opstod en fejl ved stopning af deling af denne mappe.</string>
<string name="activity_chooser_send_file_title">Send</string>
<string name="copy_link">Kopier link</string>
<item name="android:textColor">@color/button_text_color</item>
</style>
+ <!-- Notifications -->
+ <!-- Notifications -->
+ <style name="Theme.ownCloud.NotificationText.Title"
+ parent="@android:style/TextAppearance.StatusBar.EventContent.Title" >
+ <item name="android:textSize">18sp</item>
+ <item name="android:textStyle">bold</item>
+ </style>
+
+ <style name="Theme.ownCloud.NotificationText.Content"
+ parent="@android:style/TextAppearance.StatusBar.EventContent" >
+ <item name="android:textSize">16sp</item>
+ </style>
+
</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!-- Notifications -->
+ <style name="Theme.ownCloud.NotificationText.Title"
+ parent="@android:style/TextAppearance.StatusBar.EventContent.Title"
+ />
+ <style name="Theme.ownCloud.NotificationText.Content"
+ parent="@android:style/TextAppearance.StatusBar.EventContent"
+ />
+
+</resources>
<string name="auth_unsupported_auth_method">The server does not support this authentication method</string>
<string name="auth_unsupported_multiaccount">%1$s does not support multiple accounts</string>
<string name="auth_fail_get_user_name">Your server is not returning a correct user id, please contact an administrator</string>
+ <string name="auth_can_not_auth_against_server">Can not authenticate against this server</string>
<string name="fd_keep_in_sync">Keep file up to date</string>
<string name="common_rename">Rename</string>
<string name="copy_link">Copy link</string>
<string name="clipboard_text_copied">Copied to clipboard</string>
+
</resources>
<item name="android:indeterminateDrawable">@drawable/abs__progress_medium_holo</item>
</style>
+ <!-- Notifications -->
+ <style name="Theme.ownCloud.NotificationText.Title"
+ parent="@android:style/TextAppearance">
+ <item name="android:textColor">#ff000000</item>
+ <item name="android:textSize">18sp</item>
+ <item name="android:textStyle">bold</item>
+ </style>
+ <style name="Theme.ownCloud.NotificationText.Content"
+ parent="@android:style/TextAppearance">
+ <item name="android:textColor">#ff000000</item>
+ <item name="android:textSize">14sp</item>
+ </style>
</resources>
android:title="@string/prefs_select_oc_account"
android:summary="@string/prefs_summary_select_oc_account"
/ -->
- <Preference android:title="@string/prefs_manage_accounts" android:key="manage_account" />
- <CheckBoxPreference android:title="@string/prefs_pincode" android:key="set_pincode"
+ <com.owncloud.android.ui.PreferenceMultiline android:title="@string/prefs_manage_accounts" android:key="manage_account" />
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:title="@string/prefs_pincode" android:key="set_pincode"
android:summary="@string/prefs_pincode_summary"/>
- <CheckBoxPreference android:key="instant_uploading"
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading"
android:title="@string/prefs_instant_upload"
android:summary="@string/prefs_instant_upload_summary"/>
- <CheckBoxPreference android:dependency="instant_uploading"
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:dependency="instant_uploading"
android:disableDependentsState="true"
android:title="@string/instant_upload_on_wifi"
android:key="instant_upload_on_wifi"/>
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;\r
import com.owncloud.android.lib.common.OwnCloudClientFactory;\r
import com.owncloud.android.lib.common.OwnCloudClient;\r
+import com.owncloud.android.operations.DetectAuthenticationMethodOperation;\r
+import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod;\r
import com.owncloud.android.operations.OAuth2GetAccessToken;\r
import com.owncloud.android.lib.common.network.CertificateCombinedException;\r
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;\r
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;\r
import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;\r
-
+\r
import com.owncloud.android.ui.dialog.SamlWebViewDialog;\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;\r
* @author David A. Velasco\r
*/\r
public class AuthenticatorActivity extends AccountAuthenticatorActivity\r
- implements OnRemoteOperationListener, OnFocusChangeListener, OnEditorActionListener, \r
- SsoWebViewClientListener, OnSslUntrustedCertListener {\r
+implements OnRemoteOperationListener, OnFocusChangeListener, OnEditorActionListener, \r
+SsoWebViewClientListener, OnSslUntrustedCertListener {\r
\r
private static final String TAG = AuthenticatorActivity.class.getSimpleName();\r
\r
private static final String AUTH_ON = "on";\r
private static final String AUTH_OFF = "off";\r
private static final String AUTH_OPTIONAL = "optional";\r
- \r
+\r
private static final int DIALOG_LOGIN_PROGRESS = 0;\r
private static final int DIALOG_CERT_NOT_SAVED = 1;\r
private static final int DIALOG_OAUTH2_LOGIN_PROGRESS = 2;\r
public static final byte ACTION_UPDATE_TOKEN = 1;\r
\r
private static final String TAG_SAML_DIALOG = "samlWebViewDialog";\r
- \r
+\r
private String mHostBaseUrl;\r
private OwnCloudVersion mDiscoveredVersion;\r
\r
private Account mAccount;\r
\r
private TextView mAuthMessage;\r
- \r
+\r
private EditText mHostUrlInput;\r
private boolean mHostUrlInputEnabled;\r
private View mRefreshButton;\r
\r
private String mAuthTokenType;\r
- \r
+\r
private EditText mUsernameInput;\r
private EditText mPasswordInput;\r
- \r
+\r
private CheckBox mOAuth2Check;\r
- \r
+\r
private TextView mOAuthAuthEndpointText;\r
private TextView mOAuthTokenEndpointText;\r
- \r
+\r
private SamlWebViewDialog mSamlDialog;\r
- \r
+\r
private View mOkButton;\r
- \r
+\r
private String mAuthToken;\r
- \r
+\r
private boolean mResumed; // Control if activity is resumed\r
\r
public static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT";\r
\r
+ private DetectAuthenticationMethodOperation mDetectAuthenticationOperation;\r
+\r
\r
/**\r
* {@inheritDoc}\r
mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);\r
mOkButton = findViewById(R.id.buttonOK);\r
mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); \r
- \r
+\r
/// set Host Url Input Enabled\r
mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input);\r
- \r
+\r
/// set visibility of link for new users\r
boolean accountRegisterVisibility = getResources().getBoolean(R.bool.show_welcome_link);\r
Button welcomeLink = (Button) findViewById(R.id.welcome_link);\r
mAccount = null;\r
mHostBaseUrl = "";\r
boolean refreshButtonEnabled = false;\r
- \r
+\r
// URL input configuration applied\r
if (!mHostUrlInputEnabled)\r
{\r
mHostUrlInput.setText(mHostBaseUrl);\r
String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));\r
mUsernameInput.setText(userName);
- \r
+\r
}\r
initAuthorizationMethod(); // checks intent and setup.xml to determine mCurrentAuthorizationMethod\r
mJustCreated = true;\r
- \r
+\r
if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) {\r
checkOcServer(); \r
}\r
- \r
+\r
} else {\r
mResumed = true;\r
/// connection state and info\r
if (savedInstanceState.getBoolean(KEY_PASSWORD_VISIBLE, false)) {\r
showPassword();\r
}\r
- \r
+\r
/// server data\r
String ocVersion = savedInstanceState.getString(KEY_OC_VERSION);\r
String ocVersionString = savedInstanceState.getString(KEY_OC_VERSION_STRING);\r
mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
if (mAuthTokenType == null) {\r
mAuthTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
- \r
+\r
}\r
\r
// check if server check was interrupted by a configuration change\r
if (savedInstanceState.getBoolean(KEY_SERVER_CHECK_IN_PROGRESS, false)) {\r
checkOcServer();\r
} \r
- \r
+\r
// refresh button enabled\r
refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
- \r
+\r
\r
}\r
\r
adaptViewAccordingToAuthenticationMethod();\r
showServerStatus();\r
showAuthStatus();\r
- \r
+\r
if (mAction == ACTION_UPDATE_TOKEN) {\r
/// lock things that should not change\r
mHostUrlInput.setEnabled(false);\r
mUsernameInput.setFocusable(false);\r
mOAuth2Check.setVisibility(View.GONE);\r
}\r
- \r
+\r
//if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton();\r
if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
mResumed = false;\r
}\r
});\r
- \r
+\r
mPasswordInput.setOnFocusChangeListener(this);\r
mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);\r
mPasswordInput.setOnEditorActionListener(this);
return true;\r
}\r
});\r
- \r
+\r
findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() {\r
@Override\r
public boolean onTouch(View view, MotionEvent event) {\r
}\r
});\r
}\r
- \r
- \r
+\r
+\r
\r
private void initAuthorizationMethod() {\r
boolean oAuthRequired = false;\r
\r
mAuthTokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);\r
- \r
+\r
// TODO could be a good moment to validate the received token type, if not null\r
- \r
+\r
if (mAuthTokenType == null) { \r
if (mAccount != null) {\r
/// same authentication method than the one used to create the account to update\r
oAuthRequired = (mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null);\r
samlWebSsoRequired = (mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null);\r
- \r
+\r
} else {\r
/// use the one set in setup.xml\r
oAuthRequired = AUTH_ON.equals(getString(R.string.auth_method_oauth2));\r
mAuthTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
}\r
}\r
- \r
+\r
if (mAccount != null) {\r
String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));\r
mUsernameInput.setText(userName);\r
}\r
- \r
+\r
mOAuth2Check.setChecked(AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType));\r
- \r
+\r
}\r
\r
/**\r
outState.putParcelable(KEY_ACCOUNT, mAccount);\r
}\r
outState.putString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE, mAuthTokenType);\r
- \r
+\r
// refresh button enabled\r
outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));\r
- \r
+\r
\r
}\r
\r
}\r
\r
mJustCreated = false;\r
- \r
+\r
}\r
\r
\r
\r
private void checkOcServer() {\r
String uri = trimUrlWebdav(mHostUrlInput.getText().toString().trim());\r
- \r
+\r
if (!mHostUrlInputEnabled){\r
uri = getString(R.string.server_url);\r
}\r
- \r
+\r
mServerIsValid = false;\r
mServerIsChecked = false;\r
mOkButton.setEnabled(false);\r
private boolean isPasswordVisible() {\r
return ((mPasswordInput.getInputType() & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);\r
}\r
- \r
+\r
private void hidePasswordButton() {\r
mPasswordInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
}\r
mPasswordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);\r
showViewPasswordButton();\r
}\r
- \r
+\r
private void hidePassword() {\r
mPasswordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);\r
showViewPasswordButton();\r
}\r
- \r
- \r
+\r
+\r
/**\r
* Cancels the authenticator activity\r
* \r
mAuthStatusIcon = R.drawable.progress_small;\r
mAuthStatusText = R.string.oauth_login_connection;\r
showAuthStatus();\r
- \r
+\r
\r
// GET AUTHORIZATION request\r
//Uri uri = Uri.parse(getString(R.string.oauth2_url_endpoint_auth));\r
mAuthStatusText = R.string.auth_connecting_auth_server;\r
showAuthStatus();\r
showDialog(DIALOG_LOGIN_PROGRESS);\r
- \r
+\r
/// get the path to the root folder through WebDAV from the version server\r
String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);\r
\r
mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false);\r
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false);\r
mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
- \r
+\r
}\r
\r
/**\r
} else if (operation instanceof ExistenceCheckRemoteOperation) {\r
if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result);\r
- \r
+\r
} else {\r
onAuthorizationCheckFinish((ExistenceCheckRemoteOperation)operation, result);\r
}\r
} else if (operation instanceof GetRemoteUserNameOperation) {\r
onGetUserNameFinish((GetRemoteUserNameOperation) operation, result);\r
- \r
+\r
+ } else if (operation instanceof DetectAuthenticationMethodOperation) {\r
+ onDetectAutheticationFinish((DetectAuthenticationMethodOperation) operation, result);\r
+ }\r
+\r
+ }\r
+\r
+ private void onDetectAutheticationFinish(DetectAuthenticationMethodOperation operation, RemoteOperationResult result) {\r
+ // Read authentication method\r
+ if (result.getData().size() > 0) {\r
+ AuthenticationMethod authMethod = (AuthenticationMethod) result.getData().get(0);\r
+ String basic = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
+ String oAuth = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());\r
+ String saml = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType());\r
+\r
+ if ( ( mAuthTokenType.equals(basic) && !authMethod.equals(AuthenticationMethod.BASIC_HTTP_AUTH) ) ||\r
+ ( mAuthTokenType.equals(oAuth) && !authMethod.equals(AuthenticationMethod.BEARER_TOKEN) ) || \r
+ ( mAuthTokenType.equals(saml) && !authMethod.equals(AuthenticationMethod.SAML_WEB_SSO) ) ) {\r
+\r
+ mOkButton.setEnabled(false);\r
+ mServerIsValid = false;\r
+ //show an alert message ( Server Status )\r
+ updateServerStatusIconNoRegularAuth();\r
+ showServerStatus();\r
+\r
+ } else {\r
+ mOkButton.setEnabled(true);\r
+\r
+ // Show server status\r
+ showServerStatus();\r
+ }\r
+\r
}\r
- \r
}\r
\r
+\r
+\r
private void onGetUserNameFinish(GetRemoteUserNameOperation operation, RemoteOperationResult result) {\r
- \r
+\r
if (result.isSuccess()) {\r
boolean success = false;\r
String username = operation.getUserName();\r
- \r
+\r
if ( mAction == ACTION_CREATE) {\r
mUsernameInput.setText(username);\r
success = createAccount();\r
} else {\r
- \r
+\r
if (!mUsernameInput.getText().toString().equals(username)) {\r
// fail - not a new account, but an existing one; disallow\r
result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME); \r
showAuthStatus();\r
Log_OC.d(TAG, result.getLogMessage());\r
} else {\r
- updateToken();\r
- success = true;\r
+ updateToken();\r
+ success = true;\r
}\r
}\r
- \r
+\r
if (success)\r
finish();\r
} else {\r
showAuthStatus();\r
Log_OC.e(TAG, "Access to user name failed: " + result.getLogMessage());\r
}\r
- \r
+\r
}\r
\r
private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperation operation, RemoteOperationResult result) {\r
} catch (IllegalArgumentException e) {\r
// NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens\r
}\r
-
+
//if (result.isTemporalRedirection() && result.isIdPRedirection()) {\r
if (result.isIdPRedirection()) {
String url = result.getRedirectedLocation();\r
String targetUrl = mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);\r
- \r
+\r
// Show dialog\r
mSamlDialog = SamlWebViewDialog.newInstance(url, targetUrl); \r
mSamlDialog.show(getSupportFragmentManager(), TAG_SAML_DIALOG);\r
- \r
+\r
mAuthStatusIcon = 0;\r
mAuthStatusText = 0;\r
- \r
+\r
} else {\r
mAuthStatusIcon = R.drawable.common_error;\r
mAuthStatusText = R.string.auth_unsupported_auth_method;\r
- \r
+\r
}\r
showAuthStatus();\r
}\r
mIsSslConn = (result.getCode() == ResultCode.OK_SSL);\r
mOcServerChkOperation = null;\r
\r
+\r
+ /// retrieve discovered version and normalize server URL\r
+ mDiscoveredVersion = operation.getDiscoveredVersion();\r
+ mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
+\r
+ // Refresh server status, but don't show it\r
+ updateServerStatusIconAndText(result);\r
+\r
/// update status icon and text\r
if (mServerIsValid) {\r
hideRefreshButton();\r
+ // Try to create an account with user and pass "", to know if it is a regular server\r
+ // Update connect button in the answer of this method\r
+ detectAuthorizationMethod();\r
} else {\r
showRefreshButton();\r
+ // Show server status\r
+ showServerStatus();\r
}\r
- updateServerStatusIconAndText(result);\r
- showServerStatus();\r
\r
/// very special case (TODO: move to a common place for all the remote operations)\r
if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {\r
showUntrustedCertDialog(result);\r
}\r
\r
- /// retrieve discovered version and normalize server URL\r
- mDiscoveredVersion = operation.getDiscoveredVersion();\r
- mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
\r
- /// allow or not the user try to access the server\r
- mOkButton.setEnabled(mServerIsValid);\r
- \r
} // else nothing ; only the last check operation is considered; \r
// multiple can be triggered if the user amends a URL before a previous check can be triggered\r
}\r
\r
\r
+ /**\r
+ * Try to access with user/pass ""/"", to know if it is a regular server\r
+ */\r
+ private void detectAuthorizationMethod() {\r
+\r
+ Log_OC.d(TAG, "Trying empty authorization to detect authentication method");\r
+\r
+ /// get the path to the root folder through WebDAV from the version server\r
+ String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);\r
+\r
+ /// test credentials \r
+ mDetectAuthenticationOperation = new DetectAuthenticationMethodOperation(this);\r
+ OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
+ mOperationThread = mDetectAuthenticationOperation.execute(client, this, mHandler);\r
+ }\r
+\r
+\r
private String normalizeUrl(String url) {\r
if (url != null && url.length() > 0) {\r
url = url.trim();\r
} \r
return (url != null ? url : "");\r
}\r
- \r
- \r
+\r
+\r
/**\r
* Chooses the right icon and text to show to the user for the received operation result.\r
* \r
\r
\r
private void updateStatusIconFailUserName(){\r
- mAuthStatusIcon = android.R.drawable.ic_secure;\r
+ mAuthStatusIcon = R.drawable.common_error;\r
mAuthStatusText = R.string.auth_fail_get_user_name;\r
}\r
- \r
+\r
+ private void updateServerStatusIconNoRegularAuth(){\r
+ mServerStatusIcon = R.drawable.common_error;\r
+ mServerStatusText = R.string.auth_can_not_auth_against_server;\r
+ }\r
+\r
/**\r
* Processes the result of the request for and access token send \r
* to an OAuth authorization server.\r
if (success) {\r
finish();\r
}\r
-\r
- } else if (result.isServerFail() || result.isException()) {\r
+ \r
+ } else if (result.isServerFail() || result.isException()) {
/// if server fail or exception in authorization, the UI is updated as when a server check failed\r
mServerIsChecked = true;\r
mServerIsValid = false;\r
mAuthStatusIcon = 0;\r
mAuthStatusText = 0;\r
showAuthStatus();\r
- \r
+\r
// update input controls state\r
showRefreshButton();\r
mOkButton.setEnabled(false);\r
showAuthStatus();\r
Log_OC.d(TAG, "Access failed: " + result.getLogMessage());\r
}\r
-\r
}\r
\r
\r
+\r
+\r
/**\r
* Sets the proper response to get that the Account Authenticator that started this activity saves \r
* a new authorization token for mAccount.\r
Bundle response = new Bundle();\r
response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);\r
response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);\r
- \r
+\r
if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) { \r
response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);\r
// the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention\r
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
- \r
+\r
} else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
- \r
+\r
response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);\r
// the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention\r
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
- \r
+\r
} else {\r
response.putString(AccountManager.KEY_AUTHTOKEN, mPasswordInput.getText().toString());\r
mAccountMgr.setPassword(mAccount, mPasswordInput.getText().toString());\r
}\r
setAccountAuthenticatorResult(response);\r
- \r
+\r
}\r
\r
\r
showAuthStatus();\r
Log_OC.d(TAG, result.getLogMessage());\r
return false;\r
- \r
+\r
} else {\r
- \r
+\r
if (isOAuth || isSaml) {\r
mAccountMgr.addAccountExplicitly(mAccount, "", null); // with external authorizations, the password is never input in the app\r
} else {\r
mAccountMgr.addAccountExplicitly(mAccount, mPasswordInput.getText().toString(), null);\r
}\r
- \r
+\r
/// add the new account as default in preferences, if there is none already\r
Account defaultAccount = AccountUtils.getCurrentOwnCloudAccount(this);\r
if (defaultAccount == null) {\r
editor.putString("select_oc_account", accountName);\r
editor.commit();\r
}\r
- \r
+\r
/// prepare result to return to the Authenticator\r
// TODO check again what the Authenticator makes with it; probably has the same effect as addAccountExplicitly, but it's not well done\r
final Intent intent = new Intent(); \r
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mDiscoveredVersion.getVersion());\r
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION_STRING, mDiscoveredVersion.getVersionString());\r
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mHostBaseUrl);\r
-
+
if (isSaml) {\r
mAccountMgr.setUserData(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); \r
} else if (isOAuth) {\r
mAccountMgr.setUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2, "TRUE"); \r
}\r
- \r
+\r
setAccountAuthenticatorResult(intent.getExtras());\r
setResult(RESULT_OK, intent);\r
- \r
+\r
return true;\r
}\r
}\r
public void onRefreshClick(View view) {\r
checkOcServer();\r
}\r
- \r
- \r
+\r
+\r
/**\r
* Called when the eye icon in the password field is clicked.\r
* \r
adaptViewAccordingToAuthenticationMethod();\r
}\r
\r
- \r
+\r
/**\r
* Changes the visibility of input elements depending on\r
* the current authorization method.\r
mOAuthTokenEndpointText.setVisibility(View.VISIBLE);\r
mUsernameInput.setVisibility(View.GONE);\r
mPasswordInput.setVisibility(View.GONE);\r
- \r
+\r
} else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
// SAML-based web Single Sign On\r
mOAuthAuthEndpointText.setVisibility(View.GONE);\r
mPasswordInput.setVisibility(View.VISIBLE);\r
}\r
}\r
- \r
+\r
/**\r
* Called when the 'action' button in an IME is pressed ('enter' in software keyboard).\r
* \r
if (mOkButton.isEnabled()) {\r
mOkButton.performClick();\r
}\r
- \r
+\r
} else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null && inputField.equals(mHostUrlInput)) {\r
if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
checkOcServer();\r
private abstract static class RightDrawableOnTouchListener implements OnTouchListener {\r
\r
private int fuzz = 75;\r
- \r
+\r
/**\r
* {@inheritDoc}\r
*/\r
final int y = (int) event.getY();\r
final Rect bounds = rightDrawable.getBounds();\r
if (x >= (view.getRight() - bounds.width() - fuzz) && x <= (view.getRight() - view.getPaddingRight() + fuzz)\r
- && y >= (view.getPaddingTop() - fuzz) && y <= (view.getHeight() - view.getPaddingBottom()) + fuzz) {\r
- \r
+ && y >= (view.getPaddingTop() - fuzz) && y <= (view.getHeight() - view.getPaddingBottom()) + fuzz) {\r
+\r
return onDrawableTouch(event);\r
}\r
}\r
\r
public void onSamlDialogSuccess(String sessionCookie) {\r
mAuthToken = sessionCookie;\r
- \r
+\r
if (sessionCookie != null && sessionCookie.length() > 0) {\r
mAuthToken = sessionCookie;\r
\r
getUserOperation.execute(client, this, mHandler);\r
}\r
\r
- \r
+\r
}\r
\r
\r
// TODO - show fail\r
Log_OC.d(TAG, "SSO failed");\r
}\r
- \r
+\r
}\r
- \r
+\r
/** Show auth_message \r
* \r
* @param message\r
*/\r
private void showAuthMessage(String message) {\r
- mAuthMessage.setVisibility(View.VISIBLE);\r
- mAuthMessage.setText(message);\r
+ mAuthMessage.setVisibility(View.VISIBLE);\r
+ mAuthMessage.setText(message);\r
}\r
- \r
+\r
private void hideAuthMessage() {\r
mAuthMessage.setVisibility(View.GONE);\r
}\r
ft.addToBackStack(null);\r
dialog.show(ft, DIALOG_UNTRUSTED_CERT);\r
}\r
- \r
+\r
/**\r
* Show untrusted cert dialog \r
*/\r
FragmentTransaction ft = fm.beginTransaction();\r
ft.addToBackStack(null);\r
dialog.show(ft, DIALOG_UNTRUSTED_CERT);\r
- \r
+\r
}\r
- \r
+\r
/**\r
* Dismiss untrusted cert dialog\r
*/\r
SslErrorViewAdapter dialog = (SslErrorViewAdapter) frag;\r
dialog.dismiss();\r
}\r
- */\r
+ */\r
}\r
- \r
+\r
/**\r
* Called from SslValidatorDialog when a new server certificate was correctly saved.\r
*/\r
public void onCancelCertificate() {\r
cancelWebView();\r
}\r
- \r
+\r
\r
public void cancelWebView() {\r
Fragment fd = getSupportFragmentManager().findFragmentByTag(TAG_SAML_DIALOG);\r
d.dismiss();\r
}\r
}\r
- \r
+\r
}\r
\r
}\r
+++ /dev/null
-/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
- * Copyright (C) 2012-2013 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/>.
- *
- */
-
-package com.owncloud.android.files.managers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.owncloud.android.R;
-import com.owncloud.android.utils.DisplayUtils;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.content.Context;
-import android.widget.RemoteViews;
-
-
-public class OCNotificationManager {
-
- enum NotificationType {
- NOTIFICATION_SIMPLE,
- NOTIFICATION_PROGRESS
- }
-
- static public class NotificationData {
- private String mText, mSubtitle;
- private int mPercent;
- private boolean mOngoing;
-
- public NotificationData(String text, String subtitle, boolean ongoing) {
- this(text, subtitle, -1, ongoing);
- }
-
- public NotificationData(int percent, boolean ongoing) {
- this(null, null, percent, ongoing);
- }
-
- public NotificationData(String text, int percent, boolean ongoing) {
- this(text, null, percent, ongoing);
- }
-
- public NotificationData(String text, String subtitle, int percent, boolean ongoing) {
- mText = text;
- mPercent = percent;
- mSubtitle = subtitle;
- mOngoing = ongoing;
- }
-
- public String getText() { return mText; }
- public int getPercent() { return mPercent; }
- public String getSubtitle() { return mSubtitle; }
- public boolean getOngoing() { return mOngoing; }
- }
-
- static private OCNotificationManager mInstance = null;
-
- private class NotificationTypePair {
- public Notification mNotificaiton;
- public NotificationType mType;
- public NotificationTypePair(Notification n, NotificationType type) {
- mNotificaiton = n;
- mType = type;
- }
- }
-
- private Context mContext;
- private Map<Integer, NotificationTypePair> mNotificationMap;
- private int mNotificationCounter;
- NotificationManager mNM;
-
- static OCNotificationManager getInstance(Context context) {
- if (mInstance == null)
- mInstance = new OCNotificationManager(context);
- return mInstance;
- }
-
- OCNotificationManager(Context context) {
- mContext = context;
- mNotificationMap = new HashMap<Integer, NotificationTypePair>();
- mNM = (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- mNotificationCounter = 0;
- }
-
- public int postNotification(NotificationType type, NotificationData data) {
- mNotificationCounter++;
- Notification notification = null;
-
- switch (type) {
- case NOTIFICATION_SIMPLE:
- notification = new Notification(DisplayUtils.getSeasonalIconId(), data.getText(), System.currentTimeMillis());
- break;
- case NOTIFICATION_PROGRESS:
- notification = new Notification();
- notification.contentView = new RemoteViews(mContext.getPackageName(), R.layout.progressbar_layout);
- notification.contentView.setTextViewText(R.id.status_text,
- data.getText());
- notification.contentView.setImageViewResource(R.id.status_icon,
- R.id.icon);
- notification.contentView.setProgressBar(R.id.status_progress,
- 100,
- data.getPercent(),
- false);
- break;
- default:
- return -1;
- }
- if (data.getOngoing()) {
- notification.flags |= notification.flags | Notification.FLAG_ONGOING_EVENT;
- }
-
- mNotificationMap.put(mNotificationCounter, new NotificationTypePair(notification, type));
- return mNotificationCounter;
- }
-
- public boolean updateNotification(int notification_id, NotificationData data) {
- if (!mNotificationMap.containsKey(notification_id)) {
- return false;
- }
- NotificationTypePair pair = mNotificationMap.get(notification_id);
- switch (pair.mType) {
- case NOTIFICATION_PROGRESS:
- pair.mNotificaiton.contentView.setProgressBar(R.id.status_text,
- 100,
- data.getPercent(),
- false);
- return true;
- case NOTIFICATION_SIMPLE:
- pair.mNotificaiton = new Notification(DisplayUtils.getSeasonalIconId(),
- data.getText(), System.currentTimeMillis());
- mNM.notify(notification_id, pair.mNotificaiton);
- return true;
- default:
- return false;
- }
- }
-
- public void discardNotification(int notification_id) {
- mNM.cancel(notification_id);
- mNotificationMap.remove(notification_id);
- }
-}
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.preview.PreviewImageActivity;
import com.owncloud.android.ui.preview.PreviewImageFragment;
-import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.Log_OC;
+import com.owncloud.android.utils.NotificationBuilderWithProgressBar;
import android.accounts.Account;
import android.accounts.AccountsException;
-import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
-import android.widget.RemoteViews;
+import android.support.v4.app.NotificationCompat;
public class FileDownloader extends Service implements OnDatatransferProgressListener {
private DownloadFileOperation mCurrentDownload = null;
private NotificationManager mNotificationManager;
- private Notification mNotification;
+ private NotificationCompat.Builder mNotificationBuilder;
private int mLastPercent;
private void notifyDownloadStart(DownloadFileOperation download) {
/// create status notification with a progress bar
mLastPercent = 0;
- mNotification = new Notification(DisplayUtils.getSeasonalIconId(), getString(R.string.downloader_download_in_progress_ticker), System.currentTimeMillis());
- mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
- mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);
- mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, download.getSize() < 0);
- mNotification.contentView.setTextViewText(R.id.status_text, String.format(getString(R.string.downloader_download_in_progress_content), 0, new File(download.getSavePath()).getName()));
- mNotification.contentView.setImageViewResource(R.id.status_icon, DisplayUtils.getSeasonalIconId());
-
+ mNotificationBuilder =
+ NotificationBuilderWithProgressBar.newNotificationBuilderWithProgressBar(this);
+ mNotificationBuilder
+ .setSmallIcon(R.drawable.notification_icon)
+ .setTicker(getString(R.string.downloader_download_in_progress_ticker))
+ .setContentTitle(getString(R.string.downloader_download_in_progress_ticker))
+ .setOngoing(true)
+ .setProgress(100, 0, download.getSize() < 0)
+ .setContentText(
+ String.format(getString(R.string.downloader_download_in_progress_content), 0,
+ new File(download.getSavePath()).getName())
+ );
+
/// includes a pending intent in the notification showing the details view of the file
Intent showDetailsIntent = null;
if (PreviewImageFragment.canBePreviewed(download.getFile())) {
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, download.getFile());
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, download.getAccount());
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);
- mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotification);
+ mNotificationBuilder.setContentIntent(PendingIntent.getActivity(
+ this, (int) System.currentTimeMillis(), showDetailsIntent, 0
+ ));
+
+ mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotificationBuilder.build());
}
public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String filePath) {
int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer));
if (percent != mLastPercent) {
- mNotification.contentView.setProgressBar(R.id.status_progress, 100, percent, totalToTransfer < 0);
+ mNotificationBuilder.setProgress(100, percent, totalToTransfer < 0);
String fileName = filePath.substring(filePath.lastIndexOf(FileUtils.PATH_SEPARATOR) + 1);
String text = String.format(getString(R.string.downloader_download_in_progress_content), percent, fileName);
- mNotification.contentView.setTextViewText(R.id.status_text, text);
- mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotification);
+ mNotificationBuilder.setContentText(text);
+ mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotificationBuilder.build());
}
mLastPercent = percent;
}
if (!downloadResult.isCancelled()) {
int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
int contentId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_content : R.string.downloader_download_failed_content;
- Notification finalNotification = new Notification(DisplayUtils.getSeasonalIconId(), getString(tickerId), System.currentTimeMillis());
- finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
+ mNotificationBuilder
+ .setTicker(getString(tickerId))
+ .setContentTitle(getString(tickerId))
+ .setAutoCancel(true)
+ .setOngoing(false)
+ .setProgress(0, 0, false);
boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
// (downloadResult.isTemporalRedirection() && downloadResult.isIdPRedirection()
(downloadResult.isIdPRedirection()
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
- finalNotification.contentIntent = PendingIntent.getActivity(this, (int)System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT);
- finalNotification.setLatestEventInfo( getApplicationContext(),
- getString(tickerId),
- String.format(getString(contentId), new File(download.getSavePath()).getName()),
- finalNotification.contentIntent);
+ mNotificationBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ this, (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT
+ ))
+ .setContentText(String.format(getString(contentId), new File(download.getSavePath()).getName()));
mDownloadClient = null; // grant that future retries on the same account will get the fresh credentials
} else {
// TODO put something smart in showDetailsIntent
showDetailsIntent = new Intent();
}
- finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);
- finalNotification.setLatestEventInfo(getApplicationContext(), getString(tickerId), String.format(getString(contentId), new File(download.getSavePath()).getName()), finalNotification.contentIntent);
+ mNotificationBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ this, (int) System.currentTimeMillis(), showDetailsIntent, 0
+ ))
+ .setContentText(String.format(getString(contentId), new File(download.getSavePath()).getName()));
}
- mNotificationManager.notify(tickerId, finalNotification);
+ mNotificationManager.notify(tickerId, mNotificationBuilder.build());
}
}
import com.owncloud.android.ui.activity.InstantUploadActivity;
import com.owncloud.android.ui.preview.PreviewImageActivity;
import com.owncloud.android.ui.preview.PreviewImageFragment;
-import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.Log_OC;
+import com.owncloud.android.utils.NotificationBuilderWithProgressBar;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountsException;
-import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
+import android.support.v4.app.NotificationCompat;
import android.webkit.MimeTypeMap;
-import android.widget.RemoteViews;
private UploadFileOperation mCurrentUpload = null;
private NotificationManager mNotificationManager;
- private Notification mNotification;
+ private NotificationCompat.Builder mNotificationBuilder;
private int mLastPercent;
- private RemoteViews mDefaultNotificationContentView;
public static String getUploadFinishMessage() {
*
* @param upload Upload operation starting.
*/
- @SuppressWarnings("deprecation")
private void notifyUploadStart(UploadFileOperation upload) {
// / create status notification with a progress bar
mLastPercent = 0;
- mNotification = new Notification(DisplayUtils.getSeasonalIconId(), getString(R.string.uploader_upload_in_progress_ticker),
- System.currentTimeMillis());
- mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
- mDefaultNotificationContentView = mNotification.contentView;
- mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(),
- R.layout.progressbar_layout);
- mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, false);
- mNotification.contentView.setTextViewText(R.id.status_text,
- String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName()));
- mNotification.contentView.setImageViewResource(R.id.status_icon, DisplayUtils.getSeasonalIconId());
-
+ mNotificationBuilder =
+ NotificationBuilderWithProgressBar.newNotificationBuilderWithProgressBar(this);
+ mNotificationBuilder
+ .setOngoing(true)
+ .setSmallIcon(R.drawable.notification_icon)
+ .setTicker(getString(R.string.uploader_upload_in_progress_ticker))
+ .setContentTitle(getString(R.string.uploader_upload_in_progress_ticker))
+ .setProgress(100, 0, false)
+ .setContentText(
+ String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName()));
+
/// includes a pending intent in the notification showing the details view of the file
Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class);
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(),
- (int) System.currentTimeMillis(), showDetailsIntent, 0);
+ mNotificationBuilder.setContentIntent(PendingIntent.getActivity(
+ this, (int) System.currentTimeMillis(), showDetailsIntent, 0
+ ));
- mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification);
+ mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
}
/**
public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String filePath) {
int percent = (int) (100.0 * ((double) totalTransferredSoFar) / ((double) totalToTransfer));
if (percent != mLastPercent) {
- mNotification.contentView.setProgressBar(R.id.status_progress, 100, percent, false);
+ mNotificationBuilder.setProgress(100, percent, false);
String fileName = filePath.substring(filePath.lastIndexOf(FileUtils.PATH_SEPARATOR) + 1);
String text = String.format(getString(R.string.uploader_upload_in_progress_content), percent, fileName);
- mNotification.contentView.setTextViewText(R.id.status_text, text);
- mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification);
+ mNotificationBuilder.setContentText(text);
+ mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
}
mLastPercent = percent;
}
} else if (uploadResult.isSuccess()) {
// / success -> silent update of progress notification to success
// message
- mNotification.flags ^= Notification.FLAG_ONGOING_EVENT; // remove
- // the
- // ongoing
- // flag
- mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
- mNotification.contentView = mDefaultNotificationContentView;
+ mNotificationBuilder
+ .setOngoing(false)
+ .setAutoCancel(true)
+ .setProgress(0, 0, false);
/// includes a pending intent in the notification showing the details view of the file
Intent showDetailsIntent = null;
}
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
- showDetailsIntent.putExtra(FileActivity.EXTRA_FROM_NOTIFICATION, true);
- showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(),
- (int) System.currentTimeMillis(), showDetailsIntent, 0);
-
- mNotification.setLatestEventInfo(getApplicationContext(),
- getString(R.string.uploader_upload_succeeded_ticker),
- String.format(getString(R.string.uploader_upload_succeeded_content_single), upload.getFileName()),
- mNotification.contentIntent);
-
- mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification); // NOT
- // AN
+ showDetailsIntent.putExtra(FileActivity.EXTRA_FROM_NOTIFICATION, true);;
+ mNotificationBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ this, (int) System.currentTimeMillis(), showDetailsIntent, 0
+ ))
+ .setTicker(getString(R.string.uploader_upload_succeeded_ticker))
+ .setContentTitle(getString(R.string.uploader_upload_succeeded_ticker))
+ .setContentText(
+ String.format(getString(R.string.uploader_upload_succeeded_content_single),
+ upload.getFileName())
+ );
+
+ mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build()); // NOT
+ // AN
DbHandler db = new DbHandler(this.getBaseContext());
db.removeIUPendingFile(mCurrentUpload.getOriginalStoragePath());
db.close();
// / fail -> explicit failure notification
mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker);
- Notification finalNotification = new Notification(DisplayUtils.getSeasonalIconId(),
- getString(R.string.uploader_upload_failed_ticker), System.currentTimeMillis());
- finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
+ NotificationCompat.Builder errorBuilder = new NotificationCompat.Builder(this);
+ errorBuilder
+ .setSmallIcon(R.drawable.notification_icon)
+ .setTicker(getString(R.string.uploader_upload_failed_ticker))
+ .setContentTitle(getString(R.string.uploader_upload_failed_ticker))
+ .setAutoCancel(true);
String content = null;
boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED ||
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
- finalNotification.contentIntent = PendingIntent.getActivity(this, (int)System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT);
+ errorBuilder.setContentIntent(PendingIntent.getActivity(
+ this, (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT
+ ));
content = String.format(getString(R.string.uploader_upload_failed_content_single), upload.getFileName());
- finalNotification.setLatestEventInfo(getApplicationContext(),
- getString(R.string.uploader_upload_failed_ticker), content, finalNotification.contentIntent);
mUploadClient = null; // grant that future retries on the same account will get the fresh credentials
} else {
// TODO put something smart in the contentIntent below
- // finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);
- //}
if (uploadResult.getCode() == ResultCode.LOCAL_STORAGE_FULL
|| uploadResult.getCode() == ResultCode.LOCAL_STORAGE_NOT_COPIED) {
detailUploadIntent = new Intent(this, FailedUploadActivity.class);
detailUploadIntent.putExtra(FailedUploadActivity.MESSAGE, content);
}
- finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(),
- (int) System.currentTimeMillis(), detailUploadIntent, PendingIntent.FLAG_UPDATE_CURRENT
- | PendingIntent.FLAG_ONE_SHOT);
-
+ errorBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ this, (int) System.currentTimeMillis(), detailUploadIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT
+ ))
+ .setContentText(content);
+
if (upload.isInstant()) {
DbHandler db = null;
try {
}
}
}
- finalNotification.setLatestEventInfo(getApplicationContext(),
- getString(R.string.uploader_upload_failed_ticker), content, finalNotification.contentIntent);
- mNotificationManager.notify(R.string.uploader_upload_failed_ticker, finalNotification);
+ mNotificationManager.notify(R.string.uploader_upload_failed_ticker, errorBuilder.build());
}
}
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation;
import com.owncloud.android.lib.resources.files.FileUtils;
public class CreateShareOperation extends SyncOperation {
private static final String TAG = CreateShareOperation.class.getSimpleName();
+
protected FileDataStorageManager mStorageManager;
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
- CreateRemoteShareOperation operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions);
- RemoteOperationResult result = operation.execute(client);
-
+ RemoteOperation operation = null;
+
+ // Check if the share link already exists
+ operation = new GetRemoteSharesForFileOperation(mPath, false, false);
+ RemoteOperationResult result = ((GetRemoteSharesForFileOperation)operation).execute(client);
+
+ if (!result.isSuccess() || result.getData().size() <= 0) {
+ operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions);
+ result = ((CreateRemoteShareOperation)operation).execute(client);
+ }
+
if (result.isSuccess()) {
-
if (result.getData().size() > 0) {
OCShare share = (OCShare) result.getData().get(0);
-
- // Update DB with the response
- share.setPath(mPath);
- if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
- share.setIsFolder(true);
- } else {
- share.setIsFolder(false);
- }
- share.setPermissions(mPermissions);
-
- getStorageManager().saveShare(share);
-
- // Update OCFile with data from share: ShareByLink and publicLink
- OCFile file = getStorageManager().getFileByPath(mPath);
- if (file!=null) {
- mSendIntent.putExtra(Intent.EXTRA_TEXT, share.getShareLink());
- file.setPublicLink(share.getShareLink());
- file.setShareByLink(true);
- getStorageManager().saveFile(file);
- Log_OC.d(TAG, "Public Link = " + file.getPublicLink());
-
- }
- }
+ updateData(share);
+ }
}
-
-
+
return result;
}
public Intent getSendIntent() {
return mSendIntent;
}
+
+ private void updateData(OCShare share) {
+ // Update DB with the response
+ share.setPath(mPath);
+ if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
+ share.setIsFolder(true);
+ } else {
+ share.setIsFolder(false);
+ }
+ share.setPermissions(mPermissions);
+
+ getStorageManager().saveShare(share);
+
+ // Update OCFile with data from share: ShareByLink and publicLink
+ OCFile file = getStorageManager().getFileByPath(mPath);
+ if (file!=null) {
+ mSendIntent.putExtra(Intent.EXTRA_TEXT, share.getShareLink());
+ file.setPublicLink(share.getShareLink());
+ file.setShareByLink(true);
+ getStorageManager().saveFile(file);
+ Log_OC.d(TAG, "Public Link = " + file.getPublicLink());
+
+ }
+ }
}
--- /dev/null
+/* ownCloud Android Library is available under MIT license
+ * Copyright (C) 2014 ownCloud Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+package com.owncloud.android.operations;
+
+import java.util.ArrayList;
+
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
+
+import android.content.Context;
+import android.net.Uri;
+import android.util.Log;
+
+/**
+ * Operation to find out what authentication method requires
+ * the server to access files.
+ *
+ * Basically, tries to access to the root folder without authorization
+ * and analyzes the response.
+ *
+ * When successful, the instance of {@link RemoteOperationResult} passed
+ * through {@link OnRemoteOperationListener#onRemoteOperationFinish(RemoteOperation,
+ * RemoteOperationResult)} returns in {@link RemoteOperationResult#getData()}
+ * a value of {@link AuthenticationMethod}.
+ *
+ * @author David A. Velasco
+ */
+public class DetectAuthenticationMethodOperation extends RemoteOperation {
+
+ private static final String TAG = DetectAuthenticationMethodOperation.class.getSimpleName();
+
+ public enum AuthenticationMethod {
+ UNKNOWN,
+ NONE,
+ BASIC_HTTP_AUTH,
+ SAML_WEB_SSO,
+ BEARER_TOKEN
+ }
+
+ private Context mContext;
+
+ /**
+ * Constructor
+ *
+ * @param context Android context of the caller.
+ */
+ public DetectAuthenticationMethodOperation(Context context) {
+ mContext = context;
+ }
+
+
+ /**
+ * Performs the operation.
+ *
+ * Triggers a check of existence on the root folder of the server, granting
+ * that the request is not authenticated.
+ *
+ * Analyzes the result of check to find out what authentication method, if
+ * any, is requested by the server.
+ */
+ @Override
+ protected RemoteOperationResult run(OwnCloudClient client) {
+ RemoteOperationResult result = null;
+ AuthenticationMethod authMethod = AuthenticationMethod.UNKNOWN;
+
+ RemoteOperation operation = new ExistenceCheckRemoteOperation("", mContext, false);
+ client.setBasicCredentials("", "");
+ client.setFollowRedirects(false);
+
+ // try to access the root folder, following redirections but not SAML SSO redirections
+ result = operation.execute(client);
+ while (result.isTemporalRedirection() && !result.isIdPRedirection()) {
+ client.setWebdavUri(Uri.parse(result.getRedirectedLocation()));
+ result = operation.execute(client);
+ }
+
+ // analyze response
+ if (result.getCode() == ResultCode.UNAUTHORIZED) {
+ String authRequest = ((result.getAuthenticateHeader()).trim()).toLowerCase();
+ if (authRequest.startsWith("basic")) {
+ authMethod = AuthenticationMethod.BASIC_HTTP_AUTH;
+
+ } else if (authRequest.startsWith("bearer")) {
+ authMethod = AuthenticationMethod.BEARER_TOKEN;
+ }
+ // else - fall back to UNKNOWN
+
+ } else if (result.isSuccess()) {
+ authMethod = AuthenticationMethod.NONE;
+
+ } else if (result.isIdPRedirection()) {
+ authMethod = AuthenticationMethod.SAML_WEB_SSO;
+ }
+ // else - fall back to UNKNOWN
+ Log.d(TAG, "Authentication method found: " + authenticationMethodToString(authMethod));
+
+ ArrayList<Object> data = new ArrayList<Object>();
+ data.add(authMethod);
+ result.setData(data);
+ return result; // same result instance, so that other errors can be handled by the caller transparently
+ }
+
+
+ private String authenticationMethodToString(AuthenticationMethod value) {
+ switch (value){
+ case NONE:
+ return "NONE";
+ case BASIC_HTTP_AUTH:
+ return "BASIC_HTTP_AUTH";
+ case BEARER_TOKEN:
+ return "BEARER_TOKEN";
+ case SAML_WEB_SSO:
+ return "SAML_WEB_SSO";
+ default:
+ return "UNKNOWN";
+ }
+ }
+
+}
sendLocalBroadcast(EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result);
}
- if (result.isSuccess() && mIsShareSupported) {
- RemoteOperationResult shareResult = refreshSharesForFolder(client);
- if (shareResult.getCode() != ResultCode.FILE_NOT_FOUND) {
- result = shareResult;
- } // else , keep the previous result ; being conservative for servers where Sharing API is supported, but disabled
+ if (result.isSuccess() && mIsShareSupported && !mSyncFullAccount) {
+ refreshSharesForFolder(client); // share result is ignored
}
if (!mSyncFullAccount) {
if (remoteFile.isFolder()) {
remoteFile.setFileLength(localFile.getFileLength()); // TODO move operations about size of folders to FileContentProvider
}
+ remoteFile.setPublicLink(localFile.getPublicLink());
+ remoteFile.setShareByLink(localFile.isShareByLink());
} else {
remoteFile.setEtag(""); // remote eTag will not be updated unless contents are synchronized (Synchronize[File|Folder]Operation with remoteFile as parameter)
}
import com.owncloud.android.operations.UpdateOCVersionOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.ui.activity.ErrorsWhileCopyingHandlerActivity;
-import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.Log_OC;
-
import android.accounts.Account;
import android.accounts.AccountsException;
-import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.AbstractThreadedSyncAdapter;
import android.content.Intent;
import android.content.SyncResult;
import android.os.Bundle;
-//import android.support.v4.content.LocalBroadcastManager;
+import android.support.v4.app.NotificationCompat;
/**
* Implementation of {@link AbstractThreadedSyncAdapter} responsible for synchronizing
* Notifies the user about a failed synchronization through the status notification bar
*/
private void notifyFailedSynchronization() {
- Notification notification = new Notification(DisplayUtils.getSeasonalIconId(), getContext().getString(R.string.sync_fail_ticker), System.currentTimeMillis());
- notification.flags |= Notification.FLAG_AUTO_CANCEL;
+ NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
+ notificationBuilder.setTicker(i18n(R.string.sync_fail_ticker));
boolean needsToUpdateCredentials = (mLastFailedResult != null &&
( mLastFailedResult.getCode() == ResultCode.UNAUTHORIZED ||
( mLastFailedResult.isIdPRedirection() &&
)
);
// TODO put something smart in the contentIntent below for all the possible errors
- notification.contentIntent = PendingIntent.getActivity(getContext().getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);
+ notificationBuilder.setContentTitle(i18n(R.string.sync_fail_ticker));
if (needsToUpdateCredentials) {
// let the user update credentials with one click
Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
- notification.contentIntent = PendingIntent.getActivity(getContext(), (int)System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT);
- notification.setLatestEventInfo(getContext().getApplicationContext(),
- getContext().getString(R.string.sync_fail_ticker),
- String.format(getContext().getString(R.string.sync_fail_content_unauthorized), getAccount().name),
- notification.contentIntent);
+ notificationBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ getContext(), (int)System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT
+ ))
+ .setContentText(i18n(R.string.sync_fail_content_unauthorized, getAccount().name));
} else {
- notification.setLatestEventInfo(getContext().getApplicationContext(),
- getContext().getString(R.string.sync_fail_ticker),
- String.format(getContext().getString(R.string.sync_fail_content), getAccount().name),
- notification.contentIntent);
+ notificationBuilder
+ .setContentText(i18n(R.string.sync_fail_content, getAccount().name));
}
- ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(R.string.sync_fail_ticker, notification);
+
+ showNotification(R.string.sync_fail_ticker, notificationBuilder);
}
*/
private void notifyFailsInFavourites() {
if (mFailedResultsCounter > 0) {
- Notification notification = new Notification(DisplayUtils.getSeasonalIconId(), getContext().getString(R.string.sync_fail_in_favourites_ticker), System.currentTimeMillis());
- notification.flags |= Notification.FLAG_AUTO_CANCEL;
+ NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
+ notificationBuilder.setTicker(i18n(R.string.sync_fail_in_favourites_ticker));
+
// TODO put something smart in the contentIntent below
- notification.contentIntent = PendingIntent.getActivity(getContext().getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);
- notification.setLatestEventInfo(getContext().getApplicationContext(),
- getContext().getString(R.string.sync_fail_in_favourites_ticker),
- String.format(getContext().getString(R.string.sync_fail_in_favourites_content), mFailedResultsCounter + mConflictsFound, mConflictsFound),
- notification.contentIntent);
- ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(R.string.sync_fail_in_favourites_ticker, notification);
+ notificationBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ getContext(), (int) System.currentTimeMillis(), new Intent(), 0
+ ))
+ .setContentTitle(i18n(R.string.sync_fail_in_favourites_ticker))
+ .setContentText(i18n(R.string.sync_fail_in_favourites_content, mFailedResultsCounter + mConflictsFound, mConflictsFound));
+ showNotification(R.string.sync_fail_in_favourites_ticker, notificationBuilder);
} else {
- Notification notification = new Notification(DisplayUtils.getSeasonalIconId(), getContext().getString(R.string.sync_conflicts_in_favourites_ticker), System.currentTimeMillis());
- notification.flags |= Notification.FLAG_AUTO_CANCEL;
+ NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
+ notificationBuilder.setTicker(i18n(R.string.sync_conflicts_in_favourites_ticker));
+
// TODO put something smart in the contentIntent below
- notification.contentIntent = PendingIntent.getActivity(getContext().getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);
- notification.setLatestEventInfo(getContext().getApplicationContext(),
- getContext().getString(R.string.sync_conflicts_in_favourites_ticker),
- String.format(getContext().getString(R.string.sync_conflicts_in_favourites_content), mConflictsFound),
- notification.contentIntent);
- ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(R.string.sync_conflicts_in_favourites_ticker, notification);
+ notificationBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ getContext(), (int) System.currentTimeMillis(), new Intent(), 0
+ ))
+ .setContentTitle(i18n(R.string.sync_conflicts_in_favourites_ticker))
+ .setContentText(i18n(R.string.sync_conflicts_in_favourites_ticker, mConflictsFound));
+
+ showNotification(R.string.sync_conflicts_in_favourites_ticker, notificationBuilder);
}
}
* We won't consider a synchronization as failed when foreign files can not be copied to the ownCloud local directory.
*/
private void notifyForgottenLocalFiles() {
- Notification notification = new Notification(DisplayUtils.getSeasonalIconId(), getContext().getString(R.string.sync_foreign_files_forgotten_ticker), System.currentTimeMillis());
- notification.flags |= Notification.FLAG_AUTO_CANCEL;
-
+ NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
+ notificationBuilder.setTicker(i18n(R.string.sync_foreign_files_forgotten_ticker));
+
/// includes a pending intent in the notification showing a more detailed explanation
Intent explanationIntent = new Intent(getContext(), ErrorsWhileCopyingHandlerActivity.class);
explanationIntent.putExtra(ErrorsWhileCopyingHandlerActivity.EXTRA_ACCOUNT, getAccount());
explanationIntent.putExtra(ErrorsWhileCopyingHandlerActivity.EXTRA_REMOTE_PATHS, remotePaths);
explanationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- notification.contentIntent = PendingIntent.getActivity(getContext().getApplicationContext(), (int)System.currentTimeMillis(), explanationIntent, 0);
- notification.setLatestEventInfo(getContext().getApplicationContext(),
- getContext().getString(R.string.sync_foreign_files_forgotten_ticker),
- String.format(getContext().getString(R.string.sync_foreign_files_forgotten_content), mForgottenLocalFiles.size(), getContext().getString(R.string.app_name)),
- notification.contentIntent);
- ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(R.string.sync_foreign_files_forgotten_ticker, notification);
+ notificationBuilder
+ .setContentIntent(PendingIntent.getActivity(
+ getContext(), (int) System.currentTimeMillis(), explanationIntent, 0
+ ))
+ .setContentTitle(i18n(R.string.sync_foreign_files_forgotten_ticker))
+ .setContentText(i18n(R.string.sync_foreign_files_forgotten_content, mForgottenLocalFiles.size(), i18n(R.string.app_name)));
+ showNotification(R.string.sync_foreign_files_forgotten_ticker, notificationBuilder);
}
+ /**
+ * Creates a notification builder with some commonly used settings
+ *
+ * @return
+ */
+ private NotificationCompat.Builder createNotificationBuilder() {
+ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext());
+ notificationBuilder.setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
+ return notificationBuilder;
+ }
+ /**
+ * Builds and shows the notification
+ *
+ * @param id
+ * @param builder
+ */
+ private void showNotification(int id, NotificationCompat.Builder builder) {
+ ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE))
+ .notify(id, builder.build());
+ }
+ /**
+ * Shorthand translation
+ *
+ * @param key
+ * @param args
+ * @return
+ */
+ private String i18n(int key, Object... args) {
+ return getContext().getString(key, args);
+ }
}
--- /dev/null
+/* ownCloud Android client application
+ * Copyright (C) 2014 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/>.
+ *
+ */
+
+package com.owncloud.android.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.TextView;
+import android.preference.CheckBoxPreference;
+
+public class CheckBoxPreferenceWithLongTitle extends CheckBoxPreference{
+
+ public CheckBoxPreferenceWithLongTitle(Context context) {
+ super(context);
+ }
+
+ public CheckBoxPreferenceWithLongTitle(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+ public CheckBoxPreferenceWithLongTitle(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ TextView titleView = (TextView) view.findViewById(android.R.id.title);
+ titleView.setSingleLine(false);
+ titleView.setMaxLines(3);
+ titleView.setEllipsize(null);
+ }
+}
\ No newline at end of file
--- /dev/null
+/* ownCloud Android client application
+ * Copyright (C) 2014 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/>.
+ *
+ */
+
+package com.owncloud.android.ui;
+
+import android.content.Context;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.TextView;
+
+/**
+ * Allow multiline titles in preferences
+ *
+ * @author masensio
+ *
+ */
+public class PreferenceMultiline extends Preference {
+
+ public PreferenceMultiline(Context context) {
+ super(context);
+ }
+
+ public PreferenceMultiline(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public PreferenceMultiline(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ TextView titleView = (TextView) view.findViewById(android.R.id.title);
+ titleView.setSingleLine(false);
+ titleView.setMaxLines(3);
+ }
+}
import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.syncadapter.FileSyncAdapter;
-import com.owncloud.android.ui.adapter.SslErrorViewAdapter;
import com.owncloud.android.ui.dialog.EditNameDialog;
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener;
--- /dev/null
+/* ownCloud Android client application
+ * Copyright (C) 2014 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/>.
+ *
+ */
+
+package com.owncloud.android.utils;
+
+import com.owncloud.android.R;
+
+import android.app.Notification;
+import android.content.Context;
+import android.os.Build;
+import android.support.v4.app.NotificationCompat;
+import android.view.View;
+import android.widget.RemoteViews;
+
+/**
+ * Extends the support class {@link NotificationCompat.Builder} to grant that
+ * a progress bar is available in every Android version, because
+ * {@link NotificationCompat.Builder#setProgress(int, int, boolean)} has no
+ * real effect for Android < 4.0
+ *
+ * @author David A. Velasco
+ */
+public class NotificationBuilderWithProgressBar extends NotificationCompat.Builder {
+
+ /**
+ * Custom view to replace the original layout of the notifications
+ */
+ private RemoteViews mContentView = null;
+
+ /**
+ * Fatory method.
+ *
+ * Instances of this class will be only returned in Android versions needing it.
+ *
+ * @param context Context that will use the builder to create notifications
+ * @return An instance of this class, or of the regular
+ * {@link NotificationCompat.Builder}, when it is good enough.
+ */
+ public static NotificationCompat.Builder newNotificationBuilderWithProgressBar(Context context) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ return new NotificationBuilderWithProgressBar(context);
+ } else {
+ return new NotificationCompat.Builder(context);
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param context Context that will use the builder to create notifications.
+ */
+ private NotificationBuilderWithProgressBar(Context context) {
+ super(context);
+ mContentView = new RemoteViews(context.getPackageName(), R.layout.notification_with_progress_bar);
+ setContent(mContentView);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NotificationCompat.Builder setProgress(int max, int progress, boolean indeterminate) {
+ mContentView.setProgressBar(R.id.progress, max, progress, indeterminate);
+ if (max > 0) {
+ mContentView.setViewVisibility(R.id.progressHolder, View.VISIBLE);
+ } else {
+ mContentView.setViewVisibility(R.id.progressHolder, View.GONE);
+ }
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NotificationCompat.Builder setSmallIcon(int icon) {
+ super.setSmallIcon(icon); // necessary
+ mContentView.setImageViewResource(R.id.icon, icon);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NotificationCompat.Builder setContentTitle(CharSequence title) {
+ super.setContentTitle(title);
+ mContentView.setTextViewText(R.id.title, title);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NotificationCompat.Builder setContentText(CharSequence text) {
+ super.setContentText(text);
+ mContentView.setTextViewText(R.id.text, text);
+ if (text != null && text.length() > 0) {
+ mContentView.setViewVisibility(R.id.text, View.VISIBLE);
+ } else {
+ mContentView.setViewVisibility(R.id.text, View.GONE);
+ }
+ return this;
+ }
+
+ @Override
+ public Notification build() {
+ Notification result = super.build();
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ // super.build() in Android 2.x totally ruins whatever was made #setContent
+ result.contentView = mContentView;
+ }
+ return result;
+ }
+
+}