diff --git a/res/layout/activity_new_conversation.xml b/res/layout/fragment_new_conversation.xml
similarity index 89%
rename from res/layout/activity_new_conversation.xml
rename to res/layout/fragment_new_conversation.xml
index 13eb1f2896..c0246d83af 100644
--- a/res/layout/activity_new_conversation.xml
+++ b/res/layout/fragment_new_conversation.xml
@@ -18,7 +18,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
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"/>
+ android:text="@string/fragment_new_conversation_public_key_explanation" />
@@ -52,7 +52,7 @@
app:cpb_colorProgress="@color/textsecure_primary"
app:cpb_cornerRadius="4dp"
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" />
diff --git a/res/layout/fragment_qr_code.xml b/res/layout/fragment_qr_code.xml
index 98093f215b..8a3df0f20b 100644
--- a/res/layout/fragment_qr_code.xml
+++ b/res/layout/fragment_qr_code.xml
@@ -1,7 +1,6 @@
diff --git a/res/layout/fragment_scan_qr_code.xml b/res/layout/fragment_scan_qr_code.xml
index ab9407f515..e86ae68ba8 100644
--- a/res/layout/fragment_scan_qr_code.xml
+++ b/res/layout/fragment_scan_qr_code.xml
@@ -12,7 +12,7 @@
app:camera="0" />
Search by name or public key
- New Conversation
- Public Key
- 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\".
- Scan a QR Code Instead
- Next
- Invalid Public Key
+ New Conversation
+ Public Key
+ 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\".
+ Scan a QR Code Instead
+ Next
+ Invalid Public Key
Accept
Reject
diff --git a/src/org/thoughtcrime/securesms/DeviceActivity.java b/src/org/thoughtcrime/securesms/DeviceActivity.java
index dbed6f7902..a93f1c8ddb 100644
--- a/src/org/thoughtcrime/securesms/DeviceActivity.java
+++ b/src/org/thoughtcrime/securesms/DeviceActivity.java
@@ -71,11 +71,11 @@ public class DeviceActivity extends PassphraseRequiredActionBarActivity
this.deviceListFragment.setAddDeviceButtonListener(this);
this.deviceAddFragment.setScanListener(this);
- if (getIntent().getBooleanExtra("add", false)) {
+// if (getIntent().getBooleanExtra("add", false)) {
initFragment(android.R.id.content, deviceAddFragment, dynamicLanguage.getCurrentLocale());
- } else {
- initFragment(android.R.id.content, deviceListFragment, dynamicLanguage.getCurrentLocale());
- }
+// } else {
+// initFragment(android.R.id.content, deviceListFragment, dynamicLanguage.getCurrentLocale());
+// }
}
@Override
diff --git a/src/org/thoughtcrime/securesms/NewConversationActivity.java b/src/org/thoughtcrime/securesms/NewConversationActivity.java
index 8fd3f3aaa2..30871c5fcb 100644
--- a/src/org/thoughtcrime/securesms/NewConversationActivity.java
+++ b/src/org/thoughtcrime/securesms/NewConversationActivity.java
@@ -53,7 +53,7 @@ public class NewConversationActivity extends ContactSelectionActivity {
boolean isValid = PublicKeyValidation.isValid(number);
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;
}
diff --git a/src/org/thoughtcrime/securesms/loki/NewConversationActivity.kt b/src/org/thoughtcrime/securesms/loki/NewConversationActivity.kt
index e1b6d59ba4..21b8df4b7e 100644
--- a/src/org/thoughtcrime/securesms/loki/NewConversationActivity.kt
+++ b/src/org/thoughtcrime/securesms/loki/NewConversationActivity.kt
@@ -25,7 +25,7 @@ class NewConversationActivity : PassphraseRequiredActionBarActivity(), ScanListe
}
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)
val fragment = NewConversationFragment()
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))
.onAllGranted {
val fragment = ScanQRCodeFragment()
- fragment.setScanListener(this)
+ fragment.scanListener = this
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() }
@@ -75,7 +75,7 @@ class NewConversationActivity : PassphraseRequiredActionBarActivity(), ScanListe
startActivity(intent)
finish()
} 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()
}
}
}
\ No newline at end of file
diff --git a/src/org/thoughtcrime/securesms/loki/NewConversationFragment.kt b/src/org/thoughtcrime/securesms/loki/NewConversationFragment.kt
index 322cd6f74d..6b02093d2f 100644
--- a/src/org/thoughtcrime/securesms/loki/NewConversationFragment.kt
+++ b/src/org/thoughtcrime/securesms/loki/NewConversationFragment.kt
@@ -5,13 +5,13 @@ import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
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
class NewConversationFragment() : Fragment() {
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?) {
@@ -30,6 +30,6 @@ class NewConversationFragment() : Fragment() {
override fun onResume() {
super.onResume()
val activity = activity as NewConversationActivity
- activity.supportActionBar!!.setTitle(R.string.activity_new_conversation_title)
+ activity.supportActionBar!!.setTitle(R.string.fragment_new_conversation_title)
}
}
\ No newline at end of file
diff --git a/src/org/thoughtcrime/securesms/loki/ScanQRCodeFragment.kt b/src/org/thoughtcrime/securesms/loki/ScanQRCodeFragment.kt
index 322217dce4..a4686bef21 100644
--- a/src/org/thoughtcrime/securesms/loki/ScanQRCodeFragment.kt
+++ b/src/org/thoughtcrime/securesms/loki/ScanQRCodeFragment.kt
@@ -1,98 +1,58 @@
package org.thoughtcrime.securesms.loki
-import android.annotation.TargetApi
import android.content.res.Configuration
-import android.os.Build
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
-import android.view.ViewAnimationUtils
import android.view.ViewGroup
-import android.view.animation.DecelerateInterpolator
import android.widget.LinearLayout
+import kotlinx.android.synthetic.main.fragment_scan_qr_code.*
import network.loki.messenger.R
-import org.thoughtcrime.securesms.components.camera.CameraView
import org.thoughtcrime.securesms.qr.ScanListener
import org.thoughtcrime.securesms.qr.ScanningThread
-import org.thoughtcrime.securesms.util.ViewUtil
class ScanQRCodeFragment : Fragment() {
+ private val scanningThread = ScanningThread()
+ var scanListener: ScanListener? = null
+ set(value) { field = value; scanningThread.setScanListener(scanListener) }
- private var container: ViewGroup? = null
- private var overlay: LinearLayout? = null
- private var scannerView: CameraView? = null
- private var scanningThread: ScanningThread? = null
- private var scanListener: ScanListener? = null
+ override fun onCreateView(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, bundle: Bundle?): View? {
+ return layoutInflater.inflate(R.layout.fragment_scan_qr_code, viewGroup, false)
+ }
- 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
+ override fun onViewCreated(view: View, bundle: Bundle?) {
+ super.onViewCreated(view, bundle)
+ when (resources.configuration.orientation) {
+ Configuration.ORIENTATION_LANDSCAPE -> overlayView.orientation = LinearLayout.HORIZONTAL
+ else -> overlayView.orientation = LinearLayout.VERTICAL
}
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- this.container!!.addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- override fun onLayoutChange(v: View, left: Int, top: Int, right: Int, bottom: Int,
- oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) {
- 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() {
super.onResume()
- this.scanningThread = ScanningThread()
- this.scanningThread!!.setScanListener(scanListener)
- this.scannerView!!.onResume()
- this.scannerView!!.setPreviewCallback(scanningThread!!)
- this.scanningThread!!.start()
+ this.scanningThread.setScanListener(scanListener)
+ this.cameraView.onResume()
+ this.cameraView.setPreviewCallback(scanningThread)
+ this.scanningThread.start()
val activity = activity as NewConversationActivity
activity.supportActionBar!!.setTitle(R.string.fragment_scan_qr_code_title)
}
override fun onPause() {
super.onPause()
- this.scannerView!!.onPause()
- this.scanningThread!!.stopScanning()
+ this.cameraView.onPause()
+ this.scanningThread.stopScanning()
}
- override fun onConfigurationChanged(newConfiguration: Configuration?) {
+ override fun onConfigurationChanged(newConfiguration: Configuration) {
super.onConfigurationChanged(newConfiguration)
-
- this.scannerView!!.onPause()
-
- if (newConfiguration!!.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- overlay!!.orientation = LinearLayout.HORIZONTAL
- } else {
- overlay!!.orientation = LinearLayout.VERTICAL
+ this.cameraView.onPause()
+ when (newConfiguration.orientation) {
+ Configuration.ORIENTATION_LANDSCAPE -> overlayView.orientation = LinearLayout.HORIZONTAL
+ else -> overlayView.orientation = LinearLayout.VERTICAL
}
-
- this.scannerView!!.onResume()
- this.scannerView!!.setPreviewCallback(scanningThread!!)
+ cameraView.onResume()
+ cameraView.setPreviewCallback(scanningThread)
}
-
- fun setScanListener(scanListener: ScanListener) {
- this.scanListener = scanListener
-
- if (this.scanningThread != null) {
- this.scanningThread!!.setScanListener(scanListener)
- }
- }
-
-
}
\ No newline at end of file