Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sdk #66

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.5.1'
}
}

Expand All @@ -23,15 +23,15 @@ allprojects {
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdk 35
namespace "org.billthefarmer.tuner"

defaultConfig {
applicationId "org.billthefarmer.tuner"
minSdkVersion 23
targetSdkVersion 28
versionName "1.56"
versionCode 156
targetSdkVersion 35
versionName "1.57"
versionCode 157

buildConfigField "long", "BUILT", System.currentTimeMillis() + "L"
}
Expand All @@ -40,11 +40,8 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
disable 'IconDensities', 'ClickableViewAccessibility', 'AndroidGradlePluginVersion',
'CustomViewStyleable', 'TypographyFractions', 'OldTargetApi',
'NonConstantResourceId', 'ExpiredTargetSdkVersion', 'MissingInflatedId'
// abortOnError false
lint {
disable 'IconDensities', 'ClickableViewAccessibility', 'AndroidGradlePluginVersion', 'CustomViewStyleable', 'TypographyFractions', 'NonConstantResourceId', 'MissingInflatedId'
}

}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
org.gradle.jvmargs=-Xmx1536M
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 4 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
</activity>
<activity android:name="org.billthefarmer.tuner.Settings">

</activity>
<activity android:name=".CustomTemperament"
android:windowSoftInputMode="adjustResize">

</activity>
</application>

Expand Down
118 changes: 118 additions & 0 deletions src/main/java/org/billthefarmer/tuner/CustomTemperament.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package org.billthefarmer.tuner;

import android.app.ActionBar;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class CustomTemperament extends Activity {

private static final String CUSTOM_FILE = "Custom.txt";

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Get preferences
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(this);

int theme = Integer.parseInt(preferences.getString(Tuner.PREF_THEME,
"0"));
switch (theme)
{
case Tuner.LIGHT:
setTheme(R.style.AppTheme);
break;

case Tuner.DARK:
setTheme(R.style.AppDarkTheme);
break;

case Tuner.WHITE:
setTheme(R.style.AppWhiteTheme);
break;

case Tuner.BLACK:
setTheme(R.style.AppBlackTheme);
break;
}

// Enable back navigation on action bar
ActionBar actionBar = getActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);

setContentView(R.layout.temperament_editor);

EditText customTemperamentsText = findViewById(R.id.customTemperamentText);
Button saveButton = findViewById(R.id.saveButton);

// Check custom temperaments file
File custom = new File(getExternalFilesDir(null),
CUSTOM_FILE);

if (custom.exists()) {
try
{
FileInputStream fis = new FileInputStream(custom);
InputStreamReader sr = new InputStreamReader(fis);
BufferedReader reader = new BufferedReader(sr);

StringBuilder fileText = new StringBuilder();
String line;
while((line = reader.readLine()) != null) {
fileText.append(line);
fileText.append("\n");
}
customTemperamentsText.setText(fileText);
reader.close();
}

catch(Exception e)
{
Log.e("CustomTemperaments", "Error loading custom temperaments", e);
return;
}
}

saveButton.setOnClickListener(view -> {
String textToSave = customTemperamentsText.getText().toString();

try {
if (!custom.exists()) {
custom.createNewFile();
}
FileWriter fw = new FileWriter(custom);

fw.write(textToSave);
fw.close();
finish();
} catch (IOException ioe) {
Log.e("CustomTemperaments", "Error saving custom temperaments", ioe);
}
});
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home){
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
}
18 changes: 5 additions & 13 deletions src/main/java/org/billthefarmer/tuner/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@

import android.app.ActionBar;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
Expand Down Expand Up @@ -59,7 +57,6 @@ public class SettingsFragment extends android.preference.PreferenceFragment

private static final String TAG = "Tuner";
private static final String CUSTOM_FILE = "Custom.txt";
private static final String CUSTOM_PATH = "Tuner/Custom.txt";

private String summary;

Expand Down Expand Up @@ -120,9 +117,6 @@ public void onCreate(Bundle savedInstanceState)
String s = String.format(summary, f);
picker.setSummary(s);

// Load custom temperaments
loadCustomTemperaments();

// Reset bach preference on solfa
CheckBoxPreference check =
(CheckBoxPreference) findPreference(Tuner.PREF_SOLFA);
Expand Down Expand Up @@ -159,6 +153,7 @@ public void onCreate(Bundle savedInstanceState)
public void onResume()
{
super.onResume();
loadCustomTemperaments();
getPreferenceScreen().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
Expand Down Expand Up @@ -314,9 +309,6 @@ private void loadCustomTemperaments()
// Check custom temperaments file
File custom = new File(getActivity().getExternalFilesDir(null),
CUSTOM_FILE);
if (!custom.canRead())
custom = new File(Environment.getExternalStorageDirectory(),
CUSTOM_PATH);
if (!custom.canRead())
return;

Expand Down Expand Up @@ -358,10 +350,10 @@ private void loadCustomTemperaments()
// Get the temperament entries and entry values
ListPreference preference =
(ListPreference) findPreference(Tuner.PREF_TEMPER);
List<CharSequence> entries = new
ArrayList<CharSequence>(Arrays.asList(preference.getEntries()));
List<CharSequence> values = new
ArrayList<CharSequence>(Arrays.asList(preference.getEntryValues()));
List<String> entries = new ArrayList<>(
Arrays.asList(getResources().getStringArray(R.array.pref_temper_entries)));
List<String> values = new ArrayList<>(
Arrays.asList(getResources().getStringArray(R.array.pref_temper_entry_values)));

// Add custom entries and entry values
int value = values.size();
Expand Down
26 changes: 26 additions & 0 deletions src/main/res/layout/temperament_editor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Custom temperament data"
android:labelFor="@id/customTemperamentText"
/>
<EditText
android:id="@+id/customTemperamentText"
android:layout_width="match_parent"
android:layout_height="0dp"
android:ems="10"
android:gravity="start|top"
android:inputType="textMultiLine"
android:layout_weight="1"/>
<Button
android:id="@+id/saveButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"/>
</LinearLayout>
8 changes: 8 additions & 0 deletions src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@
android:key="pref_temper"
android:summary="@string/pref_temper_summ"
android:title="@string/pref_temper" />
<Preference
android:dialogIcon="?attr/pref_temper"
android:title="Set Custom Temperaments"
android:key="custom_temper">
<intent
android:targetPackage="org.billthefarmer.tuner"
android:targetClass="org.billthefarmer.tuner.CustomTemperament" />
</Preference>
<ListPreference
android:defaultValue="@integer/default_key"
android:dialogIcon="?attr/pref_key"
Expand Down