Skip to content

Commit 2760ad5

Browse files
committed
Improved Code Quality- 3
1 parent 9735d1b commit 2760ad5

File tree

64 files changed

+170
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+170
-231
lines changed

source-code/app/src/androidTest/java/org/buildmlearn/toolkit/espresso/ComprehensionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
@LargeTest
6565
public class ComprehensionTest {
6666
@Rule
67-
public ActivityTestRule<TemplateEditor> mActivityRule =
67+
public final ActivityTestRule<TemplateEditor> mActivityRule =
6868
new ActivityTestRule<TemplateEditor>(TemplateEditor.class) {
6969
@Override
7070
protected Intent getActivityIntent() {
@@ -204,15 +204,15 @@ public void saveAPK() {
204204
onView(withText("Save APK")).perform(click());
205205

206206
Intent intent = new Intent();
207-
intent.setAction(android.content.Intent.ACTION_VIEW);
207+
intent.setAction(Intent.ACTION_VIEW);
208208
String finalApk = getText(allOf(withResourceName("content"), is(instanceOf(AppCompatTextView.class))));
209209
finalApk = finalApk.substring(18, finalApk.length());
210210
File file = new File(finalApk);
211211
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
212212
mActivityRule.getActivity().startActivity(intent);
213213
}
214214

215-
String getText(final Matcher<View> matcher) {
215+
private String getText(final Matcher<View> matcher) {
216216
final String[] stringHolder = {null};
217217
onView(matcher).perform(new ViewAction() {
218218
@Override

source-code/app/src/main/java/org/buildmlearn/toolkit/ToolkitApplication.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
*/
1717
public class ToolkitApplication extends Application {
1818

19-
private String projectDir;
20-
private String toolkitDir;
21-
private String apkDir;
22-
2319
private String dir;
2420
private boolean isExternalStorageAvailable = false;
2521

source-code/app/src/main/java/org/buildmlearn/toolkit/activity/HomeActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ protected void onCreate(Bundle savedInstanceState) {
3838
*/
3939
NavigationDrawerFragment mNavigationDrawerFragment = (NavigationDrawerFragment)
4040
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
41-
CharSequence mTitle = getTitle();
4241

4342
// Set up the drawer.
4443
mNavigationDrawerFragment.setUp(

source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected void onCreate(Bundle savedInstanceState) {
3030
ActionBar actionBar = getSupportActionBar();
3131
actionBar.setDisplayHomeAsUpEnabled(true);
3232
actionBar.setHomeButtonEnabled(true);
33-
ListAdapter mAdapter = new TemplateAdapter(this, 6);
33+
ListAdapter mAdapter = new TemplateAdapter(this);
3434
AbsListView mListView = (AbsListView) findViewById(android.R.id.list);
3535
mListView.setAdapter(mAdapter);
3636

source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,12 @@ public void onClick(View v) {
135135
}
136136
});
137137

138-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
139-
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
138+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
140139
!= PackageManager.PERMISSION_GRANTED) {
141140
ActivityCompat.requestPermissions(this,
142141
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
143142
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE_RESULT);
144143
}
145-
}
146144
}
147145

148146
/**
@@ -525,6 +523,8 @@ public void onFail(Exception e) {
525523
case android.R.id.home:
526524
onBackPressed();
527525
break;
526+
default: //do nothing
527+
break;
528528
}
529529
return true;
530530
}
@@ -602,10 +602,10 @@ private String saveProject() {
602602
String author = ((EditText) findViewById(R.id.author_name)).getText().toString();
603603
assert findViewById(R.id.template_title) != null;
604604
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();
605-
if (author.equals("")) {
605+
if ("".equals(author)) {
606606
assert authorEditText != null;
607607
authorEditText.setError("Author name is required");
608-
} else if (title.equals("")) {
608+
} else if ("".equals(title)) {
609609
assert titleEditText != null;
610610
titleEditText.setError("Title is required");
611611
} else {

source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/NavigationDrawerMenuAdapter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
100100
tv.setText(sectionTitle);
101101
tv.setCompoundDrawablesWithIntrinsicBounds(sectionIcon, null, null, null);
102102
tv.setBackgroundColor(backgroundColor);
103-
} else if (menu.getType() == Section.SECTION_DIVIDER) {
104-
if (convertView == null) {
103+
} else if (menu.getType() == Section.SECTION_DIVIDER && convertView == null) {
105104
convertView = inflater.inflate(R.layout.item_section_divider, parent, false);
106-
}
107105
}
108106
return convertView;
109107
}

source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/SavedProjectAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
7979
}
8080

8181
public class ProjectHolder {
82-
TextViewPlus projectName;
83-
TextViewPlus projectIcon;
84-
TextViewPlus details;
82+
public TextViewPlus projectName;
83+
public TextViewPlus projectIcon;
84+
public TextViewPlus details;
8585
}
8686
}

source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/TemplateAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class TemplateAdapter extends BaseAdapter {
2626
private final Template[] templates = Template.values();
2727
private final ListColor[] colors = ListColor.values();
2828

29-
public TemplateAdapter(Context context, int count) {
29+
public TemplateAdapter(Context context) {
3030
this.context = context;
3131
}
3232

source-code/app/src/main/java/org/buildmlearn/toolkit/comprehensionTemplate/Constants.java renamed to source-code/app/src/main/java/org/buildmlearn/toolkit/comprehensiontemplate/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.buildmlearn.toolkit.comprehensionTemplate;
1+
package org.buildmlearn.toolkit.comprehensiontemplate;
22

33
/**
44
* Created by Anupam (opticod) on 5/6/16.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.buildmlearn.toolkit.comprehensionTemplate.data;
1+
package org.buildmlearn.toolkit.comprehensiontemplate.data;
22

33
import android.provider.BaseColumns;
44

0 commit comments

Comments
 (0)