Skip to content

Commit e71e2d4

Browse files
author
Chris Bellew
committed
Default to Manual Login when attempting to fetch a pin code fails.
1 parent 92dc2b3 commit e71e2d4

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

mobile/src/main/java/com/atomjack/vcfp/activities/MainActivity.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ public void onSuccess(Pin pin) {
815815
@Override
816816
public void onFailure(Throwable error) {
817817
error.printStackTrace();
818-
feedback.e(R.string.login_error);
818+
showManualLogin(true);
819819
}
820820
});
821821
}
@@ -923,13 +923,21 @@ private void showFindingPlexClientsAndServers() {
923923
}
924924

925925
private void showManualLogin() {
926+
showManualLogin(false);
927+
}
928+
929+
private void showManualLogin(boolean showPinError) {
926930
LayoutInflater layoutInflater = LayoutInflater.from(MainActivity.this);
927931
View view = layoutInflater.inflate(R.layout.login, null);
928932
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
929933
builder.setView(view);
930934
final EditText usernameInput = (EditText) view.findViewById(R.id.usernameInput);
931935
final EditText passwordInput = (EditText) view.findViewById(R.id.passwordInput);
932936

937+
if(showPinError) {
938+
TextView loginPinError = (TextView) view.findViewById(R.id.loginPinError);
939+
loginPinError.setVisibility(View.VISIBLE);
940+
}
933941
final AlertDialog alertD = builder.create();
934942

935943
Button popupManualLoginPinButton = (Button)view.findViewById(R.id.popupManualLoginPinButton);

mobile/src/main/java/com/atomjack/vcfp/net/PlexHttpClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ public static void getPinCode(final PlexPinResponseHandler responseHandler) {
530530
call.enqueue(new Callback<Pin>() {
531531
@Override
532532
public void onResponse(Response<Pin> response) {
533-
responseHandler.onSuccess(response.body());
533+
if(response.code() == 200 || response.code() == 201)
534+
responseHandler.onSuccess(response.body());
535+
else
536+
responseHandler.onFailure(new Throwable());
534537
}
535538

536539
@Override

mobile/src/main/res/layout/login.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@
7474
android:layout_alignParentEnd="true"/>
7575
</RelativeLayout>
7676

77+
<TextView
78+
android:layout_width="wrap_content"
79+
android:layout_height="wrap_content"
80+
android:textAppearance="?android:attr/textAppearanceMedium"
81+
android:text="@string/pin_popup_error"
82+
android:id="@+id/loginPinError"
83+
android:layout_marginTop="10dp"
84+
android:textColor="@color/white"
85+
android:visibility="gone"/>
86+
7787
</LinearLayout>

mobile/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
<string name="localmedia_purchase_from_menu">If you would like to unlock this feature in the future, you can purchase it via the Settings portion of the Navigation Menu.</string>
200200
<string name="localmedia_purchase_reminder">Playback to the local device is restricted to one minute. Would you like to unlock it(%s)?</string>
201201
<string name="purchase_localmedia">Purchase Local Media Playback</string>
202+
<string name="pin_popup_error">An error was encountered attempting to request a Pin code from plex.tv.</string>
202203

203204
<!-- Tutorial time! -->
204205
<string name="tutorial1_cast_button">Tap the cast icon to select a Plex client.</string>

0 commit comments

Comments
 (0)