Skip to content

Commit 0b74466

Browse files
author
Chris Bellew
committed
Disabled Splunk network monitoring due to conflict with server-side sockets. Redid UI of login popups.
1 parent f67708e commit 0b74466

File tree

4 files changed

+221
-65
lines changed

4 files changed

+221
-65
lines changed

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

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,10 @@ private void switchToFragment(Fragment fragment) {
400400
private void init() {
401401
handler = new Handler();
402402

403-
if(BuildConfig.USE_BUGSENSE)
403+
if(BuildConfig.USE_BUGSENSE) {
404+
Mint.disableNetworkMonitoring();
404405
Mint.initAndStartSession(getApplicationContext(), BUGSENSE_APIKEY);
406+
}
405407

406408
// Set a Toolbar to replace the ActionBar.
407409
toolbar = (Toolbar) findViewById(R.id.toolbar);
@@ -575,32 +577,32 @@ public void onFailure(Throwable error) {
575577

576578
private void showPin(final Pin pin) {
577579
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
578-
alertDialogBuilder.setTitle(R.string.pin_title);
579-
alertDialogBuilder.setMessage(String.format(getString(R.string.pin_message), pin.code));
580-
alertDialogBuilder
581-
.setCancelable(false)
582-
.setNegativeButton("Cancel",
583-
new DialogInterface.OnClickListener() {
584-
public void onClick(DialogInterface dialog, int id) {
585-
dialog.cancel();
586-
fetchPinTask.getFuture().cancel(false);
587-
}
588-
}
589-
)
590-
.setNeutralButton("Manual", new DialogInterface.OnClickListener() {
591-
@Override
592-
public void onClick(final DialogInterface dialog, int id) {
593-
dialog.dismiss();
594-
fetchPinTask.getFuture().cancel(false);
595-
showManualLogin();
596-
}
597-
});
598-
599-
580+
View view = getLayoutInflater().inflate(R.layout.popup_plex_pin, null);
581+
alertDialogBuilder.setView(view);
600582
// create and show an alert dialog
601583
final AlertDialog pinAlert = alertDialogBuilder.create();
602584
pinAlert.show();
603585

586+
TextView popupPlexPinMessage = (TextView)view.findViewById(R.id.popupPlexPinMessage);
587+
popupPlexPinMessage.setText(String.format(getString(R.string.pin_message), pin.code));
588+
Button popupPlexPinManualButton = (Button)view.findViewById(R.id.popupPlexPinManualButton);
589+
popupPlexPinManualButton.setOnClickListener(new View.OnClickListener() {
590+
@Override
591+
public void onClick(View v) {
592+
pinAlert.dismiss();
593+
fetchPinTask.getFuture().cancel(false);
594+
showManualLogin();
595+
}
596+
});
597+
Button popupPlexPinCancelButton = (Button)view.findViewById(R.id.popupPlexPinCancelButton);
598+
popupPlexPinCancelButton.setOnClickListener(new View.OnClickListener() {
599+
@Override
600+
public void onClick(View v) {
601+
pinAlert.cancel();
602+
fetchPinTask.getFuture().cancel(false);
603+
}
604+
});
605+
604606
// Now set up a task to hit the below url (based on the "id" field returned in the above http POST)
605607
// every second. Once the user has entered the code on the plex website, the xml returned from the
606608
// below http GET will contain their authentication token. Once that is retrieved, save it, switch
@@ -618,7 +620,6 @@ public void onSuccess(Pin pin) {
618620
PlexHttpClient.signin(authToken, new PlexHttpUserHandler() {
619621
@Override
620622
public void onSuccess(PlexUser user) {
621-
Logger.d("Got user: %s", user.username);
622623
prefs.put(Preferences.PLEX_USERNAME, user.username);
623624
prefs.put(Preferences.PLEX_EMAIL, user.email);
624625
if(doingFirstTimeSetup) {
@@ -628,7 +629,6 @@ public void onSuccess(PlexUser user) {
628629
} else {
629630
setupNavigationDrawer();
630631
refreshServers(null);
631-
refreshServers.run();
632632
}
633633
}
634634

@@ -679,45 +679,33 @@ private void showFindingPlexClientsAndServers() {
679679

680680
private void showManualLogin() {
681681
LayoutInflater layoutInflater = LayoutInflater.from(MainActivity.this);
682-
View promptView = layoutInflater.inflate(R.layout.login, null);
683-
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
684-
alertDialogBuilder.setView(promptView);
685-
alertDialogBuilder.setTitle(R.string.login_title);
686-
alertDialogBuilder.setMessage(R.string.login_message);
687-
final EditText usernameInput = (EditText) promptView.findViewById(R.id.usernameInput);
688-
final EditText passwordInput = (EditText) promptView.findViewById(R.id.passwordInput);
689-
alertDialogBuilder
690-
.setCancelable(true)
691-
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
692-
@Override
693-
public void onClick(final DialogInterface dialog, int id) {
694-
}
695-
})
696-
.setNeutralButton(R.string.button_pin, new DialogInterface.OnClickListener() {
697-
@Override
698-
public void onClick(final DialogInterface dialog, int id) {
699-
dialog.dismiss();
700-
showLogin();
701-
}
702-
})
703-
.setNegativeButton(R.string.cancel,
704-
new DialogInterface.OnClickListener() {
705-
public void onClick(DialogInterface dialog, int id) {
706-
dialog.cancel();
707-
}
708-
}
709-
);
710-
682+
View view = layoutInflater.inflate(R.layout.login, null);
683+
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
684+
builder.setView(view);
685+
final EditText usernameInput = (EditText) view.findViewById(R.id.usernameInput);
686+
final EditText passwordInput = (EditText) view.findViewById(R.id.passwordInput);
711687

712-
// create an alert dialog
713-
final AlertDialog alertD = alertDialogBuilder.create();
688+
final AlertDialog alertD = builder.create();
714689

715-
alertD.show();
716-
717-
Button b = alertD.getButton(DialogInterface.BUTTON_POSITIVE);
718-
b.setOnClickListener(new View.OnClickListener() {
690+
Button popupManualLoginPinButton = (Button)view.findViewById(R.id.popupManualLoginPinButton);
691+
popupManualLoginPinButton.setOnClickListener(new View.OnClickListener() {
719692
@Override
720-
public void onClick(View view) {
693+
public void onClick(View v) {
694+
alertD.dismiss();
695+
showLogin();
696+
}
697+
});
698+
Button popupManualLoginCancelButton = (Button)view.findViewById(R.id.popupManualLoginCancelButton);
699+
popupManualLoginCancelButton.setOnClickListener(new View.OnClickListener() {
700+
@Override
701+
public void onClick(View v) {
702+
alertD.cancel();
703+
}
704+
});
705+
Button popupManualLoginOKButton = (Button)view.findViewById(R.id.popupManualLoginOKButton);
706+
popupManualLoginOKButton.setOnClickListener(new View.OnClickListener() {
707+
@Override
708+
public void onClick(View v) {
721709
PlexHttpClient.signin(usernameInput.getText().toString(), passwordInput.getText().toString(), new PlexHttpUserHandler() {
722710
@Override
723711
public void onSuccess(PlexUser user) {
@@ -730,6 +718,9 @@ public void onSuccess(PlexUser user) {
730718
showFindingPlexClientsAndServers();
731719
refreshServers.run();
732720
refreshClients.run();
721+
} else {
722+
setupNavigationDrawer();
723+
refreshServers(null);
733724
}
734725
alertD.cancel();
735726
}
@@ -747,6 +738,9 @@ public void onFailure(int statusCode) {
747738
});
748739
}
749740
});
741+
builder
742+
.setCancelable(true);
743+
alertD.show();
750744
}
751745

752746
private void setServer(PlexServer s) {
@@ -973,7 +967,8 @@ else if(castPlayerManager.isSubscribed())
973967
private void onFirstTimeScanFinished() {
974968
doingFirstTimeSetup = false;
975969
prefs.put(Preferences.FIRST_TIME_SETUP_COMPLETED, true);
976-
alertDialog.dismiss();
970+
if(alertDialog != null)
971+
alertDialog.dismiss();
977972
init();
978973
drawerToggle.syncState();
979974
doAutomaticDeviceScan();
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical"
4+
android:layout_width="wrap_content"
5+
android:layout_height="match_parent"
6+
android:background="@color/settings_popup_background"
7+
android:padding="20dp">
8+
9+
<TextView
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:textAppearance="?android:attr/textAppearanceLarge"
13+
android:text="@string/create_shortcut"
14+
android:id="@+id/textView10"
15+
android:textColor="@color/white"/>
16+
17+
<TextView
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:textAppearance="?android:attr/textAppearanceMedium"
21+
android:text="@string/create_shortcut_blurb"
22+
android:id="@+id/popupCreateShortcutMessage"
23+
android:textColor="@color/white"
24+
android:paddingTop="20dp"/>
25+
26+
<RelativeLayout
27+
android:layout_width="match_parent"
28+
android:layout_height="wrap_content"
29+
android:paddingTop="30dp">
30+
31+
<Button
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:text="@string/specify_now"
35+
android:id="@+id/popupCreateShortcutSpecifyButton"
36+
android:layout_alignParentTop="true"
37+
android:layout_alignParentRight="true"
38+
android:layout_alignParentEnd="true"/>
39+
40+
<Button
41+
android:layout_width="wrap_content"
42+
android:layout_height="wrap_content"
43+
android:text="@string/use_current"
44+
android:id="@+id/popupCreateShortcutUseCurrentButton"
45+
android:layout_alignTop="@+id/popupCreateShortcutSpecifyButton"
46+
android:layout_toLeftOf="@+id/popupCreateShortcutSpecifyButton"
47+
android:layout_toStartOf="@+id/popupCreateShortcutSpecifyButton"/>
48+
49+
<Button
50+
android:layout_width="wrap_content"
51+
android:layout_height="wrap_content"
52+
android:text="@string/cancel"
53+
android:id="@+id/popupCreateShortcutCancelButton"
54+
android:layout_alignTop="@+id/popupCreateShortcutUseCurrentButton"
55+
android:layout_alignParentLeft="true"
56+
android:layout_alignParentStart="true"/>
57+
</RelativeLayout>
58+
59+
</LinearLayout>

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

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,75 @@
33
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
44
android:orientation="vertical"
55
android:layout_width="match_parent"
6-
android:layout_height="match_parent">
6+
android:layout_height="match_parent"
7+
android:background="@color/settings_popup_background"
8+
android:padding="20dp">
9+
10+
<TextView
11+
android:layout_width="wrap_content"
12+
android:layout_height="wrap_content"
13+
android:textAppearance="?android:attr/textAppearanceLarge"
14+
android:text="@string/login_title"
15+
android:id="@+id/textView15"
16+
android:textColor="@color/white"/>
17+
18+
<TextView
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:textAppearance="?android:attr/textAppearanceMedium"
22+
android:text="@string/login_message"
23+
android:id="@+id/textView16"
24+
android:textColor="@color/white"
25+
android:layout_marginTop="20dp"/>
26+
727
<EditText
828
android:id="@+id/usernameInput"
929
android:layout_width="match_parent"
1030
android:inputType="text"
1131
android:text=""
1232
android:hint="@string/username"
13-
android:layout_height="wrap_content" />
33+
android:layout_height="wrap_content"
34+
android:textColor="@color/white"
35+
android:textColorHint="@color/white"
36+
android:clickable="true"
37+
android:layout_marginTop="20dp"/>
1438
<EditText
1539
android:id="@+id/passwordInput"
1640
android:layout_width="match_parent"
1741
android:inputType="textPassword"
1842
android:text=""
1943
android:hint="@string/password"
20-
android:layout_height="wrap_content" />
44+
android:layout_height="wrap_content"
45+
android:textColor="@color/white"
46+
android:textColorHint="@color/white"/>
47+
48+
<RelativeLayout
49+
android:layout_width="match_parent"
50+
android:layout_height="wrap_content">
51+
52+
<Button
53+
android:layout_width="wrap_content"
54+
android:layout_height="wrap_content"
55+
android:text="@string/button_pin"
56+
android:id="@+id/popupManualLoginPinButton"/>
57+
58+
<Button
59+
android:layout_width="wrap_content"
60+
android:layout_height="wrap_content"
61+
android:text="@string/cancel"
62+
android:id="@+id/popupManualLoginCancelButton"
63+
android:layout_alignParentTop="true"
64+
android:layout_toLeftOf="@+id/popupManualLoginOKButton"
65+
android:layout_toStartOf="@+id/popupManualLoginOKButton"/>
66+
67+
<Button
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:text="@string/ok"
71+
android:id="@+id/popupManualLoginOKButton"
72+
android:layout_alignParentTop="true"
73+
android:layout_alignParentRight="true"
74+
android:layout_alignParentEnd="true"/>
75+
</RelativeLayout>
76+
2177
</LinearLayout>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="@color/settings_popup_background"
7+
android:padding="20dp">
8+
9+
<TextView
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:textAppearance="?android:attr/textAppearanceLarge"
13+
android:text="@string/pin_title"
14+
android:id="@+id/textView14"
15+
android:textColor="@color/white"/>
16+
17+
<TextView
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:textAppearance="?android:attr/textAppearanceMedium"
21+
android:id="@+id/popupPlexPinMessage"
22+
android:layout_marginTop="20dp"
23+
android:textColor="@color/white"/>
24+
25+
<RelativeLayout
26+
android:layout_width="match_parent"
27+
android:layout_height="wrap_content"
28+
android:layout_marginTop="20dp">
29+
30+
<Button
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:id="@+id/popupPlexPinManualButton"
34+
android:text="@string/button_manual"/>
35+
36+
<Button
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
android:text="@string/cancel"
40+
android:id="@+id/popupPlexPinCancelButton"
41+
android:layout_alignParentTop="true"
42+
android:layout_alignParentRight="true"
43+
android:layout_alignParentEnd="true"/>
44+
</RelativeLayout>
45+
46+
</LinearLayout>

0 commit comments

Comments
 (0)