Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

134 - Improve UX of crosswalk to webview migration #162

Merged
merged 8 commits into from
Mar 17, 2021
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 {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.noveogroup.android:check:1.2.5'
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<activity android:name="EmbeddedBrowserActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize"/>
<activity android:name="UpgradingActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize"/>
<activity android:name="FreeSpaceWarningActivity"
android:screenOrientation="portrait"/>
<activity android:name="SettingsDialogActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.os.Bundle;
import android.net.Uri;

import static org.medicmobile.webapp.mobile.BuildConfig.DEBUG;
import static org.medicmobile.webapp.mobile.MedicLog.trace;

public class AppUrlIntentActivity extends Activity {
Expand All @@ -14,7 +13,7 @@ public class AppUrlIntentActivity extends Activity {
Intent appLinkIntent = getIntent();
Uri appLinkData = appLinkIntent.getData();

if(DEBUG) trace(this, "TOKEN LOGIN=%s", appLinkData.toString());
trace(this, "onCreate() :: Token Login: %s", appLinkData.toString());

startActivity(new Intent(Intent.ACTION_VIEW, appLinkData, this, EmbeddedBrowserActivity.class));
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.json.JSONException;
import org.json.JSONObject;

import static org.medicmobile.webapp.mobile.BuildConfig.DEBUG;
import static org.medicmobile.webapp.mobile.BuildConfig.DISABLE_APP_URL_VALIDATION;
import static org.medicmobile.webapp.mobile.MedicLog.trace;
import static org.medicmobile.webapp.mobile.R.string.errAppUrl_apiNotReady;
Expand Down Expand Up @@ -37,7 +36,7 @@ public AppUrlVerification verify(String appUrl) {
return AppUrlVerification.failure(appUrl,
errAppUrl_appNotFound);
} catch(IOException ex) {
if(DEBUG) trace(ex, "Exception caught trying to verify url: %s", redactUrl(appUrl));
trace(ex, "Exception caught trying to verify url: %s", redactUrl(appUrl));
return AppUrlVerification.failure(appUrl,
errAppUrl_serverNotFound);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.view.View;
import android.widget.TextView;

import static org.medicmobile.webapp.mobile.BuildConfig.DEBUG;
import static org.medicmobile.webapp.mobile.MedicLog.trace;
import static org.medicmobile.webapp.mobile.Utils.startAppActivityChain;

Expand All @@ -14,7 +13,7 @@ public class FreeSpaceWarningActivity extends LockableActivity {

@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(DEBUG) trace(this, "Starting...");
trace(this, "onCreate()");

setContentView(R.layout.free_space_warning);

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/medicmobile/webapp/mobile/LockScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.widget.TextView;
import android.widget.Toast;

import static org.medicmobile.webapp.mobile.BuildConfig.DEBUG;
import static org.medicmobile.webapp.mobile.MedicLog.trace;
import static org.medicmobile.webapp.mobile.MedicLog.warn;

Expand Down Expand Up @@ -42,7 +41,7 @@ enum Task {

@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(DEBUG) trace(this, "Starting...");
trace(this, "onCreate()");

task = Task.valueOf(getIntent().getStringExtra(X_TASK));

Expand Down
26 changes: 8 additions & 18 deletions src/main/java/org/medicmobile/webapp/mobile/MedicLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,32 @@ private MedicLog() {}

public static void trace(Object caller, String message, Object... extras) {
if(!DEBUG) return;

d(LOG_TAG, messageWithCaller(caller, message, extras));
}

public static void log(String message, Object... extras) {
message = format(message, extras);

i(LOG_TAG, message);
}

public static void trace(Exception ex, String message, Object... extras) {
message = format(message, extras);
if(!DEBUG) return;
d(LOG_TAG, format(message, extras), ex);
}

d(LOG_TAG, message, ex);
public static void log(Object caller, String message, Object... extras) {
i(LOG_TAG, messageWithCaller(caller, message, extras));
}

public static void log(Exception ex, String message, Object... extras) {
message = format(message, extras);

i(LOG_TAG, message, ex);
i(LOG_TAG, format(message, extras), ex);
}

public static void warn(Object caller, String message, Object... extras) {
w(LOG_TAG, messageWithCaller(caller, message, extras));
}

public static void warn(Exception ex, String message, Object... extras) {
message = format(message, extras);

w(LOG_TAG, message, ex);
w(LOG_TAG, format(message, extras), ex);
}

public static void error(Exception ex, String message, Object... extras) {
message = format(message, extras);

e(LOG_TAG, message, ex);
e(LOG_TAG, format(message, extras), ex);
}

private static String messageWithCaller(Object caller, String message, Object... extras) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void onPostExecute(AppUrlVerification result) {

@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(DEBUG) trace(this, "Starting...");
trace(this, "onCreate()");

this.settings = SettingsStore.in(this);
this.serverRepo = new ServerRepo(this);
Expand Down Expand Up @@ -100,7 +100,7 @@ private void displayCustomServerForm() {

//> EVENT HANDLERS
public void verifyAndSave(View view) {
if(DEBUG) trace(this, "verifyAndSave");
trace(this, "verifyAndSave()");

submitButton().setEnabled(false);
cancelButton().setEnabled(false);
Expand All @@ -111,7 +111,7 @@ public void verifyAndSave(View view) {
}

public void cancelSettingsEdit(View view) {
if(DEBUG) trace(this, "cancelSettingsEdit");
trace(this, "cancelSettingsEdit()");
backToWebview();
}

Expand Down Expand Up @@ -141,12 +141,12 @@ private void saveSettings(WebappSettings s) {
settings.updateWith(s);
this.backToWebview();
} catch(IllegalSettingsException ex) {
if(DEBUG) trace(ex, "Tried to save illegal setting.");
trace(ex, "Tried to save illegal setting.");
for(IllegalSetting error : ex.errors) {
showError(error);
}
} catch(SettingsException ex) {
if(DEBUG) trace(ex, "Problem savung settings.");
trace(ex, "Problem saving settings.");
submitButton().setError(ex.getMessage());
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ class ServerMetadata {
}

ServerMetadata(String name, String url) {
if(DEBUG) trace(this, "constructor :: name:%s, url:%s", name, redactUrl(url));
trace(this, "ServerMetadata() :: name: %s, url: %s", name, redactUrl(url));
this.name = name;
this.url = url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import static org.medicmobile.webapp.mobile.BuildConfig.DEBUG;
import static org.medicmobile.webapp.mobile.SimpleJsonClient2.redactUrl;
import static org.medicmobile.webapp.mobile.MedicLog.log;
import static org.medicmobile.webapp.mobile.MedicLog.trace;

@SuppressWarnings("PMD.ShortMethodName")
Expand Down Expand Up @@ -72,7 +71,7 @@ void setUserDeniedGeolocation() throws SettingsException {
}

static SettingsStore in(Context ctx) {
if(DEBUG) log("Loading settings for context %s...", ctx);
trace(SettingsStore.class, "Loading settings for context %s...", ctx);

SharedPreferences prefs = ctx.getSharedPreferences(
SettingsStore.class.getName(),
Expand Down Expand Up @@ -137,7 +136,7 @@ class WebappSettings {
public final String appUrl;

public WebappSettings(String appUrl) {
if(DEBUG) trace(this, "WebappSettings() appUrl=%s", redactUrl(appUrl));
trace(this, "WebappSettings() :: appUrl: %s", redactUrl(appUrl));
this.appUrl = appUrl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ String process(int requestCode, Intent i) {
}
}

log("Simprints ident returned IDs: " + result + "; requestId=" + requestId);
log(this, "Simprints ident returned IDs: " + result + "; requestId=" + requestId);

return jsResponse("identify", requestId, result);
} catch(JSONException ex) {
Expand All @@ -91,7 +91,7 @@ String process(int requestCode, Intent i) {
if(i == null || !i.hasExtra(SIMPRINTS_REGISTRATION)) return "console.log('No registration data returned from simprints app.')";
Registration registration = i.getParcelableExtra(SIMPRINTS_REGISTRATION);
String id = registration.getGuid();
log("Simprints registration returned ID: " + id + "; requestId=" + requestCode);
log(this, "Simprints registration returned ID: " + id + "; requestId=" + requestCode);
return jsResponse("register", requestId, json("id", id));
} catch(JSONException ex) {
warn(ex, "Problem serialising simprints registration result.");
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/medicmobile/webapp/mobile/SmsSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SmsSender {

parent.registerReceiver(new BroadcastReceiver() {
@Override public void onReceive(Context ctx, Intent intent) {
log("BroadcastReceiver.onReceive() :: %s", intent.getAction());
log(this, "onReceive() :: %s", intent.getAction());

try {
switch(intent.getAction()) {
Expand Down Expand Up @@ -158,11 +158,11 @@ class DeliveryReportHandler {

//> PUBLIC API
public void handle(Intent intent) {
log("Received delivery report for message %s.", describe(intent));
log(this, "Received delivery report for message: %s", describe(intent));

int status = createFromPdu(intent).getStatus();

log("Delivery status: 0x" + toHexString(status));
log(this, "Delivery status: 0x" + toHexString(status));

if((status & GSM_STATUS_MASK) == status) {
handleGsmDelivery(intent, status);
Expand Down Expand Up @@ -235,17 +235,17 @@ private void handleGsmDelivery(Intent intent, int status) {
} else throw new IllegalStateException("Unexpected status (> 0x7F) : 0x" + toHexString(status));

reportStatus(intent, "FAILED", fDetail);
log("Delivering message to %s failed (cause: %s)", describe(intent), fDetail);
log(this, "Delivering message to %s failed (cause: %s)", describe(intent), fDetail);
}

private void handleCdmaDelivery() {
log("Delivery reports not yet supported on CDMA devices.");
log(this, "Delivery reports not yet supported on CDMA devices.");
}
}

class SendingReportHandler {
void handle(Intent intent, int resultCode) {
log("Received sending report for message %s.", describe(intent));
log(this, "Received sending report for message: %s", describe(intent));

if(resultCode == RESULT_OK) {
reportStatus(intent, "SENT");
Expand All @@ -268,7 +268,7 @@ void handle(Intent intent, int resultCode) {
failureReason = "unknown; resultCode=" + resultCode;
}
reportStatus(intent, "FAILED", failureReason);
log("Sending message %s failed. Cause: %s", describe(intent), failureReason);
log(this, "Sending message %s failed. Cause: %s", describe(intent), failureReason);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import android.content.Intent;
import android.os.Bundle;

import static org.medicmobile.webapp.mobile.BuildConfig.DEBUG;
import static org.medicmobile.webapp.mobile.MedicLog.trace;
import static org.medicmobile.webapp.mobile.Utils.createUseragentFrom;
import static org.medicmobile.webapp.mobile.Utils.startAppActivityChain;

public class StartupActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(DEBUG) trace(this, "Starting...");
trace(this, "onCreate()");

configureAndStartNextActivity();

Expand Down
39 changes: 39 additions & 0 deletions src/main/res/layout/upgrading.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">

<ProgressBar
android:id="@+id/progressBarIcon"
style="?android:attr/progressBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:contentDescription="@string/loadingIconDescription"
android:padding="20dp" />

<TextView
android:id="@+id/upgradingTitleText"
style="@android:style/Widget.DeviceDefault.Light.TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/progressBarIcon"
android:layout_marginTop="5dp"
android:padding="20dp"
android:text="@string/upgradingTitle"
android:textSize="20sp"
android:textStyle="bold" />

<TextView
android:id="@+id/upgradingMessageText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/upgradingTitleText"
android:padding="20dp"
android:text="@string/upgradingMessage"
android:textSize="18sp" />

</RelativeLayout>
4 changes: 4 additions & 0 deletions src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
<string name="locRequestOkButton">Activar</string>
<string name="locRequestDenyButton">No gracias</string>
<string name="locRequestIconDescription">Ícono de mi ubicación</string>

<string name="loadingIconDescription">Cargando…</string>
<string name="upgradingTitle">Actualizando la app</string>
<string name="upgradingMessage">Estás actualizando a la última versión. Por favor aguarda mientras tus datos son migrados.</string>
</resources>
4 changes: 4 additions & 0 deletions src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
<string name="locRequestOkButton">Activer</string>
<string name="locRequestDenyButton">Non merci</string>
<string name="locRequestIconDescription">Icône de mon emplacement</string>

<string name="loadingIconDescription">Chargement…</string>
<string name="upgradingTitle">Mettre à jour votre application</string>
<string name="upgradingMessage">Vous passez à la dernière version. Veuillez patienter pendant la migration de vos données.</string>
mrsarm marked this conversation as resolved.
Show resolved Hide resolved
</resources>
4 changes: 4 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
<string name="locRequestOkButton">Turn on</string>
<string name="locRequestDenyButton">No thanks</string>
<string name="locRequestIconDescription">My location icon</string>

<string name="loadingIconDescription">Loading…</string>
<string name="upgradingTitle">Upgrading your app</string>
<string name="upgradingMessage">You\'re upgrading to the latest version. Please wait while your data is being migrated.</string>
</resources>
Loading