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
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "io.github.iso53.nothingcompass"
minSdk = 27
targetSdk = 36
versionCode = 3
versionName = "1.3.0"
versionCode = 4
versionName = "1.3.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
</intent-filter>
</activity>
<activity android:name=".OptionsActivity" />
<activity
android:name=".NorthTypeActivity"
android:parentActivityName=".OptionsActivity" />
<activity android:name=".AboutActivity" />
</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package io.github.iso53.nothingcompass;

import android.content.SharedPreferences;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.materialswitch.MaterialSwitch;
import androidx.appcompat.widget.Toolbar;
import androidx.preference.PreferenceManager;

import io.github.iso53.nothingcompass.preference.PreferenceConstants;

public class NorthTypeActivity extends AppCompatActivity {

private ImageView northAnimation;
private MaterialSwitch switchTrueNorth;
private SharedPreferences prefs;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_north_type);

setupToolbar();

northAnimation = findViewById(R.id.north_animation);
switchTrueNorth = findViewById(R.id.switch_true_north);
prefs = PreferenceManager.getDefaultSharedPreferences(this);

boolean isTrueNorth = prefs.getBoolean(PreferenceConstants.TRUE_NORTH, false);
switchTrueNorth.setChecked(isTrueNorth);

switchTrueNorth.setOnCheckedChangeListener((buttonView, isChecked) -> {
prefs.edit().putBoolean(PreferenceConstants.TRUE_NORTH, isChecked).apply();
});
}

private void setupToolbar() {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
toolbar.setNavigationOnClickListener(v -> finish());

// Apply custom font to CollapsingToolbarLayout
com.google.android.material.appbar.CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapseToolbar);
android.graphics.Typeface typeface = androidx.core.content.res.ResourcesCompat.getFont(this, R.font.ntype82headline);
if (typeface != null) {
collapsingToolbar.setExpandedTitleTypeface(typeface);
collapsingToolbar.setCollapsedTitleTypeface(typeface);
}
}

@Override
protected void onResume() {
super.onResume();
if (northAnimation.getDrawable() instanceof AnimatedVectorDrawable) {
((AnimatedVectorDrawable) northAnimation.getDrawable()).start();
}
}

@Override
protected void onPause() {
super.onPause();
if (northAnimation.getDrawable() instanceof AnimatedVectorDrawable) {
((AnimatedVectorDrawable) northAnimation.getDrawable()).stop();
}
}

@Override
public boolean onSupportNavigateUp() {
finish();
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package io.github.iso53.nothingcompass;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;

Expand Down Expand Up @@ -72,7 +76,7 @@ private void setupRecyclerView() {
items.add(new OptionItem(getString(R.string.item_high_precision), null,
R.drawable.precision, v -> showHighPrecisionSelectionDialog()));
items.add(new OptionItem(getString(R.string.item_north_reference), null,
R.drawable.ic_compass, v -> showNorthReferenceSelectionDialog()));
R.drawable.ic_compass, v -> startActivity(new Intent(this, NorthTypeActivity.class))));

// Category: App
items.add(new OptionItem(getString(R.string.category_app)));
Expand Down Expand Up @@ -206,7 +210,8 @@ private void sendFeedbackEmail() {
+ 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;
+ "\nProduct: " + android.os.Build.PRODUCT
+ getSensorInfo();

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
Expand All @@ -222,6 +227,43 @@ private void sendFeedbackEmail() {
}
}

private String getSensorInfo() {
SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
StringBuilder sb = new StringBuilder();
sb.append("\n\n--- Sensor Information ---");

if (sensorManager != null) {
List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL);
sb.append("\nTotal Sensors: ").append(sensors.size());

// Focus on key sensors for a compass app
int[] keyTypes = {Sensor.TYPE_MAGNETIC_FIELD, Sensor.TYPE_ACCELEROMETER,
Sensor.TYPE_GYROSCOPE, Sensor.TYPE_ROTATION_VECTOR};
String[] keyNames = {"Magnetometer", "Accelerometer", "Gyroscope", "Rotation Vector"};

for (int i = 0; i < keyTypes.length; i++) {
Sensor s = sensorManager.getDefaultSensor(keyTypes[i]);
sb.append("\n").append(keyNames[i]).append(": ");
if (s != null) {
sb.append(s.getName()).append(" (").append(s.getVendor()).append(")");
} else {
sb.append("Not Available");
}
}
}

LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (locationManager != null) {
sb.append("\n\n--- Location Status ---");
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
sb.append("\nGPS Provider: ").append(gpsEnabled ? "Enabled" : "Disabled");
sb.append("\nNetwork Provider: ").append(networkEnabled ? "Enabled" : "Disabled");
}

return sb.toString();
}

private final androidx.activity.result.ActivityResultLauncher<String> requestPermissionLauncher = registerForActivityResult(
new androidx.activity.result.contract.ActivityResultContracts.RequestPermission(),
isGranted -> {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/animator/anim_declination_rotation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="rotation"
android:valueFrom="0"
android:valueTo="13"
android:valueType="floatType"
android:duration="1400"
android:startOffset="600"
android:interpolator="@android:anim/overshoot_interpolator"
android:repeatCount="infinite"
android:repeatMode="reverse" />
6 changes: 6 additions & 0 deletions app/src/main/res/color/switch_thumb_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/colorTertiary" />
<item android:state_checked="true" android:color="@color/colorBackground" />
<item android:state_checked="false" android:color="@color/colorTertiary" />
</selector>
6 changes: 6 additions & 0 deletions app/src/main/res/color/switch_track_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@android:color/transparent" />
<item android:state_checked="true" android:color="@color/colorOnBackground" />
<item android:state_checked="false" android:color="@android:color/transparent" />
</selector>
6 changes: 6 additions & 0 deletions app/src/main/res/color/switch_track_decoration_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/colorTertiary" />
<item android:state_checked="true" android:color="@color/colorOnBackground" />
<item android:state_checked="false" android:color="@color/colorTertiary" />
</selector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/avd_north_comparison.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/vd_compass_needles">
<target
android:name="true_needle_group"
android:animation="@animator/anim_declination_rotation" />
</animated-vector>
59 changes: 59 additions & 0 deletions app/src/main/res/drawable/vd_compass_needles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="200"
android:viewportHeight="200">
<group android:name="root_group">
<!-- Compass Outer Ring -->
<path
android:fillColor="@android:color/transparent"
android:pathData="M 100,100 m -85,0 a 85,85 0 1,1 170,0 a 85,85 0 1,1 -170,0"
android:strokeColor="@color/colorTertiary"
android:strokeWidth="1.5" />

<!-- Magnetic North North Group -->
<group
android:name="magnetic_needle_group"
android:pivotX="100"
android:pivotY="100">
<path
android:fillColor="@color/colorOnBackground"
android:pathData="M 100,28 L 107,98 L 100,112 L 93,98 Z" />
<path
android:fillColor="@color/colorSecondary"
android:pathData="M 100,112 L 107,98 L 100,172 L 93,98 Z" />
<!-- Magnetic Label "M" -->
<path
android:fillColor="@color/colorOnBackground"
android:pathData="M 97,18 L 100,23 L 103,18 L 104.5,18 L 104.5,26 L 103,26 L 103,20 L 100.5,24 L 99.5,24 L 97,20 L 97,26 L 95.5,26 L 95.5,18 Z" />
</group>

<!-- True North Needle Group -->
<group
android:name="true_needle_group"
android:pivotX="100"
android:pivotY="100"
android:rotation="0">
<path
android:fillColor="@color/colorSecondary"
android:pathData="M 100,34 L 105,98 L 100,110 L 95,98 Z" />
<path
android:fillColor="@color/colorTertiary"
android:pathData="M 100,110 L 105,98 L 100,166 L 95,98 Z" />
<!-- True Label "T" -->
<path
android:fillColor="@color/colorSecondary"
android:pathData="M 96,18 L 104,18 L 104,19.5 L 100.75,19.5 L 100.75,26 L 99.25,26 L 99.25,19.5 L 96,19.5 Z" />
</group>

<!-- Center Pivot Dot -->
<path
android:fillColor="@color/colorSecondary"
android:pathData="M 100,100 m -5,0 a 5,5 0 1,1 10,0 a 5,5 0 1,1 -10,0" />

<!-- Red Center Accent Dot -->
<path
android:fillColor="@color/colorPrimary"
android:pathData="M 100,100 m -2,0 a 2,2 0 1,1 4,0 a 2,2 0 1,1 -4,0" />
</group>
</vector>
Loading
Loading