Skip to content

Commit b05e2f3

Browse files
authored
Merge pull request #161 from BuildmLearn/bug-fixes
Update the Master Branch from bug-fixes branch - Added a preview link of App - Improved Code Quality - 5 - Refactor Codes - fixed app crash in phones with api level<19 due to object.equals - added header and footer views before setting adapter - added search functionality for list views
2 parents 2cc66c3 + 904ffd3 commit b05e2f3

File tree

87 files changed

+656
-385
lines changed

Some content is hidden

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

87 files changed

+656
-385
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/BuildmLearn/BuildmLearn-Toolkit-Android.svg)](https://travis-ci.org/BuildmLearn/BuildmLearn-Toolkit-Android) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/05c83f4ecad84cc0a2e57d7ea39df41f)](https://www.codacy.com/app/anupam/BuildmLearn-Toolkit-Android?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=BuildmLearn/BuildmLearn-Toolkit-Android&amp;utm_campaign=Badge_Grade)
1+
[![Preview the app](https://img.shields.io/badge/Preview-Appetize.io-green.svg)](https://appetize.io/app/k56b095hpt7ppmhmmhbg2ayj20) [![Build Status](https://travis-ci.org/BuildmLearn/BuildmLearn-Toolkit-Android.svg)](https://travis-ci.org/BuildmLearn/BuildmLearn-Toolkit-Android) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/05c83f4ecad84cc0a2e57d7ea39df41f)](https://www.codacy.com/app/anupam/BuildmLearn-Toolkit-Android?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=BuildmLearn/BuildmLearn-Toolkit-Android&amp;utm_campaign=Badge_Grade)
22

33
# BuildmLearn-Toolkit-Android
44

@@ -70,3 +70,9 @@ Redistributions in binary form must reproduce the above copyright notice, this l
7070
Neither the name of the BuildmLearn nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
7171

7272
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73+
74+
## Maintainers
75+
The project is maintained by
76+
- Pankaj Nathani ([@croozeus](https://github.com/croozeus))
77+
- Anupam Das ([@opticod](https://github.com/opticod))
78+

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

+15-17
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
/**
1212
* @brief Extended Application class
13-
*
14-
*
13+
* <p/>
14+
* <p/>
1515
* Created by Abhishek on 31-05-2015.
1616
*/
1717
public class ToolkitApplication extends Application {
@@ -20,6 +20,13 @@ public class ToolkitApplication extends Application {
2020

2121
private boolean isExternalStorageAvailable = false;
2222

23+
/**
24+
* @return Folder path
25+
* @brief Returns folder path for unzipped apks
26+
*/
27+
public static String getUnZipDir() {
28+
return dir + Constants.UNZIP;
29+
}
2330

2431
@Override
2532
public void onCreate() {
@@ -48,58 +55,49 @@ public void onCreate() {
4855
}
4956

5057
/**
51-
* @brief Returns external storage directory.
5258
* @return folder file
59+
* @brief Returns external storage directory.
5360
*/
5461
public File getDir() {
5562
return Environment.getExternalStorageDirectory();
5663
}
5764

5865
/**
59-
* @brief Returns directory for BuildmLearn toolkit manually created files.
6066
* @return folder path
67+
* @brief Returns directory for BuildmLearn toolkit manually created files.
6168
*/
6269
public String getProjectDir() {
6370
return dir + Constants.BUILD_M_LEARN_PATH;
6471

6572
}
6673

6774
/**
68-
* @brief Returns folder path for saved projects
6975
* @return Folder path
76+
* @brief Returns folder path for saved projects
7077
*/
7178
public String getSavedDir() {
7279
return dir + Constants.SAVED_DIR;
7380
}
7481

7582
/**
76-
* @brief Returns folder path for saved projects
7783
* @return Folder path
84+
* @brief Returns folder path for saved projects
7885
*/
7986
public String getDraftDir() {
8087
return dir + Constants.DRAFT_DIR;
8188
}
8289

83-
8490
/**
85-
* @brief Returns folder path for unzipped apks
8691
* @return Folder path
87-
*/
88-
public static String getUnZipDir() {
89-
return dir + Constants.UNZIP;
90-
}
91-
92-
/**
9392
* @brief Returns folder path for storing generated apks
94-
* @return Folder path
9593
*/
9694
public String getApkDir() {
9795
return dir + Constants.APK_DIR;
9896
}
9997

10098
/**
101-
* @brief Checks if external storage is present for storing data
10299
* @return true if external storage is present, else false
100+
* @brief Checks if external storage is present for storing data
103101
*/
104102
public boolean checkExternalStorage() {
105103

@@ -117,8 +115,8 @@ public boolean isExternalStorageAvailable() {
117115
}
118116

119117
/**
120-
* @brief Returns folder path for Download directory
121118
* @return Folder path
119+
* @brief Returns folder path for Download directory
122120
*/
123121
public String getDownloadDirectory() {
124122
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ protected void onCreate(Bundle savedInstanceState) {
3636
} catch (PackageManager.NameNotFoundException e) {
3737
assert findViewById(R.id.app_version) != null;
3838
assert ((TextView) findViewById(R.id.app_version)) != null;
39-
((TextView)findViewById(R.id.app_version)).setText("Version: 1.0");
39+
((TextView) findViewById(R.id.app_version)).setText("Version: 1.0");
4040
e.printStackTrace();
4141
}
4242

4343

44-
4544
}
4645

4746
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/**
2424
* @brief Activity responsible for handling files opened from file explorer
25-
*
25+
* <p/>
2626
* This activity is started whenever users opens a .buildmlearn file from file explorer.
2727
* This activity is responsible for getting the template type from the file, and passes the template Id and
2828
* file path to Template Editor/ activity.

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

+31-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import org.buildmlearn.toolkit.R;
1313
import org.buildmlearn.toolkit.constant.Constants;
14+
import org.buildmlearn.toolkit.fragment.LoadApkFragment;
15+
import org.buildmlearn.toolkit.fragment.LoadProjectFragment;
1416
import org.buildmlearn.toolkit.fragment.NavigationDrawerFragment;
1517
import org.buildmlearn.toolkit.fragment.SettingsFragment;
1618
import org.buildmlearn.toolkit.model.Section;
@@ -45,17 +47,15 @@ protected void onCreate(Bundle savedInstanceState) {
4547
mNavigationDrawerFragment.setUp(
4648
R.id.navigation_drawer,
4749
(DrawerLayout) findViewById(R.id.drawer_layout));
48-
if (getIntent().hasExtra(Constants.START_FRAGMENT)) {
49-
if (getIntent().getIntExtra(Constants.START_FRAGMENT, 0) == 3) {
50-
currentSection.setIsSelected(false);
51-
Section[] menuItem = Section.values();
52-
Section selectedMenuItem = menuItem[3];
53-
selectedMenuItem.setIsSelected(true);
54-
currentSection = selectedMenuItem;
55-
FragmentTransaction ft = getFragmentManager().beginTransaction();
56-
ft.replace(R.id.container, new SettingsFragment());
57-
ft.commit();
58-
}
50+
if (getIntent().hasExtra(Constants.START_FRAGMENT) && getIntent().getIntExtra(Constants.START_FRAGMENT, 0) == 3) {
51+
currentSection.setIsSelected(false);
52+
Section[] menuItem = Section.values();
53+
Section selectedMenuItem = menuItem[3];
54+
selectedMenuItem.setIsSelected(true);
55+
currentSection = selectedMenuItem;
56+
FragmentTransaction ft = getFragmentManager().beginTransaction();
57+
ft.replace(R.id.container, new SettingsFragment());
58+
ft.commit();
5959
}
6060
}
6161

@@ -64,8 +64,26 @@ protected void onCreate(Bundle savedInstanceState) {
6464
*/
6565
@Override
6666
public void onNavigationDrawerItemSelected(int position) {
67+
if (position == -1) {
68+
if (currentSection != null) {
69+
if (currentSection.toString().equals("OPEN_PROJECT")) {
70+
LoadProjectFragment f = (LoadProjectFragment) getFragmentManager().findFragmentByTag(currentSection.getViewName());
71+
if (f != null)
72+
f.closeSearch();
73+
} else if (currentSection.toString().equals("OPEN_APK")) {
74+
LoadApkFragment f = (LoadApkFragment) getFragmentManager().findFragmentByTag(currentSection.getViewName());
75+
if (f != null)
76+
f.closeSearch();
77+
}
78+
}
79+
return;
80+
}
6781
Section[] menuItem = Section.values();
6882
Section selectedMenuItem = menuItem[position];
83+
if (getSupportActionBar() != null) {
84+
getSupportActionBar().setDisplayShowHomeEnabled(true);
85+
getSupportActionBar().setDisplayShowCustomEnabled(false);
86+
}
6987
if (selectedMenuItem.getType() == Section.ACTIVITY) {
7088
Class<?> c;
7189
if (selectedMenuItem.getViewName() != null) {
@@ -79,7 +97,7 @@ public void onNavigationDrawerItemSelected(int position) {
7997
}
8098
}
8199
} else if (selectedMenuItem.getType() == Section.FRAGMENT) {
82-
if (currentSection == null || selectedMenuItem != currentSection) {
100+
if (currentSection == null || !selectedMenuItem.equals(currentSection)) {
83101
currentSection = selectedMenuItem;
84102
FragmentManager fm = getFragmentManager();
85103
FragmentTransaction ft = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(null);
@@ -107,6 +125,7 @@ public void onNavigationDrawerItemSelected(int position) {
107125

108126
@Override
109127
public void onBackPressed() {
128+
110129
if (mNavigationDrawerFragment.isDrawerOpen()) {
111130
mNavigationDrawerFragment.closeDrawer();
112131
return;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/**
1414
* @brief Activity responsible for changing settings from android settings menu
15-
* <p>
15+
* <p/>
1616
* This activity is started whenever users clicks App Settings under App notifications in android settings menu.
1717
*/
1818
public class SettingsLinkerActivity extends Activity {

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

+33-24
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ protected void onCreate(Bundle savedInstanceState) {
101101
oldFileName = null;
102102
setContentView(R.layout.activity_template_editor);
103103
KeyboardHelper.hideKeyboard(this, findViewById(R.id.toolbar));
104-
KeyboardHelper.hideKeyboard(this,findViewById(R.id.template_editor_listview));
105-
KeyboardHelper.hideKeyboard(this,findViewById(R.id.empty));
104+
KeyboardHelper.hideKeyboard(this, findViewById(R.id.template_editor_listview));
105+
KeyboardHelper.hideKeyboard(this, findViewById(R.id.empty));
106106
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
107107
toolkit = (ToolkitApplication) getApplicationContext();
108108
templateId = getIntent().getIntExtra(Constants.TEMPLATE_ID, -1);
@@ -136,11 +136,11 @@ public void onClick(View v) {
136136
});
137137

138138
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
139-
!= PackageManager.PERMISSION_GRANTED) {
140-
ActivityCompat.requestPermissions(this,
141-
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
142-
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE_RESULT);
143-
}
139+
!= PackageManager.PERMISSION_GRANTED) {
140+
ActivityCompat.requestPermissions(this,
141+
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
142+
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE_RESULT);
143+
}
144144
}
145145

146146
/**
@@ -223,14 +223,14 @@ private void populateListView(final BaseAdapter adapter) {
223223
if (templateEdtiorList == null) {
224224
templateEdtiorList = (ListView) findViewById(R.id.template_editor_listview);
225225
}
226-
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
227-
View templateHeader = inflater.inflate(R.layout.listview_header_template, templateEdtiorList, false);
228-
templateEdtiorList.addHeaderView(templateHeader, null, false);
226+
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
227+
View templateHeader = inflater.inflate(R.layout.listview_header_template, templateEdtiorList, false);
228+
templateEdtiorList.addHeaderView(templateHeader, null, false);
229229

230-
EditText authorEditText = (EditText) findViewById(R.id.author_name);
231-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
232-
assert authorEditText != null;
233-
authorEditText.setText(preferences.getString(getString(R.string.key_user_name), ""));
230+
EditText authorEditText = (EditText) findViewById(R.id.author_name);
231+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
232+
assert authorEditText != null;
233+
authorEditText.setText(preferences.getString(getString(R.string.key_user_name), ""));
234234

235235
setAdapter(adapter);
236236

@@ -552,7 +552,7 @@ public void restoreSelectedView() {
552552
if (selectedView instanceof CardView) {
553553
((CardView) selectedView).setCardBackgroundColor(Color.WHITE);
554554
} else {
555-
selectedView.setBackgroundResource(0);
555+
selectedView.setBackgroundResource(0);
556556
}
557557
}
558558

@@ -683,8 +683,8 @@ private String saveProject() {
683683
@Override
684684
public void onBackPressed() {
685685
super.onBackPressed();
686-
if (saveDraft()!=null)
687-
Toast.makeText(getApplicationContext(),"Saved in Draft!",Toast.LENGTH_SHORT).show();
686+
if (saveDraft() != null)
687+
Toast.makeText(getApplicationContext(), "Saved in Draft!", Toast.LENGTH_SHORT).show();
688688

689689
}
690690

@@ -739,24 +739,24 @@ private String saveDraft() {
739739

740740
int draftFileIndex = 0;
741741
File draftDir = new File(toolkit.getDraftDir());
742-
String probableFileName = "draft"+draftFileIndex+ ".buildmlearn";
742+
String probableFileName = "draft" + draftFileIndex + ".buildmlearn";
743743
File probableFile = new File(draftDir, probableFileName);
744744

745-
while(probableFile.exists()) {
745+
while (probableFile.exists()) {
746746
draftFileIndex++;
747-
probableFileName = "draft"+draftFileIndex+ ".buildmlearn";
747+
probableFileName = "draft" + draftFileIndex + ".buildmlearn";
748748
probableFile = new File(draftDir, probableFileName);
749749
}
750750

751751
//Create temporary File, if that file content matches with OldContent
752752
// Then Don't make Draft
753753
File tempFile = new File(toolkit.getDraftDir(), ".temp");
754754
File oldFile = null;
755-
if (oldFileName!=null)
755+
if (oldFileName != null)
756756
oldFile = new File(oldFileName);
757757

758758
FileUtils.saveXmlFile(toolkit.getDraftDir(), ".temp", doc);
759-
if (oldFile == null || !FileUtils.equalContent(tempFile,oldFile)) {
759+
if (oldFile == null || !FileUtils.equalContent(tempFile, oldFile)) {
760760
tempFile.renameTo(probableFile);
761761
return toolkit.getDraftDir() + probableFileName;
762762
} else {
@@ -768,7 +768,7 @@ private String saveDraft() {
768768
} catch (ParserConfigurationException e) {
769769
e.printStackTrace();
770770
}
771-
return null;
771+
return null;
772772
}
773773

774774

@@ -832,7 +832,7 @@ private void parseSavedFile(String path) {
832832
populateMetaView(selectedTemplate.loadProjectMetaEditor(this, doc));
833833
}
834834
File draftDir = new File(toolkit.getDraftDir());
835-
if (fXmlFile.getParentFile().compareTo(draftDir) ==0 ) {
835+
if (fXmlFile.getParentFile().compareTo(draftDir) == 0) {
836836
//If Draft File
837837
fXmlFile.delete();
838838
}
@@ -877,4 +877,13 @@ private void setAdapterMeta(BaseAdapter adapter) {
877877
templateMetaList.setAdapter(adapter);
878878
}
879879

880+
@Override
881+
protected void onStop() {
882+
super.onStop();
883+
if (mApkGenerationDialog != null) {
884+
mApkGenerationDialog.dismiss();
885+
mApkGenerationDialog = null;
886+
}
887+
}
888+
880889
}

0 commit comments

Comments
 (0)