mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 04:25:18 +00:00
Refactor & match design
This commit is contained in:
parent
49d344f7f7
commit
ff21d760f6
@ -3,7 +3,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/unimportant" />
|
||||
<solid android:color="@color/profile_picture_background" />
|
||||
|
||||
<corners android:radius="38dp" />
|
||||
|
||||
|
@ -7,5 +7,5 @@
|
||||
|
||||
<corners android:radius="38dp" />
|
||||
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/border" />
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/profile_picture_border" />
|
||||
</shape>
|
@ -3,7 +3,9 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/unimportant" />
|
||||
<solid android:color="@color/profile_picture_background" />
|
||||
|
||||
<corners android:radius="23dp" />
|
||||
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/profile_picture_border" />
|
||||
</shape>
|
@ -7,5 +7,5 @@
|
||||
|
||||
<corners android:radius="23dp" />
|
||||
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/border" />
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/profile_picture_border" />
|
||||
</shape>
|
@ -3,7 +3,9 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#353535" />
|
||||
<solid android:color="@color/profile_picture_background" />
|
||||
|
||||
<corners android:radius="23dp" />
|
||||
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/profile_picture_border" />
|
||||
</shape>
|
@ -3,7 +3,9 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/unimportant" />
|
||||
<solid android:color="@color/profile_picture_background" />
|
||||
|
||||
<corners android:radius="18dp" />
|
||||
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/profile_picture_border" />
|
||||
</shape>
|
@ -7,5 +7,5 @@
|
||||
|
||||
<corners android:radius="18dp" />
|
||||
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/border" />
|
||||
<stroke android:width="@dimen/profile_picture_border_thickness" android:color="@color/profile_picture_border" />
|
||||
</shape>
|
@ -34,8 +34,7 @@
|
||||
android:layout_height="@dimen/small_profile_picture_size"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="9dp"
|
||||
android:foreground="@drawable/circle_touch_highlight_background"/>
|
||||
android:layout_marginLeft="9dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -24,8 +24,7 @@
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/large_profile_picture_size"
|
||||
android:layout_height="@dimen/large_profile_picture_size"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:foreground="@drawable/circle_touch_highlight_background" />
|
||||
android:layout_marginTop="@dimen/medium_spacing" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/ctnGroupNameSection"
|
||||
|
@ -19,9 +19,13 @@
|
||||
android:id="@+id/doubleModeImageView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:alpha="0.65"
|
||||
android:background="@drawable/profile_picture_view_small_background" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/profile_picture_view_small_foreground" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
@ -36,6 +40,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/profile_picture_view_small_background" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/profile_picture_view_small_foreground" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -51,6 +60,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/profile_picture_view_medium_background" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/profile_picture_view_medium_foreground" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
@ -73,6 +87,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/profile_picture_view_large_background" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/profile_picture_view_large_foreground" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -7,6 +7,8 @@
|
||||
<color name="text">#000000</color>
|
||||
<color name="destructive">#f26f55</color>
|
||||
<color name="unimportant">#606060</color>
|
||||
<color name="profile_picture_border">#23000000</color>
|
||||
<color name="profile_picture_background">#B0B0B0</color>
|
||||
<color name="cell_background">#FCFCFC</color>
|
||||
<color name="cell_selected">#DFDFDF</color>
|
||||
<color name="navigation_bar_background">#FCFCFC</color>
|
||||
|
@ -7,6 +7,8 @@
|
||||
<color name="text">#FFFFFF</color>
|
||||
<color name="destructive">#FF453A</color>
|
||||
<color name="unimportant">#D8D8D8</color>
|
||||
<color name="profile_picture_border">#23FFFFFF</color>
|
||||
<color name="profile_picture_background">#353535</color>
|
||||
<color name="border">#979797</color>
|
||||
<color name="cell_background">#1B1B1B</color>
|
||||
<color name="cell_selected">#0C0C0C</color>
|
||||
@ -29,6 +31,13 @@
|
||||
<color name="pn_option_background">#1B1B1B</color>
|
||||
<color name="pn_option_border">#212121</color>
|
||||
<color name="paths_building">#FFCE3A</color>
|
||||
|
||||
<array name="profile_picture_placeholder_colors">
|
||||
<item>#5ff8b0</item>
|
||||
<item>#26cdb9</item>
|
||||
<item>#f3c615</item>
|
||||
<item>#fcac5a</item>
|
||||
</array>
|
||||
<!-- Session -->
|
||||
|
||||
<!-- Loki -->
|
||||
@ -108,11 +117,4 @@
|
||||
<color name="default_background_start">#121212</color>
|
||||
<color name="default_background_end">#171717</color>
|
||||
|
||||
<array name="user_pic_placeholder_primary">
|
||||
<item>#2bca81</item>
|
||||
<item>#ee7117</item>
|
||||
<item>#239edf</item>
|
||||
<item>#bb35e9</item>
|
||||
</array>
|
||||
|
||||
</resources>
|
||||
|
@ -52,10 +52,8 @@ import java.security.SecureRandom
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
private var displayNameEditActionMode: ActionMode? = null
|
||||
set(value) { field = value; handleDisplayNameEditActionModeChanged() }
|
||||
|
||||
private lateinit var glide: GlideRequests
|
||||
private var displayNameToBeUploaded: String? = null
|
||||
private var profilePictureToBeUploaded: ByteArray? = null
|
||||
@ -71,20 +69,17 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
// region Lifecycle
|
||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||
super.onCreate(savedInstanceState, isReady)
|
||||
|
||||
setContentView(R.layout.activity_settings)
|
||||
|
||||
val origUserDisplayName = DatabaseFactory.getLokiUserDatabase(this).getDisplayName(hexEncodedPublicKey)
|
||||
|
||||
val displayName = DatabaseFactory.getLokiUserDatabase(this).getDisplayName(hexEncodedPublicKey)
|
||||
glide = GlideApp.with(this)
|
||||
profilePictureView.glide = glide
|
||||
profilePictureView.publicKey = hexEncodedPublicKey
|
||||
profilePictureView.displayName = origUserDisplayName
|
||||
profilePictureView.displayName = displayName
|
||||
profilePictureView.isLarge = true
|
||||
profilePictureView.update()
|
||||
profilePictureView.setOnClickListener { showEditProfilePictureUI() }
|
||||
ctnGroupNameSection.setOnClickListener { startActionMode(DisplayNameEditActionModeCallback()) }
|
||||
btnGroupNameDisplay.text = origUserDisplayName
|
||||
btnGroupNameDisplay.text = displayName
|
||||
publicKeyTextView.text = hexEncodedPublicKey
|
||||
copyButton.setOnClickListener { copyPublicKey() }
|
||||
shareButton.setOnClickListener { sharePublicKey() }
|
||||
@ -106,12 +101,9 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.settings_general, menu)
|
||||
|
||||
// Update UI mode menu icon.
|
||||
// It uses three-level selector where each level corresponds to the related UiMode ordinal value.
|
||||
// Update UI mode menu icon
|
||||
val uiMode = UiModeUtilities.getUserSelectedUiMode(this)
|
||||
menu.findItem(R.id.action_change_theme).icon!!.level = uiMode.ordinal
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,10 @@ import network.loki.messenger.R
|
||||
import java.util.*
|
||||
|
||||
object AvatarPlaceholderGenerator {
|
||||
private val tmpFloatArray = FloatArray(3)
|
||||
|
||||
private const val EMPTY_LABEL = "0";
|
||||
|
||||
private val tmpFloatArray = FloatArray(3)
|
||||
|
||||
fun generate(context: Context, pixelSize: Int, hashString: String, displayName: String?): BitmapDrawable {
|
||||
//TODO That should be replaced with a proper hash extraction code.
|
||||
val hash: Long
|
||||
@ -26,7 +25,7 @@ object AvatarPlaceholderGenerator {
|
||||
}
|
||||
|
||||
// Do not cache color array, it may be different depends on the current theme.
|
||||
val colorArray = context.resources.getIntArray(R.array.user_pic_placeholder_primary)
|
||||
val colorArray = context.resources.getIntArray(R.array.profile_picture_placeholder_colors)
|
||||
val colorPrimary = colorArray[(hash % colorArray.size).toInt()]
|
||||
val colorSecondary = changeColorHueBy(colorPrimary, 12f)
|
||||
|
||||
@ -43,7 +42,7 @@ object AvatarPlaceholderGenerator {
|
||||
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
paint.shader = LinearGradient(0f, 0f, 0f, pixelSize.toFloat(),
|
||||
colorPrimary,
|
||||
colorSecondary,
|
||||
colorPrimary,
|
||||
Shader.TileMode.REPEAT)
|
||||
canvas.drawCircle(pixelSize.toFloat() / 2, pixelSize.toFloat() / 2, pixelSize.toFloat() / 2, paint)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.thoughtcrime.securesms.loki.views
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -9,7 +8,6 @@ import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.annotation.DimenRes
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import kotlinx.android.synthetic.main.view_conversation.view.*
|
||||
import kotlinx.android.synthetic.main.view_profile_picture.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto
|
||||
@ -79,10 +77,12 @@ class ProfilePictureView : RelativeLayout {
|
||||
users.remove(masterPublicKey)
|
||||
}
|
||||
val randomUsers = users.sorted() // Sort to provide a level of stability
|
||||
publicKey = randomUsers.getOrNull(0) ?: ""
|
||||
displayName = getUserDisplayName(randomUsers.getOrNull(0) ?: "")
|
||||
additionalPublicKey = randomUsers.getOrNull(1) ?: ""
|
||||
additionalDisplayName = getUserDisplayName(randomUsers.getOrNull(1) ?: "")
|
||||
val pk = randomUsers.getOrNull(0) ?: ""
|
||||
publicKey = pk
|
||||
displayName = getUserDisplayName(pk)
|
||||
val apk = randomUsers.getOrNull(1) ?: ""
|
||||
additionalPublicKey = apk
|
||||
additionalDisplayName = getUserDisplayName(apk)
|
||||
isRSSFeed = recipient.name == "Loki News" || recipient.name == "Session Updates"
|
||||
}
|
||||
} else {
|
||||
@ -101,7 +101,6 @@ class ProfilePictureView : RelativeLayout {
|
||||
singleModeImageViewContainer.visibility = if (additionalPublicKey == null && !isRSSFeed && !isLarge) View.VISIBLE else View.INVISIBLE
|
||||
largeSingleModeImageViewContainer.visibility = if (additionalPublicKey == null && !isRSSFeed && isLarge) View.VISIBLE else View.INVISIBLE
|
||||
rssImageView.visibility = if (isRSSFeed) View.VISIBLE else View.INVISIBLE
|
||||
|
||||
setProfilePictureIfNeeded(
|
||||
doubleModeImageView1,
|
||||
publicKey,
|
||||
@ -124,21 +123,21 @@ class ProfilePictureView : RelativeLayout {
|
||||
R.dimen.large_profile_picture_size)
|
||||
}
|
||||
|
||||
private fun setProfilePictureIfNeeded(imageView: ImageView, hexEncodedPublicKey: String, displayName: String?, @DimenRes sizeResId: Int) {
|
||||
private fun setProfilePictureIfNeeded(imageView: ImageView, publicKey: String, displayName: String?, @DimenRes sizeResId: Int) {
|
||||
glide.clear(imageView)
|
||||
if (hexEncodedPublicKey.isNotEmpty()) {
|
||||
val recipient = Recipient.from(context, Address.fromSerialized(hexEncodedPublicKey), false);
|
||||
if (publicKey.isNotEmpty()) {
|
||||
val recipient = Recipient.from(context, Address.fromSerialized(publicKey), false);
|
||||
val signalProfilePicture = recipient.contactPhoto
|
||||
if (signalProfilePicture != null && (signalProfilePicture as? ProfileContactPhoto)?.avatarObject != "0" && (signalProfilePicture as? ProfileContactPhoto)?.avatarObject != "") {
|
||||
if (signalProfilePicture != null && (signalProfilePicture as? ProfileContactPhoto)?.avatarObject != "0"
|
||||
&& (signalProfilePicture as? ProfileContactPhoto)?.avatarObject != "") {
|
||||
glide.load(signalProfilePicture).diskCacheStrategy(DiskCacheStrategy.ALL).circleCrop().into(imageView)
|
||||
} else {
|
||||
val sizePx = resources.getDimensionPixelSize(sizeResId)
|
||||
val masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||
val hepk = if (recipient.isLocalNumber && masterHexEncodedPublicKey != null) masterHexEncodedPublicKey else hexEncodedPublicKey
|
||||
// val jazzIcon = JazzIdenticonDrawable(size, size, hepk)
|
||||
val sizeInPX = resources.getDimensionPixelSize(sizeResId)
|
||||
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||
val hepk = if (recipient.isLocalNumber && masterPublicKey != null) masterPublicKey else publicKey
|
||||
glide.load(AvatarPlaceholderGenerator.generate(
|
||||
context,
|
||||
sizePx,
|
||||
sizeInPX,
|
||||
hepk,
|
||||
displayName
|
||||
)).diskCacheStrategy(DiskCacheStrategy.ALL).circleCrop().into(imageView)
|
||||
|
@ -49,6 +49,13 @@ class UserView : LinearLayout {
|
||||
|
||||
// region Updating
|
||||
fun bind(user: Recipient, glide: GlideRequests, actionIndicator: ActionIndicator, isSelected: Boolean = false) {
|
||||
fun getUserDisplayName(publicKey: String?): String? {
|
||||
if (publicKey == null || publicKey.isBlank()) {
|
||||
return null
|
||||
} else {
|
||||
return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey!!)
|
||||
}
|
||||
}
|
||||
val address = user.address.serialize()
|
||||
if (user.isGroupRecipient) {
|
||||
if ("Session Public Chat" == user.name || user.address.isRSSFeed) {
|
||||
@ -58,15 +65,14 @@ class UserView : LinearLayout {
|
||||
profilePictureView.isRSSFeed = true
|
||||
} else {
|
||||
val threadID = GroupManager.getThreadIDFromGroupID(address, context)
|
||||
val userKeys = MentionsManager.shared.userPublicKeyCache[threadID]?.toList() ?: listOf()
|
||||
val sortedUserKeys = userKeys.sorted() // Sort to provide a level of stability
|
||||
val userKey0 = sortedUserKeys.getOrNull(0) ?: ""
|
||||
val userKey1 = sortedUserKeys.getOrNull(1) ?: ""
|
||||
|
||||
profilePictureView.publicKey = userKey0
|
||||
profilePictureView.displayName = getUserDisplayName(userKey0)
|
||||
profilePictureView.additionalPublicKey = userKey1
|
||||
profilePictureView.additionalDisplayName = getUserDisplayName(userKey1)
|
||||
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toList() ?: listOf()
|
||||
val randomUsers = users.sorted() // Sort to provide a level of stability
|
||||
val pk = randomUsers.getOrNull(0) ?: ""
|
||||
profilePictureView.publicKey = pk
|
||||
profilePictureView.displayName = getUserDisplayName(pk)
|
||||
val apk = randomUsers.getOrNull(1) ?: ""
|
||||
profilePictureView.additionalPublicKey = apk
|
||||
profilePictureView.additionalDisplayName = getUserDisplayName(apk)
|
||||
profilePictureView.isRSSFeed = false
|
||||
}
|
||||
} else {
|
||||
@ -93,10 +99,5 @@ class UserView : LinearLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getUserDisplayName(publicKey: String?): String? {
|
||||
if (TextUtils.isEmpty(publicKey)) return null
|
||||
return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey!!)
|
||||
}
|
||||
// endregion
|
||||
}
|
@ -14,19 +14,19 @@ import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationCompat.Action;
|
||||
import androidx.core.app.RemoteInput;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.todo.AvatarPlaceholderGenerator;
|
||||
@ -93,10 +93,10 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
.get());
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
Log.w(TAG, e);
|
||||
setLargeIcon(obtainAvatarPlaceholderDrawable(context, recipient));
|
||||
setLargeIcon(getPlaceholderDrawable(context, recipient));
|
||||
}
|
||||
} else {
|
||||
setLargeIcon(obtainAvatarPlaceholderDrawable(context, recipient));
|
||||
setLargeIcon(getPlaceholderDrawable(context, recipient));
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -320,9 +320,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
return content;
|
||||
}
|
||||
|
||||
private static Drawable obtainAvatarPlaceholderDrawable(Context context, Recipient recipient) {
|
||||
//TODO Copied from ProfilePictureView#setProfilePictureIfNeeded
|
||||
// Refactor this code to use the same recipient placeholder generator method across the app.
|
||||
private static Drawable getPlaceholderDrawable(Context context, Recipient recipient) {
|
||||
String publicKey = recipient.getAddress().serialize();
|
||||
String hepk = (recipient.isLocalNumber() && publicKey != null)
|
||||
? TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||
|
Loading…
Reference in New Issue
Block a user