Remove unused views and util function

This commit is contained in:
tzugen 2021-04-17 21:41:12 +02:00
parent 116307df56
commit 1ee36322db
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
3 changed files with 1 additions and 383 deletions

View File

@ -21,7 +21,6 @@ package org.moire.ultrasonic.util;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.*; import android.content.*;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -35,7 +34,6 @@ import android.graphics.drawable.Drawable;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
@ -44,17 +42,14 @@ import android.util.DisplayMetrics;
import timber.log.Timber; import timber.log.Timber;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.RemoteViews;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import org.moire.ultrasonic.R; import org.moire.ultrasonic.R;
import org.moire.ultrasonic.activity.NavigationActivity;
import org.moire.ultrasonic.data.ActiveServerProvider; import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.domain.*; import org.moire.ultrasonic.domain.*;
import org.moire.ultrasonic.domain.MusicDirectory.Entry; import org.moire.ultrasonic.domain.MusicDirectory.Entry;
@ -852,6 +847,7 @@ public class Util
return; return;
} }
// FIXME: This is probably a bug.
if (currentSong != currentSong) if (currentSong != currentSong)
{ {
Util.currentSong = currentSong; Util.currentSong = currentSong;
@ -1004,74 +1000,6 @@ public class Util
return inSampleSize; return inSampleSize;
} }
public static void linkButtons(Context context, RemoteViews views, boolean playerActive)
{
Intent intent = new Intent(context, NavigationActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
if (playerActive)
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHOW_PLAYER, true);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.appwidget_coverart, pendingIntent);
views.setOnClickPendingIntent(R.id.appwidget_top, pendingIntent);
// Emulate media button clicks.
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
pendingIntent = PendingIntent.getBroadcast(context, 1, intent, 0);
views.setOnClickPendingIntent(R.id.control_play, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT));
pendingIntent = PendingIntent.getBroadcast(context, 2, intent, 0);
views.setOnClickPendingIntent(R.id.control_next, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS));
pendingIntent = PendingIntent.getBroadcast(context, 3, intent, 0);
views.setOnClickPendingIntent(R.id.control_previous, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_STOP));
pendingIntent = PendingIntent.getBroadcast(context, 4, intent, 0);
views.setOnClickPendingIntent(R.id.control_stop, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_1));
pendingIntent = PendingIntent.getBroadcast(context, 5, intent, 0);
views.setOnClickPendingIntent(R.id.notification_five_star_1, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_2));
pendingIntent = PendingIntent.getBroadcast(context, 6, intent, 0);
views.setOnClickPendingIntent(R.id.notification_five_star_2, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_3));
pendingIntent = PendingIntent.getBroadcast(context, 7, intent, 0);
views.setOnClickPendingIntent(R.id.notification_five_star_3, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_4));
pendingIntent = PendingIntent.getBroadcast(context, 8, intent, 0);
views.setOnClickPendingIntent(R.id.notification_five_star_4, pendingIntent);
intent = new Intent(Constants.CMD_PROCESS_KEYCODE);
intent.setPackage(context.getPackageName());
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_5));
pendingIntent = PendingIntent.getBroadcast(context, 9, intent, 0);
views.setOnClickPendingIntent(R.id.notification_five_star_5, pendingIntent);
}
// TODO: Shouldn't this be used when making requests? // TODO: Shouldn't this be used when making requests?
public static int getNetworkTimeout(Context context) public static int getNetworkTimeout(Context context)
{ {

View File

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/statusbar"
android:layout_width="fill_parent"
android:layout_height="64dp"
android:orientation="horizontal"
android:background="@color/background_color_dark"
>
<ImageView
android:id="@+id/notification_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:gravity="center"
tools:background="#FF00FF"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start"
android:orientation="vertical"
android:paddingLeft="12dip"
android:paddingStart="12dp"
>
<TextView
android:id="@+id/trackname"
style="@android:style/TextAppearance.StatusBar.EventContent.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:ellipsize="marquee"
android:focusable="true"
android:maxLines="1"
tools:text="Track name"
/>
<TextView
android:id="@+id/artist"
style="@android:style/TextAppearance.StatusBar.EventContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:ellipsize="end"
android:scrollHorizontally="true"
android:maxLines="1"
tools:text="Artist"
/>
<TextView
android:id="@+id/album"
style="@android:style/TextAppearance.StatusBar.EventContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:ellipsize="end"
android:scrollHorizontally="true"
android:maxLines="1"
tools:text="Album"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="end"
android:orientation="horizontal"
android:paddingRight="8dp">
<ImageButton
android:id="@+id/control_previous"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/btn_bg"
android:scaleType="fitXY"
android:layout_margin="2dp"
android:src="@drawable/media_backward_normal_dark" />
<ImageButton
android:id="@+id/control_play"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@drawable/btn_bg"
android:scaleType="fitXY"
android:src="@drawable/media_pause_normal_dark" />
<ImageButton
android:id="@+id/control_next"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/btn_bg"
android:scaleType="fitXY"
android:layout_margin="2dp"
android:src="@drawable/media_forward_normal_dark" />
<ImageButton
android:id="@+id/control_stop"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:alpha="70"
android:background="@drawable/btn_bg"
android:scaleType="fitXY"
android:src="@drawable/ic_menu_close_dark"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" />
</LinearLayout>
</LinearLayout>

View File

@ -1,189 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/statusbar"
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="horizontal"
android:background="@color/background_color_dark" >
<ImageView
android:id="@+id/notification_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:gravity="center"
tools:background="#ff00ff"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="8dip"
android:paddingTop="8dip"
android:paddingRight="8dip"
android:paddingBottom="8dip"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingRight="4dp">
<TextView
android:id="@+id/trackname"
style="@android:style/TextAppearance.StatusBar.EventContent.Title"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center|start"
android:layout_weight="1"
android:ellipsize="marquee"
android:focusable="true"
android:singleLine="true"
tools:text="Track name" />
<ImageButton
android:id="@+id/control_stop"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_gravity="center|end"
android:background="@drawable/btn_bg"
android:gravity="center_vertical"
android:scaleType="fitXY"
android:src="@drawable/ic_menu_close_dark" />
</LinearLayout>
<TextView
android:id="@+id/artist"
style="@android:style/TextAppearance.StatusBar.EventContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:ellipsize="end"
android:scrollHorizontally="true"
android:maxLines="1"
tools:text="Artist"
/>
<TextView
android:id="@+id/album"
style="@android:style/TextAppearance.StatusBar.EventContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:ellipsize="end"
android:scrollHorizontally="true"
android:maxLines="1"
tools:text="Album"
/>
<LinearLayout
android:id="@+id/notification_rating"
android:layout_width="match_parent"
android:layout_height="24dip"
android:layout_gravity="center"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:id="@+id/notification_five_star_1"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:focusable="false"
android:gravity="center_vertical"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/notification_five_star_2"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:focusable="false"
android:gravity="center_vertical"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/notification_five_star_3"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:focusable="false"
android:gravity="center_vertical"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/notification_five_star_4"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:focusable="false"
android:gravity="center_vertical"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/notification_five_star_5"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:focusable="false"
android:gravity="center_vertical"
android:scaleType="fitCenter" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dip"
android:layout_marginBottom="10dip"
android:background="#DD696969"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/control_previous"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/btn_bg"
android:src="@drawable/media_backward_normal_dark" />
<ImageButton
android:id="@+id/control_play"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/btn_bg"
android:src="@drawable/media_pause_normal_dark" />
<ImageButton
android:id="@+id/control_next"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/btn_bg"
android:src="@drawable/media_forward_normal_dark" />
</LinearLayout>
</LinearLayout>
</LinearLayout>