fix assorted crap reported by code analysis

This commit is contained in:
Andrew Dolgov 2014-10-31 13:42:19 +03:00
parent 3e078aa1d7
commit 8a15540c61
25 changed files with 87 additions and 185 deletions

View File

@ -27,11 +27,10 @@ dependencies {
compile files('libs/dashclock-api-r1.1.jar')
compile files('libs/jsoup-1.6.1.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
/* compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar' */
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.viewpagerindicator:library:2.4.1'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.code.gson:gson:1.7.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:appcompat-v7:21.0.0'
}

View File

@ -85,8 +85,8 @@
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
<orderEntry type="library" exported="" name="dashclock-api-r1.1" level="project" />
<orderEntry type="library" exported="" name="systembartint-1.0.3" level="project" />
<orderEntry type="library" exported="" name="gson-2.2.4" level="project" />
<orderEntry type="library" exported="" name="jsoup-1.6.1" level="project" />
<orderEntry type="library" exported="" name="gson-1.7.1" level="project" />
<orderEntry type="library" exported="" name="library-2.4.1" level="project" />
<orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.0" level="project" />

View File

@ -1,5 +1,21 @@
package org.fox.ttrss;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.Base64;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
@ -17,30 +33,14 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.Base64;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonElement> {
private final String TAG = this.getClass().getSimpleName();
public enum ApiError { NO_ERROR, HTTP_UNAUTHORIZED, HTTP_FORBIDDEN, HTTP_NOT_FOUND,
HTTP_SERVER_ERROR, HTTP_OTHER_ERROR, SSL_REJECTED, SSL_HOSTNAME_REJECTED, PARSE_ERROR, IO_ERROR, OTHER_ERROR, API_DISABLED,
API_UNKNOWN, LOGIN_FAILED, INVALID_URL, API_INCORRECT_USAGE, NETWORK_UNAVAILABLE, API_UNKNOWN_METHOD };
API_UNKNOWN, LOGIN_FAILED, INVALID_URL, API_INCORRECT_USAGE, NETWORK_UNAVAILABLE, API_UNKNOWN_METHOD }
public static final int API_STATUS_OK = 0;
public static final int API_STATUS_OK = 0;
public static final int API_STATUS_ERR = 1;
private String m_api;

View File

@ -19,7 +19,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebView.HitTestResult;
@ -51,7 +50,7 @@ public class ArticleFragment extends Fragment {
m_article = article;
}
private View.OnTouchListener m_gestureListener;
//private View.OnTouchListener m_gestureListener;
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
@ -84,7 +83,6 @@ public class ArticleFragment extends Fragment {
@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
m_activity.setProgressBarVisibility(true);
if (savedInstanceState != null) {
m_article = savedInstanceState.getParcelable("article");
@ -209,7 +207,7 @@ public class ArticleFragment extends Fragment {
}
final WebView web = (WebView)view.findViewById(R.id.content);
final WebView web = (WebView)view.findViewById(R.id.article_content);
if (web != null) {
@ -241,16 +239,6 @@ public class ArticleFragment extends Fragment {
}
}
web.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
m_activity.setProgress(Math.round(((float)progress / 100f) * 10000));
if (progress == 100) {
m_activity.setProgressBarVisibility(false);
}
}
});
String content;
String cssOverride = "";
@ -359,8 +347,8 @@ public class ArticleFragment extends Fragment {
e.printStackTrace();
}
if (m_activity.isSmallScreen())
web.setOnTouchListener(m_gestureListener);
// if (m_activity.isSmallScreen())
// web.setOnTouchListener(m_gestureListener);
web.setVisibility(View.VISIBLE);
}

View File

@ -17,7 +17,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -184,12 +183,6 @@ public class ArticleImagesPagerActivity extends CommonActivity {
// we use that before parent onCreate so let's init locally
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
requestWindowFeature(Window.FEATURE_PROGRESS);
setProgressBarVisibility(false);
setProgressBarIndeterminateVisibility(false);
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);

View File

@ -94,8 +94,6 @@ public class ArticlePager extends Fragment {
m_listener.onArticleSelected(m_article, false);
m_activity.setProgressBarVisibility(true);
pager.setAdapter(m_adapter);
UnderlinePageIndicator indicator = (UnderlinePageIndicator)view.findViewById(R.id.article_titles);
@ -142,9 +140,6 @@ public class ArticlePager extends Fragment {
@SuppressWarnings({ "serial" })
protected void refresh(boolean append) {
//m_activity.setLoadingStatus(R.string.blank, true);
m_activity.setProgressBarVisibility(true);
//m_activity.m_pullToRefreshAttacher.setRefreshing(true);
if (!m_feed.equals(GlobalState.getInstance().m_activeFeed)) {
append = false;
@ -160,9 +155,6 @@ public class ArticlePager extends Fragment {
protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
m_activity.setProgressBarVisibility(false);
//m_activity.m_pullToRefreshAttacher.setRefreshComplete();
super.onPostExecute(result);
if (result != null) {

View File

@ -324,7 +324,6 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
protected void onPostExecute(JsonElement result) {
if (isDetached()) return;
m_activity.setProgressBarVisibility(false);
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(false);
if (getView() != null) {

View File

@ -520,8 +520,6 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
}
}
m_activity.setProgressBarVisibility(false);
//m_activity.m_pullToRefreshAttacher.setRefreshComplete();
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(false);
if (result != null) {

View File

@ -68,9 +68,9 @@ import java.util.HashMap;
import java.util.TimeZone;
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener {
public static enum ArticlesSelection { ALL, NONE, UNREAD };
public static enum ArticlesSelection { ALL, NONE, UNREAD }
public static final int HEADLINES_REQUEST_SIZE = 30;
public static final int HEADLINES_REQUEST_SIZE = 30;
public static final int HEADLINES_BUFFER_MAX = 500;
private final String TAG = this.getClass().getSimpleName();
@ -417,7 +417,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
m_refreshInProgress = true;
if (m_swipeLayout != null) m_swipeLayout.setRefreshing(true);
m_activity.setProgressBarVisibility(true);
if (!m_feed.equals(GlobalState.getInstance().m_activeFeed)) {
append = false;
@ -459,8 +458,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
}
}
m_activity.setProgressBarVisibility(false);
super.onPostExecute(result);
if (isAdded()) {

View File

@ -25,7 +25,6 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;
@ -76,9 +75,9 @@ public class OnlineActivity extends CommonActivity {
protected abstract class OnLoginFinishedListener {
public abstract void OnLoginSuccess();
public abstract void OnLoginFailed();
};
}
private BroadcastReceiver m_broadcastReceiver = new BroadcastReceiver() {
private BroadcastReceiver m_broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context content, Intent intent) {
@ -134,9 +133,9 @@ public class OnlineActivity extends CommonActivity {
onOptionsItemSelected(item);
return false;
}
};
}
protected String getSessionId() {
protected String getSessionId() {
return GlobalState.getInstance().m_sessionId;
}
@ -152,19 +151,10 @@ public class OnlineActivity extends CommonActivity {
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
// if (canUseProgress()) {
requestWindowFeature(Window.FEATURE_PROGRESS);
// }
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarVisibility(false);
setProgressBarIndeterminateVisibility(false);
// SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE);
SharedPreferences localPrefs = getSharedPreferences("localprefs", Context.MODE_PRIVATE);
@ -1207,8 +1197,6 @@ public class OnlineActivity extends CommonActivity {
if (loadingContainer != null) {
loadingContainer.setVisibility(status == R.string.blank ? View.GONE : View.VISIBLE);
}
setProgressBarIndeterminateVisibility(showProgress);
}
protected void logout() {

View File

@ -21,7 +21,6 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;
@ -71,9 +70,9 @@ public class OfflineActivity extends CommonActivity {
onOptionsItemSelected(item);
return false;
}
};
}
@Override
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
/* AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo(); */
@ -167,14 +166,10 @@ public class OfflineActivity extends CommonActivity {
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
requestWindowFeature(Window.FEATURE_PROGRESS);
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);
setProgressBarVisibility(false);
setContentView(R.layout.login);
initMenu();

View File

@ -22,7 +22,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebView.HitTestResult;
@ -217,40 +216,30 @@ public class OfflineArticleFragment extends Fragment {
note.setVisibility(View.GONE);
}
final WebView web = (WebView)view.findViewById(R.id.content);
final WebView web = (WebView)view.findViewById(R.id.article_content);
if (web != null) {
web.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
HitTestResult result = ((WebView)v).getHitTestResult();
@Override
public boolean onLongClick(View v) {
HitTestResult result = ((WebView) v).getHitTestResult();
if (result != null && (result.getType() == HitTestResult.IMAGE_TYPE || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) {
registerForContextMenu(web);
m_activity.openContextMenu(web);
unregisterForContextMenu(web);
return true;
} else {
if (m_activity.isCompatMode()) {
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
shiftPressEvent.dispatch(web);
}
if (result != null && (result.getType() == HitTestResult.IMAGE_TYPE || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) {
registerForContextMenu(web);
m_activity.openContextMenu(web);
unregisterForContextMenu(web);
return true;
} else {
if (m_activity.isCompatMode()) {
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
shiftPressEvent.dispatch(web);
}
return false;
}
}
});
web.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
m_activity.setProgress(Math.round(((float)progress / 100f) * 10000));
if (progress == 100) {
m_activity.setProgressBarVisibility(false);
}
}
});
return false;
}
}
});
String content;
String cssOverride = "";

View File

@ -48,9 +48,9 @@ import java.util.Date;
import java.util.TimeZone;
public class OfflineHeadlinesFragment extends Fragment implements OnItemClickListener, AbsListView.OnScrollListener {
public static enum ArticlesSelection { ALL, NONE, UNREAD };
public static enum ArticlesSelection { ALL, NONE, UNREAD }
private final String TAG = this.getClass().getSimpleName();
private final String TAG = this.getClass().getSimpleName();
private int m_feedId;
private boolean m_feedIsCat = false;
@ -324,8 +324,6 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
list.setEmptyView(view.findViewById(R.id.no_headlines));
registerForContextMenu(list);
getActivity().setProgressBarIndeterminateVisibility(false);
return view;
}

View File

@ -1,12 +1,5 @@
package org.fox.ttrss.offline;
import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.OnlineActivity;
import org.fox.ttrss.R;
import org.fox.ttrss.util.DatabaseHelper;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
@ -20,6 +13,13 @@ import android.util.Log;
import com.google.gson.JsonElement;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.OnlineActivity;
import org.fox.ttrss.R;
import org.fox.ttrss.util.DatabaseHelper;
import java.util.HashMap;
public class OfflineUploadService extends IntentService {
private final String TAG = this.getClass().getSimpleName();
@ -122,9 +122,9 @@ public class OfflineUploadService extends IntentService {
private enum ModifiedCriteria {
READ, MARKED, PUBLISHED
};
}
private String getModifiedIds(ModifiedCriteria criteria) {
private String getModifiedIds(ModifiedCriteria criteria) {
String criteriaStr = "";

View File

@ -1,10 +1,5 @@
package org.fox.ttrss.share;
import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@ -14,6 +9,11 @@ import android.widget.EditText;
import com.google.gson.JsonElement;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import java.util.HashMap;
public class ShareActivity extends CommonShareActivity {
private final String TAG = this.getClass().getSimpleName();

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ics_divider_vertical_bitmap"
android:gravity="fill_vertical|right" />

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ics_divider_vertical_bitmap"
android:gravity="fill_vertical|right" />

View File

@ -92,7 +92,7 @@
android:text="[Article note]" />
<org.fox.ttrss.util.LessBrokenWebView
android:id="@+id/content"
android:id="@+id/article_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

View File

@ -7,7 +7,7 @@
android:padding="5sp" >
<org.fox.ttrss.util.TitleWebView
android:id="@+id/content"
android:id="@+id/article_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">

View File

@ -1,15 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="@+id/feeds_fragment"
android:background="?smallScreenBackground"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>

View File

@ -31,7 +31,7 @@
android:singleLine="true"
android:text="{FEED}"
android:textColor="?feedlistTextColor"
android:textSize="18dip" />
android:textSize="18sp" />
<TextView
android:id="@+id/unread_counter"

View File

@ -32,7 +32,7 @@
android:singleLine="true"
android:text="{FEED}"
android:textColor="?feedlistSelectedTextColor"
android:textSize="18dip" />
android:textSize="18sp" />
<TextView
android:id="@+id/unread_counter"

View File

@ -1,9 +1,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines"
android:fitsSystemWindows="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/fragment_container"
@ -29,4 +28,4 @@
</FrameLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@ -17,6 +17,7 @@
<EditText
android:id="@+id/url"
android:inputType="textUri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"

View File

@ -1,9 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.fox.ttrss.ArticleImagesPagerActivity" >
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>