Skip to content

Commit 3ed01dd

Browse files
committed
fix all interface
1 parent f1617dd commit 3ed01dd

12 files changed

Lines changed: 724 additions & 6 deletions

app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@
4848
android:theme="@style/AppTheme"
4949
tools:ignore="GoogleAppIndexingWarning"
5050
tools:replace="android:icon,android:label">
51+
<activity
52+
android:name=".SearchActivity"
53+
android:exported="false" />
54+
<activity
55+
android:name=".AboutActivity"
56+
android:exported="false" />
57+
<activity
58+
android:name=".SyncActivity"
59+
android:exported="false" />
60+
<activity
61+
android:name=".LoginActivity"
62+
android:exported="false" />
5163
<activity
5264
android:name=".PolicyActivity"
5365
android:exported="false" />
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.openimis.imispolicies;
2+
3+
import android.os.Bundle;
4+
import android.view.MenuItem;
5+
import android.widget.TextView;
6+
7+
import androidx.activity.EdgeToEdge;
8+
import androidx.annotation.NonNull;
9+
import androidx.appcompat.app.AppCompatActivity;
10+
import androidx.core.graphics.Insets;
11+
import androidx.core.view.ViewCompat;
12+
import androidx.core.view.WindowInsetsCompat;
13+
14+
public class AboutActivity extends AppCompatActivity {
15+
16+
TextView appVersion, releaseDate;
17+
ClientAndroidInterface ca;
18+
@Override
19+
protected void onCreate(Bundle savedInstanceState) {
20+
super.onCreate(savedInstanceState);
21+
setContentView(R.layout.activity_about);
22+
setTitle(R.string.About);
23+
if (getSupportActionBar() != null) {
24+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
25+
}
26+
ca = new ClientAndroidInterface(this);
27+
appVersion = findViewById(R.id.VersionValue);
28+
releaseDate = findViewById(R.id.ReleaseDateValue);
29+
appVersion.setText(ca.getVersion());
30+
releaseDate.setText(getResources().getString(R.string.ReleaseDateValue));
31+
}
32+
33+
@Override
34+
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
35+
if (item.getItemId() == android.R.id.home) {
36+
finish();
37+
return true;
38+
}
39+
return super.onOptionsItemSelected(item);
40+
}
41+
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
package org.openimis.imispolicies;
2+
3+
import android.app.AlertDialog;
4+
import android.app.ProgressDialog;
5+
import android.content.Intent;
6+
import android.os.Bundle;
7+
import android.text.Editable;
8+
import android.text.TextWatcher;
9+
import android.view.MenuItem;
10+
import android.view.View;
11+
import android.widget.ProgressBar;
12+
import android.widget.TextView;
13+
14+
import androidx.activity.EdgeToEdge;
15+
import androidx.annotation.NonNull;
16+
import androidx.appcompat.app.AppCompatActivity;
17+
import androidx.core.graphics.Insets;
18+
import androidx.core.view.ViewCompat;
19+
import androidx.core.view.WindowInsetsCompat;
20+
21+
import com.google.android.material.button.MaterialButton;
22+
import com.google.android.material.textfield.TextInputEditText;
23+
import com.google.android.material.textfield.TextInputLayout;
24+
25+
import org.openimis.imispolicies.util.AndroidUtils;
26+
27+
public class LoginActivity extends AppCompatActivity {
28+
29+
TextInputLayout layoutLoginName, layoutPassword;
30+
MaterialButton btnLogin;
31+
TextInputEditText txtLoginName, txtPassword;
32+
String officerCode;
33+
ClientAndroidInterface ca;
34+
int page;
35+
private ProgressDialog progressDialog;
36+
ProgressBar progressBar;
37+
38+
@Override
39+
protected void onCreate(Bundle savedInstanceState) {
40+
super.onCreate(savedInstanceState);
41+
setContentView(R.layout.activity_login);
42+
setTitle(getResources().getString(R.string.Login));
43+
if (getSupportActionBar() != null) {
44+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
45+
}
46+
ca = new ClientAndroidInterface(this);
47+
progressDialog = new ProgressDialog(this);
48+
officerCode = ca.getOfficerCode();
49+
page = getIntent().getIntExtra("Page",0);
50+
initViews();
51+
canSave();
52+
setupListenners();
53+
54+
btnLogin.setOnClickListener(new View.OnClickListener() {
55+
@Override
56+
public void onClick(View view) {
57+
String username = txtLoginName.getText().toString();
58+
String password = txtPassword.getText().toString();
59+
60+
boolean hasInternet = ca.CheckInternetAvailable();
61+
if(!hasInternet){
62+
ca.ShowDialog(getResources().getString(R.string.NoInternet));
63+
} else {
64+
progressBar.setVisibility(View.VISIBLE);
65+
boolean loggedIn = ca.LoginJI(username, password);
66+
if(loggedIn){
67+
if(page == 0){
68+
Intent intent = new Intent(LoginActivity.this, SyncActivity.class);
69+
startActivity(intent);
70+
} else if (page == 1) {
71+
Intent intent = new Intent(LoginActivity.this, SearchActivity.class);
72+
startActivity(intent);
73+
} else if (page == 2) {
74+
Intent intent = new Intent(LoginActivity.this, Enrolment.class);
75+
startActivity(intent);
76+
} else if (page == 4) {
77+
ca.launchActivity("Reports");
78+
} else if (page == 5) {
79+
ca.launchActivity("Enquire");
80+
} else {
81+
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
82+
startActivity(intent);
83+
}
84+
progressBar.setVisibility(View.GONE);
85+
finish();
86+
} else {
87+
progressDialog.dismiss();
88+
ca.ShowDialog(getResources().getString(R.string.LoginFail));
89+
}
90+
}
91+
92+
}
93+
});
94+
}
95+
96+
@Override
97+
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
98+
if (item.getItemId() == android.R.id.home) {
99+
finish();
100+
return true;
101+
}
102+
return super.onOptionsItemSelected(item);
103+
}
104+
105+
private void initViews(){
106+
layoutPassword = findViewById(R.id.layoutPassword);
107+
layoutLoginName = findViewById(R.id.layoutLoginName);
108+
btnLogin = findViewById(R.id.btnLogin);
109+
txtLoginName = findViewById(R.id.txtLoginName);
110+
txtPassword = findViewById(R.id.txtPassword);
111+
progressBar = findViewById(R.id.loginProgressBar);
112+
113+
txtLoginName.setText(officerCode);
114+
}
115+
116+
private void canSave(){
117+
if(txtLoginName.getText().toString().isEmpty() ||
118+
txtPassword.getText().toString().isEmpty()
119+
){
120+
btnLogin.setEnabled(false);
121+
} else {
122+
btnLogin.setEnabled(true);
123+
}
124+
}
125+
126+
private void setupListenners(){
127+
txtLoginName.addTextChangedListener(new TextWatcher() {
128+
@Override
129+
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
130+
131+
}
132+
133+
@Override
134+
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
135+
canSave();
136+
}
137+
138+
@Override
139+
public void afterTextChanged(Editable editable) {
140+
141+
}
142+
});
143+
144+
txtPassword.addTextChangedListener(new TextWatcher() {
145+
@Override
146+
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
147+
148+
}
149+
150+
@Override
151+
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
152+
canSave();
153+
}
154+
155+
@Override
156+
public void afterTextChanged(Editable editable) {
157+
158+
}
159+
});
160+
}
161+
}

app/src/main/java/org/openimis/imispolicies/MainActivity.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,14 @@ public boolean onNavigationItemSelected(MenuItem item) {
714714
} else if (id == R.id.nav_modify_family) {
715715
global = (Global) getApplicationContext();
716716
if (global.isLoggedIn()) {
717-
wv.loadUrl("file:///android_asset/pages/Search.html");
717+
//wv.loadUrl("file:///android_asset/pages/Search.html");
718+
Intent intent = new Intent(this, SearchActivity.class);
719+
startActivity(intent);
718720
} else {
719-
wv.loadUrl("file:///android_asset/pages/Login.html?s=1");
721+
//wv.loadUrl("file:///android_asset/pages/Login.html?s=1");
722+
Intent i = new Intent(this, LoginActivity.class);
723+
i.putExtra("Page", 1);
724+
startActivity(i);
720725
}
721726

722727
} else if (id == R.id.nav_renewal) {
@@ -729,15 +734,22 @@ public boolean onNavigationItemSelected(MenuItem item) {
729734
Intent i = new Intent(this, Reports.class);
730735
startActivity(i);
731736
} else {
732-
wv.loadUrl("file:///android_asset/pages/Login.html?s=4");
737+
//wv.loadUrl("file:///android_asset/pages/Login.html?s=4");
738+
Intent i = new Intent(this, LoginActivity.class);
739+
i.putExtra("Page", 4);
740+
startActivity(i);
733741
}
734742
} else if (id == R.id.nav_feedback) {
735743
Intent intent = new Intent(this, FeedbackList.class);
736744
startActivity(intent);
737745
} else if (id == R.id.nav_sync) {
738-
wv.loadUrl("file:///android_asset/pages/Sync.html");
746+
//wv.loadUrl("file:///android_asset/pages/Sync.html");
747+
Intent intent = new Intent(this, SyncActivity.class);
748+
startActivity(intent);
739749
} else if (id == R.id.nav_about) {
740-
wv.loadUrl("file:///android_asset/pages/About.html");
750+
//wv.loadUrl("file:///android_asset/pages/About.html");
751+
Intent intent = new Intent(this, AboutActivity.class);
752+
startActivity(intent);
741753
} else if (id == R.id.nav_settings) {
742754
wv.loadUrl("file:///android_asset/pages/Settings.html");
743755
} else if (id == R.id.nav_quit) {
@@ -756,7 +768,10 @@ public boolean onNavigationItemSelected(MenuItem item) {
756768
Intent intent = new Intent(this, Enquire.class);
757769
startActivity(intent);
758770
} else {
759-
wv.loadUrl("file:///android_asset/pages/Login.html?s=5");
771+
//wv.loadUrl("file:///android_asset/pages/Login.html?s=5");
772+
Intent i = new Intent(this, LoginActivity.class);
773+
i.putExtra("Page", 5);
774+
startActivity(i);
760775
}
761776
} else if (id == R.id.nav_payment) {
762777
ClientAndroidInterface ca = new ClientAndroidInterface(this);
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package org.openimis.imispolicies;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import android.text.Editable;
6+
import android.text.TextWatcher;
7+
import android.view.MenuItem;
8+
import android.view.View;
9+
import android.widget.ProgressBar;
10+
11+
import androidx.activity.EdgeToEdge;
12+
import androidx.annotation.NonNull;
13+
import androidx.appcompat.app.AppCompatActivity;
14+
import androidx.core.graphics.Insets;
15+
import androidx.core.view.ViewCompat;
16+
import androidx.core.view.WindowInsetsCompat;
17+
18+
import com.google.android.material.button.MaterialButton;
19+
import com.google.android.material.textfield.TextInputEditText;
20+
21+
public class SearchActivity extends AppCompatActivity {
22+
23+
private TextInputEditText txtSearchInsuranceNumber;
24+
MaterialButton btnSearch;
25+
ClientAndroidInterface ca;
26+
ProgressBar progressBar;
27+
28+
@Override
29+
protected void onCreate(Bundle savedInstanceState) {
30+
super.onCreate(savedInstanceState);
31+
setContentView(R.layout.activity_search);
32+
setTitle(R.string.Search);
33+
if (getSupportActionBar() != null) {
34+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
35+
}
36+
ca = new ClientAndroidInterface(this);
37+
initViews();
38+
canSearch();
39+
txtSearchInsuranceNumber.addTextChangedListener(new TextWatcher() {
40+
@Override
41+
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
42+
43+
}
44+
45+
@Override
46+
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
47+
canSearch();
48+
}
49+
50+
@Override
51+
public void afterTextChanged(Editable editable) {
52+
53+
}
54+
});
55+
56+
btnSearch.setOnClickListener(new View.OnClickListener() {
57+
@Override
58+
public void onClick(View view) {
59+
progressBar.setVisibility(View.VISIBLE);
60+
String InsuranceNumber = txtSearchInsuranceNumber.getText().toString();
61+
if (ca.ModifyFamily(InsuranceNumber) == 1) {
62+
progressBar.setVisibility(View.GONE);
63+
Intent intent = new Intent(SearchActivity.this, Enrolment.class);
64+
startActivity(intent);
65+
finish();
66+
} else {
67+
progressBar.setVisibility(View.GONE);
68+
}
69+
}
70+
});
71+
72+
73+
}
74+
75+
@Override
76+
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
77+
if (item.getItemId() == android.R.id.home) {
78+
finish();
79+
return true;
80+
}
81+
return super.onOptionsItemSelected(item);
82+
}
83+
84+
private void initViews(){
85+
btnSearch = findViewById(R.id.btnSearch);
86+
txtSearchInsuranceNumber = findViewById(R.id.txtSearchInsuranceNumber);
87+
progressBar = findViewById(R.id.loadingProgressBar);
88+
}
89+
90+
private void canSearch (){
91+
if(txtSearchInsuranceNumber.getText().toString().isEmpty()){
92+
btnSearch.setEnabled(false);
93+
} else {
94+
btnSearch.setEnabled(true);
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)