diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d4cc9ca..d9316e8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,7 +14,7 @@ android { minSdk = 27 targetSdk = 36 versionCode = 1 - versionName = "1.0.0" + versionName = "1.1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/io/github/iso53/nothingcompass/AboutActivity.java b/app/src/main/java/io/github/iso53/nothingcompass/AboutActivity.java index 099bac4..4e227f1 100644 --- a/app/src/main/java/io/github/iso53/nothingcompass/AboutActivity.java +++ b/app/src/main/java/io/github/iso53/nothingcompass/AboutActivity.java @@ -1,16 +1,18 @@ package io.github.iso53.nothingcompass; +import android.content.SharedPreferences; +import android.graphics.Typeface; import android.os.Bundle; import android.widget.TextView; import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; -import androidx.core.graphics.Insets; -import androidx.core.view.ViewCompat; -import androidx.core.view.WindowInsetsCompat; import androidx.appcompat.app.AppCompatDelegate; +import androidx.core.content.res.ResourcesCompat; import androidx.preference.PreferenceManager; -import android.content.SharedPreferences; + +import com.google.android.material.appbar.CollapsingToolbarLayout; + import io.github.iso53.nothingcompass.preference.PreferenceConstants; public class AboutActivity extends AppCompatActivity { @@ -26,15 +28,7 @@ protected void onCreate(Bundle savedInstanceState) { EdgeToEdge.enable(this); setContentView(R.layout.activity_about); - ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.aboutToolbar), (v, insets) -> { - Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); - v.setPadding(systemBars.left, systemBars.top, systemBars.right, 0); - return insets; - }); - - findViewById(R.id.aboutToolbar).setOnClickListener(v -> finish()); - ((androidx.appcompat.widget.Toolbar) findViewById(R.id.aboutToolbar)) - .setNavigationOnClickListener(v -> finish()); + setupToolbar(); TextView versionText = findViewById(R.id.textVersion); try { @@ -45,4 +39,17 @@ protected void onCreate(Bundle savedInstanceState) { versionText.setText(getString(R.string.about_version, "1.0")); } } + + private void setupToolbar() { + // Add back button + findViewById(R.id.aboutToolbar).setOnClickListener(v -> finish()); + ((androidx.appcompat.widget.Toolbar) findViewById(R.id.aboutToolbar)) + .setNavigationOnClickListener(v -> finish()); + + // Change the font of the title + CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapseToolbar); + Typeface typeface = ResourcesCompat.getFont(this, R.font.ntype82headline); + collapsingToolbar.setExpandedTitleTypeface(typeface); + collapsingToolbar.setCollapsedTitleTypeface(typeface); + } } diff --git a/app/src/main/java/io/github/iso53/nothingcompass/MainActivity.java b/app/src/main/java/io/github/iso53/nothingcompass/MainActivity.java index 3daf802..500a8a3 100644 --- a/app/src/main/java/io/github/iso53/nothingcompass/MainActivity.java +++ b/app/src/main/java/io/github/iso53/nothingcompass/MainActivity.java @@ -8,11 +8,11 @@ import androidx.activity.EdgeToEdge; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatDelegate; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; import androidx.fragment.app.Fragment; -import androidx.appcompat.app.AppCompatDelegate; import androidx.preference.PreferenceManager; import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.widget.ViewPager2; diff --git a/app/src/main/java/io/github/iso53/nothingcompass/OptionsActivity.java b/app/src/main/java/io/github/iso53/nothingcompass/OptionsActivity.java index 07f1eab..4b904f0 100644 --- a/app/src/main/java/io/github/iso53/nothingcompass/OptionsActivity.java +++ b/app/src/main/java/io/github/iso53/nothingcompass/OptionsActivity.java @@ -3,20 +3,20 @@ import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; -import androidx.core.graphics.Insets; -import androidx.core.view.ViewCompat; -import androidx.core.view.WindowInsetsCompat; +import androidx.core.content.res.ResourcesCompat; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.android.gms.oss.licenses.OssLicensesMenuActivity; +import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.util.ArrayList; @@ -40,29 +40,23 @@ protected void onCreate(Bundle savedInstanceState) { EdgeToEdge.enable(this); setContentView(R.layout.activity_options); - ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.optionsToolbar), - (v, insets) -> { - Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); - v.setPadding(systemBars.left, systemBars.top, systemBars.right, 0); - return insets; - }); - - // Handle bottom padding for RecyclerView to avoid navigation bar overlap - ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.optionsRecyclerView), (v, - insets) -> { - Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); - v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), - systemBars.bottom + v.getPaddingBottom()); - return insets; - }); - - // Setup Toolbar - findViewById(R.id.optionsToolbar).setOnClickListener(v -> finish()); - ((androidx.appcompat.widget.Toolbar) findViewById(R.id.optionsToolbar)).setNavigationOnClickListener(v -> finish()); - + setupToolbar(); setupRecyclerView(); } + private void setupToolbar() { + // Add back button + findViewById(R.id.optionsToolbar).setOnClickListener(v -> finish()); + ((androidx.appcompat.widget.Toolbar) findViewById(R.id.optionsToolbar)) + .setNavigationOnClickListener(v -> finish()); + + // Change the font of the title + CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapseToolbar); + Typeface typeface = ResourcesCompat.getFont(this, R.font.ntype82headline); + collapsingToolbar.setExpandedTitleTypeface(typeface); + collapsingToolbar.setCollapsedTitleTypeface(typeface); + } + private void setupRecyclerView() { RecyclerView recyclerView = findViewById(R.id.optionsRecyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); @@ -114,26 +108,29 @@ private void showThemeSelectionDialog() { AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); int checkedItem = 2; // Default to System - if (currentTheme == AppCompatDelegate.MODE_NIGHT_NO) checkedItem = 0; - else if (currentTheme == AppCompatDelegate.MODE_NIGHT_YES) checkedItem = 1; - - new MaterialAlertDialogBuilder(this).setTitle(R.string.item_theme).setSingleChoiceItems(themes, checkedItem, (dialog, which) -> { - int mode; - switch (which) { - case 0: - mode = AppCompatDelegate.MODE_NIGHT_NO; - break; - case 1: - mode = AppCompatDelegate.MODE_NIGHT_YES; - break; - default: - mode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; - break; - } - prefs.edit().putInt(PreferenceConstants.THEME, mode).apply(); - AppCompatDelegate.setDefaultNightMode(mode); - dialog.dismiss(); - }).show(); + if (currentTheme == AppCompatDelegate.MODE_NIGHT_NO) + checkedItem = 0; + else if (currentTheme == AppCompatDelegate.MODE_NIGHT_YES) + checkedItem = 1; + + new MaterialAlertDialogBuilder(this).setTitle(R.string.item_theme) + .setSingleChoiceItems(themes, checkedItem, (dialog, which) -> { + int mode; + switch (which) { + case 0: + mode = AppCompatDelegate.MODE_NIGHT_NO; + break; + case 1: + mode = AppCompatDelegate.MODE_NIGHT_YES; + break; + default: + mode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; + break; + } + prefs.edit().putInt(PreferenceConstants.THEME, mode).apply(); + AppCompatDelegate.setDefaultNightMode(mode); + dialog.dismiss(); + }).show(); } private void showHapticFeedbackSelectionDialog() { @@ -145,11 +142,12 @@ private void showHapticFeedbackSelectionDialog() { int checkedItem = currentHaptic ? 0 : 1; - new MaterialAlertDialogBuilder(this).setTitle(R.string.item_haptic_feedback).setSingleChoiceItems(options, checkedItem, (dialog, which) -> { - boolean enabled = (which == 0); - prefs.edit().putBoolean(PreferenceConstants.HAPTIC_FEEDBACK, enabled).apply(); - dialog.dismiss(); - }).show(); + new MaterialAlertDialogBuilder(this).setTitle(R.string.item_haptic_feedback) + .setSingleChoiceItems(options, checkedItem, (dialog, which) -> { + boolean enabled = (which == 0); + prefs.edit().putBoolean(PreferenceConstants.HAPTIC_FEEDBACK, enabled).apply(); + dialog.dismiss(); + }).show(); } private void openPlayStore() { @@ -184,7 +182,10 @@ private void sendFeedbackEmail() { String deviceInfo = "\n\n\n------------------------------" + "\nDevice Diagnostics " + "(Please do not delete):" + "\nApp Version: " + appVersion + "\nAndroid Version: " - + android.os.Build.VERSION.RELEASE + " (SDK " + android.os.Build.VERSION.SDK_INT + ")" + "\nManufacturer: " + android.os.Build.MANUFACTURER + "\nModel: " + android.os.Build.MODEL + "\nProduct: " + android.os.Build.PRODUCT; + + android.os.Build.VERSION.RELEASE + " (SDK " + android.os.Build.VERSION.SDK_INT + ")" + + "\nManufacturer: " + android.os.Build.MANUFACTURER + "\nModel: " + + android.os.Build.MODEL + + "\nProduct: " + android.os.Build.PRODUCT; Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); diff --git a/app/src/main/java/io/github/iso53/nothingcompass/view/InclinometerView.java b/app/src/main/java/io/github/iso53/nothingcompass/view/InclinometerView.java index 001b740..731e32b 100644 --- a/app/src/main/java/io/github/iso53/nothingcompass/view/InclinometerView.java +++ b/app/src/main/java/io/github/iso53/nothingcompass/view/InclinometerView.java @@ -3,7 +3,6 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; -import android.os.Build; import android.os.VibrationEffect; import android.os.Vibrator; import android.util.AttributeSet; diff --git a/app/src/main/java/io/github/iso53/nothingcompass/view/LevelMeterView.java b/app/src/main/java/io/github/iso53/nothingcompass/view/LevelMeterView.java index ca3ba09..045e6e4 100644 --- a/app/src/main/java/io/github/iso53/nothingcompass/view/LevelMeterView.java +++ b/app/src/main/java/io/github/iso53/nothingcompass/view/LevelMeterView.java @@ -5,7 +5,6 @@ import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; -import android.os.Build; import android.os.VibrationEffect; import android.os.Vibrator; import android.util.AttributeSet; @@ -13,6 +12,8 @@ import android.widget.FrameLayout; import android.widget.TextView; +import androidx.core.content.res.ResourcesCompat; + import com.google.android.material.R; import com.google.android.material.color.MaterialColors; @@ -88,6 +89,8 @@ private TextView initializeDegreeTextView(Context context) { textView.setTextSize(DEGREE_TEXT_SIZE_SP); textView.setText(" 0°"); textView.setGravity(Gravity.CENTER); + textView.setTypeface(ResourcesCompat.getFont(context, + io.github.iso53.nothingcompass.R.font.ndot57)); return textView; } @@ -241,7 +244,8 @@ private void updateOrientation() { // Determine if the rotating line is closer to horizontal or vertical // The line orientation switches every 90 degrees float normalizedAngle = normalizeAngle(spin, 180f); - isHorizontal = normalizedAngle < ORIENTATION_THRESHOLD || normalizedAngle > (180f - ORIENTATION_THRESHOLD); + isHorizontal = + normalizedAngle < ORIENTATION_THRESHOLD || normalizedAngle > (180f - ORIENTATION_THRESHOLD); } private void updateDegreeDisplay() { diff --git a/app/src/main/res/font/ndot57.otf b/app/src/main/res/font/ndot57.otf new file mode 100644 index 0000000..40409bc Binary files /dev/null and b/app/src/main/res/font/ndot57.otf differ diff --git a/app/src/main/res/font/ntype82headline.otf b/app/src/main/res/font/ntype82headline.otf new file mode 100644 index 0000000..ef566fd Binary files /dev/null and b/app/src/main/res/font/ntype82headline.otf differ diff --git a/app/src/main/res/font/ntype82regular.otf b/app/src/main/res/font/ntype82regular.otf new file mode 100644 index 0000000..2049123 Binary files /dev/null and b/app/src/main/res/font/ntype82regular.otf differ diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 7127312..5d9708b 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,5 +1,5 @@ - - + + android:fitsSystemWindows="true" + app:liftOnScrollColor="?android:attr/colorBackground"> + + + + + + + + + + + + + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + android:padding="24dp" + android:paddingBottom="80dp"> + + - - - + diff --git a/app/src/main/res/layout/activity_options.xml b/app/src/main/res/layout/activity_options.xml index b2fa332..097e802 100644 --- a/app/src/main/res/layout/activity_options.xml +++ b/app/src/main/res/layout/activity_options.xml @@ -1,5 +1,5 @@ - - + + android:fitsSystemWindows="true" + app:liftOnScrollColor="?android:attr/colorBackground"> + + + + + + + + + + + + + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + + + - diff --git a/app/src/main/res/layout/fragment_compass.xml b/app/src/main/res/layout/fragment_compass.xml index 48d24e7..f9cd702 100644 --- a/app/src/main/res/layout/fragment_compass.xml +++ b/app/src/main/res/layout/fragment_compass.xml @@ -223,7 +223,8 @@ app:layout_constraintCircle="@+id/center_point" app:layout_constraintCircleAngle="0" app:layout_constraintCircleRadius="@dimen/_90sdp" - tools:ignore="MissingConstraints" /> + tools:ignore="MissingConstraints" + android:fontFamily="@font/ntype82headline"/> + tools:ignore="MissingConstraints" + android:fontFamily="@font/ntype82headline"/> + tools:ignore="MissingConstraints" + android:fontFamily="@font/ntype82headline"/> + tools:ignore="MissingConstraints" + android:fontFamily="@font/ntype82headline"/> @@ -304,16 +308,17 @@ android:id="@+id/currentCompassDegree" android:layout_width="match_parent" android:layout_height="wrap_content" - android:fontFamily="sans-serif-medium" + android:fontFamily="@font/ndot57" android:gravity="center" android:text='@{" " + String.valueOf((int) model.azimuth.degrees) + "°"}' - android:textSize="@dimen/_40ssp" /> + android:textSize="@dimen/_45ssp" />