mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-18 05:57:44 +00:00
Clean
This commit is contained in:
parent
5d34314a00
commit
d831274920
@ -18,7 +18,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="32dp"
|
android:layout_marginTop="32dp"
|
||||||
app:labeledEditText_background="@color/loki_darkest_gray"
|
app:labeledEditText_background="@color/loki_darkest_gray"
|
||||||
app:labeledEditText_label="@string/activity_new_conversation_public_key_edit_text_label"/>
|
app:labeledEditText_label="@string/fragment_new_conversation_public_key_edit_text_label"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/explanationTextView"
|
android:id="@+id/explanationTextView"
|
||||||
@ -26,7 +26,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="@string/activity_new_conversation_public_key_explanation" />
|
android:text="@string/fragment_new_conversation_public_key_explanation" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/qrCodeButton"
|
android:id="@+id/qrCodeButton"
|
||||||
@ -35,7 +35,7 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:background="@color/transparent"
|
android:background="@color/transparent"
|
||||||
android:textColor="@color/signal_primary"
|
android:textColor="@color/signal_primary"
|
||||||
android:text="@string/activity_new_conversation_qr_code_button_title"
|
android:text="@string/fragment_new_conversation_qr_code_button_title"
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
android:stateListAnimator="@null" />
|
android:stateListAnimator="@null" />
|
||||||
|
|
||||||
@ -52,7 +52,7 @@
|
|||||||
app:cpb_colorProgress="@color/textsecure_primary"
|
app:cpb_colorProgress="@color/textsecure_primary"
|
||||||
app:cpb_cornerRadius="4dp"
|
app:cpb_cornerRadius="4dp"
|
||||||
app:cpb_selectorIdle="@drawable/progress_button_state"
|
app:cpb_selectorIdle="@drawable/progress_button_state"
|
||||||
app:cpb_textIdle="@string/activity_new_conversation_next_button_title" />
|
app:cpb_textIdle="@string/fragment_new_conversation_next_button_title" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
app:camera="0" />
|
app:camera="0" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/overlay"
|
android:id="@+id/overlayView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -1585,12 +1585,12 @@
|
|||||||
<!-- Contact selection activity -->
|
<!-- Contact selection activity -->
|
||||||
<string name="activity_contact_selection_search_bar_placeholder">Search by name or public key</string>
|
<string name="activity_contact_selection_search_bar_placeholder">Search by name or public key</string>
|
||||||
<!-- New conversation activity -->
|
<!-- New conversation activity -->
|
||||||
<string name="activity_new_conversation_title">New Conversation</string>
|
<string name="fragment_new_conversation_title">New Conversation</string>
|
||||||
<string name="activity_new_conversation_public_key_edit_text_label">Public Key</string>
|
<string name="fragment_new_conversation_public_key_edit_text_label">Public Key</string>
|
||||||
<string name="activity_new_conversation_public_key_explanation">Enter the public key of the person you\'d like to securely message. They can share their public key with you by going into Loki Messenger\'s in-app settings and clicking \"Share Public Key\".</string>
|
<string name="fragment_new_conversation_public_key_explanation">Enter the public key of the person you\'d like to securely message. They can share their public key with you by going into Loki Messenger\'s in-app settings and clicking \"Share Public Key\".</string>
|
||||||
<string name="activity_new_conversation_qr_code_button_title">Scan a QR Code Instead</string>
|
<string name="fragment_new_conversation_qr_code_button_title">Scan a QR Code Instead</string>
|
||||||
<string name="activity_new_conversation_next_button_title">Next</string>
|
<string name="fragment_new_conversation_next_button_title">Next</string>
|
||||||
<string name="activity_new_conversation_invalid_public_key_message">Invalid Public Key</string>
|
<string name="fragment_new_conversation_invalid_public_key_message">Invalid Public Key</string>
|
||||||
<!-- Friend request view -->
|
<!-- Friend request view -->
|
||||||
<string name="view_friend_request_accept_button_title">Accept</string>
|
<string name="view_friend_request_accept_button_title">Accept</string>
|
||||||
<string name="view_friend_request_reject_button_title">Reject</string>
|
<string name="view_friend_request_reject_button_title">Reject</string>
|
||||||
|
@ -71,11 +71,11 @@ public class DeviceActivity extends PassphraseRequiredActionBarActivity
|
|||||||
this.deviceListFragment.setAddDeviceButtonListener(this);
|
this.deviceListFragment.setAddDeviceButtonListener(this);
|
||||||
this.deviceAddFragment.setScanListener(this);
|
this.deviceAddFragment.setScanListener(this);
|
||||||
|
|
||||||
if (getIntent().getBooleanExtra("add", false)) {
|
// if (getIntent().getBooleanExtra("add", false)) {
|
||||||
initFragment(android.R.id.content, deviceAddFragment, dynamicLanguage.getCurrentLocale());
|
initFragment(android.R.id.content, deviceAddFragment, dynamicLanguage.getCurrentLocale());
|
||||||
} else {
|
// } else {
|
||||||
initFragment(android.R.id.content, deviceListFragment, dynamicLanguage.getCurrentLocale());
|
// initFragment(android.R.id.content, deviceListFragment, dynamicLanguage.getCurrentLocale());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,7 +53,7 @@ public class NewConversationActivity extends ContactSelectionActivity {
|
|||||||
boolean isValid = PublicKeyValidation.isValid(number);
|
boolean isValid = PublicKeyValidation.isValid(number);
|
||||||
|
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
Toast.makeText(this, R.string.activity_new_conversation_invalid_public_key_message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.fragment_new_conversation_invalid_public_key_message, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class NewConversationActivity : PassphraseRequiredActionBarActivity(), ScanListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(bundle: Bundle?, isReady: Boolean) {
|
override fun onCreate(bundle: Bundle?, isReady: Boolean) {
|
||||||
supportActionBar!!.setTitle(R.string.activity_new_conversation_title)
|
supportActionBar!!.setTitle(R.string.fragment_new_conversation_title)
|
||||||
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
|
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
|
||||||
val fragment = NewConversationFragment()
|
val fragment = NewConversationFragment()
|
||||||
initFragment(android.R.id.content, fragment, null)
|
initFragment(android.R.id.content, fragment, null)
|
||||||
@ -51,7 +51,7 @@ class NewConversationActivity : PassphraseRequiredActionBarActivity(), ScanListe
|
|||||||
.withPermanentDenialDialog(getString(R.string.fragment_qr_code_camera_permission_dialog_message))
|
.withPermanentDenialDialog(getString(R.string.fragment_qr_code_camera_permission_dialog_message))
|
||||||
.onAllGranted {
|
.onAllGranted {
|
||||||
val fragment = ScanQRCodeFragment()
|
val fragment = ScanQRCodeFragment()
|
||||||
fragment.setScanListener(this)
|
fragment.scanListener = this
|
||||||
supportFragmentManager.beginTransaction().replace(android.R.id.content, fragment).addToBackStack(null).commitAllowingStateLoss()
|
supportFragmentManager.beginTransaction().replace(android.R.id.content, fragment).addToBackStack(null).commitAllowingStateLoss()
|
||||||
}
|
}
|
||||||
.onAnyDenied { Toast.makeText(this, R.string.fragment_qr_code_camera_permission_denied_message, Toast.LENGTH_SHORT).show() }
|
.onAnyDenied { Toast.makeText(this, R.string.fragment_qr_code_camera_permission_denied_message, Toast.LENGTH_SHORT).show() }
|
||||||
@ -75,7 +75,7 @@ class NewConversationActivity : PassphraseRequiredActionBarActivity(), ScanListe
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.activity_new_conversation_invalid_public_key_message, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.fragment_new_conversation_invalid_public_key_message, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,13 +5,13 @@ import android.support.v4.app.Fragment
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import kotlinx.android.synthetic.main.activity_new_conversation.*
|
import kotlinx.android.synthetic.main.fragment_new_conversation.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
|
|
||||||
class NewConversationFragment() : Fragment() {
|
class NewConversationFragment() : Fragment() {
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.activity_new_conversation, container, false)
|
return inflater.inflate(R.layout.fragment_new_conversation, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
@ -30,6 +30,6 @@ class NewConversationFragment() : Fragment() {
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
val activity = activity as NewConversationActivity
|
val activity = activity as NewConversationActivity
|
||||||
activity.supportActionBar!!.setTitle(R.string.activity_new_conversation_title)
|
activity.supportActionBar!!.setTitle(R.string.fragment_new_conversation_title)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,98 +1,58 @@
|
|||||||
package org.thoughtcrime.securesms.loki
|
package org.thoughtcrime.securesms.loki
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewAnimationUtils
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.animation.DecelerateInterpolator
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import kotlinx.android.synthetic.main.fragment_scan_qr_code.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.components.camera.CameraView
|
|
||||||
import org.thoughtcrime.securesms.qr.ScanListener
|
import org.thoughtcrime.securesms.qr.ScanListener
|
||||||
import org.thoughtcrime.securesms.qr.ScanningThread
|
import org.thoughtcrime.securesms.qr.ScanningThread
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil
|
|
||||||
|
|
||||||
class ScanQRCodeFragment : Fragment() {
|
class ScanQRCodeFragment : Fragment() {
|
||||||
|
private val scanningThread = ScanningThread()
|
||||||
|
var scanListener: ScanListener? = null
|
||||||
|
set(value) { field = value; scanningThread.setScanListener(scanListener) }
|
||||||
|
|
||||||
private var container: ViewGroup? = null
|
override fun onCreateView(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, bundle: Bundle?): View? {
|
||||||
private var overlay: LinearLayout? = null
|
return layoutInflater.inflate(R.layout.fragment_scan_qr_code, viewGroup, false)
|
||||||
private var scannerView: CameraView? = null
|
|
||||||
private var scanningThread: ScanningThread? = null
|
|
||||||
private var scanListener: ScanListener? = null
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, viewGroup: ViewGroup?, bundle: Bundle?): View? {
|
|
||||||
this.container = ViewUtil.inflate(inflater, viewGroup!!, R.layout.fragment_scan_qr_code)
|
|
||||||
this.overlay = ViewUtil.findById(this.container!!, R.id.overlay)
|
|
||||||
this.scannerView = ViewUtil.findById(this.container!!, R.id.cameraView)
|
|
||||||
|
|
||||||
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
||||||
this.overlay!!.orientation = LinearLayout.HORIZONTAL
|
|
||||||
} else {
|
|
||||||
this.overlay!!.orientation = LinearLayout.VERTICAL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
override fun onViewCreated(view: View, bundle: Bundle?) {
|
||||||
this.container!!.addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
|
super.onViewCreated(view, bundle)
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
when (resources.configuration.orientation) {
|
||||||
override fun onLayoutChange(v: View, left: Int, top: Int, right: Int, bottom: Int,
|
Configuration.ORIENTATION_LANDSCAPE -> overlayView.orientation = LinearLayout.HORIZONTAL
|
||||||
oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) {
|
else -> overlayView.orientation = LinearLayout.VERTICAL
|
||||||
v.removeOnLayoutChangeListener(this)
|
|
||||||
|
|
||||||
val reveal = ViewAnimationUtils.createCircularReveal(v, right, bottom, 0f, Math.hypot(right.toDouble(), bottom.toDouble()).toInt().toFloat())
|
|
||||||
reveal.interpolator = DecelerateInterpolator(2f)
|
|
||||||
reveal.duration = 800
|
|
||||||
reveal.start()
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.container
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
this.scanningThread = ScanningThread()
|
this.scanningThread.setScanListener(scanListener)
|
||||||
this.scanningThread!!.setScanListener(scanListener)
|
this.cameraView.onResume()
|
||||||
this.scannerView!!.onResume()
|
this.cameraView.setPreviewCallback(scanningThread)
|
||||||
this.scannerView!!.setPreviewCallback(scanningThread!!)
|
this.scanningThread.start()
|
||||||
this.scanningThread!!.start()
|
|
||||||
val activity = activity as NewConversationActivity
|
val activity = activity as NewConversationActivity
|
||||||
activity.supportActionBar!!.setTitle(R.string.fragment_scan_qr_code_title)
|
activity.supportActionBar!!.setTitle(R.string.fragment_scan_qr_code_title)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
this.scannerView!!.onPause()
|
this.cameraView.onPause()
|
||||||
this.scanningThread!!.stopScanning()
|
this.scanningThread.stopScanning()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfiguration: Configuration?) {
|
override fun onConfigurationChanged(newConfiguration: Configuration) {
|
||||||
super.onConfigurationChanged(newConfiguration)
|
super.onConfigurationChanged(newConfiguration)
|
||||||
|
this.cameraView.onPause()
|
||||||
this.scannerView!!.onPause()
|
when (newConfiguration.orientation) {
|
||||||
|
Configuration.ORIENTATION_LANDSCAPE -> overlayView.orientation = LinearLayout.HORIZONTAL
|
||||||
if (newConfiguration!!.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
else -> overlayView.orientation = LinearLayout.VERTICAL
|
||||||
overlay!!.orientation = LinearLayout.HORIZONTAL
|
|
||||||
} else {
|
|
||||||
overlay!!.orientation = LinearLayout.VERTICAL
|
|
||||||
}
|
}
|
||||||
|
cameraView.onResume()
|
||||||
this.scannerView!!.onResume()
|
cameraView.setPreviewCallback(scanningThread)
|
||||||
this.scannerView!!.setPreviewCallback(scanningThread!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setScanListener(scanListener: ScanListener) {
|
|
||||||
this.scanListener = scanListener
|
|
||||||
|
|
||||||
if (this.scanningThread != null) {
|
|
||||||
this.scanningThread!!.setScanListener(scanListener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user