added dedicated scan button

This commit is contained in:
Daniel Gultsch 2018-02-24 21:57:42 +01:00
parent e0317cfa14
commit b0bec2c390
15 changed files with 37 additions and 14 deletions

View file

@ -73,6 +73,7 @@ android {
archivesBaseName += "-$versionName"
applicationId "eu.siacs.conversations"
resValue "string", "applicationId", applicationId
resValue "string", "app_name", "Conversations"
}
dataBinding {

View file

@ -257,6 +257,9 @@ public class ConversationActivity extends XmppActivity implements OnConversation
return true;
}
break;
case R.id.action_scan_qr_code:
UriHandlerActivity.scan(this);
return true;
}
return super.onOptionsItemSelected(item);
}

View file

@ -1616,29 +1616,31 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
private void reInit(Conversation conversation) {
Log.d(Config.LOGTAG, "reInit()");
reInit(conversation, false);
}
private void reInit(Conversation conversation, boolean restore) {
if (conversation == null) {
Log.d(Config.LOGTAG, "conversation was null :(");
return;
}
if (this.activity == null) {
Log.d(Config.LOGTAG, "activity was null");
this.conversation = conversation;
return;
}
Log.d(Config.LOGTAG, "reInit(restore="+Boolean.toString(restore)+")");
setupIme();
if (this.conversation != null) {
final String msg = this.binding.textinput.getText().toString();
if (this.conversation.setNextMessage(msg)) {
activity.xmppConnectionService.updateConversation(conversation);
}
if (this.conversation != conversation) {
if (this.conversation != conversation && !restore) {
updateChatState(this.conversation, msg);
messageListAdapter.stopAudioPlayer();
}
this.conversation.trim();
if (!restore) {
this.conversation.trim();
}
}
@ -2259,7 +2261,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
clearPending();
return;
}
reInit(conversation);
reInit(conversation, true);
}
ActivityResult activityResult = postponedActivityResult.pop();
if (activityResult != null) {

View file

@ -626,10 +626,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showJoinConferenceDialog(null);
return true;
case R.id.action_scan_qr_code:
Intent intent = new Intent(this, UriHandlerActivity.class);
intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
UriHandlerActivity.scan(this);
return true;
case R.id.action_hide_offline:
mHideOfflineContacts = !item.isChecked();

View file

@ -1,5 +1,6 @@
package eu.siacs.conversations.ui;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity ;
import android.content.Intent;
import android.net.Uri;
@ -9,6 +10,7 @@ import java.util.Arrays;
import java.util.List;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.persistance.DatabaseBackend;
import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.utils.zxing.IntentIntegrator;
@ -103,4 +105,11 @@ public class UriHandlerActivity extends AppCompatActivity {
finish();
super.onActivityResult(requestCode, requestCode, intent);
}
public static void scan(Activity activity) {
Intent intent = new Intent(activity, UriHandlerActivity.class);
intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
activity.startActivity(intent);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

View file

@ -20,6 +20,6 @@
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:src="?attr/icon_new"/>
android:src="@drawable/ic_chat_white_24dp"/>
</FrameLayout>
</layout>

View file

@ -1,5 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_scan_qr_code"
android:title="@string/scan_qr_code"
app:showAsAction="always"
android:visible="@bool/show_qr_code_scan"
android:icon="?attr/icon_scan_qr_code"/>
<item
android:id="@+id/action_accounts"
android:orderInCategory="90"

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="show_qr_code_scan">false</bool>
</resources>

View file

@ -41,4 +41,5 @@
<bool name="never_send">false</bool>
<bool name="return_to_previous">false</bool>
<bool name="validate_hostname">false</bool>
<bool name="show_qr_code_scan">true</bool>
</resources>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">Conversations</string>
<string name="action_settings">Settings</string>
<string name="action_add">New conversation</string>
<string name="action_accounts">Manage accounts</string>