Browse Source

Various fixes

pull/63/head
Apostolos Fanakis 6 years ago
parent
commit
a28ea28742
  1. 59
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java
  2. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java
  3. 1
      app/src/main/res/layout/activity_board.xml
  4. 4
      app/src/main/res/xml-v26/app_preferences_user.xml

59
app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java

@ -360,29 +360,37 @@ public class UploadActivity extends BaseActivity {
if (!editTextFilename.equals(selectedFileFilename)) {
//File should be uploaded with a different name
if (!uploadFile.isCameraPhoto()) {
//Temporarily copies the file to a another location and renames it
tempFileUri = UploadsHelper.createTempFile(this, storage,
uploadFile.getFileUri(),
FileUtils.getFilenameWithoutExtension(editTextFilename));
} else {
//Renames the photo taken
String photoPath = uploadFile.getPhotoFile().getPath();
photoPath = photoPath.substring(0, photoPath.lastIndexOf(File.separator));
String destinationFilename = photoPath + File.separator +
FileUtils.getFilenameWithoutExtension(editTextFilename) + ".jpg";
if (!storage.rename(uploadFile.getPhotoFile().getAbsolutePath(), destinationFilename)) {
//Something went wrong, abort
Toast.makeText(this, "Could not create temporary file for renaming", Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
return;
}
//Points photoFile and fileUri to the new copied and renamed file
uploadFile.setPhotoFile(storage.getFile(destinationFilename));
uploadFile.setFileUri(FileProvider.getUriForFile(this, getPackageName() +
".provider", uploadFile.getPhotoFile()));
if (checkPerms()) {
if (!uploadFile.isCameraPhoto()) {
//Temporarily copies the file to a another location and renames it
tempFileUri = UploadsHelper.createTempFile(this, storage,
uploadFile.getFileUri(),
FileUtils.getFilenameWithoutExtension(editTextFilename));
} else {
//Renames the photo taken
String photoPath = uploadFile.getPhotoFile().getPath();
photoPath = photoPath.substring(0, photoPath.lastIndexOf(File.separator));
String destinationFilename = photoPath + File.separator +
FileUtils.getFilenameWithoutExtension(editTextFilename) + ".jpg";
if (!storage.rename(uploadFile.getPhotoFile().getAbsolutePath(), destinationFilename)) {
//Something went wrong, abort
Toast.makeText(this, "Could not create temporary file for renaming", Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
return;
}
//Points photoFile and fileUri to the new copied and renamed file
uploadFile.setPhotoFile(storage.getFile(destinationFilename));
uploadFile.setFileUri(FileProvider.getUriForFile(this, getPackageName() +
".provider", uploadFile.getPhotoFile()));
}
} else {
requestPerms(UPLOAD_REQUEST_STORAGE_CODE);
zipTask = null;
dialog.cancel();
return;
}
}
} else {
@ -586,8 +594,9 @@ public class UploadActivity extends BaseActivity {
if (previousName.isEmpty()) {
uploadFilename.setText(data.getStringExtra(RESULT_FILENAME));
} else {
String extractedExtension = FileUtils.getFileExtension(previousName);
String filenameWithExtension = data.getStringExtra(RESULT_FILENAME) +
FileUtils.getFileExtension(previousName);
(extractedExtension != null ? extractedExtension : "");
uploadFilename.setText(filenameWithExtension);
}
hasModifiedFilename = true;
@ -609,7 +618,7 @@ public class UploadActivity extends BaseActivity {
break;
case UPLOAD_REQUEST_STORAGE_CODE:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED &&
zipTask != null) {
zipTask != null) {
Uri[] filesListArray = new Uri[filesList.size()];
for (int i = 0; i < filesList.size(); ++i) {
filesListArray[i] = filesList.get(i).getFileUri();
@ -617,6 +626,8 @@ public class UploadActivity extends BaseActivity {
zipTask.execute(filesListArray);
finish();
} else {
Toast.makeText(this, "Please retry uploading.", Toast.LENGTH_SHORT).show();
}
break;
}

4
app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java

@ -390,9 +390,9 @@ public class UploadFieldsBuilderActivity extends BaseActivity {
return greeklish ? "hlektronikh_1" : "Ηλεκτρονική 1";
} else if (normalisedCourse.contains(("Ηλεκτρονικές Διατάξεις και Μετρήσεις"))) {
return greeklish ? "hlektron_diatakseis_metrhseis" : "Ηλεκτρονικές Διατάξεις και Μετρήσεις";
} else if (normalisedCourse.contains(("Ηλεκτρονικά Iσχύος II"))) {
} else if (normalisedCourse.contains(("Ηλεκτρονικά Ισχύος II"))) {
return greeklish ? "isxyos_II" : "Ισχύος 2";
} else if (normalisedCourse.contains(("Ηλεκτρονικά Iσχύος I"))) {
} else if (normalisedCourse.contains(("Ηλεκτρονικά Ισχύος I"))) {
return greeklish ? "isxyos_I" : "Ισχύος 1";
} else if (normalisedCourse.contains(("Ηλεκτρομαγνητικό Πεδίο II"))) {
return greeklish ? "pedio_II" : "Πεδίο 2";

1
app/src/main/res/layout/activity_board.xml

@ -42,7 +42,6 @@
android:layout_marginTop="64dp"
android:background="@color/background"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="gr.thmmy.mthmmy.activities.topic.TopicActivity" />
<me.zhanghai.android.materialprogressbar.MaterialProgressBar

4
app/src/main/res/xml-v26/app_preferences_user.xml

@ -28,7 +28,7 @@
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory>
<!--<androidx.preference.PreferenceCategory
<androidx.preference.PreferenceCategory
android:key="pref_category_uploading_key"
android:title="@string/pref_category_uploading"
app:iconSpaceReserved="false">
@ -38,7 +38,7 @@
android:title="@string/pref_title_uploading_app_signature_enable"
android:summary="@string/pref_summary_uploading_app_signature_enable"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory>-->
</androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory
android:key="pref_category_privacy_key"

Loading…
Cancel
Save