mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 17:27:45 +00:00
Implement open group suggestion sheet
This commit is contained in:
parent
c50b599ea5
commit
f38b7a30a0
11
res/drawable/default_bottom_sheet_background.xml
Normal file
11
res/drawable/default_bottom_sheet_background.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<solid android:color="@color/dialog_background" />
|
||||||
|
|
||||||
|
<corners android:topLeftRadius="24dp" android:topRightRadius="24dp" />
|
||||||
|
|
||||||
|
<stroke android:width="@dimen/border_thickness" android:color="@color/dialog_border" />
|
||||||
|
</shape>
|
8
res/drawable/default_bottom_sheet_background_inset.xml
Normal file
8
res/drawable/default_bottom_sheet_background_inset.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<inset
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:drawable="@drawable/default_bottom_sheet_background"
|
||||||
|
android:insetLeft="-2dp"
|
||||||
|
android:insetRight="-2dp"
|
||||||
|
android:insetBottom="-2dp">
|
||||||
|
</inset>
|
37
res/drawable/ic_chat_bubbles.xml
Normal file
37
res/drawable/ic_chat_bubbles.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="129dp"
|
||||||
|
android:height="89dp"
|
||||||
|
android:viewportWidth="129"
|
||||||
|
android:viewportHeight="89">
|
||||||
|
<path
|
||||||
|
android:pathData="M84.282,21C108.03,21 127.282,35.775 127.282,54C127.282,60.581 124.772,66.712 120.446,71.86C120.387,74.448 122.309,78.125 126.213,82.89C122.04,82.593 118.037,82.029 114.202,81.199C112.522,80.835 111.249,80.511 110.382,80.226C103.147,84.476 94.098,87 84.282,87C60.534,87 41.282,72.225 41.282,54C41.282,35.775 60.534,21 84.282,21Z"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="3"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#02D370"
|
||||||
|
android:fillType="evenOdd"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M33.282,1C50.403,1 64.282,11.969 64.282,25.5C64.282,39.031 50.403,50 33.282,50C26.123,50 19.531,48.082 14.283,44.861C13.67,45.098 12.651,45.376 11.226,45.693C8.462,46.309 5.576,46.728 2.568,46.949C5.767,42.926 7.12,39.948 6.627,38.015C3.867,34.353 2.282,30.073 2.282,25.5C2.282,11.969 16.161,1 33.282,1Z"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#161616"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M64,54m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:fillColor="#02D370"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M84,54m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:fillColor="#02D370"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M100,54a3.5,4 0,1 0,7 0a3.5,4 0,1 0,-7 0z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:fillColor="#02D370"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
</vector>
|
63
res/layout/fragment_open_group_suggestion_bottom_sheet.xml
Normal file
63
res/layout/fragment_open_group_suggestion_bottom_sheet.xml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:padding="@dimen/large_spacing"
|
||||||
|
app:behavior_hideable="true"
|
||||||
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
|
||||||
|
android:background="@drawable/default_bottom_sheet_background_inset">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_chat_bubbles" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/large_spacing"
|
||||||
|
android:text="No messages yet"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="@dimen/large_font_size" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/large_spacing"
|
||||||
|
android:text="Would you like to join the Session Public Chat?"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:textSize="@dimen/medium_font_size"
|
||||||
|
android:textAlignment="center" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/MediumProminentOutlineButton"
|
||||||
|
android:id="@+id/joinButton"
|
||||||
|
android:layout_width="240dp"
|
||||||
|
android:layout_height="@dimen/medium_button_height"
|
||||||
|
android:layout_marginTop="@dimen/large_spacing"
|
||||||
|
android:text="Join Public Chat" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/MediumUnimportantOutlineButton"
|
||||||
|
android:id="@+id/dismissButton"
|
||||||
|
android:layout_width="240dp"
|
||||||
|
android:layout_height="@dimen/medium_button_height"
|
||||||
|
android:layout_marginTop="@dimen/medium_spacing"
|
||||||
|
android:text="No, thank you" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/medium_spacing"
|
||||||
|
android:textSize="@dimen/very_small_font_size"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="Open groups can be joined by anyone and do not provide full metadata protection" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -49,6 +49,14 @@
|
|||||||
<item name="buttonBarPositiveButtonStyle">@style/Session.AlertDialog.PositiveButtonStyle</item>
|
<item name="buttonBarPositiveButtonStyle">@style/Session.AlertDialog.PositiveButtonStyle</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="SessionBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
|
||||||
|
<item name="bottomSheetStyle">@style/SessionBottomSheetStyle</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="SessionBottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
|
||||||
|
<item name="android:background">@android:color/transparent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Session.AlertDialog.NegativeButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
|
<style name="Session.AlertDialog.NegativeButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
|
||||||
<item name="android:textColor">@color/accent</item>
|
<item name="android:textColor">@color/accent</item>
|
||||||
</style>
|
</style>
|
||||||
|
@ -25,7 +25,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|||||||
import org.thoughtcrime.securesms.database.loaders.DeviceListLoader;
|
import org.thoughtcrime.securesms.database.loaders.DeviceListLoader;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.devicelist.Device;
|
import org.thoughtcrime.securesms.devicelist.Device;
|
||||||
import org.thoughtcrime.securesms.loki.redesign.views.DeviceEditingOptionsBottomSheet;
|
import org.thoughtcrime.securesms.loki.redesign.dialogs.DeviceEditingOptionsBottomSheet;
|
||||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities;
|
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
@ -22,13 +22,16 @@ import android.text.style.ForegroundColorSpan
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
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 nl.komponents.kovenant.ui.successUi
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.conversation.ConversationActivity
|
import org.thoughtcrime.securesms.conversation.ConversationActivity
|
||||||
|
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||||
import org.thoughtcrime.securesms.loki.getColorWithID
|
import org.thoughtcrime.securesms.loki.getColorWithID
|
||||||
|
import org.thoughtcrime.securesms.loki.redesign.dialogs.OpenGroupSuggestionBottomSheet
|
||||||
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
||||||
import org.thoughtcrime.securesms.loki.redesign.utilities.show
|
import org.thoughtcrime.securesms.loki.redesign.utilities.show
|
||||||
import org.thoughtcrime.securesms.loki.redesign.views.ConversationView
|
import org.thoughtcrime.securesms.loki.redesign.views.ConversationView
|
||||||
@ -147,6 +150,32 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
if (hasViewedSeed || !isMasterDevice) {
|
if (hasViewedSeed || !isMasterDevice) {
|
||||||
seedReminderView.visibility = View.GONE
|
seedReminderView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
if (!TextSecurePreferences.getHasSeenOpenGroupSuggestionSheet(this)) {
|
||||||
|
val bottomSheet = OpenGroupSuggestionBottomSheet()
|
||||||
|
bottomSheet.onJoinTapped = {
|
||||||
|
TextSecurePreferences.setHasSeenOpenGroupSuggestionSheet(this)
|
||||||
|
bottomSheet.dismiss()
|
||||||
|
// TODO: Duplication of the code in JoinPublicChatActivity
|
||||||
|
val application = ApplicationContext.getInstance(this)
|
||||||
|
val channel: Long = 1
|
||||||
|
val displayName = TextSecurePreferences.getProfileName(this)
|
||||||
|
val lokiPublicChatAPI = application.lokiPublicChatAPI!!
|
||||||
|
val url = "https://chat.getsession.org"
|
||||||
|
application.lokiPublicChatManager.addChat(url, channel).successUi {
|
||||||
|
lokiPublicChatAPI.getMessages(channel, url)
|
||||||
|
lokiPublicChatAPI.setDisplayName(displayName, url)
|
||||||
|
lokiPublicChatAPI.join(channel, url)
|
||||||
|
val profileKey: ByteArray = ProfileKeyUtil.getProfileKey(this)
|
||||||
|
val profileUrl: String? = TextSecurePreferences.getProfileAvatarUrl(this)
|
||||||
|
lokiPublicChatAPI.setProfilePicture(url, profileKey, profileUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bottomSheet.onDismissTapped = {
|
||||||
|
TextSecurePreferences.setHasSeenOpenGroupSuggestionSheet(this)
|
||||||
|
bottomSheet.dismiss()
|
||||||
|
}
|
||||||
|
bottomSheet.show(supportFragmentManager, bottomSheet.tag)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
@ -15,11 +15,7 @@ import network.loki.messenger.R
|
|||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.devicelist.Device
|
import org.thoughtcrime.securesms.devicelist.Device
|
||||||
import org.thoughtcrime.securesms.loki.redesign.views.DeviceEditingOptionsBottomSheet
|
import org.thoughtcrime.securesms.loki.redesign.dialogs.*
|
||||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.EditDeviceNameDialog
|
|
||||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.EditDeviceNameDialogDelegate
|
|
||||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.LinkDeviceMasterModeDialog
|
|
||||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.LinkDeviceMasterModeDialogDelegate
|
|
||||||
import org.thoughtcrime.securesms.loki.signAndSendPairingAuthorisationMessage
|
import org.thoughtcrime.securesms.loki.signAndSendPairingAuthorisationMessage
|
||||||
import org.thoughtcrime.securesms.sms.MessageSender
|
import org.thoughtcrime.securesms.sms.MessageSender
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.thoughtcrime.securesms.loki.redesign.views
|
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.design.widget.BottomSheetDialogFragment
|
import android.support.design.widget.BottomSheetDialogFragment
|
@ -0,0 +1,29 @@
|
|||||||
|
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.design.widget.BottomSheetDialogFragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import kotlinx.android.synthetic.main.fragment_open_group_suggestion_bottom_sheet.*
|
||||||
|
import network.loki.messenger.R
|
||||||
|
|
||||||
|
public class OpenGroupSuggestionBottomSheet : BottomSheetDialogFragment() {
|
||||||
|
var onJoinTapped: (() -> Unit)? = null
|
||||||
|
var onDismissTapped: (() -> Unit)? = null
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setStyle(STYLE_NORMAL, R.style.SessionBottomSheetDialogTheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.fragment_open_group_suggestion_bottom_sheet, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
joinButton.setOnClickListener { onJoinTapped?.invoke() }
|
||||||
|
dismissButton.setOnClickListener { onDismissTapped?.invoke() }
|
||||||
|
}
|
||||||
|
}
|
@ -1250,6 +1250,14 @@ public class TextSecurePreferences {
|
|||||||
public static long getRestorationTime(Context context) {
|
public static long getRestorationTime(Context context) {
|
||||||
return getLongPreference(context, "restoration_time", 0);
|
return getLongPreference(context, "restoration_time", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getHasSeenOpenGroupSuggestionSheet(Context context) {
|
||||||
|
return getBooleanPreference(context, "has_seen_open_group_suggestion_sheet", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setHasSeenOpenGroupSuggestionSheet(Context context) {
|
||||||
|
setBooleanPreference(context, "has_seen_open_group_suggestion_sheet", true);
|
||||||
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
public static void clearAll(Context context) {
|
public static void clearAll(Context context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user