Merge branch 'develop' of git@github.com:Amab/SWADroid.git into develop
This commit is contained in:
commit
d241b47148
|
@ -180,7 +180,6 @@
|
||||||
android:name=".modules.downloads.DownloadsManager"
|
android:name=".modules.downloads.DownloadsManager"
|
||||||
android:label="@string/documentsDownloadModuleLabel"
|
android:label="@string/documentsDownloadModuleLabel"
|
||||||
android:theme="@android:style/Theme.NoTitleBar"
|
android:theme="@android:style/Theme.NoTitleBar"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
|
||||||
>
|
>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
|
|
@ -8,5 +8,5 @@
|
||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-17
|
target=android-14
|
||||||
android.library=false
|
android.library=false
|
||||||
|
|
|
@ -316,11 +316,11 @@ public class Test extends Model {
|
||||||
s = buff.toString().trim();
|
s = buff.toString().trim();
|
||||||
|
|
||||||
//Remove accents
|
//Remove accents
|
||||||
s = s.replace('á', 'a');
|
s = s.replace('‡', 'a');
|
||||||
s = s.replace('e', 'e');
|
s = s.replace('Ž', 'e');
|
||||||
s = s.replace('í', 'i');
|
s = s.replace('’', 'i');
|
||||||
s = s.replace('ó', 'o');
|
s = s.replace('—', 'o');
|
||||||
s = s.replace('ú', 'u');
|
s = s.replace('œ', 'u');
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,10 @@ public class DirectoryNavigator
|
||||||
return currentItems;
|
return currentItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<DirectoryItem> goToCurrentDirectory(){
|
||||||
|
return currentItems;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Travel inside a subdirectory.
|
* Travel inside a subdirectory.
|
||||||
* @param directoryPosition The position of the subdirectory where we will travel.
|
* @param directoryPosition The position of the subdirectory where we will travel.
|
||||||
|
|
|
@ -123,6 +123,8 @@ public class DownloadsManager extends MenuActivity {
|
||||||
private TextView currentPathText;
|
private TextView currentPathText;
|
||||||
|
|
||||||
String chosenNodeName = null;
|
String chosenNodeName = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fileSize stores the size of the last file name chosen to be downloaded
|
* fileSize stores the size of the last file name chosen to be downloaded
|
||||||
* */
|
* */
|
||||||
|
@ -137,7 +139,15 @@ public class DownloadsManager extends MenuActivity {
|
||||||
* Indicates if the menu no connection is visible
|
* Indicates if the menu no connection is visible
|
||||||
* */
|
* */
|
||||||
private boolean noConnectionView = false;
|
private boolean noConnectionView = false;
|
||||||
|
/**
|
||||||
|
* Indicates that the current state should be saved in case the activity is brought to background
|
||||||
|
* */
|
||||||
|
private boolean saveState = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the state before the activity was brought to background has o not connection
|
||||||
|
* */
|
||||||
|
private boolean previousConnection = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
|
@ -145,6 +155,7 @@ public class DownloadsManager extends MenuActivity {
|
||||||
List<Group> allGroups = dbHelper.getGroups(Global.getSelectedCourseCode());
|
List<Group> allGroups = dbHelper.getGroups(Global.getSelectedCourseCode());
|
||||||
int nGroups = allGroups.size();
|
int nGroups = allGroups.size();
|
||||||
|
|
||||||
|
if(!saveState){
|
||||||
if(nGroups != 0 || groupsRequested){ //groupsRequested is used to avoid continue requests of groups on courses that have not any group.
|
if(nGroups != 0 || groupsRequested){ //groupsRequested is used to avoid continue requests of groups on courses that have not any group.
|
||||||
myGroups = getFilteredGroups(); //only groups where the user is enrolled.
|
myGroups = getFilteredGroups(); //only groups where the user is enrolled.
|
||||||
int nMyGroups = myGroups.size();
|
int nMyGroups = myGroups.size();
|
||||||
|
@ -158,12 +169,47 @@ public class DownloadsManager extends MenuActivity {
|
||||||
activity.putExtra("courseCode", Global.getSelectedCourseCode());
|
activity.putExtra("courseCode", Global.getSelectedCourseCode());
|
||||||
startActivityForResult(activity,Global.GROUPTYPES_REQUEST_CODE);
|
startActivityForResult(activity,Global.GROUPTYPES_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
myGroups = getFilteredGroups();
|
||||||
|
this.loadGroupsSpinner(myGroups);
|
||||||
|
if(previousConnection){
|
||||||
|
setMainView();
|
||||||
|
}else{
|
||||||
|
setNoConnectionView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if(savedInstanceState != null){
|
||||||
|
this.saveState = savedInstanceState.getBoolean("saveState", false);
|
||||||
|
if(saveState){
|
||||||
|
this.groupsRequested = true;
|
||||||
|
this.previousConnection = savedInstanceState.getBoolean("previousConnection", false);
|
||||||
|
this.chosenGroupCode = savedInstanceState.getLong("chosenGroupCode",0);
|
||||||
|
this.groupPosition = savedInstanceState.getInt("groupPosition",0);
|
||||||
|
if(previousConnection){
|
||||||
|
this.tree = savedInstanceState.getString("tree");
|
||||||
|
String path = savedInstanceState.getString("path");
|
||||||
|
this.navigator = new DirectoryNavigator(this.tree);
|
||||||
|
if(path.compareTo("/") !=0){
|
||||||
|
int firstBar = path.indexOf('/',0);
|
||||||
|
int nextBar = path.indexOf('/', firstBar+1);
|
||||||
|
while(nextBar != -1){
|
||||||
|
String dir = path.substring(firstBar+1, nextBar);
|
||||||
|
this.navigator.goToSubDirectory(dir);
|
||||||
|
firstBar = nextBar;
|
||||||
|
nextBar = path.indexOf('/', firstBar+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
setContentView(R.layout.navigation);
|
setContentView(R.layout.navigation);
|
||||||
|
|
||||||
downloadsAreaCode = getIntent().getIntExtra("downloadsAreaCode",
|
downloadsAreaCode = getIntent().getIntExtra("downloadsAreaCode",
|
||||||
|
@ -234,6 +280,23 @@ public class DownloadsManager extends MenuActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean("saveState", this.saveState);
|
||||||
|
if(this.saveState){
|
||||||
|
outState.putBoolean("previousConnection", this.previousConnection);
|
||||||
|
outState.putLong("chosenGroupCode", this.chosenGroupCode);
|
||||||
|
outState.putInt("groupPosition", this.groupPosition);
|
||||||
|
if(this.previousConnection){
|
||||||
|
outState.putString("tree", this.tree);
|
||||||
|
outState.putString("path", this.navigator.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -243,10 +306,9 @@ public class DownloadsManager extends MenuActivity {
|
||||||
// course
|
// course
|
||||||
case Global.DIRECTORY_TREE_REQUEST_CODE:
|
case Global.DIRECTORY_TREE_REQUEST_CODE:
|
||||||
tree = data.getStringExtra("tree");
|
tree = data.getStringExtra("tree");
|
||||||
|
if (!refresh){
|
||||||
setMainView();
|
setMainView();
|
||||||
if (!refresh)
|
}else {
|
||||||
setMainView();
|
|
||||||
else {
|
|
||||||
refresh = false;
|
refresh = false;
|
||||||
updateButton.setVisibility(View.VISIBLE);
|
updateButton.setVisibility(View.VISIBLE);
|
||||||
progressbar.setVisibility(View.GONE);
|
progressbar.setVisibility(View.GONE);
|
||||||
|
@ -254,8 +316,6 @@ public class DownloadsManager extends MenuActivity {
|
||||||
refresh();
|
refresh();
|
||||||
else
|
else
|
||||||
setMainView();
|
setMainView();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Global.GETFILE_REQUEST_CODE:
|
case Global.GETFILE_REQUEST_CODE:
|
||||||
|
@ -284,6 +344,7 @@ public class DownloadsManager extends MenuActivity {
|
||||||
groupsRequested = true;
|
groupsRequested = true;
|
||||||
myGroups = getFilteredGroups(); //only groups where the user is enrolled.
|
myGroups = getFilteredGroups(); //only groups where the user is enrolled.
|
||||||
this.loadGroupsSpinner(myGroups);
|
this.loadGroupsSpinner(myGroups);
|
||||||
|
if(myGroups.size() == 0)
|
||||||
requestDirectoryTree();
|
requestDirectoryTree();
|
||||||
break;
|
break;
|
||||||
case Global.GROUPTYPES_REQUEST_CODE:
|
case Global.GROUPTYPES_REQUEST_CODE:
|
||||||
|
@ -319,6 +380,9 @@ public class DownloadsManager extends MenuActivity {
|
||||||
TextView courseNameText = (TextView) this.findViewById(R.id.courseSelectedText);
|
TextView courseNameText = (TextView) this.findViewById(R.id.courseSelectedText);
|
||||||
courseNameText.setText(Global.getSelectedCourseShortName());
|
courseNameText.setText(Global.getSelectedCourseShortName());
|
||||||
|
|
||||||
|
this.saveState = true;
|
||||||
|
this.previousConnection = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This method set the grid of nodes visible and paints the directory tree in its root node
|
* This method set the grid of nodes visible and paints the directory tree in its root node
|
||||||
|
@ -332,12 +396,20 @@ public class DownloadsManager extends MenuActivity {
|
||||||
|
|
||||||
currentPathText = (TextView) this.findViewById(R.id.path);
|
currentPathText = (TextView) this.findViewById(R.id.path);
|
||||||
|
|
||||||
|
ArrayList<DirectoryItem> items;
|
||||||
|
if(!(this.saveState && this.previousConnection)){
|
||||||
navigator = new DirectoryNavigator(tree);
|
navigator = new DirectoryNavigator(tree);
|
||||||
// GridView
|
items = (ArrayList<DirectoryItem>) navigator
|
||||||
ArrayList<DirectoryItem> items = (ArrayList<DirectoryItem>) navigator
|
|
||||||
.goToRoot();
|
.goToRoot();
|
||||||
|
}else{
|
||||||
|
items = (ArrayList<DirectoryItem>) navigator.goToCurrentDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
currentPathText.setText(navigator.getPath());
|
currentPathText.setText(navigator.getPath());
|
||||||
grid.setAdapter(new NodeAdapter(this, items));
|
grid.setAdapter(new NodeAdapter(this, items));
|
||||||
|
//this is used for the activity restart in case it was taken background
|
||||||
|
this.saveState = true;
|
||||||
|
this.previousConnection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -564,19 +636,19 @@ public class DownloadsManager extends MenuActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* This method is launched instead of onCreate when device rotates
|
// * This method is launched instead of onCreate when device rotates
|
||||||
* It prevents from repeating calls to web services when they are not necessary
|
// * It prevents from repeating calls to web services when they are not necessary
|
||||||
* */
|
// * */
|
||||||
@Override
|
// @Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
// public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
// super.onConfigurationChanged(newConfig);
|
||||||
|
// Log.i(TAG,"Device rotation");
|
||||||
// Checks the orientation of the screen
|
// // Checks the orientation of the screen
|
||||||
/* if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
///* if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
Log.i(TAG,"onConfigChanged - Landscape");
|
// Log.i(TAG,"onConfigChanged - Landscape");
|
||||||
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
|
// } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
|
||||||
Log.i(TAG,"onConfigChanged - Portrait");
|
// Log.i(TAG,"onConfigChanged - Portrait");
|
||||||
}*/
|
// }*/
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user