Skip to content

Commit

Permalink
bug fix in parsing docId, added missing translations
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Sep 16, 2019
1 parent a25d072 commit 56cc4ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
22 changes: 14 additions & 8 deletions app/src/main/java/co/tinode/tindroid/UiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@

import co.tinode.tinodesdk.MeTopic;
import co.tinode.tinodesdk.NotConnectedException;
import co.tinode.tinodesdk.NotSynchronizedException;
import co.tinode.tinodesdk.PromisedReply;
import co.tinode.tinodesdk.ServerResponseException;
import co.tinode.tinodesdk.Tinode;
Expand Down Expand Up @@ -883,7 +882,7 @@ public void run() {
static void attachMeTopic(final Activity activity, final MeTopic.MeListener l) {
setProgressIndicator(activity, true);

PromisedReply<ServerMessage> connectionCheck = null;
PromisedReply<ServerMessage> connectionCheck;
if (!Cache.getTinode().isAuthenticated()) {
String uid = BaseDb.getInstance().getUid();
if (!TextUtils.isEmpty(uid)) {
Expand Down Expand Up @@ -997,8 +996,7 @@ public void run() {
// Find path to content: DocumentProvider, DownloadsProvider, MediaProvider, MediaStore, File.
static String getPath(Context context, Uri uri) {
// DocumentProvider
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
DocumentsContract.isDocumentUri(context, uri)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
String authority = uri.getAuthority();
if (authority != null) {
Expand All @@ -1012,18 +1010,26 @@ static String getPath(Context context, Uri uri) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
// TODO: handle non-primary volumes
break;
}
break;
case "com.android.providers.downloads.documents": {
// DownloadsProvider
if (docId.startsWith("raw:")) {
// "raw:/storage/emulated/0/Download/app-debug.apk"
return docId.substring(4);
}

final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
try {
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
Long.valueOf(docId));
return getDataColumn(context, contentUri, null, null);
return getDataColumn(context, contentUri, null, null);
} catch (NumberFormatException e) {
Log.w(TAG, "Failed to parse document ID: " + docId);
return null;
}
}
case "com.android.providers.media.documents": {
// MediaProvider

final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,17 @@
<string name="add_credential_title">Контакты</string>
<string name="delete_credential_title">Удалить контакт</string>
<string name="delete_credential_confirmation">Удалить контакт %1$s:%2$s?</string>

<string name="leave_conversation">Выйти из чата</string>
<string name="block_contact">Заблокировать контакт</string>
<string name="report_contact">Сообщить о нарушении</string>
<string name="report_group">Сообщить о нарушении</string>
<string name="clear_messages">Удалить сообщения</string>
<string name="manage_members">Управлять участниками</string>
<string name="new_chat_report">Заблокировать и сообщить о нарушении</string>
<string name="confirm_contact_ban">Заблокировать %1$s?</string>
<string name="confirm_report">Заблокировать и сообщить о нарушении %1$s?</string>
<string name="legal">Прочее</string>
<string name="terms_of_use"><![CDATA[<a href=\"https://tinode.co/terms.html\">Пользовательское соглашение</a>]]></string>
<string name="contact_us"><![CDATA[<a href=\"mailto:info@tinode.co\">Обратная связь</a>]]></string>
<string name="privacy_policy"><![CDATA[<a href=\"https://tinode.co/privacy.html\">Политика конфиденциальности</a>]]></string>
</resources>

0 comments on commit 56cc4ae

Please sign in to comment.