mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 11:58:25 +00:00
Implement basic onion request UI
This commit is contained in:
parent
5d4c7dcb49
commit
388ca90361
@ -117,6 +117,9 @@
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.SettingsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Session.DarkTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.PathActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.QRCodeActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
BIN
captures/network.loki.messenger_2020.05.28_16.39.li
Normal file
BIN
captures/network.loki.messenger_2020.05.28_16.39.li
Normal file
Binary file not shown.
8
res/drawable/accent_dot.xml
Normal file
8
res/drawable/accent_dot.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
|
||||
<solid android:color="@color/accent" />
|
||||
|
||||
</shape>
|
@ -40,6 +40,14 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="64dp" />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/pathStatusView"
|
||||
android:layout_width="@dimen/small_profile_picture_size"
|
||||
android:layout_height="@dimen/small_profile_picture_size"
|
||||
android:background="@color/red"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
45
res/layout/activity_path.xml
Normal file
45
res/layout/activity_path.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?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="match_parent"
|
||||
android:background="@drawable/default_session_background"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<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/small_font_size"
|
||||
android:textColor="@color/text"
|
||||
android:alpha="0.6"
|
||||
android:textAlignment="center"
|
||||
android:text="@string/activity_path_explanation" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="@dimen/large_spacing">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/pathRowsContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
style="@style/MediumProminentOutlineButton"
|
||||
android:id="@+id/rebuildPathButton"
|
||||
android:layout_width="196dp"
|
||||
android:layout_height="@dimen/medium_button_height"
|
||||
android:layout_marginBottom="@dimen/medium_spacing"
|
||||
android:text="@string/activity_path_rebuild_path_button_title" />
|
||||
|
||||
</LinearLayout>
|
@ -5,6 +5,7 @@
|
||||
<dimen name="medium_button_height">44dp</dimen>
|
||||
<dimen name="tab_bar_height">48dp</dimen>
|
||||
<dimen name="setting_button_height">72dp</dimen>
|
||||
<dimen name="path_row_height">72dp</dimen>
|
||||
<!-- Session -->
|
||||
|
||||
<dimen name="album_total_width">300dp</dimen>
|
||||
|
@ -33,6 +33,8 @@
|
||||
<dimen name="dialog_corner_radius">8dp</dimen>
|
||||
<dimen name="dialog_button_corner_radius">4dp</dimen>
|
||||
<dimen name="pn_option_corner_radius">8dp</dimen>
|
||||
<dimen name="path_row_height">56dp</dimen>
|
||||
<dimen name="path_row_dot_size">8dp</dimen>
|
||||
|
||||
<!-- Distances -->
|
||||
<dimen name="small_spacing">8dp</dimen>
|
||||
|
@ -1741,6 +1741,14 @@
|
||||
<string name="view_seed_reminder_subtitle_2">Tap and hold the redacted words to reveal your recovery phrase, then store it safely to secure your Session ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_3">Make sure to store your recovery phrase in a safe place</string>
|
||||
|
||||
<string name="activity_path_title">Path</string>
|
||||
<string name="activity_path_explanation">Session hides your IP by bouncing your messages through several Service Nodes in Session\'s decentralized network. These are the Service Nodes currently being used by your device:</string>
|
||||
<string name="activity_path_device_row_title">You</string>
|
||||
<string name="activity_path_guard_node_row_title">Guard Node</string>
|
||||
<string name="activity_path_service_node_row_title">Service Node</string>
|
||||
<string name="activity_path_destination_row_title">Destination</string>
|
||||
<string name="activity_path_rebuild_path_button_title">Rebuild Path</string>
|
||||
|
||||
<string name="activity_create_private_chat_title">New Session</string>
|
||||
<string name="activity_create_private_chat_enter_session_id_tab_title">Enter Session ID</string>
|
||||
<string name="activity_create_private_chat_scan_qr_code_tab_title">Scan QR Code</string>
|
||||
|
@ -101,6 +101,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
||||
profileButton.hexEncodedPublicKey = hexEncodedPublicKey
|
||||
profileButton.update()
|
||||
profileButton.setOnClickListener { openSettings() }
|
||||
pathStatusView.setOnClickListener { showPath() }
|
||||
// Set up seed reminder view
|
||||
val isMasterDevice = (TextSecurePreferences.getMasterHexEncodedPublicKey(this) == null)
|
||||
val hasViewedSeed = TextSecurePreferences.getHasViewedSeed(this)
|
||||
@ -262,6 +263,11 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
||||
show(intent)
|
||||
}
|
||||
|
||||
private fun showPath() {
|
||||
val intent = Intent(this, PathActivity::class.java)
|
||||
show(intent)
|
||||
}
|
||||
|
||||
override fun createNewPrivateChat() {
|
||||
val intent = Intent(this, CreatePrivateChatActivity::class.java)
|
||||
show(intent)
|
||||
|
128
src/org/thoughtcrime/securesms/loki/activities/PathActivity.kt
Normal file
128
src/org/thoughtcrime/securesms/loki/activities/PathActivity.kt
Normal file
@ -0,0 +1,128 @@
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import kotlinx.android.synthetic.main.activity_path.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
||||
|
||||
class PathActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
// region Lifecycle
|
||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||
super.onCreate(savedInstanceState, isReady)
|
||||
setContentView(R.layout.activity_path)
|
||||
supportActionBar!!.title = resources.getString(R.string.activity_path_title)
|
||||
val youRow = getPathRow("You", null, LineView.Location.Top, 0.0f, 0.0f)
|
||||
val row1 = getPathRow("Guard Node", "0.0.0.0", LineView.Location.Middle, 0.0f, 0.0f)
|
||||
val row2 = getPathRow("Service Node", "0.0.0.0", LineView.Location.Middle, 0.0f, 0.0f)
|
||||
val row3 = getPathRow("Service Node", "0.0.0.0", LineView.Location.Middle, 0.0f, 0.0f)
|
||||
val destinationRow = getPathRow("Destination", null, LineView.Location.Bottom, 0.0f, 0.0f)
|
||||
pathRowsContainer.addView(youRow)
|
||||
pathRowsContainer.addView(row1)
|
||||
pathRowsContainer.addView(row2)
|
||||
pathRowsContainer.addView(row3)
|
||||
pathRowsContainer.addView(destinationRow)
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region General
|
||||
private fun getPathRow(title: String, subtitle: String?, location: LineView.Location, dotAnimationStartDelay: Float, dotAnimationRepeatInterval: Float): LinearLayout {
|
||||
val lineView = LineView(this, location, dotAnimationStartDelay, dotAnimationRepeatInterval)
|
||||
val lineViewLayoutParams = LinearLayout.LayoutParams(resources.getDimensionPixelSize(R.dimen.path_row_dot_size), resources.getDimensionPixelSize(R.dimen.path_row_height))
|
||||
lineView.layoutParams = lineViewLayoutParams
|
||||
val titleTextView = TextView(this)
|
||||
titleTextView.setTextColor(resources.getColorWithID(R.color.text, theme))
|
||||
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.medium_font_size))
|
||||
titleTextView.text = title
|
||||
val titleContainer = LinearLayout(this)
|
||||
titleContainer.orientation = LinearLayout.VERTICAL
|
||||
titleContainer.addView(titleTextView)
|
||||
val titleContainerLayoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
titleContainerLayoutParams.marginStart = resources.getDimensionPixelSize(R.dimen.large_spacing)
|
||||
titleContainer.layoutParams = titleContainerLayoutParams
|
||||
if (subtitle != null) {
|
||||
val subtitleTextView = TextView(this)
|
||||
subtitleTextView.setTextColor(resources.getColorWithID(R.color.text, theme))
|
||||
subtitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.small_font_size))
|
||||
subtitleTextView.text = subtitle
|
||||
titleContainer.addView(subtitleTextView)
|
||||
}
|
||||
val mainContainer = LinearLayout(this)
|
||||
mainContainer.orientation = LinearLayout.HORIZONTAL
|
||||
mainContainer.gravity = Gravity.CENTER_VERTICAL
|
||||
val mainContainerLayoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
mainContainer.layoutParams = mainContainerLayoutParams
|
||||
mainContainer.addView(lineView)
|
||||
mainContainer.addView(titleContainer)
|
||||
return mainContainer
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Line View
|
||||
private class LineView : RelativeLayout {
|
||||
private lateinit var location: Location
|
||||
private var dotAnimationStartDelay = 0.0f
|
||||
private var dotAnimationRepeatInterval = 0.0f
|
||||
|
||||
enum class Location {
|
||||
Top, Middle, Bottom
|
||||
}
|
||||
|
||||
constructor(context: Context, location: Location, dotAnimationStartDelay: Float, dotAnimationRepeatInterval: Float) : super(context) {
|
||||
this.location = location
|
||||
this.dotAnimationStartDelay = dotAnimationStartDelay
|
||||
this.dotAnimationRepeatInterval = dotAnimationRepeatInterval
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
throw Exception("Use LineView(context:location:dotAnimationStartDelay:dotAnimationRepeatInterval:) instead.")
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
throw Exception("Use LineView(context:location:dotAnimationStartDelay:dotAnimationRepeatInterval:) instead.")
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
throw Exception("Use LineView(context:location:dotAnimationStartDelay:dotAnimationRepeatInterval:) instead.")
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
throw Exception("Use LineView(context:location:dotAnimationStartDelay:dotAnimationRepeatInterval:) instead.")
|
||||
}
|
||||
|
||||
private fun setUpViewHierarchy() {
|
||||
val lineView = View(context)
|
||||
lineView.setBackgroundColor(resources.getColorWithID(R.color.text, context.theme))
|
||||
val lineViewHeight = when (location) {
|
||||
Location.Top, Location.Bottom -> resources.getDimensionPixelSize(R.dimen.path_row_height) / 2
|
||||
Location.Middle -> resources.getDimensionPixelSize(R.dimen.path_row_height)
|
||||
}
|
||||
val lineViewLayoutParams = LayoutParams(1, lineViewHeight)
|
||||
when (location) {
|
||||
Location.Top -> lineViewLayoutParams.addRule(ALIGN_PARENT_BOTTOM)
|
||||
Location.Middle, Location.Bottom -> lineViewLayoutParams.addRule(ALIGN_PARENT_TOP)
|
||||
}
|
||||
lineViewLayoutParams.addRule(CENTER_HORIZONTAL)
|
||||
lineView.layoutParams = lineViewLayoutParams
|
||||
addView(lineView)
|
||||
val dotView = View(context)
|
||||
dotView.setBackgroundResource(R.drawable.accent_dot)
|
||||
val dotViewSize = resources.getDimensionPixelSize(R.dimen.path_row_dot_size)
|
||||
val dotViewLayoutParams = LayoutParams(dotViewSize, dotViewSize)
|
||||
dotViewLayoutParams.addRule(CENTER_IN_PARENT)
|
||||
dotView.layoutParams = dotViewLayoutParams
|
||||
addView(dotView)
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user