mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #1060 from deltachat/remove-get-subtitle
remove calls to dc_chat_get_subtitle()
This commit is contained in:
@@ -996,15 +996,6 @@ JNIEXPORT jstring Java_com_b44t_messenger_DcChat_getName(JNIEnv *env, jobject ob
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_DcChat_getSubtitle(JNIEnv *env, jobject obj)
|
||||
{
|
||||
const char* temp = dc_chat_get_subtitle(get_dc_chat(env, obj));
|
||||
jstring ret = JSTRING_NEW(temp);
|
||||
dc_str_unref(temp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_DcChat_getProfileImage(JNIEnv *env, jobject obj)
|
||||
{
|
||||
const char* temp = dc_chat_get_profile_image(get_dc_chat(env, obj));
|
||||
|
||||
@@ -23,7 +23,6 @@ public class DcChat {
|
||||
public native boolean isGroup ();
|
||||
public native int getArchived ();
|
||||
public native String getName ();
|
||||
public native String getSubtitle ();
|
||||
public native String getProfileImage ();
|
||||
public native int getColor ();
|
||||
public native boolean isUnpromoted ();
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
@@ -118,26 +119,31 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
}
|
||||
|
||||
private void setRecipientTitle(DcChat dcChat, boolean showSubtitle) {
|
||||
|
||||
if(dcChat.getId()==DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
int chatId = dcChat.getId();
|
||||
if( chatId == DcChat.DC_CHAT_ID_DEADDROP ) {
|
||||
this.title.setText(R.string.menu_deaddrop);
|
||||
this.subtitle.setText(R.string.menu_deaddrop_subtitle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.title.setText(dcChat.getName());
|
||||
this.subtitle.setText(hackPluralsString(dcChat.getSubtitle()));
|
||||
String subtitle = "ErrSubtitle";
|
||||
|
||||
Context context = getContext();
|
||||
DcContext dcContext = DcHelper.getContext(context);
|
||||
int[] chatContacts = dcContext.getChatContacts(chatId);
|
||||
if( dcChat.isGroup() ) {
|
||||
subtitle = context.getResources().getQuantityString(R.plurals.n_members, chatContacts.length, chatContacts.length);
|
||||
} else if( chatContacts.length>=1 ) {
|
||||
if( dcChat.isSelfTalk() ) {
|
||||
subtitle = context.getString(R.string.chat_self_talk_subtitle);
|
||||
}
|
||||
else {
|
||||
subtitle = dcContext.getContact(chatContacts[0]).getAddr();
|
||||
}
|
||||
}
|
||||
|
||||
this.subtitle.setText(subtitle);
|
||||
}
|
||||
|
||||
this.subtitle.setVisibility(showSubtitle? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private String hackPluralsString(String string) {
|
||||
// the rust-core does not care about plural forms (there is just once case that was not worth the effort up to now)
|
||||
// therefore, we check if the returned string has the form "N member(s)" and localized the corrently to one/few/many/other
|
||||
if( string.endsWith(" member(s)") ) {
|
||||
int cnt = Util.objectToInt(string.substring(0, string.indexOf(" ")));
|
||||
string = getContext().getResources().getQuantityString(R.plurals.n_members, cnt, cnt);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,6 @@ public class ApplicationDcContext extends DcContext {
|
||||
setStockTranslation(40, context.getString(R.string.chat_archived_chats_title));
|
||||
setStockTranslation(42, context.getString(R.string.autocrypt_asm_subject));
|
||||
setStockTranslation(43, context.getString(R.string.autocrypt_asm_general_body));
|
||||
setStockTranslation(50, context.getString(R.string.chat_self_talk_subtitle));
|
||||
setStockTranslation(60, context.getString(R.string.login_error_cannot_login));
|
||||
setStockTranslation(61, context.getString(R.string.login_error_server_response));
|
||||
setStockTranslation(62, context.getString(R.string.systemmsg_action_by_user));
|
||||
|
||||
@@ -107,25 +107,21 @@ public class Recipient {
|
||||
|
||||
if(dcContact!=null) {
|
||||
this.address = Address.fromContact(dcContact.getId());
|
||||
String identifier = Hash.sha256(dcContact.getDisplayName() + dcContact.getAddr());
|
||||
Uri systemContactPhoto = Prefs.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
maybeSetSystemContactPhoto(context, dcContact);
|
||||
if (dcContact.getId() == DcContact.DC_CONTACT_ID_SELF) {
|
||||
setProfileAvatar("SELF");
|
||||
}
|
||||
}
|
||||
else if(dcChat!=null) {
|
||||
this.address = Address.fromChat(dcChat.getId());
|
||||
int chatId = dcChat.getId();
|
||||
this.address = Address.fromChat(chatId);
|
||||
if (!dcChat.isGroup()) {
|
||||
String identifier = Hash.sha256(dcChat.getName() + dcChat.getSubtitle());
|
||||
Uri systemContactPhoto = Prefs.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
setSystemContactPhoto(systemContactPhoto);
|
||||
DcContext dcContext = DcHelper.getContext(context);
|
||||
int[] contacts = dcContext.getChatContacts(chatId);
|
||||
if( contacts.length>=1 ) {
|
||||
maybeSetSystemContactPhoto(context, dcContext.getContact(contacts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
this.address = Address.UNKNOWN;
|
||||
@@ -235,7 +231,15 @@ public class Recipient {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSystemContactPhoto(@Nullable Uri systemContactPhoto) {
|
||||
private void maybeSetSystemContactPhoto(@NonNull Context context, DcContact contact) {
|
||||
String identifier = Hash.sha256(contact.getDisplayName() + contact.getAddr());
|
||||
Uri systemContactPhoto = Prefs.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSystemContactPhoto(@Nullable Uri systemContactPhoto) {
|
||||
boolean notify = false;
|
||||
|
||||
synchronized (this) {
|
||||
|
||||
Reference in New Issue
Block a user