Skip to content

Commit

Permalink
Adds basic dark mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
coderPaddyS committed Nov 1, 2023
1 parent f3269b0 commit 9ded6b7
Show file tree
Hide file tree
Showing 29 changed files with 353 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ public void onBindViewHolder(@NonNull NoteHolder holder, int position) {

switch (currentNote.getType()) {
case DbContract.NoteEntry.TYPE_TEXT:
holder.imageViewcategory.setImageResource(R.drawable.ic_short_text_black_24dp);
holder.imageViewcategory.setImageResource(R.drawable.ic_short_text_icon_24dp);
holder.textViewDescription.setText(Html.fromHtml(currentNote.getContent()));
holder.textViewDescription.setMaxLines(3);
break;
case DbContract.NoteEntry.TYPE_AUDIO:
holder.imageViewcategory.setImageResource(R.drawable.ic_mic_black_24dp);
holder.imageViewcategory.setImageResource(R.drawable.ic_mic_icon_24dp);
break;
case DbContract.NoteEntry.TYPE_SKETCH:
holder.imageViewcategory.setImageResource(R.drawable.ic_photo_black_24dp);
holder.imageViewcategory.setImageResource(R.drawable.ic_photo_icon_24dp);
break;
case DbContract.NoteEntry.TYPE_CHECKLIST:
holder.imageViewcategory.setImageResource(R.drawable.ic_format_list_bulleted_black_24dp);
holder.imageViewcategory.setImageResource(R.drawable.ic_format_list_bulleted_icon_24dp);
String preview = "";
try {
JSONArray content = new JSONArray(currentNote.getContent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@
You should have received a copy of the GNU General Public License
along with Privacy Friendly Notes. If not, see <http://www.gnu.org/licenses/>.
*/
package org.secuso.privacyfriendlynotes.ui.fragments;
package org.secuso.privacyfriendlynotes.ui.fragments

import android.os.Bundle;
import android.preference.PreferenceFragment;

import org.secuso.privacyfriendlynotes.R;
import android.os.Bundle
import android.preference.PreferenceFragment
import androidx.appcompat.app.AppCompatDelegate
import org.secuso.privacyfriendlynotes.R

/**
* Fragment that provides the settings.
* Created by Robin on 11.09.2016.
*/
public class SettingsFragment extends PreferenceFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_settings);
class SettingsFragment : PreferenceFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.pref_settings)
findPreference("settings_day_night_theme")?.setOnPreferenceChangeListener { _, newValue ->
AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt())
true;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.preference.PreferenceManager;
import com.google.android.material.navigation.NavigationView;
Expand All @@ -24,8 +25,10 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import android.util.Log;
import android.widget.SearchView;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.arch.core.util.Function;
import androidx.core.view.GravityCompat;
import androidx.appcompat.app.ActionBarDrawerToggle;
Expand Down Expand Up @@ -107,7 +110,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

getSupportActionBar().setStackedBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
//set the OnClickListeners
findViewById(R.id.fab_text).setOnClickListener(this);
findViewById(R.id.fab_checklist).setOnClickListener(this);
Expand Down Expand Up @@ -208,6 +211,10 @@ public boolean onQueryTextSubmit(String query) {
});

PreferenceManager.setDefaultValues(this, R.xml.pref_settings, false);

String theme = PreferenceManager.getDefaultSharedPreferences(this).getString("settings_day_night_theme", "-1");
Log.d("Theme", theme);
AppCompatDelegate.setDefaultNightMode(Integer.parseInt(theme));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ class AudioNoteActivity : BaseNoteActivity(DbContract.NoteEntry.TYPE_AUDIO) {

private fun togglePlayPauseButton() {
if (playing) {
btnPlayPause.setBackgroundResource(R.drawable.ic_pause_black_24dp)
btnPlayPause.setBackgroundResource(R.drawable.ic_pause_icon_24dp)
} else {
btnPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_black_24dp)
btnPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_icon_24dp)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="?attr/colorIconFill"
android:pathData="M4,10.5c-0.83,0 -1.5,0.67 -1.5,1.5s0.67,1.5 1.5,1.5 1.5,-0.67 1.5,-1.5 -0.67,-1.5 -1.5,-1.5zM4,4.5c-0.83,0 -1.5,0.67 -1.5,1.5S3.17,7.5 4,7.5 5.5,6.83 5.5,6 4.83,4.5 4,4.5zM4,16.67c-0.74,0 -1.33,0.6 -1.33,1.33s0.6,1.33 1.33,1.33 1.33,-0.6 1.33,-1.33 -0.59,-1.33 -1.33,-1.33zM7,19h14v-2L7,17v2zM7,13h14v-2L7,11v2zM7,5v2h14L21,5L7,5z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="?attr/colorIconFill"
android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="?attr/colorIconFill"
android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="?attr/colorIconFill"
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="?attr/colorIconFill"
android:pathData="M8,5v14l11,-7z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="?attr/colorIconFill"
android:pathData="M4,9h16v2L4,11zM4,13h10v2L4,15z"/>
</vector>
Binary file removed app/src/main/res/drawable/secuso_logo_blau_blau.png
Binary file not shown.
Loading

0 comments on commit 9ded6b7

Please sign in to comment.