mirror of
https://github.com/woheller69/solxpect.git
synced 2025-09-22 00:40:46 +02:00
add compass
This commit is contained in:
parent
07fb5f0b9e
commit
84752cee9c
4 changed files with 35 additions and 3 deletions
|
@ -41,4 +41,5 @@ dependencies {
|
||||||
implementation 'net.lingala.zip4j:zip4j:2.9.1'
|
implementation 'net.lingala.zip4j:zip4j:2.9.1'
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1" //needed due to duplicate class error
|
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1" //needed due to duplicate class error
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" //needed due to duplicate class error
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" //needed due to duplicate class error
|
||||||
|
implementation 'com.github.woheller69:CompassView:a63c67da90'
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@ package org.woheller69.weather.activities;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.redinput.compassview.CompassView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
@ -183,6 +184,7 @@ public class ManageLocationsActivity extends NavigationActivity {
|
||||||
EditText editLongitude = (EditText) dialogView.findViewById(R.id.EditLocation_Lon);
|
EditText editLongitude = (EditText) dialogView.findViewById(R.id.EditLocation_Lon);
|
||||||
EditText editCity = (EditText) dialogView.findViewById(R.id.EditLocation_Name);
|
EditText editCity = (EditText) dialogView.findViewById(R.id.EditLocation_Name);
|
||||||
EditText editAzimuth = (EditText) dialogView.findViewById(R.id.EditLocation_Azimuth);
|
EditText editAzimuth = (EditText) dialogView.findViewById(R.id.EditLocation_Azimuth);
|
||||||
|
CompassView editCompass = (CompassView) dialogView.findViewById(R.id.EditLocation_Compass);
|
||||||
EditText editTilt = (EditText) dialogView.findViewById(R.id.EditLocation_Tilt);
|
EditText editTilt = (EditText) dialogView.findViewById(R.id.EditLocation_Tilt);
|
||||||
EditText editCellsMaxPower = (EditText) dialogView.findViewById(R.id.EditLocation_Cell_Max_Power);
|
EditText editCellsMaxPower = (EditText) dialogView.findViewById(R.id.EditLocation_Cell_Max_Power);
|
||||||
EditText editCellsArea = (EditText) dialogView.findViewById(R.id.EditLocation_Cells_Area);
|
EditText editCellsArea = (EditText) dialogView.findViewById(R.id.EditLocation_Cells_Area);
|
||||||
|
@ -198,8 +200,22 @@ public class ManageLocationsActivity extends NavigationActivity {
|
||||||
editLatitude.setFilters(new InputFilter[]{ new InputFilterMinMax(-90, 90)});
|
editLatitude.setFilters(new InputFilter[]{ new InputFilterMinMax(-90, 90)});
|
||||||
editLongitude.setText(Float.toString(city.getLongitude()));
|
editLongitude.setText(Float.toString(city.getLongitude()));
|
||||||
editLongitude.setFilters(new InputFilter[]{ new InputFilterMinMax(-180, 180)});
|
editLongitude.setFilters(new InputFilter[]{ new InputFilterMinMax(-180, 180)});
|
||||||
|
editCompass.setDegrees(city.getLongitude());
|
||||||
|
editCompass.setOnCompassDragListener(degrees -> { editAzimuth.setText(Float.toString(Math.round(degrees))); });
|
||||||
editAzimuth.setText(Float.toString(city.getAzimuthAngle()));
|
editAzimuth.setText(Float.toString(city.getAzimuthAngle()));
|
||||||
editAzimuth.setFilters(new InputFilter[]{ new InputFilterMinMax(0, 360)});
|
editAzimuth.setFilters(new InputFilter[]{ new InputFilterMinMax(0, 360)});
|
||||||
|
editAzimuth.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { }
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
float azimuth = Float.parseFloat(!editAzimuth.getText().toString().isEmpty() ? editAzimuth.getText().toString() : "0");
|
||||||
|
editCompass.setDegrees(azimuth);
|
||||||
|
}
|
||||||
|
});
|
||||||
editTilt.setText(Float.toString(city.getTiltAngle()));
|
editTilt.setText(Float.toString(city.getTiltAngle()));
|
||||||
editTilt.setFilters(new InputFilter[]{ new InputFilterMinMax(0, 90)});
|
editTilt.setFilters(new InputFilter[]{ new InputFilterMinMax(0, 90)});
|
||||||
editCellsMaxPower.setText(Float.toString(city.getCellsMaxPower()));
|
editCellsMaxPower.setText(Float.toString(city.getCellsMaxPower()));
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -45,6 +45,20 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/edit_location_hint_azimuth"/>
|
android:hint="@string/edit_location_hint_azimuth"/>
|
||||||
|
|
||||||
|
<com.redinput.compassview.CompassView
|
||||||
|
android:id="@+id/EditLocation_Compass"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
app:backgroundColor="#FFFFFF"
|
||||||
|
app:showMarker="true"
|
||||||
|
app:markerColor="@color/colorAccent"
|
||||||
|
app:lineColor="#000000"
|
||||||
|
app:textColor="#000000"
|
||||||
|
app:textSize="12sp"
|
||||||
|
app:rangeDegrees="180.0"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatEditText
|
<androidx.appcompat.widget.AppCompatEditText
|
||||||
android:id="@+id/EditLocation_Azimuth"
|
android:id="@+id/EditLocation_Azimuth"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -23,6 +23,7 @@ allprojects {
|
||||||
url 'https://maven.google.com/'
|
url 'https://maven.google.com/'
|
||||||
name 'Google'
|
name 'Google'
|
||||||
}
|
}
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue