Hardcode community guidelines

This commit is contained in:
Niels Andriesse 2021-05-14 15:17:16 +10:00
parent 6e5f75d472
commit faa8c9443f
7 changed files with 198 additions and 0 deletions

View File

@ -254,6 +254,10 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="org.thoughtcrime.securesms.loki.activities.HomeActivity" />
</activity>
<activity
android:name="org.thoughtcrime.securesms.loki.activities.OpenGroupGuidelinesActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.TextSecure.DayNight"/>
<activity
android:name="org.thoughtcrime.securesms.longmessage.LongMessageActivity"
android:screenOrientation="portrait"

View File

@ -381,6 +381,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
PublicChatInfoUpdateWorker.scheduleInstant(this, publicChat.getServer(), publicChat.getChannel());
} else if (openGroupV2 != null) {
PublicChatInfoUpdateWorker.scheduleInstant(this, openGroupV2.getServer(), openGroupV2.getRoom());
if (openGroupV2.getRoom().equals("session") || openGroupV2.getRoom().equals("oxen")
|| openGroupV2.getRoom().equals("lokinet") || openGroupV2.getRoom().equals("crypto")) {
View openGroupGuidelinesView = findViewById(R.id.open_group_guidelines_view);
openGroupGuidelinesView.setVisibility(View.VISIBLE);
}
}
View rootView = findViewById(R.id.rootView);

View File

@ -0,0 +1,37 @@
package org.thoughtcrime.securesms.loki.activities
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_open_group_guidelines.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.BaseActionBarActivity
class OpenGroupGuidelinesActivity : BaseActionBarActivity() {
// region Lifecycle
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_open_group_guidelines)
communityGuidelinesTextView.text = """
In order for our open group to be a fun environment, full of robust and constructive discussion, please follow these four simple rules:
1. Keep conversations on-topic and add value to the discussion (no referral links, spamming, or off-topic discussion).
2. You don't have to love everyone, but be civil (no baiting, excessively partisan arguments, threats, and so on; use common sense).
3. Do not be a shill. Comparison and criticism is reasonable, but blatant shilling is not.
4. Don't post explicit content, be it excessive offensive language, or content which is sexual or violent in nature.
If you break these rules, youll be warned by an admin. If your behaviour doesnt improve, you will be removed from the open group.
If you see or experience any destructive behaviour, please contact an admin.
SCAMMER WARNING
Trust only those with an admin tag in the chat. No admin will ever DM you first. No admin will ever message you for Oxen coins.
""".trimIndent()
}
// endregion
}

View File

@ -0,0 +1,38 @@
package org.thoughtcrime.securesms.loki.views
import android.content.Context
import android.content.Intent
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import kotlinx.android.synthetic.main.view_open_group_guidelines.view.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.conversation.ConversationActivity
import org.thoughtcrime.securesms.loki.activities.OpenGroupGuidelinesActivity
import org.thoughtcrime.securesms.loki.utilities.push
class OpenGroupGuidelinesView : FrameLayout {
constructor(context: Context) : super(context) {
setUpViewHierarchy()
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
setUpViewHierarchy()
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
setUpViewHierarchy()
}
private fun setUpViewHierarchy() {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contentView = inflater.inflate(R.layout.view_open_group_guidelines, null)
addView(contentView)
readButton.setOnClickListener {
val activity = context as ConversationActivity
val intent = Intent(activity, OpenGroupGuidelinesActivity::class.java)
activity.push(intent)
}
}
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/large_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:textSize="@dimen/large_font_size"
android:textStyle="bold"
android:textColor="@color/text"
android:text="Community Guidelines" />
<TextView
android:id="@+id/communityGuidelinesTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_spacing"
android:layout_marginTop="@dimen/medium_spacing"
android:layout_marginRight="@dimen/large_spacing"
android:layout_marginBottom="@dimen/large_spacing"
android:textSize="@dimen/medium_font_size"
android:textColor="@color/text" />
</LinearLayout>
</ScrollView>

View File

@ -134,6 +134,12 @@
android:background="?android:dividerHorizontal"
android:elevation="1dp" />
<org.thoughtcrime.securesms.loki.views.OpenGroupGuidelinesView
android:id="@+id/open_group_guidelines_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<FrameLayout
android:id="@+id/fragment_content"
android:layout_width="match_parent"

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cell_background"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="12dp"
android:paddingTop="@dimen/small_spacing"
android:paddingBottom="@dimen/small_spacing"
android:orientation="horizontal">
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginRight="@dimen/small_spacing"
android:background="@color/accent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text"
android:textSize="@dimen/small_font_size"
android:textStyle="bold"
android:text="Pinned message" />
<TextView
android:layout_width="wrap_content"
android:maxWidth="260dp"
android:layout_height="wrap_content"
android:textColor="@color/text"
android:textSize="@dimen/small_font_size"
android:maxLines="2"
android:text="Community guidelines" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:minWidth="@dimen/small_spacing" />
<Button
style="@style/Widget.Session.Button.Common.ProminentOutline"
android:id="@+id/readButton"
android:layout_width="wrap_content"
android:layout_height="@dimen/small_button_height"
android:layout_marginRight="12dp"
android:textSize="@dimen/small_font_size"
android:textStyle="normal"
android:text="Read" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="?android:dividerHorizontal" />
</LinearLayout>