mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Add UI
This commit is contained in:
parent
13d42f542c
commit
b676c25930
@ -477,8 +477,12 @@
|
|||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" />
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" />
|
||||||
|
|
||||||
<activity android:name="org.thoughtcrime.securesms.loki.NewConversationActivity"
|
<activity android:name="org.thoughtcrime.securesms.loki.NewConversationActivity"
|
||||||
android:windowSoftInputMode="stateAlwaysVisible"
|
android:windowSoftInputMode="stateAlwaysVisible"
|
||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" />
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" />
|
||||||
|
|
||||||
|
<activity android:name="org.thoughtcrime.securesms.loki.AddPublicChatActivity"
|
||||||
|
android:windowSoftInputMode="stateAlwaysVisible"
|
||||||
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" />
|
||||||
<!-- Loki -->
|
<!-- Loki -->
|
||||||
|
|
||||||
<service android:enabled="true" android:name="org.thoughtcrime.securesms.service.WebRtcCallService"/>
|
<service android:enabled="true" android:name="org.thoughtcrime.securesms.service.WebRtcCallService"/>
|
||||||
|
48
res/layout/fragment_add_public_chat.xml
Normal file
48
res/layout/fragment_add_public_chat.xml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.components.LabeledEditText
|
||||||
|
android:id="@+id/serverUrlEditText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
app:labeledEditText_background="@color/loki_darkest_gray"
|
||||||
|
app:labeledEditText_label="@string/fragment_add_public_chat_server_url_edit_text_label"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/explanationTextView"
|
||||||
|
style="@style/Signal.Text.Body"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="@string/fragment_add_public_chat_explanation" />
|
||||||
|
|
||||||
|
<com.dd.CircularProgressButton
|
||||||
|
android:id="@+id/addButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginBottom="32dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:background="@color/signal_primary"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:cpb_colorIndicator="@color/white"
|
||||||
|
app:cpb_colorProgress="@color/textsecure_primary"
|
||||||
|
app:cpb_cornerRadius="4dp"
|
||||||
|
app:cpb_selectorIdle="@drawable/progress_button_state"
|
||||||
|
app:cpb_textIdle="@string/fragment_add_public_chat_add_button_title" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -1575,6 +1575,7 @@
|
|||||||
<string name="activity_settings_public_key_copied_message">Copied to clipboard</string>
|
<string name="activity_settings_public_key_copied_message">Copied to clipboard</string>
|
||||||
<string name="activity_settings_share_public_key_button_title">Share Public Key</string>
|
<string name="activity_settings_share_public_key_button_title">Share Public Key</string>
|
||||||
<string name="activity_settings_show_qr_code_button_title">Show QR Code</string>
|
<string name="activity_settings_show_qr_code_button_title">Show QR Code</string>
|
||||||
|
<string name="activity_settings_add_public_chat_button_title">Add Public Chat</string>
|
||||||
<string name="activity_settings_link_device_button_title">Link Device</string>
|
<string name="activity_settings_link_device_button_title">Link Device</string>
|
||||||
<string name="activity_settings_show_seed_button_title">Show Seed</string>
|
<string name="activity_settings_show_seed_button_title">Show Seed</string>
|
||||||
<string name="activity_settings_seed_dialog_title">Your Seed</string>
|
<string name="activity_settings_seed_dialog_title">Your Seed</string>
|
||||||
@ -1598,6 +1599,15 @@
|
|||||||
<string name="fragment_new_conversation_next_button_title">Next</string>
|
<string name="fragment_new_conversation_next_button_title">Next</string>
|
||||||
<string name="fragment_new_conversation_invalid_public_key_message">Invalid public key</string>
|
<string name="fragment_new_conversation_invalid_public_key_message">Invalid public key</string>
|
||||||
<string name="fragment_new_conversation_note_to_self_not_supported_message">Please enter the public key of the person you\'d like to message</string>
|
<string name="fragment_new_conversation_note_to_self_not_supported_message">Please enter the public key of the person you\'d like to message</string>
|
||||||
|
<!-- Add public chat activity -->
|
||||||
|
<string name="fragment_add_public_chat_title">Add Public Chat</string>
|
||||||
|
<string name="fragment_add_public_chat_server_url_edit_text_label">Server URL</string>
|
||||||
|
<string name="fragment_add_public_chat_explanation">Enter the full URL of the public server. E.g https://public-server.url</string>
|
||||||
|
<string name="fragment_add_public_chat_add_button_title">Add</string>
|
||||||
|
<string name="fragment_add_public_chat_adding_server_button_title">Adding Server...</string>
|
||||||
|
<string name="fragment_add_public_chat_invalid_url_message">Invalid Url provided</string>
|
||||||
|
<string name="fragment_add_public_chat_failed_connect_message">Failed to connect to server</string>
|
||||||
|
<string name="fragment_add_public_chat_success_message">Added public chat server</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>
|
||||||
|
@ -41,6 +41,10 @@
|
|||||||
android:title="@string/activity_settings_show_qr_code_button_title"
|
android:title="@string/activity_settings_show_qr_code_button_title"
|
||||||
android:icon="@drawable/icon_qr_code"/>
|
android:icon="@drawable/icon_qr_code"/>
|
||||||
|
|
||||||
|
<Preference android:key="preference_category_public_chat"
|
||||||
|
android:title="@string/activity_settings_add_public_chat_button_title"
|
||||||
|
android:icon="@drawable/ic_group_white_24dp"/>
|
||||||
|
|
||||||
<Preference android:key="preference_category_link_device"
|
<Preference android:key="preference_category_link_device"
|
||||||
android:title="@string/activity_settings_link_device_button_title"
|
android:title="@string/activity_settings_link_device_button_title"
|
||||||
android:icon="@drawable/icon_link"/>
|
android:icon="@drawable/icon_link"/>
|
||||||
|
@ -40,8 +40,10 @@ 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.AddPublicChatActivity;
|
||||||
import org.thoughtcrime.securesms.loki.DeviceLinkingDialog;
|
import org.thoughtcrime.securesms.loki.DeviceLinkingDialog;
|
||||||
import org.thoughtcrime.securesms.loki.DeviceLinkingView;
|
import org.thoughtcrime.securesms.loki.DeviceLinkingView;
|
||||||
|
import org.thoughtcrime.securesms.loki.NewConversationActivity;
|
||||||
import org.thoughtcrime.securesms.loki.QRCodeDialog;
|
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;
|
||||||
@ -85,6 +87,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
private static final String PREFERENCE_CATEGORY_QR_CODE = "preference_category_qr_code";
|
private static final String PREFERENCE_CATEGORY_QR_CODE = "preference_category_qr_code";
|
||||||
private static final String PREFERENCE_CATEGORY_LINK_DEVICE = "preference_category_link_device";
|
private static final String PREFERENCE_CATEGORY_LINK_DEVICE = "preference_category_link_device";
|
||||||
private static final String PREFERENCE_CATEGORY_SEED = "preference_category_seed";
|
private static final String PREFERENCE_CATEGORY_SEED = "preference_category_seed";
|
||||||
|
private static final String PREFERENCE_CATEGORY_PUBLIC_CHAT = "preference_category_public_chat";
|
||||||
|
|
||||||
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||||
@ -187,6 +190,9 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_PUBLIC_KEY));
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_PUBLIC_KEY));
|
||||||
this.findPreference(PREFERENCE_CATEGORY_QR_CODE)
|
this.findPreference(PREFERENCE_CATEGORY_QR_CODE)
|
||||||
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_QR_CODE));
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_QR_CODE));
|
||||||
|
this.findPreference(PREFERENCE_CATEGORY_PUBLIC_CHAT)
|
||||||
|
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_PUBLIC_CHAT));
|
||||||
|
|
||||||
Preference linkDevicePreference = this.findPreference(PREFERENCE_CATEGORY_LINK_DEVICE);
|
Preference linkDevicePreference = this.findPreference(PREFERENCE_CATEGORY_LINK_DEVICE);
|
||||||
// Hide if this is a slave device
|
// Hide if this is a slave device
|
||||||
linkDevicePreference.setVisible(isMasterDevice);
|
linkDevicePreference.setVisible(isMasterDevice);
|
||||||
@ -256,6 +262,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
Drawable qrCode = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_qr_code));
|
Drawable qrCode = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_qr_code));
|
||||||
Drawable linkDevice = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_link));
|
Drawable linkDevice = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_link));
|
||||||
Drawable seed = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_seedling));
|
Drawable seed = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_seedling));
|
||||||
|
Drawable publicChat = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_group_white_24dp));
|
||||||
|
|
||||||
int[] tintAttr = new int[]{R.attr.pref_icon_tint};
|
int[] tintAttr = new int[]{R.attr.pref_icon_tint};
|
||||||
TypedArray typedArray = context.obtainStyledAttributes(tintAttr);
|
TypedArray typedArray = context.obtainStyledAttributes(tintAttr);
|
||||||
@ -273,6 +280,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
DrawableCompat.setTint(qrCode, color);
|
DrawableCompat.setTint(qrCode, color);
|
||||||
DrawableCompat.setTint(linkDevice, color);
|
DrawableCompat.setTint(linkDevice, color);
|
||||||
DrawableCompat.setTint(seed, color);
|
DrawableCompat.setTint(seed, color);
|
||||||
|
DrawableCompat.setTint(publicChat, color);
|
||||||
|
|
||||||
// this.findPreference(PREFERENCE_CATEGORY_SMS_MMS).setIcon(sms);
|
// this.findPreference(PREFERENCE_CATEGORY_SMS_MMS).setIcon(sms);
|
||||||
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS).setIcon(notifications);
|
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS).setIcon(notifications);
|
||||||
@ -285,6 +293,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
this.findPreference(PREFERENCE_CATEGORY_QR_CODE).setIcon(qrCode);
|
this.findPreference(PREFERENCE_CATEGORY_QR_CODE).setIcon(qrCode);
|
||||||
this.findPreference(PREFERENCE_CATEGORY_LINK_DEVICE).setIcon(linkDevice);
|
this.findPreference(PREFERENCE_CATEGORY_LINK_DEVICE).setIcon(linkDevice);
|
||||||
this.findPreference(PREFERENCE_CATEGORY_SEED).setIcon(seed);
|
this.findPreference(PREFERENCE_CATEGORY_SEED).setIcon(seed);
|
||||||
|
this.findPreference(PREFERENCE_CATEGORY_PUBLIC_CHAT).setIcon(publicChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CategoryClickListener implements Preference.OnPreferenceClickListener {
|
private class CategoryClickListener implements Preference.OnPreferenceClickListener {
|
||||||
@ -369,6 +378,9 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PREFERENCE_CATEGORY_PUBLIC_CHAT:
|
||||||
|
startActivity(new Intent(getActivity(), AddPublicChatActivity.class));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
81
src/org/thoughtcrime/securesms/loki/AddPublicChatActivity.kt
Normal file
81
src/org/thoughtcrime/securesms/loki/AddPublicChatActivity.kt
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
package org.thoughtcrime.securesms.loki
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Patterns
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.Toast
|
||||||
|
import kotlinx.android.synthetic.main.activity_account_details.*
|
||||||
|
import kotlinx.android.synthetic.main.fragment_add_public_chat.*
|
||||||
|
import network.loki.messenger.R
|
||||||
|
import nl.komponents.kovenant.ui.failUi
|
||||||
|
import nl.komponents.kovenant.ui.successUi
|
||||||
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
|
import org.thoughtcrime.securesms.conversation.ConversationActivity
|
||||||
|
import org.thoughtcrime.securesms.database.Address
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
|
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
|
import org.thoughtcrime.securesms.util.DynamicTheme
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
|
import org.whispersystems.signalservice.loki.api.LokiGroupChatAPI
|
||||||
|
import org.whispersystems.signalservice.loki.utilities.Analytics
|
||||||
|
import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation
|
||||||
|
|
||||||
|
class AddPublicChatActivity : PassphraseRequiredActionBarActivity() {
|
||||||
|
private val dynamicTheme = DynamicTheme()
|
||||||
|
|
||||||
|
override fun onPreCreate() {
|
||||||
|
dynamicTheme.onCreate(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(bundle: Bundle?, isReady: Boolean) {
|
||||||
|
supportActionBar!!.setTitle(R.string.fragment_add_public_chat_title)
|
||||||
|
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
|
||||||
|
setContentView(R.layout.fragment_add_public_chat)
|
||||||
|
setButtonEnabled(true)
|
||||||
|
addButton.setOnClickListener { addPublicChatIfPossible() }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
dynamicTheme.onResume(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (item.itemId == android.R.id.home) {
|
||||||
|
onBackPressed()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addPublicChatIfPossible() {
|
||||||
|
val inputMethodManager = getSystemService(BaseActionBarActivity.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(serverUrlEditText.windowToken, 0)
|
||||||
|
|
||||||
|
val url = serverUrlEditText.text.toString().toLowerCase()
|
||||||
|
if (!Patterns.WEB_URL.matcher(url).matches()) { return Toast.makeText(this, R.string.fragment_add_public_chat_invalid_url_message, Toast.LENGTH_SHORT).show() }
|
||||||
|
|
||||||
|
setButtonEnabled(false)
|
||||||
|
|
||||||
|
ApplicationContext.getInstance(this).lokiPublicChatManager.addChat(url, 1).successUi {
|
||||||
|
Toast.makeText(this, R.string.fragment_add_public_chat_success_message, Toast.LENGTH_SHORT).show()
|
||||||
|
finish()
|
||||||
|
}.failUi {
|
||||||
|
setButtonEnabled(true)
|
||||||
|
Toast.makeText(this, R.string.fragment_add_public_chat_failed_connect_message, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setButtonEnabled(enabled: Boolean) {
|
||||||
|
addButton.isEnabled = enabled
|
||||||
|
val text = if (enabled) R.string.fragment_add_public_chat_add_button_title else R.string.fragment_add_public_chat_adding_server_button_title
|
||||||
|
addButton.setText(text)
|
||||||
|
serverUrlEditText.isEnabled = enabled
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,7 @@ class LokiPublicChatManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fun addChat(server: String, channel: Long): Promise<LokiGroupChat, Exception> {
|
public fun addChat(server: String, channel: Long): Promise<LokiGroupChat, Exception> {
|
||||||
val groupChatAPI = ApplicationContext.getInstance(context).lokiGroupChatAPI ?: return Promise.ofFail(IllegalStateException())
|
val groupChatAPI = ApplicationContext.getInstance(context).lokiGroupChatAPI ?: return Promise.ofFail(IllegalStateException("LokiGroupChatAPI is not set!"))
|
||||||
return groupChatAPI.getAuthToken(server).bind {
|
return groupChatAPI.getAuthToken(server).bind {
|
||||||
groupChatAPI.getChannelInfo(channel, server)
|
groupChatAPI.getChannelInfo(channel, server)
|
||||||
}.map {
|
}.map {
|
||||||
|
Loading…
Reference in New Issue
Block a user