mirror of
				https://github.com/oxen-io/session-android.git
				synced 2025-10-24 21:49:22 +00:00 
			
		
		
		
	Fixing mute
This commit is contained in:
		| @@ -22,27 +22,31 @@ fun showMuteDialog( | |||||||
|         if (entry.stringRes == R.string.notificationsMute) { |         if (entry.stringRes == R.string.notificationsMute) { | ||||||
|             context.getString(R.string.notificationsMute) |             context.getString(R.string.notificationsMute) | ||||||
|         } else { |         } else { | ||||||
|             val largeTimeUnitString = LocalisedTimeUtil.getDurationWithSingleLargestTimeUnit(context, Option.entries[index].getTime().milliseconds) |             val largeTimeUnitString = LocalisedTimeUtil.getDurationWithSingleLargestTimeUnit( | ||||||
|  |                 context, | ||||||
|  |                 Option.entries[index].duration.milliseconds | ||||||
|  |             ) | ||||||
|             context.getSubbedString(entry.stringRes, TIME_LARGE_KEY to largeTimeUnitString) |             context.getSubbedString(entry.stringRes, TIME_LARGE_KEY to largeTimeUnitString) | ||||||
|         } |         } | ||||||
|     }.toTypedArray()) { |     }.toTypedArray()) { | ||||||
|         onMuteDuration(Option.entries[it].getTime()) |         // Note: We add the current timestamp to the mute duration to get the un-mute timestamp | ||||||
|  |         // that gets stored in the database via ConversationMenuHelper.mute(). | ||||||
|  |         // Also: This is a kludge, but we ADD one second to the mute duration because otherwise by | ||||||
|  |         // the time the view for how long the conversation is muted for gets set then it's actually | ||||||
|  |         // less than the entire duration - so 1 hour becomes 59 minutes, 1 day becomes 23 hours etc. | ||||||
|  |         // As we really want to see the actual set time (1 hour / 1 day etc.) then we'll bump it by | ||||||
|  |         // 1 second which is neither here nor there in the grand scheme of things. | ||||||
|  |         val muteTime = Option.entries[it].duration | ||||||
|  |         val muteTimeFromNow = if (muteTime == Long.MAX_VALUE) muteTime | ||||||
|  |         else muteTime + System.currentTimeMillis() + 1.seconds.inWholeMilliseconds | ||||||
|  |         onMuteDuration(muteTimeFromNow) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| private enum class Option(@StringRes val stringRes: Int, val getTime: () -> Long) { | private enum class Option(@StringRes val stringRes: Int, val duration: Long) { | ||||||
|     ONE_HOUR(R.string.notificationsMuteFor,   duration = TimeUnit.HOURS.toMillis(1)), |     ONE_HOUR(R.string.notificationsMuteFor, duration = TimeUnit.HOURS.toMillis(1)), | ||||||
|     TWO_HOURS(R.string.notificationsMuteFor,  duration = TimeUnit.HOURS.toMillis(2)), |     TWO_HOURS(R.string.notificationsMuteFor, duration = TimeUnit.HOURS.toMillis(2)), | ||||||
|     ONE_DAY(R.string.notificationsMuteFor,    duration = TimeUnit.DAYS.toMillis(1)), |     ONE_DAY(R.string.notificationsMuteFor, duration = TimeUnit.DAYS.toMillis(1)), | ||||||
|     SEVEN_DAYS(R.string.notificationsMuteFor, duration = TimeUnit.DAYS.toMillis(7)), |     SEVEN_DAYS(R.string.notificationsMuteFor, duration = TimeUnit.DAYS.toMillis(7)), | ||||||
|     FOREVER(R.string.notificationsMute, getTime = { Long.MAX_VALUE } ); |     FOREVER(R.string.notificationsMute, duration = Long.MAX_VALUE ); | ||||||
|  |  | ||||||
|     // Note: We add the current timestamp to the mute duration to get the un-mute timestamp |  | ||||||
|     // that gets stored in the database via ConversationMenuHelper.mute(). |  | ||||||
|     // Also: This is a kludge, but we ADD one second to the mute duration because otherwise by |  | ||||||
|     // the time the view for how long the conversation is muted for gets set then it's actually |  | ||||||
|     // less than the entire duration - so 1 hour becomes 59 minutes, 1 day becomes 23 hours etc. |  | ||||||
|     // As we really want to see the actual set time (1 hour / 1 day etc.) then we'll bump it by |  | ||||||
|     // 1 second which is neither here nor there in the grand scheme of things. |  | ||||||
|     constructor(@StringRes stringRes: Int, duration: Long): this(stringRes, { duration + System.currentTimeMillis() + 1.seconds.inWholeMilliseconds } ) |  | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user
	 ThomasSession
					ThomasSession