Skip to content

Commit

Permalink
Implement large number of fixes and improvements:
Browse files Browse the repository at this point in the history
-Modify EditText whitespace filter to convert whitespace characters to underscores ('_')
-Change instances of "research subject" to "individual"
-Change instances of "wear level" to "wear score"
-Change instance of "?" to "No data" for wear score
-Rearrange WearPickerDialog options to be more intuitive
-Add new Help button to WearPickerDialog (allows user to view descriptions of each wear score)
-Enlarge "open" arrows in list views
-Fix large number of cases where keyboard would remain open after leaving text inputs
-Implement automatic opening of keyboard when TextInputDialog is opened
-Add "New individual" button to subject editor view
-Implement new auto-save preference to save project modifications automatically (on by default, but can be toggled)
-Change TextInputDialog behavior: if invalid input is received, Dialog remains open and displays error message (previous behavior: close dialog and display error message in separate dialog)
-Update version number to 180321
  • Loading branch information
SeanPesce committed Mar 21, 2018
1 parent f335be3 commit 22299e5
Show file tree
Hide file tree
Showing 34 changed files with 940 additions and 228 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ MolWear is an Android app that aims to simplify the recording and sharing of obs

* **[Kasual Business](http://www.kasual.biz/)** - Creators of [MaterialNumberPicker](https://github.com/KasualBusiness/MaterialNumberPicker)
* **[Pascal Hartig](https://github.com/passy)** - Creator of the [DirectoryChooser](https://github.com/passy/Android-DirectoryChooser) library used by this app
* **[The-QRCode-Generator](https://www.the-qrcode-generator.com/)** - QR Code generator


## License
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "mw.molarwear"
minSdkVersion 15
targetSdkVersion 27
versionCode 180308
versionName "2018.03.08"
versionCode 180321
versionName "2018.03.21"
// versionCode format: YYMMDD
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,36 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:theme">

<activity
android:name=".gui.activity.SplashActivity"
android:label="@string/app_name"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".gui.activity.MolWearMainActivity"
android:label="@string/app_name"
android:theme="@style/MainActivityTheme">

</activity>

<activity
android:name=".gui.activity.ViewProjectActivity"
android:label=""
android:parentActivityName=".gui.activity.MolWearMainActivity"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateVisible|adjustPan" >
android:windowSoftInputMode="stateHidden|adjustPan" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="mw.molarwear.gui.activity.MolWearMainActivity" />
</activity>

<activity android:name="net.rdrei.android.dirchooser.DirectoryChooserActivity" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package mw.molarwear.data.classes.dental.molar.enums;

import android.app.Activity;

import mw.molarwear.R;
import mw.molarwear.gui.dialog.DialogStringData;
import mw.molarwear.gui.dialog.TwoButtonDialog;

/**
* This enum represents varying levels (or "scores") of wear for describing the physical condition of
* the surface of human molars (Bottom surface of upper molars, or top surface of lower molars). Scores
Expand Down Expand Up @@ -87,9 +93,9 @@ public enum Wear {
/* 2 */ "Surface is worn flat, and dentine exposure covers ¼ of quadrant or less.",
/* 3 */ "Greater dentine exposure with more than ¼ of quadrant exposed. Much enamel is still " +
"present within the quadrant (if each quadrant can be visualized with three \"sides,\"" +
" the enamel fully surrounds the dentine exposed)",
" the enamel fully surrounds the dentine exposed).",
/* 4 */ "Use this score as an intermediary, when the dentine engages one of two sides (less" +
" than ⅓) to coalesce with a neighbouring quadrant",
" than ⅓) to coalesce with a neighbouring quadrant.",
/* 5 */ "Enamel is found on only two \"sides\" of the quadrant; usually suggests it has" +
" coalesced with a neighboring quadrant).",
/* 6 */ "Enamel is only found on one \"side\" of the quadrant (typically outer rim). Enamel" +
Expand All @@ -102,6 +108,17 @@ public enum Wear {
public static Wear get(int score) { return (score >= 0 && score < Wear.values().length && score != Wear.INDEX_OF_UNKNOWN) ? Wear.values()[score] : UNKNOWN; }
public static String getDescription(int score) { return (score >= 0 && score < Wear.values().length && score != Wear.INDEX_OF_UNKNOWN) ? Wear.DESCRIPTION[score] : UNKNOWN.description(); }
public static int INDEX_OF_UNKNOWN() { return Wear.INDEX_OF_UNKNOWN; }
public static void showWearDescriptionDialog(Activity activity) {
StringBuilder dlgMsg = new StringBuilder("\n\"" + activity.getString(R.string.desc_wear_lvl_unk_picker)
+ "\" - " + activity.getString(R.string.desc_wear_lvl_unk) + "\n");
for (int i = 0; i < (Wear.values().length-1); i++) {
dlgMsg.append("\n").append(i).append(" - ").append(Wear.get(i).description()).append("\n");
}
final TwoButtonDialog dlg = new TwoButtonDialog(new DialogStringData(activity,
R.string.dlg_title_wear_lvl_desc,
dlgMsg.toString()));
dlg.show();
}

// Initialize static data
static {
Expand All @@ -111,7 +128,7 @@ public enum Wear {
w._description = Wear.DESCRIPTION[w._score];
} else {
Wear.INDEX_OF_UNKNOWN = i;
w._description = "No data.";
w._description = "No available data, possibly due to surface damage, missing teeth, etc.";
}
}
}
Expand All @@ -123,14 +140,27 @@ public enum Wear {

private final int _score;
private String _description;
private boolean _initialized = false;

Wear(int score) {
_score = score;
}

public int score() { return _score; }
public String description() { return _description; }
//////////// Accessors ////////////
public int score() { return _score; }
public String description() { return _description; }
public boolean inititalized() { return _initialized; }

//////////// Mutators ////////////
public void setDescription(String description) {
// Can only be called once
if (!_initialized) {
_description = description;
_initialized = true;
}
}

//////////// Miscellaneous ////////////
public boolean equals(Wear other) { return _score == other.score(); }
public boolean equals(int other) { return _score == other; }
}
55 changes: 35 additions & 20 deletions app/src/main/java/mw/molarwear/data/handlers/ProjectHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,29 @@ public static boolean importProject(String filePath) {
dlgEdit.setPositiveButton(new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User clicked "Submit" button
if (dlgEdit.text().length() > 0 && !dlgEdit.text().equals(dlgEdit.textInputHint())) {
AppUtility.hideKeyboard(AppUtility.CONTEXT, dlgEdit.linearLayout());
if (dlgEdit.text().length() > 0) {
if (new File(FileUtility.getInternalPath(dlgEdit.text() + FileUtility.FILE_EXT_SERIALIZED_DATA)).exists()) {
// Another project with the specified title already exists
AppUtility.printSnackBarMsg(R.string.err_proj_create_fail_exists);
dlgEdit.show();
dlgEdit.textInput().setError(AppUtility.CONTEXT.getString(R.string.err_proj_create_fail_exists));
} else {
// Rename the project
p.setTitle(dlgEdit.text());
addProject(p);
p.save();
AppUtility.printSnackBarMsg(R.string.out_msg_import_success);
}
} else {
dlgEdit.show();
dlgEdit.textInput().setError(AppUtility.CONTEXT.getString(R.string.err_proj_create_fail_empty_title));
}
}
});
dlgEdit.setNegativeButton(new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User clicked "Cancel" button
AppUtility.hideKeyboard(AppUtility.CONTEXT, dlgEdit.linearLayout());
AppUtility.printSnackBarMsg(R.string.out_msg_cancelled);
}
});
Expand All @@ -121,21 +127,13 @@ public static boolean createProject(MolarWearProject newProject) {
String fileName = newProject.title() + FileUtility.FILE_EXT_SERIALIZED_DATA;
if (new File(AppUtility.CONTEXT.getFilesDir().toString() + separator + fileName).exists()) {
// Failed to create project (one with same name already exists)
TwoButtonDialog existsDlg = new TwoButtonDialog(new DialogStringData(AppUtility.CONTEXT,
R.string.err_proj_create_fail,
R.string.err_proj_create_fail_exists));
existsDlg.show();
return false;
}
if (FileUtility.saveSerializable(newProject, fileName)) {
addProject(newProject);
AppUtility.CONTEXT.runOnUiThread(new Runnable() {
public void run() {
if (projectsFragment != null) {
projectsFragment.setSelection(PROJECTS.size() - 1);
}
}
});
projectsFragment.clearSelection();
projectsFragment.selectItem(PROJECTS.size()-1);
notifyDataSetChanged();
} else {
// Failed to create project (unknown reason)
AppUtility.printSnackBarMsg(AppUtility.getResources().getString(R.string.err_proj_create_fail));
Expand All @@ -146,6 +144,9 @@ public void run() {

public static void removeProject(int index) {
if (FileUtility.deletePrivate(PROJECTS.get(index).title() + FileUtility.FILE_EXT_SERIALIZED_DATA)) {
if (projectsFragment.selectionIndex() >= (PROJECTS.size()-1)) {
projectsFragment.clearSelection();
}
PROJECTS.remove(index);
notifyDataSetChanged();
} else {
Expand Down Expand Up @@ -204,20 +205,24 @@ public static void editTitle(final int index) {
dlgEdit.setPositiveButton(new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User clicked "Submit" button
AppUtility.hideKeyboard(AppUtility.CONTEXT, dlgEdit.linearLayout());
if (dlgEdit.text().length() > 0 && !dlgEdit.text().equals(dlgEdit.textInputHint())) {
if (new File(FileUtility.getInternalPath(dlgEdit.text() + FileUtility.FILE_EXT_SERIALIZED_DATA)).exists()) {
// Another project with the specified title already exists
TwoButtonDialog existsDlg = new TwoButtonDialog(new DialogStringData(AppUtility.CONTEXT,
R.string.err_proj_edit_title_fail,
R.string.err_proj_edit_title_fail_exists));
existsDlg.show();
dlgEdit.show();
dlgEdit.textInput().setError(AppUtility.CONTEXT.getString(R.string.err_proj_edit_title_fail_exists));
} else {
// Rename the project
setTitle(index, dlgEdit.text());
}
}
}
});
dlgEdit.setNegativeButton(new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
AppUtility.hideKeyboard(AppUtility.CONTEXT, dlgEdit.linearLayout());
}
});
dlgEdit.show();
}

Expand Down Expand Up @@ -265,12 +270,22 @@ public static void newProject() {
dlg.setPositiveButton(new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User clicked "Create" button
boolean created = createProject(new MolarWearProject((!dlg.text().isEmpty()) ? dlg.text() : dlg.textInputHint()));
if (created) {
// @TODO: Open new project?
AppUtility.hideKeyboard(AppUtility.CONTEXT, dlg.linearLayout());
String fileName = ((!dlg.text().isEmpty()) ? dlg.text() : dlg.textInputHint()) + FileUtility.FILE_EXT_SERIALIZED_DATA;
if (new File(AppUtility.CONTEXT.getFilesDir().toString() + separator + fileName).exists()) {
// Failed to create project (one with same name already exists)
dlg.show();
dlg.textInput().setError(AppUtility.CONTEXT.getString(R.string.err_proj_create_fail_exists));
} else {
createProject(new MolarWearProject((!dlg.text().isEmpty()) ? dlg.text() : dlg.textInputHint()));
}
}
});
dlg.setNegativeButton(new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
AppUtility.hideKeyboard(AppUtility.CONTEXT, dlg.linearLayout());
}
});

// Determine default file name
String baseFileName = AppUtility.CONTEXT.getFilesDir().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class MolWearMainActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppUtility.CONTEXT = this;
AppUtility.SET_MAIN_ACTIVITY(this);

setContentView(R.layout.activity_main);

Expand All @@ -73,10 +72,14 @@ protected void onCreate(Bundle savedInstanceState) {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);

if (ProjectHandler.projectCount() == 0) {
ProjectHandler.loadProjects();
}

_fragProjects = (ProjectsListFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_list_projects);

AppUtility.VIEW = findViewById(R.id.content_main);
setTitle(getResources().getString(R.string.app_name) + " " + getResources().getString(R.string.title_choose_proj));
setTitle(getResources().getString(R.string.title_choose_proj));
if (AppUtility.LOAD_ERROR_COUNT() > 0) {
AppUtility.printSnackBarMsg(String.format(getString(R.string.err_startup_proj_load), AppUtility.LOAD_ERROR_COUNT()));
}
Expand All @@ -93,10 +96,12 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onResume() {
super.onResume();
_fragProjects.updateToolbar();
AppUtility.CONTEXT = this;
AppUtility.SET_MAIN_ACTIVITY(this);
AppUtility.VIEW = findViewById(R.id.content_main);
if (ProjectHandler.projectCount() == 0) {
ProjectHandler.loadProjects();
}
_fragProjects.updateToolbar();
}

@Override
Expand All @@ -112,7 +117,7 @@ public void onBackPressed() {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_settings, menu);
getMenuInflater().inflate(R.menu.options_main, menu);
return true;
}

Expand All @@ -125,6 +130,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
AppUtility.openPreferencesDialog(this);
return true;
} else if (id == R.id.bt_import) {
importProject();
Expand All @@ -142,13 +148,7 @@ public boolean onNavigationItemSelected(MenuItem item) {

if (id == R.id.nav_import_project) {
importProject();
}/* else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
}*/ else if (id == R.id.nav_share) {
} else if (id == R.id.nav_share) {
AppUtility.featureNotImplementedYet();
} else if (id == R.id.nav_github) {
Uri githubRepo = Uri.parse(getResources().getString(R.string.github));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppUtility.CONTEXT = this;
AppUtility.initializeRuntimeSettings();
AppUtility.loadPreferences(this);
ProjectHandler.loadProjects();

try {
Expand Down
Loading

0 comments on commit 22299e5

Please sign in to comment.