Skip to content

Commit 302a0f3

Browse files
authored
Merge pull request #26 from cpp-2016-autumn/develop/pacmancoder
Stabilization stage bug fixes and improvements
2 parents 4bc0ef2 + 197be2d commit 302a0f3

File tree

13 files changed

+49
-14
lines changed

13 files changed

+49
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/build
88
/captures
99
.externalNativeBuild
10+
*.apk

control/src/main/java/com/appmon/control/DeviceListActivity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class DeviceListActivity extends AppCompatActivity implements IDeviceList
3030
IDeviceListPresenter mPresenter;
3131

3232
ListView mListView;
33+
TextView mNoDevicesText;
34+
3335
List<DeviceInfo> mDeviceList;
3436
DeviceListAdapter mListAdapter;
3537

@@ -38,6 +40,7 @@ protected void onCreate(Bundle savedInstanceState) {
3840
super.onCreate(savedInstanceState);
3941
setContentView(R.layout.activity_device_list);
4042
mListView = (ListView) findViewById(R.id.deviceList);
43+
mNoDevicesText = (TextView) findViewById(R.id.noDevicesText);
4144
mPresenter = new DeviceListPresenter(ModelManager.getInstance()
4245
.getDeviceListModel());
4346
mPresenter.attachView(this);
@@ -94,6 +97,13 @@ public void openAppList(String deviceId) {
9497
public void updateList(List<DeviceInfo> devices) {
9598
mDeviceList = devices;
9699
mListAdapter.notifyDataSetChanged();
100+
if (mDeviceList.size() == 0) {
101+
mListView.setVisibility(View.GONE);
102+
mNoDevicesText.setVisibility(View.VISIBLE);
103+
} else {
104+
mNoDevicesText.setVisibility(View.GONE);
105+
mListView.setVisibility(View.VISIBLE);
106+
}
97107
}
98108

99109
@Override

control/src/main/java/com/appmon/control/SettingsActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public void showMessage(Message msg) {
133133
case NETWORK_ERROR:
134134
Toast.makeText(this, R.string.text_network_error, Toast.LENGTH_SHORT).show();
135135
break;
136+
case REAUTH_NEEDED:
137+
Toast.makeText(this, R.string.text_reauth, Toast.LENGTH_SHORT).show();
136138
}
137139
}
138140

control/src/main/java/com/appmon/control/models/applist/AppListModel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public class AppListModel implements IAppListModel {
1515
//
1616
// private Map<PresenterOps, DatabaseChildListener> mListenerBridges;
1717
private DatabaseBridgeManager<PresenterOps> mDatabaseBridgeManager;
18-
private IDatabaseService mDatabase;
1918

2019
private String lastUserId = null;
2120

2221
private IAuthService mAuth;
22+
private IDatabaseService mDatabase;
2323

2424
public AppListModel(ICloudServices cloudServices) {
2525
mDatabase = cloudServices.getDatabase();
@@ -78,10 +78,12 @@ public void onChildRemoved(IDataSnapshot prevSnapshot) {
7878
};
7979
mDatabaseBridgeManager.addListener(getRootPath() + presenter.getDeviceId(), presenter,
8080
listener);
81+
mDatabase.goOnline();
8182
}
8283

8384
@Override
8485
public void removePresenter(PresenterOps presenter) {
86+
mDatabase.goOffline();
8587
mDatabaseBridgeManager.removeListener(presenter);
8688
}
8789

control/src/main/java/com/appmon/control/models/devicelist/DeviceListModel.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.appmon.shared.IAuthService;
77
import com.appmon.shared.ICloudServices;
88
import com.appmon.shared.IDataSnapshot;
9+
import com.appmon.shared.IDatabaseService;
910
import com.appmon.shared.entities.DeviceInfo;
1011

1112
public class DeviceListModel implements IDeviceListModel {
@@ -15,9 +16,10 @@ public class DeviceListModel implements IDeviceListModel {
1516
private String lastUserId = null;
1617

1718
private IAuthService mAuth;
18-
19+
private IDatabaseService mDatabase;
1920
public DeviceListModel(ICloudServices cloudServices) {
20-
mDatabaseBridgeManager = new DatabaseBridgeManager<>(cloudServices.getDatabase());
21+
mDatabase = cloudServices.getDatabase();
22+
mDatabaseBridgeManager = new DatabaseBridgeManager<>(mDatabase);
2123
mAuth = cloudServices.getAuth();
2224
}
2325

@@ -72,11 +74,12 @@ public void onCanceled(DatabaseError error) {
7274
};
7375
// link listener
7476
mDatabaseBridgeManager.addListener(getRootPath(), presenter, listener);
75-
77+
mDatabase.goOnline();
7678
}
7779

7880
@Override
7981
public void removePresenter(PresenterOps presenter) {
82+
mDatabase.goOffline();
8083
mDatabaseBridgeManager.removeListener(presenter);
8184
}
8285
}

control/src/main/java/com/appmon/control/models/user/IUserModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface IResetPasswordListener extends IFallibleListener<ResetPasswordError> {
2424

2525
enum ChangeAppPinError { WEAK_PIN }
2626
enum ChangeClientPinError { WEAK_PIN, INTERNAL_ERROR }
27-
enum ChangePasswordError { WEAK_PASSWORD, INTERNAL_ERROR }
27+
enum ChangePasswordError { WEAK_PASSWORD, REAUTH_NEEDED, INTERNAL_ERROR }
2828
enum RegisterError { WEAK_PASSWORD, INVALID_EMAIL, USER_EXISTS, INTERNAL_ERROR }
2929
enum SignInError {INVALID_EMAIL, WRONG_PASSWORD, INTERNAL_ERROR }
3030
enum ResetPasswordError { INVALID_USER, INTERNAL_ERROR }

control/src/main/java/com/appmon/control/models/user/UserModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ public void onFailure(IUser.ChangePasswordError error) {
202202
case WEAK_PASSWORD:
203203
l.onFail(ChangePasswordError.WEAK_PASSWORD);
204204
break;
205+
case REAUTH_NEEDED:
206+
l.onFail(ChangePasswordError.REAUTH_NEEDED);
207+
break;
205208
default:
206209
l.onFail(ChangePasswordError.INTERNAL_ERROR);
207210
}
@@ -244,6 +247,7 @@ public void changeClientPin(String pin) {
244247
}
245248
return;
246249
}
250+
mDatabase.goOnline(); // can be turned off by device list model
247251
mDatabase.setValue(mUserRootPath + "pin", pin, new ResultListener<Void, DatabaseError>() {
248252
@Override
249253
public void onSuccess(Void value) {

control/src/main/java/com/appmon/control/presenters/SettingsPresenter.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public void onFail(IUserModel.ChangePasswordError error) {
3434
case WEAK_PASSWORD:
3535
mView.showInputError(ISettingsView.InputError.WEAK_PASSWORD);
3636
break;
37+
case REAUTH_NEEDED:
38+
mView.showMessage(ISettingsView.Message.REAUTH_NEEDED);
39+
mView.clearFocus();
40+
break;
3741
case INTERNAL_ERROR:
3842
mView.showMessage(ISettingsView.Message.NETWORK_ERROR);
3943
mView.clearFocus();
@@ -124,10 +128,11 @@ public void changeAppPin(String pin, String pinRepeat) {
124128

125129
@Override
126130
public void changeClientPin(String pin) {
131+
if (mView != null) {
132+
mView.setProgressVisible(true);
133+
mView.clearInputErrors();
134+
}
127135
mModel.changeClientPin(pin);
128-
if (mView == null) return;
129-
mView.setProgressVisible(true);
130-
mView.clearInputErrors();
131136
}
132137

133138
@Override

control/src/main/java/com/appmon/control/views/ISettingsView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ enum Message {
2020
APP_PIN_CHANGED,
2121
CLIENT_PIN_CHANGED,
2222
NETWORK_ERROR,
23+
REAUTH_NEEDED,
2324
}
2425

2526
/**

control/src/main/res/layout/activity_device_list.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
<ListView
1515
android:id="@+id/deviceList"
1616
android:layout_width="match_parent"
17-
android:layout_height="match_parent"/>
17+
android:layout_height="match_parent"
18+
android:visibility="gone"/>
1819
<!-- Centred "No devices" text view-->
1920
<TextView
2021
android:id="@+id/noDevicesText"
2122
android:layout_width="wrap_content"
2223
android:layout_height="wrap_content"
24+
android:layout_gravity="center"
2325
android:text="@string/text_no_devices"
24-
android:visibility="gone"/>
26+
android:visibility="visible"/>
2527
</FrameLayout>

0 commit comments

Comments
 (0)