Skip to content

Commit

Permalink
Fix #613 Crash on start. shortLabel cannot be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-niedermann committed Dec 14, 2019
1 parent 3ac8b2e commit de3ba0d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -153,15 +154,20 @@ public void onFinish() {
List<ShortcutInfo> newShortcuts = new ArrayList<>();

for (DBNote note : db.getRecentNotes(localAccount.getId())) {
Intent intent = new Intent(getApplicationContext(), EditNoteActivity.class);
intent.putExtra(EditNoteActivity.PARAM_NOTE_ID, note.getId());
intent.setAction(ACTION_SHORTCUT);

newShortcuts.add(new ShortcutInfo.Builder(getApplicationContext(), note.getId() + "")
.setShortLabel(note.getTitle())
.setIcon(Icon.createWithResource(getApplicationContext(), note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp))
.setIntent(intent)
.build());
if (!TextUtils.isEmpty(note.getTitle())) {
Intent intent = new Intent(getApplicationContext(), EditNoteActivity.class);
intent.putExtra(EditNoteActivity.PARAM_NOTE_ID, note.getId());
intent.setAction(ACTION_SHORTCUT);

newShortcuts.add(new ShortcutInfo.Builder(getApplicationContext(), note.getId() + "")
.setShortLabel(note.getTitle() + "")
.setIcon(Icon.createWithResource(getApplicationContext(), note.isFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp))
.setIntent(intent)
.build());
} else {
// Prevent crash https://github.com/stefan-niedermann/nextcloud-notes/issues/613
Log.e(TAG, "shortLabel cannot be empty " + note);
}
}
Log.d(TAG, "Update dynamic shortcuts");
shortcutManager.removeAllDynamicShortcuts();
Expand Down Expand Up @@ -213,11 +219,11 @@ protected void onCreate(Bundle savedInstanceState) {
protected void onResume() {
try {
String ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(getApplicationContext()).name;
if(localAccount == null || !localAccount.getAccountName().equals(ssoAccount)) {
if (localAccount == null || !localAccount.getAccountName().equals(ssoAccount)) {
selectAccount(SingleAccountHelper.getCurrentSingleSignOnAccount(getApplicationContext()).name);
}
} catch (NoCurrentAccountSelectedException | NextcloudFilesAppAccountNotFoundException e) {
if(!notAuthorizedAccountHandled) {
if (!notAuthorizedAccountHandled) {
handleNotAuthorizedAccount();
}
}
Expand Down Expand Up @@ -775,8 +781,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.v(TAG, "Added account: " + "name:" + account.name + ", " + account.url + ", userId" + account.userId);
try {
db.addAccount(account.url, account.userId, account.name);
} catch(SQLiteConstraintException e) {
if(db.getAccounts().size() > 1) { // TODO ideally only show snackbar when this is a not migrated account
} catch (SQLiteConstraintException e) {
if (db.getAccounts().size() > 1) { // TODO ideally only show snackbar when this is a not migrated account
Snackbar.make(coordinatorLayout, R.string.account_already_imported, Snackbar.LENGTH_LONG).show();
}
}
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/50.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- #171 Multiple NC Servers
- #375 Hardcoded list for special category images
- #418 Implement Single-Sign-On
- #613 Crash on start. shortLabel cannot be empty
- Hide FAB when scrolling down

0 comments on commit de3ba0d

Please sign in to comment.