save name instead of subject in bookmark
This commit is contained in:
		
							parent
							
								
									42b1e56cd9
								
							
						
					
					
						commit
						4c9e331e01
					
				| @ -645,12 +645,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece | |||||||
| 						if (conversation.getMucOptions().setSubject(subject)) { | 						if (conversation.getMucOptions().setSubject(subject)) { | ||||||
| 							mXmppConnectionService.updateConversation(conversation); | 							mXmppConnectionService.updateConversation(conversation); | ||||||
| 						} | 						} | ||||||
| 						final Bookmark bookmark = conversation.getBookmark(); |  | ||||||
| 						if (bookmark != null && bookmark.getBookmarkName() == null) { |  | ||||||
| 							if (bookmark.setBookmarkName(subject)) { |  | ||||||
| 								mXmppConnectionService.pushBookmarks(account); |  | ||||||
| 							} |  | ||||||
| 						} |  | ||||||
| 						mXmppConnectionService.updateConversationUi(); | 						mXmppConnectionService.updateConversationUi(); | ||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
|  | |||||||
| @ -115,6 +115,7 @@ import eu.siacs.conversations.utils.ReplacingSerialSingleThreadExecutor; | |||||||
| import eu.siacs.conversations.utils.ReplacingTaskManager; | import eu.siacs.conversations.utils.ReplacingTaskManager; | ||||||
| import eu.siacs.conversations.utils.Resolver; | import eu.siacs.conversations.utils.Resolver; | ||||||
| import eu.siacs.conversations.utils.SerialSingleThreadExecutor; | import eu.siacs.conversations.utils.SerialSingleThreadExecutor; | ||||||
|  | import eu.siacs.conversations.utils.StringUtils; | ||||||
| import eu.siacs.conversations.utils.WakeLockHelper; | import eu.siacs.conversations.utils.WakeLockHelper; | ||||||
| import eu.siacs.conversations.xml.Namespace; | import eu.siacs.conversations.xml.Namespace; | ||||||
| import eu.siacs.conversations.utils.XmppUri; | import eu.siacs.conversations.utils.XmppUri; | ||||||
| @ -2450,13 +2451,29 @@ public class XmppConnectionService extends Service { | |||||||
| 			@Override | 			@Override | ||||||
| 			public void onIqPacketReceived(Account account, IqPacket packet) { | 			public void onIqPacketReceived(Account account, IqPacket packet) { | ||||||
| 				if (packet.getType() == IqPacket.TYPE.RESULT) { | 				if (packet.getType() == IqPacket.TYPE.RESULT) { | ||||||
| 					if (conversation.getMucOptions().updateConfiguration(new ServiceDiscoveryResult(packet))) { | 
 | ||||||
|  | 					final MucOptions mucOptions = conversation.getMucOptions(); | ||||||
|  | 					final Bookmark bookmark = conversation.getBookmark(); | ||||||
|  | 					final boolean sameBefore = StringUtils.equals(bookmark == null ? null : bookmark.getBookmarkName(), mucOptions.getName()); | ||||||
|  | 
 | ||||||
|  | 					if (mucOptions.updateConfiguration(new ServiceDiscoveryResult(packet))) { | ||||||
| 						Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": muc configuration changed for " + conversation.getJid().asBareJid()); | 						Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": muc configuration changed for " + conversation.getJid().asBareJid()); | ||||||
| 						updateConversation(conversation); | 						updateConversation(conversation); | ||||||
| 					} | 					} | ||||||
|  | 
 | ||||||
|  | 					if (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) { | ||||||
|  | 						if (bookmark.setBookmarkName(mucOptions.getName())) { | ||||||
|  | 							pushBookmarks(account); | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 					if (callback != null) { | 					if (callback != null) { | ||||||
| 						callback.onConferenceConfigurationFetched(conversation); | 						callback.onConferenceConfigurationFetched(conversation); | ||||||
| 					} | 					} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 					updateConversationUi(); | 					updateConversationUi(); | ||||||
| 				} else if (packet.getType() == IqPacket.TYPE.ERROR) { | 				} else if (packet.getType() == IqPacket.TYPE.ERROR) { | ||||||
| 					if (callback != null) { | 					if (callback != null) { | ||||||
|  | |||||||
| @ -58,6 +58,7 @@ import eu.siacs.conversations.utils.XmppUri; | |||||||
| import rocks.xmpp.addr.Jid; | import rocks.xmpp.addr.Jid; | ||||||
| 
 | 
 | ||||||
| import static eu.siacs.conversations.entities.Bookmark.printableValue; | import static eu.siacs.conversations.entities.Bookmark.printableValue; | ||||||
|  | import static eu.siacs.conversations.utils.StringUtils.changed; | ||||||
| 
 | 
 | ||||||
| public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed, TextWatcher { | public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed, TextWatcher { | ||||||
|     public static final String ACTION_VIEW_MUC = "view_muc"; |     public static final String ACTION_VIEW_MUC = "view_muc"; | ||||||
| @ -368,13 +369,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private static String blankOnNull(String input) { |  | ||||||
|         return input == null ? "" : input; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     private static boolean changed(String one, String two) { |  | ||||||
|         return !blankOnNull(one).equals(blankOnNull(two)); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     protected String getShareableUri(boolean http) { |     protected String getShareableUri(boolean http) { | ||||||
| @ -558,8 +552,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     protected void saveAsBookmark() { |     protected void saveAsBookmark() { | ||||||
|         xmppConnectionService.saveConversationAsBookmark(mConversation, |         xmppConnectionService.saveConversationAsBookmark(mConversation, mConversation.getMucOptions().getName()); | ||||||
|                 mConversation.getMucOptions().getSubject()); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     protected void deleteBookmark() { |     protected void deleteBookmark() { | ||||||
|  | |||||||
							
								
								
									
										46
									
								
								src/main/java/eu/siacs/conversations/utils/StringUtils.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/main/java/eu/siacs/conversations/utils/StringUtils.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (c) 2018, Daniel Gultsch All rights reserved. | ||||||
|  |  * | ||||||
|  |  * Redistribution and use in source and binary forms, with or without modification, | ||||||
|  |  * are permitted provided that the following conditions are met: | ||||||
|  |  * | ||||||
|  |  * 1. Redistributions of source code must retain the above copyright notice, this | ||||||
|  |  * list of conditions and the following disclaimer. | ||||||
|  |  * | ||||||
|  |  * 2. Redistributions in binary form must reproduce the above copyright notice, | ||||||
|  |  * this list of conditions and the following disclaimer in the documentation and/or | ||||||
|  |  * other materials provided with the distribution. | ||||||
|  |  * | ||||||
|  |  * 3. Neither the name of the copyright holder nor the names of its contributors | ||||||
|  |  * may be used to endorse or promote products derived from this software without | ||||||
|  |  * specific prior written permission. | ||||||
|  |  * | ||||||
|  |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||||||
|  |  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||||
|  |  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||
|  |  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||||||
|  |  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||||||
|  |  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||||||
|  |  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||||||
|  |  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||||
|  |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||||||
|  |  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package eu.siacs.conversations.utils; | ||||||
|  | 
 | ||||||
|  | public class StringUtils { | ||||||
|  | 
 | ||||||
|  |     private static String blankOnNull(String input) { | ||||||
|  |         return input == null ? "" : input; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static boolean equals(String one, String two) { | ||||||
|  |         return blankOnNull(one).equals(blankOnNull(two)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static boolean changed(String one, String two) { | ||||||
|  |         return !equals(one, two); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch