mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-17 21:47:28 +00:00
Clean
This commit is contained in:
parent
5d34314a00
commit
d831274920
@ -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"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/explanationTextView"
|
||||
@ -26,7 +26,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/activity_new_conversation_public_key_explanation" />
|
||||
android:text="@string/fragment_new_conversation_public_key_explanation" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/qrCodeButton"
|
||||
@ -35,7 +35,7 @@
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@color/transparent"
|
||||
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:stateListAnimator="@null" />
|
||||
|
||||
@ -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" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
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="match_parent">
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
app:camera="0" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/overlay"
|
||||
android:id="@+id/overlayView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
@ -1585,12 +1585,12 @@
|
||||
<!-- Contact selection activity -->
|
||||
<string name="activity_contact_selection_search_bar_placeholder">Search by name or public key</string>
|
||||
<!-- New conversation activity -->
|
||||
<string name="activity_new_conversation_title">New Conversation</string>
|
||||
<string name="activity_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="activity_new_conversation_qr_code_button_title">Scan a QR Code Instead</string>
|
||||
<string name="activity_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_title">New Conversation</string>
|
||||
<string name="fragment_new_conversation_public_key_edit_text_label">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="fragment_new_conversation_qr_code_button_title">Scan a QR Code Instead</string>
|
||||
<string name="fragment_new_conversation_next_button_title">Next</string>
|
||||
<string name="fragment_new_conversation_invalid_public_key_message">Invalid Public Key</string>
|
||||
<!-- Friend request view -->
|
||||
<string name="view_friend_request_accept_button_title">Accept</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.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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user