mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Match iOS design changes
This commit is contained in:
parent
132b59347a
commit
0f6a7e88b6
@ -1,32 +0,0 @@
|
|||||||
<?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="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="32dp"
|
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:gravity="center_horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/explanationTextView"
|
|
||||||
style="@style/Signal.Text.Body"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="32dp"
|
|
||||||
android:text="@string/fragment_qr_code_explanation" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/qrCodeImageView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:background="@color/white" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
50
res/layout/view_qr_code.xml
Normal file
50
res/layout/view_qr_code.xml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?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:layout_margin="16dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/titleTextView"
|
||||||
|
style="@style/Signal.Text.Headline"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="@string/view_qr_code_title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/explanationTextView"
|
||||||
|
style="@style/Signal.Text.Body"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="@string/view_qr_code_explanation" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/qrCodeImageView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
android:background="@color/white" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancelButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:textColor="@color/signal_primary"
|
||||||
|
android:text="@string/view_qr_code_cancel_button_title"
|
||||||
|
android:elevation="0dp"
|
||||||
|
android:stateListAnimator="@null" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1606,13 +1606,14 @@
|
|||||||
<!-- Conversation activity -->
|
<!-- Conversation activity -->
|
||||||
<string name="activity_conversation_pending_friend_request_hint">Pending Friend Request…</string>
|
<string name="activity_conversation_pending_friend_request_hint">Pending Friend Request…</string>
|
||||||
<string name="activity_conversation_default_hint">New Message</string>
|
<string name="activity_conversation_default_hint">New Message</string>
|
||||||
<!-- QR code fragment -->
|
<!-- QR code view -->
|
||||||
<string name="fragment_qr_code_title">Your QR Code</string>
|
<string name="view_qr_code_title">Your QR Code</string>
|
||||||
<string name="fragment_qr_code_explanation">This is your personal QR code. Other people can scan it to start a secure conversation with you.</string>
|
<string name="view_qr_code_explanation">This is your personal QR code. Other people can scan it to start a secure conversation with you.</string>
|
||||||
<string name="fragment_qr_code_camera_permission_dialog_message">Loki Messenger needs camera access to scan QR codes.</string>
|
<string name="view_qr_code_cancel_button_title">Cancel</string>
|
||||||
<!-- Scan QR code fragment -->
|
<!-- Scan QR code fragment -->
|
||||||
<string name="fragment_scan_qr_code_title">Scan QR Code</string>
|
<string name="fragment_scan_qr_code_title">Scan QR Code</string>
|
||||||
<string name="fragment_scan_qr_code_explanation">Scan the QR code of the person you\'d like to securely message. They can find their QR code by going into Loki Messenger\'s in-app settings and clicking \"Show QR Code\".</string>
|
<string name="fragment_scan_qr_code_explanation">Scan the QR code of the person you\'d like to securely message. They can find their QR code by going into Loki Messenger\'s in-app settings and clicking \"Show QR Code\".</string>
|
||||||
|
<string name="fragment_scan_qr_code_camera_permission_dialog_message">Loki Messenger needs camera access to scan QR codes.</string>
|
||||||
<!-- Conversation activity -->
|
<!-- Conversation activity -->
|
||||||
<string name="activity_conversation_copy_public_key_button_title">Copy public key</string>
|
<string name="activity_conversation_copy_public_key_button_title">Copy public key</string>
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import android.support.v7.preference.Preference;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||||
import org.thoughtcrime.securesms.loki.QRCodeFragment;
|
import org.thoughtcrime.securesms.loki.QRCodeDialog;
|
||||||
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
||||||
import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
|
import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
|
||||||
import org.thoughtcrime.securesms.preferences.CorrectedPreferenceFragment;
|
import org.thoughtcrime.securesms.preferences.CorrectedPreferenceFragment;
|
||||||
@ -317,7 +317,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
startActivity(shareIntent);
|
startActivity(shareIntent);
|
||||||
break;
|
break;
|
||||||
case PREFERENCE_CATEGORY_QR_CODE:
|
case PREFERENCE_CATEGORY_QR_CODE:
|
||||||
fragment = new QRCodeFragment();
|
QRCodeDialog.INSTANCE.show(getContext());
|
||||||
break;
|
break;
|
||||||
case PREFERENCE_CATEGORY_SEED:
|
case PREFERENCE_CATEGORY_SEED:
|
||||||
File languageFileDirectory = new File(getContext().getApplicationInfo().dataDir);
|
File languageFileDirectory = new File(getContext().getApplicationInfo().dataDir);
|
||||||
|
@ -50,13 +50,13 @@ class NewConversationActivity : PassphraseRequiredActionBarActivity(), ScanListe
|
|||||||
Permissions.with(this)
|
Permissions.with(this)
|
||||||
.request(Manifest.permission.CAMERA)
|
.request(Manifest.permission.CAMERA)
|
||||||
.ifNecessary()
|
.ifNecessary()
|
||||||
.withPermanentDenialDialog(getString(R.string.fragment_qr_code_camera_permission_dialog_message))
|
.withPermanentDenialDialog(getString(R.string.fragment_scan_qr_code_camera_permission_dialog_message))
|
||||||
.onAllGranted {
|
.onAllGranted {
|
||||||
val fragment = ScanQRCodeFragment()
|
val fragment = ScanQRCodeFragment()
|
||||||
fragment.scanListener = 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_dialog_message, Toast.LENGTH_SHORT).show() }
|
.onAnyDenied { Toast.makeText(this, R.string.fragment_scan_qr_code_camera_permission_dialog_message, Toast.LENGTH_SHORT).show() }
|
||||||
.execute()
|
.execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
src/org/thoughtcrime/securesms/loki/QRCodeDialog.kt
Normal file
39
src/org/thoughtcrime/securesms/loki/QRCodeDialog.kt
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package org.thoughtcrime.securesms.loki
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.support.v7.app.AlertDialog
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import kotlinx.android.synthetic.main.view_qr_code.view.*
|
||||||
|
import network.loki.messenger.R
|
||||||
|
import org.thoughtcrime.securesms.qr.QrCode
|
||||||
|
import org.thoughtcrime.securesms.util.ServiceUtil
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
|
|
||||||
|
object QRCodeDialog {
|
||||||
|
|
||||||
|
fun show(context: Context) {
|
||||||
|
val view = QRCodeView(context)
|
||||||
|
val dialog = AlertDialog.Builder(context).setView(view).show()
|
||||||
|
view.onCancel = { dialog.dismiss() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class QRCodeView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : LinearLayout(context, attrs, defStyleAttr) {
|
||||||
|
var onCancel: (() -> Unit)? = null
|
||||||
|
|
||||||
|
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||||
|
constructor(context: Context) : this(context, null)
|
||||||
|
|
||||||
|
init {
|
||||||
|
inflate(getContext(), R.layout.view_qr_code, this)
|
||||||
|
val hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
|
val displayMetrics = DisplayMetrics()
|
||||||
|
ServiceUtil.getWindowManager(context).defaultDisplay.getMetrics(displayMetrics)
|
||||||
|
val size = displayMetrics.widthPixels - 2 * toPx(96, resources)
|
||||||
|
val qrCode = QrCode.create(hexEncodedPublicKey, size)
|
||||||
|
qrCodeImageView.setImageBitmap(qrCode)
|
||||||
|
cancelButton.setOnClickListener { onCancel?.invoke() }
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.loki
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.support.v4.app.Fragment
|
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import kotlinx.android.synthetic.main.fragment_qr_code.*
|
|
||||||
import network.loki.messenger.R
|
|
||||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity
|
|
||||||
import org.thoughtcrime.securesms.qr.QrCode
|
|
||||||
import org.thoughtcrime.securesms.util.ServiceUtil.getWindowManager
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
|
||||||
|
|
||||||
class QRCodeFragment : Fragment() {
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return inflater.inflate(R.layout.fragment_qr_code, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
val hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
|
||||||
val displayMetrics = DisplayMetrics()
|
|
||||||
getWindowManager(context).defaultDisplay.getMetrics(displayMetrics)
|
|
||||||
val size = displayMetrics.widthPixels - 2 * toPx(32, resources)
|
|
||||||
val qrCode = QrCode.create(hexEncodedPublicKey, size)
|
|
||||||
qrCodeImageView.setImageBitmap(qrCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
val activity = activity as ApplicationPreferencesActivity
|
|
||||||
activity.supportActionBar!!.setTitle(R.string.fragment_qr_code_title)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user