Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ public void getLocalData() {
((Activity) mContext).runOnUiThread(new Runnable() {
@Override
public void run() {
((MainActivity) mContext).openDialogFromPage();
((MainActivity) mContext).PickMasterDataFileDialogFromPage();
((MainActivity) mContext).calledFrom = "htmlpage";
}
});
Expand Down Expand Up @@ -4622,7 +4622,7 @@ public void run() {

@JavascriptInterface
public void popUpOfficerDialog() {
((MainActivity) mContext).ShowDialogTex();
((MainActivity) mContext).ShowEnrolmentOfficerDialog();
}

@JavascriptInterface
Expand All @@ -4636,17 +4636,14 @@ public void run() {
startDownloading();
finalPd.dismiss();

((Activity) mContext).runOnUiThread(new Runnable() {
@Override
public void run() {
ShowDialog(mContext.getResources().getString(R.string.DataDownloadedSuccess));
Global global = Global.getGlobal();
global.setOfficerCode("");
((Activity) mContext).runOnUiThread(() -> {
ShowDialog(mContext.getResources().getString(R.string.DataDownloadedSuccess));
Global global = Global.getGlobal();
global.setOfficerCode("");
// Intent refresh = new Intent(mContext, MainActivity.class);
// ((MainActivity)mContext).startActivity(refresh);
// ((MainActivity)mContext).finish();
((MainActivity) mContext).ShowDialogTex();
}
((MainActivity) mContext).ShowEnrolmentOfficerDialog();
});

} catch (JSONException e) {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/openimis/imispolicies/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@

package org.openimis.imispolicies;

import android.Manifest;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.util.Log;
Expand Down Expand Up @@ -64,6 +66,7 @@ public class Global extends Application {
private String OfficerName;
private int UserId;
private int OfficerId;
private String[] permissions;

private String ImageFolder;

Expand All @@ -89,6 +92,13 @@ public void onCreate() {
SubDirectories = new HashMap<>();
ProtectedDirectories = Arrays.asList("Authentications", "Database", "Images");
initSharedPrefsInts();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
permissions = new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.VIBRATE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.MANAGE_EXTERNAL_STORAGE};
} else {
permissions = new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.VIBRATE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CHANGE_WIFI_STATE};
}

}

private void initSharedPrefsInts() {
Expand Down Expand Up @@ -178,6 +188,10 @@ public void setOfficerName(String officerName) {
OfficerName = officerName;
}

public String[] getPermissions() {
return permissions;
}

public boolean isNetworkAvailable() {
ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
Expand Down
Loading