mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 23:23:39 +00:00
Customize main toolbar
This commit is contained in:
parent
ed20a96ed0
commit
1616e841da
@ -141,7 +141,8 @@
|
|||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity"
|
android:name="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity"
|
||||||
android:launchMode="singleTask" />
|
android:launchMode="singleTask"
|
||||||
|
android:theme="@style/Session.DarkTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.CreatePrivateChatActivity"
|
android:name="org.thoughtcrime.securesms.loki.redesign.activities.CreatePrivateChatActivity"
|
||||||
android:launchMode="singleTask" />
|
android:launchMode="singleTask" />
|
||||||
|
@ -1,43 +1,95 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/default_session_background">
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/default_session_background"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/recyclerView"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
app:contentInsetLeft="20dp"
|
||||||
|
app:contentInsetRight="20dp"
|
||||||
|
android:theme="?attr/actionBarStyle">
|
||||||
|
|
||||||
<!-- The button below intentionally uses dp for the text size and not sp -->
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
|
||||||
|
android:id="@+id/profileButton"
|
||||||
|
android:layout_width="@dimen/small_profile_picture_size"
|
||||||
|
android:layout_height="@dimen/small_profile_picture_size"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerVertical="true"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Messages"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:textSize="@dimen/very_large_font_size"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="64dp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/joinPublicChatButton"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/ic_globe"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_marginBottom="@dimen/new_conversation_button_bottom_offset">
|
|
||||||
|
|
||||||
<View
|
<android.support.v7.widget.RecyclerView
|
||||||
android:layout_width="72dp"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_height="72dp"
|
android:layout_width="match_parent"
|
||||||
android:background="@drawable/new_conversation_button_background" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<Button
|
<!-- The button below intentionally uses dp for the text size and not sp -->
|
||||||
android:id="@+id/newConversationButton"
|
|
||||||
android:layout_width="@dimen/new_conversation_button_size"
|
<RelativeLayout
|
||||||
android:layout_height="@dimen/new_conversation_button_size"
|
android:layout_width="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="1dp"
|
android:layout_centerHorizontal="true"
|
||||||
android:paddingBottom="2dp"
|
android:layout_alignParentBottom="true"
|
||||||
android:background="@drawable/new_conversation_button_foreground"
|
android:layout_marginBottom="@dimen/new_conversation_button_bottom_offset">
|
||||||
android:fontFamily="@font/roboto_light"
|
|
||||||
android:textSize="40dp"
|
<View
|
||||||
android:textColor="#121212"
|
android:layout_width="72dp"
|
||||||
android:text="+"
|
android:layout_height="72dp"
|
||||||
android:elevation="0dp"
|
android:background="@drawable/new_conversation_button_background" />
|
||||||
android:stateListAnimator="@null" />
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/newConversationButton"
|
||||||
|
android:layout_width="@dimen/new_conversation_button_size"
|
||||||
|
android:layout_height="@dimen/new_conversation_button_size"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:paddingLeft="1dp"
|
||||||
|
android:paddingBottom="2dp"
|
||||||
|
android:background="@drawable/new_conversation_button_foreground"
|
||||||
|
android:fontFamily="@font/roboto_light"
|
||||||
|
android:textSize="40dp"
|
||||||
|
android:textColor="#121212"
|
||||||
|
android:text="+"
|
||||||
|
android:elevation="0dp"
|
||||||
|
android:stateListAnimator="@null" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</LinearLayout>
|
@ -9,6 +9,13 @@
|
|||||||
<item name="colorPrimaryDark">@color/action_bar_background</item>
|
<item name="colorPrimaryDark">@color/action_bar_background</item>
|
||||||
<item name="android:navigationBarColor">@color/navigation_bar_background</item>
|
<item name="android:navigationBarColor">@color/navigation_bar_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Session.DarkTheme.NoActionBar" parent="@style/Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="actionBarStyle">@style/Session.DarkActionBar</item>
|
||||||
|
<item name="colorPrimary">@color/action_bar_background</item>
|
||||||
|
<item name="colorPrimaryDark">@color/action_bar_background</item>
|
||||||
|
<item name="android:navigationBarColor">@color/navigation_bar_background</item>
|
||||||
|
</style>
|
||||||
<!-- Session -->
|
<!-- Session -->
|
||||||
|
|
||||||
<style name="TextSecure.LightNoActionBar" parent="@style/TextSecure.LightTheme">
|
<style name="TextSecure.LightNoActionBar" parent="@style/TextSecure.LightTheme">
|
||||||
|
@ -14,8 +14,6 @@ import android.support.v4.content.Loader
|
|||||||
import android.support.v7.widget.LinearLayoutManager
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper
|
import android.support.v7.widget.helper.ItemTouchHelper
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuItem
|
|
||||||
import kotlinx.android.synthetic.main.activity_home.*
|
import kotlinx.android.synthetic.main.activity_home.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
@ -42,9 +40,15 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
// Set content view
|
// Set content view
|
||||||
setContentView(R.layout.activity_home)
|
setContentView(R.layout.activity_home)
|
||||||
// Set title
|
// Set title
|
||||||
supportActionBar!!.title = "Messages"
|
setSupportActionBar(toolbar)
|
||||||
// Set up Glide
|
// Set up Glide
|
||||||
glide = GlideApp.with(this)
|
glide = GlideApp.with(this)
|
||||||
|
// Set up toolbar buttons
|
||||||
|
profileButton.glide = glide
|
||||||
|
profileButton.hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)
|
||||||
|
profileButton.update()
|
||||||
|
profileButton.setOnClickListener { openSettings() }
|
||||||
|
joinPublicChatButton.setOnClickListener { joinPublicChat() }
|
||||||
// Set up recycler view
|
// Set up recycler view
|
||||||
val cursor = DatabaseFactory.getThreadDatabase(this).conversationList
|
val cursor = DatabaseFactory.getThreadDatabase(this).conversationList
|
||||||
val homeAdapter = HomeAdapter(this, cursor)
|
val homeAdapter = HomeAdapter(this, cursor)
|
||||||
@ -85,22 +89,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
|
||||||
menuInflater.inflate(R.menu.menu_home, menu)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Interaction
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
val id = item.itemId
|
|
||||||
when (id) {
|
|
||||||
R.id.joinPublicChatItem -> joinPublicChat()
|
|
||||||
else -> { /* Do nothing */ }
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onConversationClick(view: ConversationView) {
|
override fun onConversationClick(view: ConversationView) {
|
||||||
val thread = view.thread ?: return
|
val thread = view.thread ?: return
|
||||||
openConversation(thread)
|
openConversation(thread)
|
||||||
@ -121,6 +109,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
push(intent)
|
push(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openSettings() {
|
||||||
|
// TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
private fun createPrivateChat() {
|
private fun createPrivateChat() {
|
||||||
val intent = Intent(this, CreatePrivateChatActivity::class.java)
|
val intent = Intent(this, CreatePrivateChatActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
|
@ -22,7 +22,6 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.annimon.stream.function.Consumer;
|
import com.annimon.stream.function.Consumer;
|
||||||
|
|
||||||
@ -34,7 +33,6 @@ import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
|||||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.GroupRecordContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.GroupRecordContactPhoto;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.SystemContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.SystemContactPhoto;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.TransparentContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.TransparentContactPhoto;
|
||||||
import org.thoughtcrime.securesms.database.Address;
|
import org.thoughtcrime.securesms.database.Address;
|
||||||
@ -477,7 +475,7 @@ public class Recipient implements RecipientModifiedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized @Nullable ContactPhoto getContactPhoto() {
|
public synchronized @Nullable ContactPhoto getContactPhoto() {
|
||||||
if (isLocalNumber) return new ProfileContactPhoto(address, String.valueOf(TextSecurePreferences.getProfileAvatarId(context)));
|
if (isLocalNumber && profileAvatar != null) return new ProfileContactPhoto(address, String.valueOf(TextSecurePreferences.getProfileAvatarId(context)));
|
||||||
else if (isGroupRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
|
else if (isGroupRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
|
||||||
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
|
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
|
||||||
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
|
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user