Skip to content

Commit

Permalink
Lowered code technical debt of 20%
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Feb 21, 2015
1 parent 6807aa5 commit 9258ac6
Show file tree
Hide file tree
Showing 68 changed files with 388 additions and 1,555 deletions.
27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,30 @@ allprojects {
}
}
}







apply plugin: "sonar-runner"

sonarRunner {
sonarProperties {
// can be also set on command line like -Dsonar.analysis.mode=incremental
property "sonar.host.url", "http://localhost:9000"
property "sonar.analysis.mode", "incremental"
property 'sonar.sourceEncoding', 'UTF-8'
property 'sonar.language', 'java'
property 'sonar.profile', 'Default'
}
}

subprojects {
sonarRunner {
sonarProperties {
properties["sonar.sources"] += "omniNotes/src/main/java"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testRemoveExistentDetailFragment() {

public MainActivity getActivity() {
if (super.getActivity().getClass().isAssignableFrom(MainActivity.class)) {
return (MainActivity) super.getActivity();
return super.getActivity();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@

package it.feio.android.omninotes.test.utils;

import android.test.InstrumentationTestCase;

import org.junit.Test;

import java.io.IOException;

import it.feio.android.omninotes.OmniNotes;
import it.feio.android.omninotes.utils.ConnectionManager;
import it.feio.android.omninotes.utils.GeocodeHelper;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;

public class GeocodeHelperTest extends InstrumentationTestCase {

private final Double LAT = 43.799328;
private final Double LON = 11.171552;
public class GeocodeHelperTest {

@Test
public void testGetAddressFromCoordinates() throws IOException {
if (ConnectionManager.internetAvailable(OmniNotes.getAppContext())) {
Double LAT = 43.799328;
Double LON = 11.171552;
String address = GeocodeHelper.getAddressFromCoordinates(OmniNotes.getAppContext(), LAT, LON);
assertTrue(address.length() > 0);
Assert.assertTrue(address.length() > 0);
}
}
}
6 changes: 3 additions & 3 deletions omniNotes/src/main/assets/html/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="padded center">
<p>
Omni Notes is an open source project available at&nbsp;<a href="http://goo.gl/Fc15Wy">https://github.com/federicoiosue/Omni-Notes</a>&nbsp;and
the complete app changelog is available</span> <span style="color:#0099cc;"><a
the complete app changelog is available<span style="color:#0099cc;"><a
href="https://github.com/federicoiosue/Omni-Notes/commits/master">here</a></span>
</p>

Expand All @@ -73,7 +73,7 @@
</div>

<div class="padded">
<strong>Opensource libraries and scripts used</strong></p>
<strong>Opensource libraries and scripts used</strong>
<ul>
<li><a href="https://github.com/ACRA/acra">Acra</a> by A.C.R.A</li>
<li><a href="https://github.com/gabrielemariotti/changeloglib">ChangelogLib</a> by Gabriele Mariotti</li>
Expand All @@ -91,7 +91,7 @@
</div>

<div class="padded">
<strong>Contributions</strong></p>
<strong>Contributions</strong>
<p>These companies gave their paid products for free to contributo to open-source</p>
<ul>
<li><a href="https://testobject.com">TestObject</a> by TestObject</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import roboguice.util.Ln;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;

//import com.espian.showcaseview.ShowcaseView;
Expand All @@ -57,8 +58,6 @@
@SuppressLint("Registered")
public class BaseActivity extends ActionBarActivity implements LocationListener {

private final boolean TEST = false;

protected final int TRANSITION_VERTICAL = 0;
protected final int TRANSITION_HORIZONTAL = 1;

Expand Down Expand Up @@ -86,15 +85,7 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
protected void onCreate(Bundle savedInstanceState) {
/*
* Executing the application in test will activate ScrictMode to debug
* heavy i/o operations on main thread and data sending to GA will be
* disabled
*/
if (TEST) {
StrictMode.enableDefaults();
// GoogleAnalytics.getInstance(this).setDryRun(true);
}
StrictMode.enableDefaults();
// Preloads shared preferences for all derived classes
prefs = getSharedPreferences(Constants.PREFS_NAME, MODE_MULTI_PROCESS);
// Starts location manager
Expand All @@ -107,7 +98,8 @@ protected void onCreate(Bundle savedInstanceState) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception ex) {
} catch (Exception e) {
Ln.d("Just a little issue in physical menu button management", e);
}
super.onCreate(savedInstanceState);
}
Expand Down Expand Up @@ -157,11 +149,6 @@ public void onProviderDisabled(String provider) {
}


protected boolean navigationArchived() {
return "1".equals(prefs.getString(Constants.PREF_NAVIGATION, "0"));
}


protected void showToast(CharSequence text, int duration) {
if (prefs.getBoolean("settings_enable_info", true)) {
Toast.makeText(getApplicationContext(), text, duration).show();
Expand All @@ -183,7 +170,7 @@ public static void requestPassword(final Activity mActivity, final PasswordValid
MaterialDialog dialog = new MaterialDialog.Builder(mActivity)
.autoDismiss(false)
.title(R.string.insert_security_password)
.customView(v)
.customView(v, false)
.positiveText(R.string.ok)
.callback(new MaterialDialog.SimpleCallback() {
@Override
Expand Down Expand Up @@ -256,7 +243,7 @@ public void onPasswordValidated(boolean passwordConfirmed) {


public void updateNavigation(String nav) {
prefs.edit().putString(Constants.PREF_NAVIGATION, nav).commit();
prefs.edit().putString(Constants.PREF_NAVIGATION, nav).apply();
navigation = nav;
navigationTmp = null;
}
Expand Down Expand Up @@ -335,7 +322,7 @@ public static void notifyAppWidgets(Context mActivity) {
// Home widgets
AppWidgetManager mgr = AppWidgetManager.getInstance(mActivity);
int[] ids = mgr.getAppWidgetIds(new ComponentName(mActivity, ListWidgetProvider.class));
Ln.d("Notifies AppWidget data changed for widgets " + ids);
Ln.d("Notifies AppWidget data changed for widgets " + Arrays.toString(ids));
mgr.notifyAppWidgetViewDataChanged(ids, R.id.widget_list);

// Dashclock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class CategoryActivity extends Activity {
ColorPicker picker;
Button deleteBtn;
Button saveBtn;
Button discardBtn;
private CategoryActivity mActivity;
private boolean colorChanged = false;

Expand Down Expand Up @@ -84,12 +83,6 @@ protected void onCreate(Bundle savedInstanceState) {
}


// @Override
// public void onBackPressed() {
// discard();
// }


private void initViews() {
title = (EditText) findViewById(R.id.category_title);
description = (EditText) findViewById(R.id.category_description);
Expand Down Expand Up @@ -146,12 +139,6 @@ public void onClick(View v) {
}
}
});
// discardBtn.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View v) {
// discard();
// }
// });
}


Expand Down Expand Up @@ -181,11 +168,6 @@ private void saveCategory() {
DbHelper db = DbHelper.getInstance(this);
category = db.updateCategory(category);

// If category has no its an insertion and id is filled from db
// if (category.getId() == null) {
// category.setId((int)n);
// }

// Sets result to show proper message
getIntent().putExtra(Constants.INTENT_TAG, category);
setResult(RESULT_OK, getIntent());
Expand All @@ -205,36 +187,6 @@ private void deleteCategory() {
msg = getString(R.string.delete_unused_category_confirmation);

// Showing dialog
// final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
// alertDialogBuilder.setMessage(msg)
// .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int id) {
// // Changes navigation if actually are shown notes associated with this category
// SharedPreferences prefs = getSharedPreferences(Constants.PREFS_NAME, MODE_MULTI_PROCESS);
// String navNotes = getResources().getStringArray(R.array.navigation_list_codes)[0];
// String navigation = prefs.getString(Constants.PREF_NAVIGATION, navNotes);
// if (String.valueOf(category.getId()).equals(navigation))
// prefs.edit().putString(Constants.PREF_NAVIGATION, navNotes).commit();
// // Removes category and edit notes associated with it
// DbHelper db = DbHelper.getInstance(mActivity);
// db.deleteCategory(category);
//
// // Sets result to show proper message
// setResult(RESULT_CANCELED);
// finish();
// }
// }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
// dialog = alertDialogBuilder.create();
// dialog.show();

new MaterialDialog.Builder(this)
.content(msg)
.positiveText(R.string.ok)
Expand All @@ -246,7 +198,7 @@ public void onPositive(MaterialDialog dialog) {
String navNotes = getResources().getStringArray(R.array.navigation_list_codes)[0];
String navigation = prefs.getString(Constants.PREF_NAVIGATION, navNotes);
if (String.valueOf(category.getId()).equals(navigation))
prefs.edit().putString(Constants.PREF_NAVIGATION, navNotes).commit();
prefs.edit().putString(Constants.PREF_NAVIGATION, navNotes).apply();
// Removes category and edit notes associated with it
DbHelper db = DbHelper.getInstance(mActivity);
db.deleteCategory(category);
Expand All @@ -258,29 +210,18 @@ public void onPositive(MaterialDialog dialog) {
}).build().show();
}

// private void discard() {
// // Sets result to show proper message
// setResult(RESULT_FIRST_USER);
// finish();
// }


public boolean goHome() {

public void goHome() {
// In this case the caller activity is DetailActivity
if (getIntent().getBooleanExtra("noHome", false)) {
setResult(RESULT_OK);
super.finish();
return true;
}

NavUtils.navigateUpFromSameTask(this);
return true;
}


public void save(Bitmap bitmap) {

if (bitmap == null) {
setResult(RESULT_CANCELED);
super.finish();
Expand All @@ -290,6 +231,7 @@ public void save(Bitmap bitmap) {
Uri uri = getIntent().getParcelableExtra(MediaStore.EXTRA_OUTPUT);
File bitmapFile = new File(uri.getPath());
FileOutputStream out = new FileOutputStream(bitmapFile);
assert bitmap != null;
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);

if (bitmapFile.exists()) {
Expand All @@ -302,8 +244,7 @@ public void save(Bitmap bitmap) {
super.finish();

} catch (Exception e) {
e.printStackTrace();
Ln.d("Error writing sketch image data");
Ln.d("Bitmap not found", e);
}
}
}
Loading

0 comments on commit 9258ac6

Please sign in to comment.