Skip to content
Merged
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
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
minSdk = 27
targetSdk = 36
versionCode = 1
versionName = "1.0.0"
versionName = "1.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
33 changes: 20 additions & 13 deletions app/src/main/java/io/github/iso53/nothingcompass/AboutActivity.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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:"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
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;
import android.view.Gravity;
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;

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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() {
Expand Down
Binary file added app/src/main/res/font/ndot57.otf
Binary file not shown.
Binary file added app/src/main/res/font/ntype82headline.otf
Binary file not shown.
Binary file added app/src/main/res/font/ntype82regular.otf
Binary file not shown.
82 changes: 58 additions & 24 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
tools:context=".AboutActivity">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/aboutToolbar"
<!-- AppBar with collapsing toolbar -->
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorBackground"
android:elevation="0dp"
app:layout_constraintTop_toTopOf="parent"
app:navigationIcon="@drawable/ic_back"
app:title="@string/about_title"
app:titleTextAppearance="@style/TextAppearance.Material3.TitleLarge" />
android:fitsSystemWindows="true"
app:liftOnScrollColor="?android:attr/colorBackground">

<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapseToolbar"
android:layout_width="match_parent"
android:layout_height="112dp"
app:collapsedTitleTextAppearance="@style/TextAppearance.Material3.TitleLarge"
app:collapsedTitleTextColor="?android:attr/textColorPrimary"
app:contentScrim="?android:attr/colorBackground"
app:expandedTitleMarginBottom="16dp"
app:expandedTitleMarginStart="24dp"
app:expandedTitleTextAppearance="@style/TextAppearance.Material3.HeadlineLarge"
app:expandedTitleTextColor="?android:attr/textColorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:title="@string/about_title"
app:titleEnabled="true">

<!-- Transparent background for the expanded state -->
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
app:layout_collapseMode="parallax" />

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/aboutToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:elevation="0dp"
app:layout_collapseMode="pin"
app:navigationIcon="@drawable/ic_back" />

</com.google.android.material.appbar.CollapsingToolbarLayout>

</com.google.android.material.appbar.AppBarLayout>

<!-- Main scrolling content -->
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/textDisclaimer"
app:layout_constraintTop_toBottomOf="@id/aboutToolbar">
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="24dp">
android:padding="24dp"
android:paddingBottom="80dp">

<com.google.android.material.card.MaterialCardView
android:layout_width="120dp"
Expand Down Expand Up @@ -87,18 +122,17 @@
android:text="@string/about_developed_by"
android:textColor="?android:attr/textColorSecondary" />

<TextView
android:id="@+id/textDisclaimer"
style="@style/TextAppearance.Material3.LabelSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:gravity="center"
android:text="@string/about_legal_disclaimer"
android:textColor="?android:attr/textColorSecondary" />

</LinearLayout>
</androidx.core.widget.NestedScrollView>

<TextView
android:id="@+id/textDisclaimer"
style="@style/TextAppearance.Material3.LabelSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="24dp"
android:text="@string/about_legal_disclaimer"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading