Skip to content

Commit

Permalink
Cleanup some Android Studio lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Aug 28, 2018
1 parent 75c48ad commit 033e4df
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 102 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light" >
android:theme="@android:style/Theme.Material.Light"
tools:ignore="GoogleAppIndexingWarning">
<receiver android:name="com.termux.api.TermuxApiReceiver"/>
<activity android:name="com.termux.api.DialogActivity" android:theme="@style/DialogTheme" android:noHistory="true" android:excludeFromRecents="true" android:exported="false"/>
<activity android:name=".FingerprintAPI$FingerprintActivity" android:theme="@android:style/Theme.NoDisplay"
Expand Down
16 changes: 0 additions & 16 deletions app/src/main/java/com/termux/api/DialogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ protected void onDestroy() {

/**
* Extract value extras from intent into String array
* @param intent
* @return
*/
static String[] getInputValues(Intent intent) {
String[] items = new String[] { };
Expand All @@ -115,8 +113,6 @@ static String[] getInputValues(Intent intent) {

/**
* Writes the InputResult to the console
* @param context
* @param result
*/
protected void postResult(final Context context, final InputResult result) {
ResultReturner.returnData(context, getIntent(), new ResultReturner.ResultJsonWriter() {
Expand Down Expand Up @@ -692,7 +688,6 @@ protected InputMethodManager getInputMethodManager() {

/**
* Checks to see if foreground application is Termux
* @return
*/
protected boolean isCurrentAppTermux() {
final ActivityManager activityManager = (ActivityManager) Objects.requireNonNull(getContext()).getSystemService(Context.ACTIVITY_SERVICE);
Expand Down Expand Up @@ -834,7 +829,6 @@ public void onResults(Bundle results) {

/**
* Get string description for error code
* @param error
*/
@Override
public void onError(int error) {
Expand Down Expand Up @@ -956,9 +950,6 @@ void initActivityDisplay(Activity activity) {

/**
* Places our generic widget view type inside a FrameLayout
* @param activity
* @param view
* @return
*/
View getLayoutView(AppCompatActivity activity, T view) {
FrameLayout layout = getFrameLayout(activity);
Expand Down Expand Up @@ -998,9 +989,6 @@ public void onDismiss(DialogInterface dialogInterface) {

/**
* Creates a dialog builder to initialize a dialog w/ a view and button click listeners
* @param activity
* @param clickListener
* @return
*/
AlertDialog.Builder getDialogBuilder(AppCompatActivity activity, DialogInterface.OnClickListener clickListener) {
final Intent intent = activity.getIntent();
Expand Down Expand Up @@ -1029,8 +1017,6 @@ void onDismissed() {

/**
* Create a basic frame layout that will add a margin around our main widget view
* @param activity
* @return
*/
FrameLayout getFrameLayout(AppCompatActivity activity) {
FrameLayout layout = new FrameLayout(activity);
Expand All @@ -1046,8 +1032,6 @@ FrameLayout getFrameLayout(AppCompatActivity activity) {

/**
* Returns an InputResult containing code of our button and the text if we hit OK
* @param button
* @return
*/
InputResult onDialogClick(int button) {
// receive indication of whether the OK or CANCEL button is clicked
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/termux/api/DownloadAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DownloadAPI {
static void onReceive(TermuxApiReceiver apiReceiver, final Context context, final Intent intent) {
ResultReturner.returnData(apiReceiver, intent, new ResultWriter() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
final Uri downloadUri = intent.getData();
if (downloadUri == null) {
out.println("No download URI specified");
Expand Down
21 changes: 0 additions & 21 deletions app/src/main/java/com/termux/api/FingerprintAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public class FingerprintAPI {

/**
* Handles setup of fingerprint sensor and writes Fingerprint result to console
* @param context
* @param intent
*/
static void onReceive(final Context context, final Intent intent) {
resetFingerprintResult();
Expand All @@ -92,9 +90,6 @@ static void onReceive(final Context context, final Intent intent) {

/**
* Writes the result of our fingerprint result to the console
* @param context
* @param intent
* @param result
*/
protected static void postFingerprintResult(Context context, Intent intent, final FingerprintResult result) {
ResultReturner.returnData(context, intent, new ResultReturner.ResultJsonWriter() {
Expand Down Expand Up @@ -123,8 +118,6 @@ public void writeJson(JsonWriter out) throws Exception {

/**
* Ensure that we have a fingerprint sensor and that the user has already enrolled fingerprints
* @param fingerprintManager
* @return
*/
@TargetApi(Build.VERSION_CODES.M)
protected static boolean validateFingerprintSensor(Context context, FingerprintManager fingerprintManager) {
Expand Down Expand Up @@ -186,10 +179,6 @@ protected void handleFingerprint() {

/**
* Handles authentication callback from our fingerprint sensor
* @param context
* @param intent
* @param fingerprintManager
* @param cipher
*/
protected static void authenticateWithFingerprint(final Context context, final Intent intent, final FingerprintManager fingerprintManager, Cipher cipher) {
FingerprintManager.AuthenticationCallback authenticationCallback = new FingerprintManager.AuthenticationCallback() {
Expand Down Expand Up @@ -237,9 +226,6 @@ public void onAuthenticationHelp(int helpCode, CharSequence helpString) { }
/**
* Adds a timeout for our fingerprint sensor which will force a result return if we
* haven't already received one
* @param context
* @param intent
* @param cancellationSignal
*/
protected static void addSensorTimeout(final Context context, final Intent intent, final CancellationSignal cancellationSignal) {
final Handler timeoutHandler = new Handler(Looper.getMainLooper());
Expand All @@ -255,10 +241,6 @@ public void run() {
}, SENSOR_TIMEOUT);
}

/**
* Generates our key
* @param keyStore
*/
protected static void generateKey(KeyStore keyStore) {
try {
KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, KEYSTORE_NAME);
Expand All @@ -280,7 +262,6 @@ protected static void generateKey(KeyStore keyStore) {

/**
* Create the cipher needed for use with our SecretKey
* @return
*/
protected static Cipher getCipher() {
Cipher cipher = null;
Expand Down Expand Up @@ -313,15 +294,13 @@ protected static void addFailedAttempt() {

/**
* Add an error to our fingerprint result
* @param error
*/
protected static void appendFingerprintError(String error) {
fingerprintResult.errors.add(error);
}

/**
* Set the final result of our authentication
* @param authResult
*/
protected static void setAuthResult(String authResult) {
fingerprintResult.authResult = authResult;
Expand Down
16 changes: 1 addition & 15 deletions app/src/main/java/com/termux/api/MediaPlayerAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public class MediaPlayerAPI {

/**
* Starts our PlayerService
* @param context
* @param intent
*/
static void onReceive(final Context context, final Intent intent) {
// Create intent for starting our player service and make sure
Expand All @@ -38,8 +36,6 @@ static void onReceive(final Context context, final Intent intent) {
/**
* Converts time in seconds to a formatted time string: HH:MM:SS
* Hours will not be included if it is 0
* @param totalSeconds
* @return
*/
public static String getTimeString(int totalSeconds) {
int hours = (totalSeconds / 3600);
Expand Down Expand Up @@ -73,7 +69,6 @@ public static class PlayerService extends Service implements MediaPlayer.OnError

/**
* Returns our MediaPlayer instance and ensures it has all the necessary callbacks
* @return
*/
protected MediaPlayer getMediaPlayer() {
if (mediaPlayer == null) {
Expand All @@ -88,10 +83,6 @@ protected MediaPlayer getMediaPlayer() {

/**
* What we received from TermuxApiReceiver but now within this service
* @param intent
* @param flags
* @param startId
* @return
*/
public int onStartCommand(Intent intent, int flags, int startId) {
String command = intent.getAction();
Expand Down Expand Up @@ -166,16 +157,13 @@ public MediaCommandResult handle(MediaPlayer player, Context context, Intent int

/**
* Returns result of executing a media command to termux
* @param context
* @param intent
* @param result
*/
protected static void postMediaCommandResult(final Context context, final Intent intent,
final MediaCommandResult result) {

ResultReturner.returnData(context, intent, new ResultReturner.ResultWriter() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
out.append(result.message + "\n");
if (result.error != null) {
out.append(result.error + "\n");
Expand Down Expand Up @@ -263,8 +251,6 @@ public MediaCommandResult handle(MediaPlayer player, Context context, Intent int

/**
* Creates string showing current position in active track
* @param player
* @return
*/
protected static String getPlaybackPositionString(MediaPlayer player) {
int duration = player.getDuration() / 1000;
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/termux/api/MicRecorderAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public class MicRecorderAPI {

/**
* Starts our MicRecorder service
* @param context
* @param intent
*/
static void onReceive(final Context context, final Intent intent) {
Intent recorderService = new Intent(context, MicRecorderService.class);
Expand Down Expand Up @@ -109,7 +107,6 @@ public void writeResult(PrintWriter out) {

/**
* Returns our MediaPlayer instance and ensures it has all the necessary callbacks
* @return
*/
protected MediaRecorder getMediaRecorder() {
if (mediaRecorder == null) {
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/termux/api/NotificationAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static void onReceiveShowNotification(TermuxApiReceiver apiReceiver, final Conte

ResultReturner.returnData(apiReceiver, intent, new ResultReturner.WithStringInput() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

if (!TextUtils.isEmpty(inputString)) {
Expand Down Expand Up @@ -224,7 +224,6 @@ static PendingIntent createAction(final Context context, String action){
executeIntent.setClassName("com.termux", TERMUX_SERVICE);
executeIntent.putExtra(EXTRA_EXECUTE_IN_BACKGROUND, true);
executeIntent.putExtra(EXTRA_ARGUMENTS, arguments);
PendingIntent pi = PendingIntent.getService(context, 0, executeIntent, 0);
return pi;
return PendingIntent.getService(context, 0, executeIntent, 0);
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/termux/api/NotificationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ public class NotificationService extends NotificationListenerService {
static NotificationService _this;

public static NotificationService get() {
NotificationService ret = _this;
return ret;
return _this;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/termux/api/PhotoAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void onReceive(TermuxApiReceiver apiReceiver, final Context context, Inte

ResultReturner.returnData(apiReceiver, intent, new ResultReturner.ResultWriter() {
@Override
public void writeResult(PrintWriter stdout) throws Exception {
public void writeResult(PrintWriter stdout) {
if (!(outputDir.isDirectory() || outputDir.mkdirs())) {
stdout.println("Not a folder (and unable to create it): " + outputDir.getAbsolutePath());
} else {
Expand Down
11 changes: 1 addition & 10 deletions app/src/main/java/com/termux/api/SensorAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public class SensorAPI {

/**
* Starts our SensorReader service
* @param context
* @param intent
*/
public static void onReceive(final Context context, final Intent intent) {
Intent serviceIntent = new Intent(context, SensorReaderService.class);
Expand Down Expand Up @@ -165,7 +163,7 @@ private void postSensorCommandResult(final Context context, final Intent intent,

ResultReturner.returnData(context, intent, new ResultReturner.ResultWriter() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
out.append(result.message + "\n");
if (result.error != null) {
out.append(result.error + "\n");
Expand Down Expand Up @@ -260,8 +258,6 @@ public SensorCommandResult handle(SensorManager sensorManager, Context context,

/**
* Gets a string array of all user requested sensor names to listen to
* @param intent
* @return
*/
protected static String[] getUserRequestedSensors(Intent intent) {
// sensor values passed to us from user
Expand All @@ -271,9 +267,6 @@ protected static String[] getUserRequestedSensors(Intent intent) {

/**
* Gets a list of all sensors to listen to, that were requested and are available
* @param sensorManager
* @param requestedSensors
* @return
*/
protected static List<Sensor> getSensorsToListenTo(SensorManager sensorManager, String[] requestedSensors, Intent intent) {
List<Sensor> availableSensors = sensorManager.getSensorList(Sensor.TYPE_ALL);
Expand Down Expand Up @@ -320,8 +313,6 @@ protected static void clearSensorValues() {

/**
* Creates SensorOutputWriter to write sensor values to stdout
* @param intent
* @return
*/
protected static SensorOutputWriter createSensorOutputWriter(Intent intent) {
String socketAddress = intent.getStringExtra("socket_output");
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/termux/api/ShareAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void onReceive(TermuxApiReceiver apiReceiver, final Context context, fina
// Read text to share from stdin.
ResultReturner.returnData(apiReceiver, intent, new ResultReturner.WithStringInput() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
if (TextUtils.isEmpty(inputString)) {
out.println("Error: Nothing to share");
return;
Expand All @@ -74,7 +74,7 @@ public void writeResult(PrintWriter out) throws Exception {
// Share specified file.
ResultReturner.returnData(apiReceiver, intent, new ResultReturner.ResultWriter() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
final File fileToShare = new File(fileExtra);
if (!(fileToShare.isFile() && fileToShare.canRead())) {
out.println("ERROR: Not a readable file: '" + fileToShare.getAbsolutePath() + "'");
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/termux/api/SmsSendAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SmsSendAPI {
static void onReceive(TermuxApiReceiver apiReceiver, final Intent intent) {
ResultReturner.returnData(apiReceiver, intent, new ResultReturner.WithStringInput() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
final SmsManager smsManager = SmsManager.getDefault();
String[] recipients = intent.getStringArrayExtra("recipients");

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/termux/api/StorageGetAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class StorageGetAPI {
static void onReceive(TermuxApiReceiver apiReceiver, final Context context, final Intent intent) {
ResultReturner.returnData(apiReceiver, intent, new ResultReturner.ResultWriter() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {
final String fileExtra = intent.getStringExtra("file");
if (fileExtra == null || !new File(fileExtra).getParentFile().canWrite()) {
out.println("ERROR: Not a writable folder: " + fileExtra);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/termux/api/TelephonyAPI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.termux.api;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
Expand Down Expand Up @@ -110,6 +111,7 @@ public void writeJson(JsonWriter out) throws Exception {

static void onReceiveTelephonyDeviceInfo(TermuxApiReceiver apiReceiver, final Context context, final Intent intent) {
ResultReturner.returnData(apiReceiver, intent, new ResultReturner.ResultJsonWriter() {
@SuppressLint("HardwareIds")
@Override
public void writeJson(JsonWriter out) throws Exception {
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/termux/api/TextToSpeechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void onInit(int status) {

ResultReturner.returnData(this, intent, new ResultReturner.WithInput() {
@Override
public void writeResult(PrintWriter out) throws Exception {
public void writeResult(PrintWriter out) {

try {
try {
Expand Down
Loading

0 comments on commit 033e4df

Please sign in to comment.