Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static def getDate() {
}

android {
compileSdk 34
compileSdk = 36
namespace = "org.openimis.imispolicies"
if (keystorePropertiesFile.exists()) {
signingConfigs {
Expand All @@ -35,7 +35,7 @@ android {
}
defaultConfig {
applicationId "org.openimis.imispolicies"
minSdkVersion 21
minSdkVersion 26
targetSdkVersion 33
versionCode gitVersionCode
versionName gitVersionName
Expand Down Expand Up @@ -240,6 +240,7 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'cz.msebera.android:httpclient:4.5.8'
implementation 'androidx.activity:activity:1.11.0'

androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
2 changes: 2 additions & 0 deletions app/src/localeMv/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,6 @@
<string name="pay_type_cash">Cash</string>
<string name="pay_type_mobile_phone">Téléphone portable</string>
<string name="pay_type_bank_transfer">Virement banquaire</string>
<string name="fieldRequired">Champs requis</string>
<string name="connecting">Connexion</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:icon,android:label">
<activity
android:name=".Signing"
android:exported="false" />

<service
android:name=".ControlNumberService"
android:exported="false" />
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/org/openimis/imispolicies/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,14 @@ public void onReceivedTitle(WebView view, String title) {
OfficerName = headerview.findViewById(R.id.tvOfficerName);

Login.setOnClickListener(v -> {
wv.loadUrl("file:///android_asset/pages/Login.html?s=3");
if(ca.isLoggedIn()) {
global.setOfficerCode("");
global.setOfficerName("");
ca.Logout();
}
Intent intent = new Intent(this, Signing.class);
intent.putExtra("page", 3);
startActivity(intent);
drawer.closeDrawer(GravityCompat.START);
SetLoggedIn();
});
Expand Down Expand Up @@ -742,7 +749,10 @@ public boolean onNavigationItemSelected(MenuItem item) {
Intent intent = new Intent(this, Enquire.class);
startActivity(intent);
} else {
wv.loadUrl("file:///android_asset/pages/Login.html?s=5");
Intent intent = new Intent(this, Signing.class);
intent.putExtra("page", 5);
startActivity(intent);
//wv.loadUrl("file:///android_asset/pages/Login.html?s=5");
}
} else if (id == R.id.nav_payment) {
ClientAndroidInterface ca = new ClientAndroidInterface(this);
Expand Down
128 changes: 128 additions & 0 deletions app/src/main/java/org/openimis/imispolicies/Signing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package org.openimis.imispolicies;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.google.android.material.progressindicator.CircularProgressIndicator;

import org.openimis.imispolicies.tools.Log;
import org.openimis.imispolicies.usecase.Login;

public class Signing extends AppCompatActivity {

private EditText etLogin, etPassword;
private Button btnLogin;
private TextView tvError;
protected ProgressDialog progressDialog;
private CircularProgressIndicator cp;
private int page = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_signing);
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimary));
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(getResources().getString(R.string.Login));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Intent intent = getIntent();
page = intent.getIntExtra("page", 0);

etLogin = findViewById(R.id.etLogin);
etPassword = findViewById(R.id.etPassword);
btnLogin = findViewById(R.id.btnSignIn);
tvError = findViewById(R.id.tvLoginError);
cp = findViewById(R.id.cp_load_login);
tvError.setEnabled(false);
cp.setIndeterminate(false);

btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(isFormValid()){
etLogin.setBackground(getDrawable(R.drawable.edit_text));
etPassword.setBackground(getDrawable(R.drawable.edit_text));
tvError.setText("");
String username = etLogin.getText().toString().trim();
String password = etPassword.getText().toString().trim();
cp.setIndeterminate(true);
Thread thread = new Thread(){
@Override
public void run() {
try{
new Login().execute(username, password);
runOnUiThread(() -> {
MainActivity.SetLoggedIn();
if(page == 5){
Intent intent = new Intent(Signing.this , Enquire.class);
startActivity(intent);
finish();
} else {
finish();
}
});
} catch (Exception e){
e.printStackTrace();
runOnUiThread(()->{
cp.setIndeterminate(false);
tvError.setText(getResources().getString(R.string.LoginFail));
});
}
}
};
thread.start();
}
}
});
}

@Override
public boolean onSupportNavigateUp() {
finish();
return true;
}

private boolean isFormValid(){
if(etLogin.getText().toString().trim().isEmpty() || etPassword.getText().toString().trim().isEmpty()){
tvError.setText(getResources().getString(R.string.fieldRequired));
if(etLogin.getText().toString().trim().isEmpty()){
etLogin.setBackground(getDrawable(R.drawable.edit_text_error));
}else{
etLogin.setBackground(getDrawable(R.drawable.edit_text));
}
if(etPassword.getText().toString().trim().isEmpty()) {
etPassword.setBackground(getDrawable(R.drawable.edit_text_error));
}else{
etPassword.setBackground(getDrawable(R.drawable.edit_text));
}
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public Login(

@WorkerThread
public void execute(@NonNull String username, @NonNull String password) throws Exception {
if (Global.getGlobal().getOfficerCode() == null) {
Global.getGlobal().setOfficerCode(username);
}
String officerCode = Global.getGlobal().getOfficerCode();
if (officerCode == null) {
throw new IllegalStateException("OfficerCode should not be null on login");
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="8dp" /> <!-- Rounded corners -->
<solid android:color="@color/colorPrimary" />
</shape>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/edit_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="8dp" /> <!-- Rounded corners -->
<solid android:color="#FFFFFF" /> <!-- Background color -->
<stroke android:width="1dp" android:color="#CCCCCC" /> <!-- Border -->
<padding android:left="12dp" android:top="8dp" android:right="12dp" android:bottom="8dp" />
</shape>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/edit_text_error.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="8dp" /> <!-- Rounded corners -->
<solid android:color="#FFFFFF" /> <!-- Background color -->
<stroke android:width="1dp" android:color="@color/red" /> <!-- Border -->
<padding android:left="12dp" android:top="8dp" android:right="12dp" android:bottom="8dp" />
</shape>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_eye.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="32dp" android:tint="#BEBEBE" android:viewportHeight="24" android:viewportWidth="24" android:width="32dp">

<path android:fillColor="@android:color/white" android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>

</vector>
79 changes: 79 additions & 0 deletions app/src/main/res/layout/activity_signing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
tools:context=".Signing">



<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:orientation="vertical">
<EditText
android:id="@+id/etLogin"
android:inputType="textEmailAddress"
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="@string/LoginName"
android:background="@drawable/edit_text"
android:padding="12dp"
android:layout_marginBottom="20dp"/>


<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="@string/Password"
android:background="@drawable/edit_text"
android:inputType="textPassword"
android:padding="12dp"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/btnSignIn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Login"
android:textColor="@color/white"
android:layout_marginBottom="20dp"
android:background="@drawable/button"/>

<TextView
android:id="@+id/tvLoginError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="18sp"
android:textColor="@color/red"/>

<com.google.android.material.progressindicator.CircularProgressIndicator
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cp_load_login"
android:indeterminate="true"
app:indicatorColor="@color/colorPrimary"/>


</LinearLayout>




</LinearLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,6 @@
<string name="pay_type_cash">Cash</string>
<string name="pay_type_mobile_phone">Mobile Phone</string>
<string name="pay_type_bank_transfer">Bank Transfer</string>
<string name="fieldRequired">Field required</string>
<string name="connecting">Connecting</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:textColorHint">@color/grey</item>
<item name="android:statusBarColor">@color/colorPrimary</item>
</style>

<style name="AppTheme.NoActionBar">
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.android.tools.build:gradle:8.13.0'
classpath "org.ajoberstar.grgit:grgit-gradle:4.1.1"
classpath 'com.apollographql.apollo:apollo-gradle-plugin:2.5.14'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip