Merge branch 'master' into legacy

legacy
sh123 2022-07-26 16:01:36 +03:00
commit 3e1fb4f30e
11 zmienionych plików z 121 dodań i 8 usunięć

Wyświetl plik

@ -1,7 +1,5 @@
package com.radio.codec2talkie.protocol.aprs;
import android.util.Log;
import java.nio.ByteBuffer;
public class AprsDataFactory {

Wyświetl plik

@ -0,0 +1,88 @@
package com.radio.codec2talkie.protocol.aprs.tools;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.widget.ImageView;
import com.radio.codec2talkie.R;
import java.util.ArrayList;
public class AprsSymbolTable {
private final ArrayList<Bitmap> _primaryTableIcons;
private final ArrayList<Bitmap> _secondaryTableIcons;
private final ArrayList<Bitmap> _overlayTableIcons;
private final int _cellWidth = 24;
private final int _cellHeight = 24;
private final int _cntWidth = 16;
private final int _cntHeight = 6;
private static AprsSymbolTable _symbolTable;
public static AprsSymbolTable getInstance(Context context) {
if (_symbolTable == null) {
synchronized (AprsSymbolTable.class) {
_symbolTable = new AprsSymbolTable(context);
}
}
return _symbolTable;
}
private AprsSymbolTable(Context context) {
ImageView imageViewPrimary = new ImageView(context);
imageViewPrimary.setImageResource(R.drawable.aprs_symbols_24_0);
_primaryTableIcons = Load(imageViewPrimary, _cellWidth, _cellHeight, _cntWidth, _cntHeight);
ImageView imageViewSecondary = new ImageView(context);
imageViewSecondary.setImageResource(R.drawable.aprs_symbols_24_1);
_secondaryTableIcons = Load(imageViewSecondary, _cellWidth, _cellHeight, _cntWidth, _cntHeight);
ImageView imageViewOverlay = new ImageView(context);
imageViewOverlay.setImageResource(R.drawable.aprs_symbols_24_2);
_overlayTableIcons = Load(imageViewOverlay, _cellWidth, _cellHeight, _cntWidth, _cntHeight);
}
public Bitmap bitmapFromSymbol(String symbolCode) {
if (symbolCode.length() != 2) return null;
char table = symbolCode.charAt(0);
char symbol = symbolCode.charAt(1);
int symbolIconIndex = (int)symbol - 33;
int overlayIconIndex = (int)table - 33;
if (symbolIconIndex < 0 || symbolIconIndex >= (_cntWidth * _cntHeight)) return null;
if (table == '/') {
return _primaryTableIcons.get(symbolIconIndex);
} else if (table == '\\') {
return _secondaryTableIcons.get(symbolIconIndex);
}
if (overlayIconIndex < 0 || overlayIconIndex >= (_cntWidth * _cntHeight)) return null;
Bitmap icon = _secondaryTableIcons.get(symbolIconIndex);
Bitmap overlayIcon = _overlayTableIcons.get(overlayIconIndex);
Bitmap bmOverlay = Bitmap.createBitmap(icon.getWidth() * 2, icon.getHeight() * 2, icon.getConfig());
Canvas canvas = new Canvas(bmOverlay);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
canvas.drawBitmap(icon, 0, 0, paint);
canvas.drawBitmap(overlayIcon, 0, 0, paint);
return bmOverlay;
}
private ArrayList<Bitmap> Load(ImageView imageView, int cellWidth, int cellHeight, int cntWidth, int cntHeight) {
ArrayList<Bitmap> bitmaps = new ArrayList<>(cntWidth * cntHeight);
BitmapDrawable bitmapDrawable = (BitmapDrawable) imageView.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
for (int y = 0; y < cntHeight; y++) {
for (int x = 0; x < cntWidth; x++) {
Bitmap cellBitmap = Bitmap.createBitmap(bitmap, x * cellWidth, y * cellHeight, cellWidth, cellHeight);
bitmaps.add(cellBitmap);
}
}
return bitmaps;
}
}

Wyświetl plik

@ -2,16 +2,21 @@ package com.radio.codec2talkie.storage.log.group;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.location.Location;
import android.location.LocationManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.radio.codec2talkie.MainActivity;
import com.radio.codec2talkie.R;
import com.radio.codec2talkie.protocol.aprs.tools.AprsSymbolTable;
import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.tools.UnitTools;
@ -19,23 +24,29 @@ import java.util.Locale;
public class LogItemGroupHolder extends RecyclerView.ViewHolder {
private static final String TAG = RecyclerView.class.getSimpleName();
private final TextView _logItemViewTitle;
private final TextView _logItemViewDistance;
private final TextView _logItemViewMessage;
private final ImageView _symbolIcon;
private final LocationManager _locationManager;
private final AprsSymbolTable _symbolTable;
private LogItemGroupHolder(View itemView) {
super(itemView);
_logItemViewTitle = itemView.findViewById(R.id.log_view_group_item_title);
_logItemViewDistance = itemView.findViewById(R.id.log_view_group_item_distance);
_logItemViewMessage = itemView.findViewById(R.id.log_view_group_item_message);
_symbolIcon = itemView.findViewById(R.id.log_view_group_item_icon);
_symbolTable = AprsSymbolTable.getInstance(itemView.getContext());
_locationManager = (LocationManager) itemView.getContext().getSystemService(Context.LOCATION_SERVICE);
}
public void bind(LogItemGroup group) {
@SuppressLint("MissingPermission") Location loc = _locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (loc == null) {
_logItemViewDistance.setText(R.string.log_item_group_holder_unknown_km);
_logItemViewDistance.setText("");
} else {
double distanceKm = Position.distanceTo(loc.getLatitude(), loc.getLongitude(), loc.getAltitude(),
group.getLatitude(), group.getLongitude(), group.getAltitudeMeters()) / 1000.0;
@ -44,8 +55,7 @@ public class LogItemGroupHolder extends RecyclerView.ViewHolder {
}
_logItemViewTitle.setText(String.format(Locale.US, "%s",
group.getSrcCallsign()));
_logItemViewMessage.setText(String.format(Locale.US, "%s %s %f %f %03d° %03dkm/h %04dm %s %s",
group.getSymbolCode(),
_logItemViewMessage.setText(String.format(Locale.US, "%s %f %f %03d° %03dkm/h %04dm %s %s",
group.getMaidenHead(),
group.getLatitude(),
group.getLongitude(),
@ -54,6 +64,13 @@ public class LogItemGroupHolder extends RecyclerView.ViewHolder {
(int)group.getAltitudeMeters(),
group.getStatus(),
group.getComment()));
String symbol = group.getSymbolCode();
Bitmap iconBitmap = _symbolTable.bitmapFromSymbol(symbol);
if (iconBitmap == null) {
Log.e(TAG, "Cannot load bitmap for " + symbol);
} else {
_symbolIcon.setImageBitmap(iconBitmap);
}
}
static LogItemGroupHolder create(ViewGroup parent) {

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 38 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 41 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 12 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 124 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 131 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 40 KiB

Wyświetl plik

@ -6,13 +6,22 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/log_view_group_item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/log_view_group_item_icon_description"
android:src="@drawable/ic_app_action"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/log_view_group_item_title"
style="@style/log_item_title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:lines="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@+id/log_view_group_item_icon"
app:layout_constraintTop_toTopOf="parent" />
<TextView
@ -30,7 +39,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/log_view_group_item_title" />
</androidx.constraintlayout.widget.ConstraintLayout>

Wyświetl plik

@ -289,4 +289,5 @@
<string name="log_view_menu_stations">View stations</string>
<string name="log_view_station_history">Station history</string>
<string name="log_item_group_holder_unknown_km">\? km</string>
<string name="log_view_group_item_icon_description">APRS icon</string>
</resources>