Skip to content

Commit

Permalink
Help page added, web view gui optimization, menu button in song view …
Browse files Browse the repository at this point in the history
…to add song to setlist
  • Loading branch information
AndInTheClouds committed Nov 30, 2022
1 parent ed66ccf commit 5985f7e
Show file tree
Hide file tree
Showing 44 changed files with 647 additions and 367 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username e.g., user1
issuehunt: # Replace with a single IssueHunt username e.g., user1
otechie: # Replace with a single Otechie username e.g., user1
custom: ['https://flattr.com/@AndInTheClouds']
custom: ['https://paypal.me/hollowbamboo']
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It's an app that:
height="80">](https://f-droid.org/packages/org.hollowbamboo.chordreader2/)

## Status
This is a fork of the abandoned ChordReader app by Nolan Lawson, and Marcel Klehr respectively. It's still under development, e.g. playlists are planned to be implementend.
This is a fork of the abandoned ChordReader app by Nolan Lawson, and Marcel Klehr respectively.
> It's my first project at all. Every comment or support is welcomed.
## License
Expand All @@ -24,6 +24,7 @@ This is a fork of the abandoned ChordReader app by Nolan Lawson, and Marcel Kleh

## Donation
If you would like to donate, visit
[Flattr][2].
[paypal.me/hollowbamboo][2].

[2]: https://paypal.me/hollowbamboo

[2]: https://flattr.com/@AndInTheClouds
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.navigation:navigation-ui:2.5.2'
implementation 'androidx.navigation:navigation-fragment:2.5.2'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.navigation:navigation-ui:2.5.3'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.hollowbamboo.chordreader2"
android:versionCode="2"
android:versionName="2.1.0">
android:versionCode="3"
android:versionName="2.1.1">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
Expand Down
45 changes: 35 additions & 10 deletions app/src/main/java/org/hollowbamboo/chordreader2/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
Expand All @@ -17,7 +15,6 @@
import android.os.HandlerThread;
import android.provider.Settings;
import android.text.method.LinkMovementMethod;
import android.util.DisplayMetrics;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
Expand All @@ -29,10 +26,13 @@
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

Expand All @@ -43,8 +43,6 @@
import org.hollowbamboo.chordreader2.helper.PreferenceHelper;
import org.hollowbamboo.chordreader2.model.DataViewModel;

import java.util.Locale;

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {

private static final int STORAGE_PERMISSION_CODE = 100;
Expand Down Expand Up @@ -107,13 +105,40 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
MobileNavigationDirections.ActionDrawerToListFragment action =
MobileNavigationDirections.actionDrawerToListFragment("Songs");
Navigation.findNavController(this, R.id.nav_host_fragment_content_main).navigate(action);
} else if(itemId == R.id.nav_list_view_playlists) {
} else if(itemId == R.id.nav_list_view_setlists) {
MobileNavigationDirections.ActionDrawerToListFragment action =
MobileNavigationDirections.actionDrawerToListFragment("Playlists");
MobileNavigationDirections.actionDrawerToListFragment("Setlists");
Navigation.findNavController(this, R.id.nav_host_fragment_content_main).navigate(action);
} else if(itemId == R.id.nav_help) {
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment_content_main);

String sectionID = "";

Fragment f = navHostFragment.getChildFragmentManager().getFragments().get(0);
String tag = f.toString();

if (tag.contains("List")) {
if (tag.contains("DraggableList"))
sectionID = ". Setlists";
else {
Bundle bundle = f.getArguments();
if (bundle != null) {
String mode = bundle.getString("mode");
if (mode.equals("Songs"))
sectionID = ". Song";
else if (mode.equals("Setlists") ||
mode.equals("SetlistSongsSelection"))
sectionID = ". Setlists";
}
}
} else if (tag.contains("SongView"))
sectionID = ". Song";
else if (tag.contains("WebSearch"))
sectionID = ". " + getString(R.string.web_search);

MobileNavigationDirections.ActionDrawerToHelpFragment action =
MobileNavigationDirections.actionDrawerToHelpFragment(sectionID);
Navigation.findNavController(this, R.id.nav_host_fragment_content_main).navigate(action);
// TODO: Add help
// } else if(itemId == R.id.nav_help) {
// Navigation.findNavController(this, R.id.nav_host_fragment_content_main).navigate(R.id.nav_help);
} else if(itemId == R.id.nav_settings) {
Navigation.findNavController(this, R.id.nav_host_fragment_content_main).navigate(R.id.nav_settings);
} else if(itemId == R.id.nav_about) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public RecyclerViewAdapter(ArrayList<String> data, OnItemClickListener onItemCli
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_item_playlist_songs, viewGroup, false);
.inflate(R.layout.list_item_setlist_songs, viewGroup, false);

return new ViewHolder(view);
}
Expand Down Expand Up @@ -108,10 +108,10 @@ public ViewHolder(@NonNull View itemView) {

rowView = itemView;

listItemDeleteImageView = itemView.findViewById(R.id.playlist_item_delete);
listItemCountTextView = itemView.findViewById(R.id.playlist_song_count_text_view);
songFileNameTextView = itemView.findViewById(R.id.playlist_song_filename_text_view);
listItemDragHandleImageView = itemView.findViewById(R.id.playlist_item_drag_handle);
listItemDeleteImageView = itemView.findViewById(R.id.setlist_item_delete);
listItemCountTextView = itemView.findViewById(R.id.setlist_song_count_text_view);
songFileNameTextView = itemView.findViewById(R.id.setlist_song_filename_text_view);
listItemDragHandleImageView = itemView.findViewById(R.id.setlist_item_drag_handle);
}

public TextView getListItemCountTextView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void setFirstRunPreference(Context context, boolean bool) {

editor.putBoolean(context.getString(R.string.pref_first_run), bool);

editor.commit();
editor.apply();

}
public static boolean getFirstRunPreference(Context context) {
Expand Down Expand Up @@ -75,7 +75,7 @@ public static void setColorScheme(Context context, ColorScheme colorScheme) {
editor.putString(context.getString(R.string.pref_scheme).toString(),
context.getText(colorScheme.getNameResource()).toString());

editor.commit();
editor.apply();

}

Expand All @@ -96,7 +96,7 @@ public static void setNoteNaming(Context context, String noteNameValue) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Editor editor = sharedPrefs.edit();
editor.putString(context.getString(R.string.pref_note_naming), noteNameValue);
editor.commit();
editor.apply();

}

Expand All @@ -117,7 +117,7 @@ public static void setSearchEngineURL(Context context, String searchEngineURL) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Editor editor = sharedPrefs.edit();
editor.putString(context.getString(R.string.pref_search_engine), searchEngineURL);
editor.commit();
editor.apply();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public static boolean checkIfSdCardExists() {

public static boolean fileExists(String filename) {

filename = rectifyFilename(filename);

File catlogDir = getBaseDirectory();

File file = new File(catlogDir, filename);
Expand All @@ -46,8 +44,6 @@ public static boolean fileExists(String filename) {

public static void deleteFile(String filename) {

filename = rectifyFilename(filename);

File catlogDir = getBaseDirectory();

File file = new File(catlogDir, filename);
Expand All @@ -60,8 +56,6 @@ public static void deleteFile(String filename) {

public static Date getLastModifiedDate(String filename) {

filename = rectifyFilename(filename);

File catlogDir = getBaseDirectory();

File file = new File(catlogDir, filename);
Expand Down Expand Up @@ -98,15 +92,15 @@ public static List<String> getSavedSongNames() {
List<String> result = new ArrayList<String>();

for (File file : tempArrayList) {
String fileName = file.getName().replace("_", " ").replace(".txt", "");
String fileName = file.getName().replace(".txt", "");
result.add(fileName);
}

return result;
}


public static List<String> getSavedPlayListNames() {
public static List<String> getSavedSetListNames() {
List<File> fileNames = getFilenamesInBaseDirectory();

ArrayList<File> tempArrayList = new ArrayList<File>();
Expand All @@ -129,7 +123,7 @@ public int compare(File object1, File object2) {
List<String> result = new ArrayList<String>();

for (File file : tempArrayList) {
String fileName = file.getName().replace("_", " ").replace(".pl", "");
String fileName = file.getName().replace(".pl", "");
result.add(fileName);
}

Expand Down Expand Up @@ -159,23 +153,14 @@ public static boolean isInvalidFilename(CharSequence filename) {
|| filenameAsString.contains("\\")
|| filenameAsString.contains("*")
|| filenameAsString.contains("|")
|| filenameAsString.contains(":")
|| filenameAsString.contains("<")
|| filenameAsString.contains(">")
|| filenameAsString.contains("?");

}

public static String rectifyFilename(String filename) {
filename = filename.replace(" ", "_");

return filename;
}

public static String openFile(String filename) {

filename = rectifyFilename(filename);

File baseDir = getBaseDirectory();
File logFile;

Expand Down Expand Up @@ -211,10 +196,10 @@ public static String openFile(String filename) {
return result.toString();
}

public static List<String> openPlaylist(String filename) {
public static List<String> openSetList(String filename) {

if (!filename.endsWith(".pl"))
filename = rectifyFilename(filename).concat(".pl");
filename = filename.concat(".pl");

File baseDir = getBaseDirectory();
File logFile;
Expand All @@ -235,7 +220,7 @@ public static List<String> openPlaylist(String filename) {
while (bufferedReader.ready()) {
String songFile = bufferedReader.readLine();
if (fileExists(songFile)) {
String songFileName = songFile.replace(".txt", "").replace("_"," ");
String songFileName = songFile.replace(".txt", "");
filenames.add(songFileName);
}
}
Expand All @@ -256,8 +241,6 @@ public static List<String> openPlaylist(String filename) {

public static boolean saveFile(String filetext, String filename) {

filename = rectifyFilename(filename);

File baseDir = getBaseDirectory();

File newFile = new File(baseDir, filename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@
public class DataViewModel extends ViewModel {

public String mode;
public ArrayList<String> playlistSongs;
public ArrayList<String> setListSongs;

private MutableLiveData<String> playlistMLD;
public MutableLiveData<ArrayList<String>> playlistSongsMLD;
private MutableLiveData<String> setListMLD;
public MutableLiveData<ArrayList<String>> setListSongsMLD;

public void setPlaylistMLD(String playlist) {
playlistMLD = new MutableLiveData<>();
playlistMLD.setValue(playlist);
public void setSetListMLD(String setlist) {
setListMLD = new MutableLiveData<>();
setListMLD.setValue(setlist);

playlistSongs = (ArrayList<String>) SaveFileHelper.openPlaylist(playlist);
setListSongs = (ArrayList<String>) SaveFileHelper.openSetList(setlist);

playlistSongsMLD = new MutableLiveData<>();
playlistSongsMLD.setValue(playlistSongs);
setListSongsMLD = new MutableLiveData<>();
setListSongsMLD.setValue(setListSongs);
}

public MutableLiveData<String> getPlaylistMLD() {
return playlistMLD;
public MutableLiveData<String> getSetListMLD() {
return setListMLD;
}

public MutableLiveData<ArrayList<String>> getPlaylistSongsMLD() { return playlistSongsMLD; }
public MutableLiveData<ArrayList<String>> getSetListSongsMLD() { return setListSongsMLD; }

public void setPlaylistSongs(ArrayList<String> playlistSongs) {
this.playlistSongs = playlistSongs;
playlistSongsMLD.setValue(playlistSongs);
public void setSetListSongs(ArrayList<String> setListSongs) {
this.setListSongs = setListSongs;
setListSongsMLD.setValue(setListSongs);
}

public void resetData() {
playlistSongs = null;
playlistMLD = null;
playlistSongsMLD = null;
setListSongs = null;
setListMLD = null;
setListSongsMLD = null;
}
}
Loading

0 comments on commit 5985f7e

Please sign in to comment.