Skip to content

Commit 02350f5

Browse files
committed
Fixed some (not all) warnings by Android Studio
1 parent 468d33b commit 02350f5

15 files changed

+124
-173
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ The Android App JobLogTimer keeps track of the time you work and alarms your to
44

55
# ChangeLog
66

7-
V0.13: versionCode 11, 09.02.2018 Mr
7+
V0.13: versionCode 11, 13.02.2018 Mr
88
- Migrated project to Android Studio
99
- Updated minSdkVersion to 14 and targetSdkVersion to 27 (Android 8.1 / OREO)
1010
- Switched from Locale.US to Locale.getDefault()
1111
- Fixed a bug when work started or ended at fix break time (wrong calc)
12+
- Fixed some (not all) warnings by Android Studio
1213

1314
V0.12: versionCode 10, 18.10.2017 Mr
1415
- Fixed ic_launcher_bw notification icon for V21 (Lollipop) and later.

app/app.iml

+8-22
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@
4949
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
5050
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
5151
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
52-
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
53-
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
54-
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
55-
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
56-
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
57-
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
58-
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
5952
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
6053
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
6154
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
6255
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
6356
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
6457
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
6558
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
59+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
60+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
61+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
62+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
63+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
64+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
65+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
6666
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
6767
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
6868
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
@@ -84,32 +84,18 @@
8484
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
8585
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
8686
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
87-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8887
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
89-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
9088
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
91-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
9289
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
93-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
94-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
95-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
96-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
97-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
98-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
99-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
90+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
10091
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
10192
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
102-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
10393
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
10494
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
105-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
106-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
10795
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
10896
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
10997
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
110-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
11198
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
112-
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
11399
</content>
114100
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
115101
<orderEntry type="sourceFolder" forTests="false" />

app/src/main/AndroidManifest.xml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- $Id: AndroidManifest.xml 202 2017-10-20 07:30:33Z hmueller $ -->
32
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
43
package="de.euhm.jlt"
54
android:versionCode="11"

app/src/main/java/de/euhm/jlt/AboutFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* @name AboutFragment.java
2+
* @file AboutFragment.java
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License")
55
* http://www.apache.org/licenses/LICENSE-2.0

app/src/main/java/de/euhm/jlt/CustomApplication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* $Id: CustomApplication.java 78 2015-02-03 21:19:21Z hmueller $
2+
* @file CustomApplication.java
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License")
55
* http://www.apache.org/licenses/LICENSE-2.0

app/src/main/java/de/euhm/jlt/CustomViewPager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/**
2-
* $Id: CustomViewPager.java 86 2015-02-06 19:48:13Z hmueller $
1+
/*
2+
* @file CustomViewPager.java
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License")
55
* http://www.apache.org/licenses/LICENSE-2.0

app/src/main/java/de/euhm/jlt/MainActivity.java

+33-43
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
/**
2-
* $Id: MainActivity.java 196 2017-01-16 16:58:20Z hmueller $
1+
/*
2+
* @file MainActivity.java
33
*
4-
* Main activity of JobLog
5-
* based on Google EffectiveNavigation example
4+
* Main activity of JobLogTimer
65
*
76
* Licensed under the Apache License, Version 2.0 (the "License")
87
* http://www.apache.org/licenses/LICENSE-2.0
98
*/
109
package de.euhm.jlt;
1110

12-
import java.io.File;
13-
import java.util.Calendar;
14-
import java.util.Locale;
15-
1611
import android.Manifest;
1712
import android.annotation.TargetApi;
1813
import android.app.AlertDialog;
@@ -26,6 +21,7 @@
2621
import android.os.Bundle;
2722
import android.os.Environment;
2823
import android.preference.PreferenceManager;
24+
import android.support.annotation.NonNull;
2925
import android.support.design.widget.FloatingActionButton;
3026
import android.support.design.widget.NavigationView;
3127
import android.support.design.widget.TabLayout;
@@ -39,7 +35,6 @@
3935
import android.support.v4.view.GravityCompat;
4036
import android.support.v4.view.ViewPager;
4137
import android.support.v4.widget.DrawerLayout;
42-
import android.support.v7.app.ActionBar;
4338
import android.support.v7.app.ActionBarDrawerToggle;
4439
import android.support.v7.app.AppCompatActivity;
4540
import android.support.v7.widget.Toolbar;
@@ -52,6 +47,11 @@
5247
import android.widget.ImageView;
5348
import android.widget.TextView;
5449
import android.widget.Toast;
50+
51+
import java.io.File;
52+
import java.util.Calendar;
53+
import java.util.Locale;
54+
5555
import de.euhm.jlt.dao.Times;
5656
import de.euhm.jlt.dao.TimesWork;
5757
import de.euhm.jlt.database.JobLogContract;
@@ -119,32 +119,23 @@ public class MainActivity extends AppCompatActivity implements
119119
* Register in onCreate() and unregister in onDestroy()!
120120
*/
121121
private final BroadcastReceiver receiverRecreate = new BroadcastReceiver() {
122-
@Override
123-
public void onReceive(Context context, Intent intent) {
122+
@Override
123+
public void onReceive(Context context, Intent intent) {
124124
Log.v(LOG_TAG, "Received BroadcastReceiver " + Constants.RECEIVER_RECREATE);
125-
if (Build.VERSION.SDK_INT >= 11) {
126-
recreate();
127-
} else {
128-
Intent mainIntent = getIntent();
129-
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
130-
finish();
131-
overridePendingTransition(0, 0);
132-
startActivity(mainIntent);
133-
overridePendingTransition(0, 0);
134-
}
135-
}
125+
recreate();
126+
}
136127
};
137128

138129
/**
139130
* A {@link BroadcastReceiver} to update the view in this activity.<br>
140131
* Register in onCreate() and unregister in onDestroy()!
141132
*/
142133
private final BroadcastReceiver receiverUpdateView = new BroadcastReceiver() {
143-
@Override
144-
public void onReceive(Context context, Intent intent) {
134+
@Override
135+
public void onReceive(Context context, Intent intent) {
145136
Log.v(LOG_TAG, "Received BroadcastReceiver " + Constants.RECEIVER_UPDATE_VIEW);
146-
supportInvalidateOptionsMenu();
147-
}
137+
supportInvalidateOptionsMenu();
138+
}
148139
};
149140

150141

@@ -183,7 +174,7 @@ public void onCreate(Bundle savedInstanceState) {
183174
//mTW.timeEnd(-1); // only for debugging, resetting End time
184175

185176
// Setup FloatingActionButton from android.support.design.widget.FloatingActionButton for API < 21.
186-
mFab = (FloatingActionButton) findViewById(R.id.fab);
177+
mFab = findViewById(R.id.fab);
187178
// handle the FloatingActionButton click event
188179
mFab.setOnClickListener(new View.OnClickListener() {
189180
@Override
@@ -204,25 +195,24 @@ public void onClick(View v) {
204195
});
205196

206197
// Setup the action bar from android.support.v7.app.ActionBar for API < 21.
207-
Toolbar supportToolbar = (Toolbar) findViewById(R.id.toolbar);
198+
Toolbar supportToolbar = findViewById(R.id.toolbar);
208199
setSupportActionBar(supportToolbar);
209-
final ActionBar actionBar = getSupportActionBar();
210200

211201
// Specify that the Home/Up button should not be enabled, since there is no hierarchical parent.
212-
actionBar.setHomeButtonEnabled(false);
202+
getSupportActionBar().setHomeButtonEnabled(false);
213203

214204
// Setup the ViewPager.
215-
mViewPager = (CustomViewPager) findViewById(R.id.pager);
205+
mViewPager = findViewById(R.id.pager);
216206
// Create the adapter that will return a fragment for each of the primary sections of the app.
217207
mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager(), context);
218208
mViewPager.setAdapter(mAppSectionsPagerAdapter);
219209

220210
// Setup the TabLayout and connect it to the ViewPager.
221-
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
222-
// setupWithViewPager() does not work very well, so we do all the things ourself (see below)
211+
TabLayout tabLayout = findViewById(R.id.tabLayout);
212+
// setupWithViewPager() does not work very well, so we do all the things oneself (see below)
223213
//tabLayout.setupWithViewPager(mViewPager);
224214
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
225-
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
215+
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
226216
@Override
227217
public void onTabSelected(TabLayout.Tab tab) {
228218
// When the given tab is selected, switch to the corresponding page in the ViewPager.
@@ -266,8 +256,8 @@ public void onTabReselected(TabLayout.Tab tab) {
266256
Tab tab = tabLayout.newTab();
267257
tab.setCustomView(R.layout.custom_tab_title);
268258
View tab_view = tab.getCustomView();
269-
TextView tab_title = (TextView) tab_view.findViewById(R.id.title);
270-
ImageView img = (ImageView) tab_view.findViewById(R.id.icon);
259+
TextView tab_title = tab_view.findViewById(R.id.title);
260+
ImageView img = tab_view.findViewById(R.id.icon);
271261
tab_title.setText(mAppSectionsPagerAdapter.getPageTitle(i));
272262
int icon = mAppSectionsPagerAdapter.getPageIcon(i);
273263
if (icon != 0)
@@ -277,7 +267,7 @@ public void onTabReselected(TabLayout.Tab tab) {
277267

278268

279269
// setup the navigation drawer view from android.support.v4.widget.DrawerLayout for API < 21.
280-
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerlayout);
270+
mDrawerLayout = findViewById(R.id.drawerlayout);
281271
// Necessary for automatically animated navigation drawer upon open and close.
282272
// The two strings are not displayed to the user.
283273
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout,
@@ -290,7 +280,7 @@ public void onDrawerStateChanged(int newState) {
290280
mDrawerLayout.addDrawerListener(toggle);
291281
toggle.syncState();
292282

293-
NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_drawer);
283+
NavigationView navigationView = findViewById(R.id.navigation_drawer);
294284
navigationView.setNavigationItemSelectedListener(this);
295285
}
296286

@@ -446,7 +436,7 @@ public boolean onKeyUp(int keycode, KeyEvent event) {
446436

447437
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
448438
@Override
449-
public boolean onNavigationItemSelected(MenuItem item) {
439+
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
450440
// Close drawer on item click
451441
mDrawerLayout.closeDrawers();
452442

@@ -568,7 +558,6 @@ public void onBackPressed() {
568558
@Override
569559
public boolean dispatchTouchEvent(MotionEvent event) {
570560
boolean result = false;
571-
boolean retVal= false;
572561

573562
// detect pinching
574563
int pointerCount = event.getPointerCount();
@@ -598,7 +587,7 @@ public boolean dispatchTouchEvent(MotionEvent event) {
598587
if (!result) {
599588
result = super.dispatchTouchEvent(event);
600589
}
601-
return retVal || result;
590+
return result;
602591
}
603592

604593
// EditTimes Listener
@@ -775,8 +764,9 @@ public void onFinishDatePickerFragment(Calendar cal, int titleId) {
775764
}
776765

777766
@Override
778-
public void onRequestPermissionsResult(int requestCode,
779-
String[] permissions, int[] grantResults) {
767+
public void onRequestPermissionsResult(int requestCode,
768+
@NonNull String[] permissions,
769+
@NonNull int[] grantResults) {
780770
// Handle the permissions request response.
781771
switch (requestCode) {
782772
case Constants.PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE:

0 commit comments

Comments
 (0)