Skip to content

Commit

Permalink
LINESDK-198 Move send message dialog to internal page (line#13)
Browse files Browse the repository at this point in the history
* NO-ISSUE Internal repo master branch rebase open source repo master branch (line#12)

* support "amr" in id_token

* new feature: add a new param to set the login pages language (line#16)

* Fix English (line#20)

Fixed some grammar and style issues in comments.

* update version to 5.1

* config travis build (line#24)

* IMPROVE: get expected `IdToken.Issuer` from OpenId Discovery Document (line#26)

* LINESDK-198 Move send message dialog to internal page

* LINESDK-198 Limit scopes for sharing message to only for internal usage
  • Loading branch information
mutant0113 committed Aug 19, 2019
1 parent 74fe44d commit 90868d5
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 51 deletions.
25 changes: 1 addition & 24 deletions app/src/main/java/com/linecorp/linesdktest/ApisFragment.java
@@ -1,6 +1,5 @@
package com.linecorp.linesdktest;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand All @@ -9,17 +8,15 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.linecorp.linesdk.dialog.SendMessageDialog;
import com.linecorp.linesdktest.settings.TestSetting;
import com.linecorp.linesdktest.util.FlexMessageGenerator;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ApisFragment extends BaseApisFragment implements SendMessageDialog.OnSendListener {
public class ApisFragment extends BaseApisFragment {
private final FlexMessageGenerator flexMessageGenerator = new FlexMessageGenerator();

@Nullable
Expand Down Expand Up @@ -78,31 +75,11 @@ void getCurrentToken() {
startApiAsyncTask("getCurrentToken", () -> lineApiClient.getCurrentAccessToken());
}

@OnClick(R.id.send_message)
void sendMessage() {
SendMessageDialog sendMessageDialog = new SendMessageDialog(getContext(), lineApiClient);
sendMessageDialog.setMessageData(flexMessageGenerator.createFlexCarouselContainerMessage());
sendMessageDialog.setOnSendListener(this);
sendMessageDialog.setOnCancelListener(
dialog -> Toast.makeText(getContext(), "Sending message is canceled.", Toast.LENGTH_LONG).show());
sendMessageDialog.show();
}

@Override
protected void addLog(@NonNull String logText) {
Log.d("LineSdkTest", logText);
if (logView != null) {
logView.setText(logView.getText() + LOG_SEPARATOR + logText);
}
}

@Override
public void onSendSuccess(DialogInterface dialog) {
Toast.makeText(getContext(), "Message sent successfully.", Toast.LENGTH_LONG).show();
}

@Override
public void onSendFailure(DialogInterface dialog) {
Toast.makeText(getContext(), "Message sent failure.", Toast.LENGTH_LONG).show();
}
}
Expand Up @@ -2,6 +2,7 @@

import android.R.layout;
import android.R.string;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand All @@ -27,6 +28,7 @@
import com.linecorp.linesdk.LineApiResponseCode;
import com.linecorp.linesdk.LineGroup;
import com.linecorp.linesdk.LineProfile;
import com.linecorp.linesdk.dialog.SendMessageDialog;
import com.linecorp.linesdk.message.AudioMessage;
import com.linecorp.linesdk.message.ImageMessage;
import com.linecorp.linesdk.message.LocationMessage;
Expand Down Expand Up @@ -55,7 +57,7 @@

import static java.util.Arrays.asList;

public class InternalApisFragment extends BaseApisFragment {
public class InternalApisFragment extends BaseApisFragment implements SendMessageDialog.OnSendListener {
private final FlexMessageGenerator flexMessageGenerator = new FlexMessageGenerator();

private final ReceiverList receivers = new ReceiverList();
Expand Down Expand Up @@ -279,6 +281,26 @@ void sendFlexCarouselContainerMessage() {
sendMessages(flexMessageGenerator.createFlexCarouselContainerMessage());
}

@OnClick(R.id.send_message_dialog)
void sendMessageDialog() {
SendMessageDialog sendMessageDialog = new SendMessageDialog(getContext(), lineApiClient);
sendMessageDialog.setMessageData(flexMessageGenerator.createFlexCarouselContainerMessage());
sendMessageDialog.setOnSendListener(this);
sendMessageDialog.setOnCancelListener(
dialog -> Toast.makeText(getContext(), "Sending message is canceled.", Toast.LENGTH_LONG).show());
sendMessageDialog.show();
}

@Override
public void onSendSuccess(DialogInterface dialog) {
Toast.makeText(getContext(), "Message sent successfully.", Toast.LENGTH_LONG).show();
}

@Override
public void onSendFailure(DialogInterface dialog) {
Toast.makeText(getContext(), "Message sent failure.", Toast.LENGTH_LONG).show();
}

@NonNull
private List<ClickActionForTemplateMessage> createActionList() {
return asList(
Expand Down
41 changes: 22 additions & 19 deletions app/src/main/java/com/linecorp/linesdktest/SignInFragment.java
Expand Up @@ -104,21 +104,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}

private void buildScopeCheckBoxes() {
final List<Scope> scopes = (BuildConfig.INCLUDE_INTERNAL_API_TEST)?
Arrays.asList(Scope.PROFILE,
Scope.OPENID_CONNECT,
Scope.OC_EMAIL,
Scope.OC_PHONE_NUMBER,
Scope.OC_GENDER,
Scope.OC_BIRTHDATE,
Scope.OC_ADDRESS,
Scope.OC_REAL_NAME)
:
Arrays.asList(Scope.PROFILE,
Scope.OPENID_CONNECT,
Scope.FRIEND,
Scope.GROUP,
Scope.MESSAGE);
final List<Scope> scopes = (BuildConfig.INCLUDE_INTERNAL_API_TEST) ?
Arrays.asList(
Scope.PROFILE,
Scope.OPENID_CONNECT,
Scope.OC_EMAIL,
Scope.OC_PHONE_NUMBER,
Scope.OC_GENDER,
Scope.OC_BIRTHDATE,
Scope.OC_ADDRESS,
Scope.OC_REAL_NAME,
Scope.FRIEND,
Scope.GROUP,
Scope.MESSAGE
) :
Arrays.asList(
Scope.PROFILE,
Scope.OPENID_CONNECT
);


final FragmentActivity activity = getActivity();
Expand All @@ -144,14 +147,14 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
addLog("==========================");
} else {
addLog("Illegal response : onActivityResult("
+ requestCode + ", " + resultCode + ", " + data + ")");
+ requestCode + ", " + resultCode + ", " + data + ")");
}
}

@NonNull
private LineAuthenticationConfig createLineAuthenticationConfigForTest() {
return LineAuthenticationTestConfigFactory.createTestConfig(channelId,
!useLineAppAuthCheckbox.isChecked());
!useLineAppAuthCheckbox.isChecked());
}

@NonNull
Expand Down Expand Up @@ -215,8 +218,8 @@ public void onSignInBtnClick() {
createAuthenticationParamsForTest());
startActivityForResult(intent, REQUEST_CODE);
addLog("Sign-in is started. [" + LOG_SEPARATOR
+ " channelId : " + channelId + LOG_SEPARATOR
+ "]");
+ " channelId : " + channelId + LOG_SEPARATOR
+ "]");
} catch (Exception e) {
addLog(e.toString());
}
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/layout/fragment_apis.xml
Expand Up @@ -61,12 +61,6 @@
android:text="@string/apis_get_friendship_status"
android:textAllCaps="false" />

<Button
android:id="@+id/send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/apis_send_message_with_picker"
android:textAllCaps="false" />
</LinearLayout>
</ScrollView>

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/fragment_internal_apis.xml
Expand Up @@ -132,6 +132,12 @@
android:layout_height="wrap_content"
android:text="send ImageCarousel template message" />

<Button
android:id="@+id/send_message_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/apis_send_message_dialog" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Expand Up @@ -39,7 +39,7 @@
<string name="apis_get_friends_approvers">getFriendsApprovers</string>
<string name="apis_get_groups_approvers">getGroupsApprovers</string>
<string name="apis_send_message">send all Messages</string>
<string name="apis_send_message_with_picker">sendMessage</string>
<string name="apis_send_message_dialog">send message dialog</string>
<string name="apis_send_template_message">send all Template Messages</string>
<string name="apis_section_title_internal_apis">Internal APIs</string>
<string name="apis_section_title_flex_message_apis">Flex Message APIs</string>
Expand Down
Expand Up @@ -30,6 +30,7 @@
import java.util.Map;

/**
* @hide
* A subclass of Dialog that shows the friend and group list for user to pick and send the
* passed-in messageData. You can register a listener through
* {@link #setOnSendListener(OnSendListener)} know whether the messageData is sent or not.
Expand Down

0 comments on commit 90868d5

Please sign in to comment.