Remove permanent notification in favor of tile

Cleanup after #348 (Added support for a quick settings tile for creating a new note)
This commit is contained in:
Niedermann IT-Dienstleistungen 2018-04-06 20:56:36 +02:00
parent 6c16a9292a
commit 5d50b55af3
4 changed files with 12 additions and 54 deletions

View file

@ -114,16 +114,10 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
setupNotesList(); setupNotesList();
setupNavigationList(categoryAdapterSelectedItem); setupNavigationList(categoryAdapterSelectedItem);
setupNavigationMenu(); setupNavigationMenu();
// Show persistant notification for creating a new note
checkNotificationSetting();
} }
@Override @Override
protected void onResume() { protected void onResume() {
// Show persistant notification for creating a new note
checkNotificationSetting();
// refresh and sync every time the activity gets visible // refresh and sync every time the activity gets visible
refreshLists(); refreshLists();
db.getNoteServerSyncHelper().addCallbackPull(syncCallBack); db.getNoteServerSyncHelper().addCallbackPull(syncCallBack);
@ -355,33 +349,6 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
listNavigationMenu.setAdapter(adapterMenu); listNavigationMenu.setAdapter(adapterMenu);
} }
protected void checkNotificationSetting() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean showNotification = preferences.getBoolean(getString(R.string.pref_key_show_notification), false);
if (showNotification) {
// add notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
PendingIntent newNoteIntent = PendingIntent.getActivity(this, 0,
new Intent(this, EditNoteActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP),
0);
builder.setSmallIcon(R.drawable.ic_action_new)
.setContentTitle(getString(R.string.action_create))
.setContentText("")
.setOngoing(true)
.setContentIntent(newNoteIntent)
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
NotificationManager notificationManager = (NotificationManager) getSystemService(
NOTIFICATION_SERVICE);
notificationManager.notify(10, builder.build());
} else {
// remove notification
NotificationManager nMgr = (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
nMgr.cancel(10);
}
}
public void initList() { public void initList() {
adapter = new ItemAdapter(this); adapter = new ItemAdapter(this);
RecyclerView listView = findViewById(R.id.recycler_view); RecyclerView listView = findViewById(R.id.recycler_view);
@ -499,7 +466,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
getMenuInflater().inflate(R.menu.menu_list_view, menu); getMenuInflater().inflate(R.menu.menu_list_view, menu);
// Associate searchable configuration with the SearchView // Associate searchable configuration with the SearchView
final MenuItem item = menu.findItem(R.id.search); final MenuItem item = menu.findItem(R.id.search);
searchView = (SearchView) MenuItemCompat.getActionView(item); searchView = (SearchView) item.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {

View file

@ -97,24 +97,24 @@ public class NoteSQLiteOpenHelper extends SQLiteOpenHelper {
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if(oldVersion<3) { if (oldVersion < 3) {
recreateDatabase(db); recreateDatabase(db);
} }
if(oldVersion<4) { if (oldVersion < 4) {
clearDatabase(db); clearDatabase(db);
} }
if(oldVersion<5) { if (oldVersion < 5) {
db.execSQL("ALTER TABLE "+table_notes+" ADD COLUMN "+key_remote_id+" INTEGER"); db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_remote_id + " INTEGER");
db.execSQL("UPDATE "+table_notes+" SET "+key_remote_id+"="+key_id+" WHERE ("+key_remote_id+" IS NULL OR "+key_remote_id+"=0) AND "+key_status+"!=?", new String[]{DBStatus.LOCAL_CREATED.getTitle()}); db.execSQL("UPDATE " + table_notes + " SET " + key_remote_id + "=" + key_id + " WHERE (" + key_remote_id + " IS NULL OR " + key_remote_id + "=0) AND " + key_status + "!=?", new String[]{DBStatus.LOCAL_CREATED.getTitle()});
db.execSQL("UPDATE "+table_notes+" SET "+key_remote_id+"=0, "+key_status+"=? WHERE "+key_status+"=?", new String[]{DBStatus.LOCAL_EDITED.getTitle(), DBStatus.LOCAL_CREATED.getTitle()}); db.execSQL("UPDATE " + table_notes + " SET " + key_remote_id + "=0, " + key_status + "=? WHERE " + key_status + "=?", new String[]{DBStatus.LOCAL_EDITED.getTitle(), DBStatus.LOCAL_CREATED.getTitle()});
} }
if(oldVersion<6) { if (oldVersion < 6) {
db.execSQL("ALTER TABLE "+table_notes+" ADD COLUMN "+key_favorite+" INTEGER DEFAULT 0"); db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_favorite + " INTEGER DEFAULT 0");
} }
if(oldVersion<7) { if (oldVersion < 7) {
dropIndexes(db); dropIndexes(db);
db.execSQL("ALTER TABLE "+table_notes+" ADD COLUMN "+key_category+" TEXT NOT NULL DEFAULT ''"); db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_category + " TEXT NOT NULL DEFAULT ''");
db.execSQL("ALTER TABLE "+table_notes+" ADD COLUMN "+key_etag+" TEXT"); db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_etag + " TEXT");
createIndexes(db); createIndexes(db);
} }
} }

View file

@ -57,8 +57,6 @@
<string name="settings_submitting">Connecting &#8230;</string> <string name="settings_submitting">Connecting &#8230;</string>
<string name="settings_view_category">View settings</string> <string name="settings_view_category">View settings</string>
<string name="settings_note_mode">Display mode for Notes</string> <string name="settings_note_mode">Display mode for Notes</string>
<string name="settings_notification_title">\"Create note\" as notification</string>
<string name="settings_notification">Enable to show a persistent notification for quickly creating new notes.</string>
<string name="settings_cert_category">Certificates</string> <string name="settings_cert_category">Certificates</string>
<string name="settings_cert_trust_system">Trust system certificates</string> <string name="settings_cert_trust_system">Trust system certificates</string>
<string name="settings_cert_trust_system_on">System and user-added CAs will be trusted (recommended)</string> <string name="settings_cert_trust_system_on">System and user-added CAs will be trusted (recommended)</string>
@ -140,7 +138,6 @@
<!-- Key / Values for preferences --> <!-- Key / Values for preferences -->
<string name="pref_key_trust_system_certs" translatable="false">trustSystemCerts</string> <string name="pref_key_trust_system_certs" translatable="false">trustSystemCerts</string>
<string name="pref_key_reset_trust" translatable="false">resetTrust</string> <string name="pref_key_reset_trust" translatable="false">resetTrust</string>
<string name="pref_key_show_notification" translatable="false">showNotification</string>
<string name="pref_key_note_mode" translatable="false">noteMode</string> <string name="pref_key_note_mode" translatable="false">noteMode</string>
<string name="pref_key_last_note_mode" translatable="false">lastNoteMode</string> <string name="pref_key_last_note_mode" translatable="false">lastNoteMode</string>
<string name="pref_value_mode_edit" translatable="false">edit</string> <string name="pref_value_mode_edit" translatable="false">edit</string>

View file

@ -9,12 +9,6 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/settings_view_category"> <PreferenceCategory android:title="@string/settings_view_category">
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/pref_key_show_notification"
android:title="@string/settings_notification_title"
android:summary="@string/settings_notification"
/>
<ListPreference <ListPreference
android:defaultValue="@string/pref_value_mode_edit" android:defaultValue="@string/pref_value_mode_edit"
android:key="@string/pref_key_note_mode" android:key="@string/pref_key_note_mode"