# Conflicts: # app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.javapull/34/head
@ -1,333 +0,0 @@ |
|||
package gr.thmmy.mthmmy.activities; |
|||
|
|||
import android.content.Intent; |
|||
import android.net.Uri; |
|||
import android.os.AsyncTask; |
|||
import android.os.Bundle; |
|||
import android.support.v7.widget.AppCompatSpinner; |
|||
import android.util.Log; |
|||
import android.view.View; |
|||
import android.widget.AdapterView; |
|||
import android.widget.ArrayAdapter; |
|||
import android.widget.EditText; |
|||
import android.widget.LinearLayout; |
|||
import android.widget.ProgressBar; |
|||
import android.widget.Spinner; |
|||
|
|||
import net.gotev.uploadservice.MultipartUploadRequest; |
|||
import net.gotev.uploadservice.UploadNotificationConfig; |
|||
|
|||
import org.jsoup.nodes.Document; |
|||
import org.jsoup.nodes.Element; |
|||
import org.jsoup.select.Elements; |
|||
|
|||
import java.net.URLEncoder; |
|||
import java.util.ArrayList; |
|||
|
|||
import gr.thmmy.mthmmy.R; |
|||
import gr.thmmy.mthmmy.base.BaseActivity; |
|||
import gr.thmmy.mthmmy.base.BaseApplication; |
|||
import gr.thmmy.mthmmy.model.UploadCategory; |
|||
import gr.thmmy.mthmmy.utils.AppCompatSpinnerWithoutDefault; |
|||
import gr.thmmy.mthmmy.utils.parsing.ParseException; |
|||
import gr.thmmy.mthmmy.utils.parsing.ParseTask; |
|||
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; |
|||
import timber.log.Timber; |
|||
|
|||
public class UploadActivity extends BaseActivity { |
|||
/** |
|||
* The key to use when putting upload's category String to {@link UploadActivity}'s Bundle. |
|||
*/ |
|||
public static final String BUNDLE_UPLOAD_CATEGORY = "UPLOAD_CATEGORY"; |
|||
private static final String uploadIndexUrl = "https://www.thmmy.gr/smf/index.php?action=tpmod;dl=upload"; |
|||
private static final int REQUEST_CODE_CHOOSE_FILE = 8; |
|||
|
|||
private static ArrayList<UploadCategory> uploadRootCategories = new ArrayList<>(); |
|||
//private String currentUploadCategory = "";
|
|||
private ParseUploadPageTask parseUploadPageTask; |
|||
private String categorySelected = "-1"; |
|||
private String uploaderProfileIndex = "1"; |
|||
private Uri fileUri; |
|||
|
|||
//UI elements
|
|||
private MaterialProgressBar progressBar; |
|||
private LinearLayout categoriesSpinners; |
|||
private AppCompatSpinnerWithoutDefault rootCategorySpinner; |
|||
private EditText uploadTitle; |
|||
private EditText uploadDescription; |
|||
//private static AppCompatButton titleDescriptionBuilderButton;
|
|||
|
|||
@Override |
|||
protected void onCreate(Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
setContentView(R.layout.activity_upload); |
|||
|
|||
/*Bundle extras = getIntent().getExtras(); |
|||
if (extras != null) { |
|||
//TODO auto fill category from bundle
|
|||
currentUploadCategory = extras.getString(BUNDLE_UPLOAD_CATEGORY); |
|||
if (currentUploadCategory != null && !Objects.equals(currentUploadCategory, "")) { |
|||
} |
|||
}*/ |
|||
|
|||
//Initialize toolbar
|
|||
toolbar = findViewById(R.id.toolbar); |
|||
toolbar.setTitle("Upload"); |
|||
setSupportActionBar(toolbar); |
|||
if (getSupportActionBar() != null) { |
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|||
getSupportActionBar().setDisplayShowHomeEnabled(true); |
|||
} |
|||
|
|||
createDrawer(); |
|||
drawer.setSelection(UPLOAD_ID); |
|||
|
|||
progressBar = findViewById(R.id.progressBar); |
|||
|
|||
findViewById(R.id.upload_outer_scrollview).setVerticalScrollBarEnabled(false); |
|||
categoriesSpinners = findViewById(R.id.upload_spinners); |
|||
rootCategorySpinner = findViewById(R.id.upload_spinner_category_root); |
|||
rootCategorySpinner.setOnItemSelectedListener(new CustomOnItemSelectedListener(uploadRootCategories)); |
|||
|
|||
/*titleDescriptionBuilderButton = findViewById(R.id.upload_title_description_builder); |
|||
titleDescriptionBuilderButton.setEnabled(false); |
|||
titleDescriptionBuilderButton.setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View v) { |
|||
//TODO some dialog?
|
|||
} |
|||
});*/ |
|||
|
|||
uploadTitle = findViewById(R.id.upload_title); |
|||
uploadDescription = findViewById(R.id.upload_description); |
|||
|
|||
findViewById(R.id.upload_select_file_button).setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View v) { |
|||
String[] mimeTypes = {"image/jpeg", "text/html", "image/png", "image/jpg", "image/gif", |
|||
"application/pdf", "application/rar", "application/x-tar", "application/zip", |
|||
"application/msword", "image/vnd.djvu", "application/gz", "application/tar.gz"}; |
|||
|
|||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT) |
|||
//.setType("*/*")
|
|||
.setType("image/jpeg") |
|||
.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); |
|||
|
|||
startActivityForResult(intent, REQUEST_CODE_CHOOSE_FILE); |
|||
} |
|||
}); |
|||
|
|||
findViewById(R.id.upload_upload_button).setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View v) { |
|||
String uploadTitleText = uploadTitle.getText().toString(); |
|||
String uploadDescriptionText = uploadDescription.getText().toString(); |
|||
|
|||
if (uploadTitleText.equals("")) { |
|||
uploadTitle.setError("Required"); |
|||
} |
|||
if (uploadDescriptionText.equals("")) { |
|||
uploadDescription.setError("Required"); |
|||
} |
|||
/*if (categorySelected.equals("-1")){ |
|||
//TODO set error
|
|||
//rootCategorySpinner
|
|||
}*/ |
|||
|
|||
if (categorySelected.equals("-1") || uploadTitleText.equals("") || |
|||
fileUri == null || uploadDescriptionText.equals("")) { |
|||
return; |
|||
} |
|||
|
|||
try { |
|||
String uploadId = new MultipartUploadRequest(v.getContext(), uploadIndexUrl) |
|||
.setUtf8Charset() |
|||
.addParameter("tp-dluploadtitle", uploadTitleText) |
|||
.addParameter("tp-dluploadcat", categorySelected) |
|||
.addParameter("tp-dluploadtext", uploadDescriptionText) |
|||
.addFileToUpload(fileUri.toString(), "tp-dluploadfile") |
|||
.addParameter("tp_dluploadicon", "blank.gif") //TODO auto-select this
|
|||
.addParameter("tp-uploaduser", uploaderProfileIndex) |
|||
.setNotificationConfig(new UploadNotificationConfig()) |
|||
.setMaxRetries(2).startUpload(); |
|||
} catch (Exception exception) { |
|||
Timber.e(exception, "AndroidUploadService: %s", exception.getMessage()); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
|
|||
if (uploadRootCategories.isEmpty()) { |
|||
parseUploadPageTask = new ParseUploadPageTask(); |
|||
parseUploadPageTask.execute(uploadIndexUrl); |
|||
} else { |
|||
String[] tmpSpinnerArray = new String[uploadRootCategories.size()]; |
|||
for (int i = 0; i < uploadRootCategories.size(); ++i) { |
|||
tmpSpinnerArray[i] = uploadRootCategories.get(i).getCategoryTitle(); |
|||
} |
|||
|
|||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>( |
|||
BaseApplication.getInstance().getApplicationContext(), |
|||
android.R.layout.simple_spinner_dropdown_item, tmpSpinnerArray); |
|||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|||
rootCategorySpinner.setAdapter(spinnerArrayAdapter); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onBackPressed() { |
|||
if (drawer.isDrawerOpen()) { |
|||
drawer.closeDrawer(); |
|||
return; |
|||
} |
|||
super.onBackPressed(); |
|||
} |
|||
|
|||
@Override |
|||
protected void onResume() { |
|||
drawer.setSelection(UPLOAD_ID); |
|||
super.onResume(); |
|||
} |
|||
|
|||
@Override |
|||
protected void onDestroy() { |
|||
super.onDestroy(); |
|||
if (parseUploadPageTask != null && parseUploadPageTask.getStatus() != AsyncTask.Status.RUNNING) |
|||
parseUploadPageTask.cancel(true); |
|||
} |
|||
|
|||
@Override |
|||
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
|||
if (requestCode == REQUEST_CODE_CHOOSE_FILE && data != null) { |
|||
//TODO upload the correct file
|
|||
//Check this https://stackoverflow.com/questions/5568874/how-to-extract-the-file-name-from-uri-returned-from-intent-action-get-content/25005243
|
|||
fileUri = data.getData(); |
|||
} else { |
|||
super.onActivityResult(requestCode, resultCode, data); |
|||
} |
|||
} |
|||
|
|||
private class CustomOnItemSelectedListener implements AdapterView.OnItemSelectedListener { |
|||
private ArrayList<UploadCategory> parentCategories, childCategories; |
|||
|
|||
private CustomOnItemSelectedListener() { |
|||
//Disable default constructor
|
|||
} |
|||
|
|||
CustomOnItemSelectedListener(ArrayList<UploadCategory> parentCategories) { |
|||
this.parentCategories = parentCategories; |
|||
} |
|||
|
|||
@Override |
|||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
|||
//Removes old, unneeded sub categories spinner(s)
|
|||
int viewIndex = categoriesSpinners.indexOfChild((AppCompatSpinnerWithoutDefault) view.getParent()); |
|||
|
|||
if (viewIndex + 1 != categoriesSpinners.getChildCount()) { //Makes sure this is not the last child
|
|||
categoriesSpinners.removeViews(viewIndex + 1, categoriesSpinners.getChildCount() - viewIndex - 1); |
|||
} |
|||
|
|||
categorySelected = parentCategories.get(position).getValue(); |
|||
|
|||
//Adds new sub categories spinner
|
|||
if (parentCategories.get(position).hasSubCategories()) { |
|||
childCategories = parentCategories.get(position).getSubCategories(); |
|||
|
|||
String[] tmpSpinnerArray = new String[childCategories.size()]; |
|||
for (int i = 0; i < tmpSpinnerArray.length; ++i) { |
|||
tmpSpinnerArray[i] = childCategories.get(i).getCategoryTitle(); |
|||
} |
|||
|
|||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(getApplicationContext(), |
|||
android.R.layout.simple_spinner_dropdown_item, tmpSpinnerArray); |
|||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|||
|
|||
AppCompatSpinnerWithoutDefault subSpinner = new AppCompatSpinnerWithoutDefault(categoriesSpinners.getContext()); |
|||
subSpinner.setPromptId(R.string.upload_spinners_prompt); |
|||
subSpinner.setPopupBackgroundResource(R.color.primary); |
|||
subSpinner.setAdapter(spinnerArrayAdapter); |
|||
subSpinner.setOnItemSelectedListener(new CustomOnItemSelectedListener(childCategories)); |
|||
|
|||
categoriesSpinners.addView(subSpinner); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onNothingSelected(AdapterView<?> parent) { |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* An {@link ParseTask} that handles asynchronous fetching of the upload page and parsing the |
|||
* upload categories. |
|||
*/ |
|||
private class ParseUploadPageTask extends ParseTask { |
|||
@Override |
|||
protected void onPreExecute() { |
|||
progressBar.setVisibility(ProgressBar.VISIBLE); |
|||
} |
|||
|
|||
@Override |
|||
protected void parse(Document uploadPage) throws ParseException { |
|||
Elements categoriesElements; |
|||
Element uploaderProfileIndexElement; |
|||
|
|||
try { |
|||
categoriesElements = uploadPage.select("select[name='tp-dluploadcat']>option"); |
|||
uploaderProfileIndexElement = uploadPage.select("input[name=\"tp-uploaduser\"]").first(); |
|||
} catch (Exception e) { |
|||
throw new ParseException("Parsing failed (UploadActivity)"); |
|||
} |
|||
|
|||
uploaderProfileIndex = uploaderProfileIndexElement.attr("value"); |
|||
|
|||
for (Element category : categoriesElements) { |
|||
String categoryValue = category.attr("value"); |
|||
String categoryText = category.text(); |
|||
|
|||
if (categoryText.startsWith("- ")) { |
|||
//This is a level one subcategory
|
|||
uploadRootCategories.get(uploadRootCategories.size() - 1).addSubCategory(categoryValue, categoryText); |
|||
} else if (categoryText.startsWith("-- ")) { |
|||
//This is a level two subcategory
|
|||
UploadCategory rootLevelCategory = uploadRootCategories.get(uploadRootCategories.size() - 1); |
|||
UploadCategory firstLevelCategory = rootLevelCategory.getSubCategories().get(rootLevelCategory.getSubCategories().size() - 1); |
|||
firstLevelCategory.addSubCategory(categoryValue, categoryText); |
|||
} else if (categoryText.startsWith("--- ")) { |
|||
//This is a level three subcategory
|
|||
UploadCategory rootLevelCategory = uploadRootCategories.get(uploadRootCategories.size() - 1); |
|||
UploadCategory firstLevelCategory = rootLevelCategory.getSubCategories().get(rootLevelCategory.getSubCategories().size() - 1); |
|||
UploadCategory secondLevelCategory = firstLevelCategory.getSubCategories().get(firstLevelCategory.getSubCategories().size() - 1); |
|||
secondLevelCategory.addSubCategory(categoryValue, categoryText); |
|||
} else if (categoryText.startsWith("---- ")) { |
|||
//This is a level three subcategory
|
|||
UploadCategory rootLevelCategory = uploadRootCategories.get(uploadRootCategories.size() - 1); |
|||
UploadCategory firstLevelCategory = rootLevelCategory.getSubCategories().get(rootLevelCategory.getSubCategories().size() - 1); |
|||
UploadCategory secondLevelCategory = firstLevelCategory.getSubCategories().get(firstLevelCategory.getSubCategories().size() - 1); |
|||
UploadCategory thirdLevelCategory = secondLevelCategory.getSubCategories().get(secondLevelCategory.getSubCategories().size() - 1); |
|||
thirdLevelCategory.addSubCategory(categoryValue, categoryText); |
|||
} else { |
|||
//This is a root category
|
|||
uploadRootCategories.add(new UploadCategory(categoryValue, categoryText)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
protected void postExecution(ResultCode result) { |
|||
String[] tmpSpinnerArray = new String[uploadRootCategories.size()]; |
|||
for (int i = 0; i < uploadRootCategories.size(); ++i) { |
|||
tmpSpinnerArray[i] = uploadRootCategories.get(i).getCategoryTitle(); |
|||
} |
|||
|
|||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>( |
|||
BaseApplication.getInstance().getApplicationContext(), |
|||
android.R.layout.simple_spinner_dropdown_item, tmpSpinnerArray); |
|||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|||
rootCategorySpinner.setAdapter(spinnerArrayAdapter); |
|||
//titleDescriptionBuilderButton.setEnabled(true);
|
|||
|
|||
progressBar.setVisibility(ProgressBar.GONE); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,643 @@ |
|||
package gr.thmmy.mthmmy.activities.upload; |
|||
|
|||
import android.app.Activity; |
|||
import android.content.Context; |
|||
import android.content.DialogInterface; |
|||
import android.content.Intent; |
|||
import android.content.SharedPreferences; |
|||
import android.database.Cursor; |
|||
import android.net.Uri; |
|||
import android.os.AsyncTask; |
|||
import android.os.Bundle; |
|||
import android.provider.MediaStore; |
|||
import android.provider.OpenableColumns; |
|||
import android.support.annotation.NonNull; |
|||
import android.support.annotation.Nullable; |
|||
import android.support.v7.app.AlertDialog; |
|||
import android.support.v7.preference.PreferenceManager; |
|||
import android.support.v7.widget.AppCompatButton; |
|||
import android.view.View; |
|||
import android.widget.AdapterView; |
|||
import android.widget.ArrayAdapter; |
|||
import android.widget.EditText; |
|||
import android.widget.LinearLayout; |
|||
import android.widget.ProgressBar; |
|||
import android.widget.Toast; |
|||
|
|||
import net.gotev.uploadservice.MultipartUploadRequest; |
|||
import net.gotev.uploadservice.ServerResponse; |
|||
import net.gotev.uploadservice.UploadInfo; |
|||
import net.gotev.uploadservice.UploadNotificationConfig; |
|||
import net.gotev.uploadservice.UploadStatusDelegate; |
|||
|
|||
import org.jsoup.nodes.Document; |
|||
import org.jsoup.nodes.Element; |
|||
import org.jsoup.select.Elements; |
|||
|
|||
import java.io.BufferedInputStream; |
|||
import java.io.BufferedOutputStream; |
|||
import java.io.File; |
|||
import java.io.FileOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
|
|||
import gr.thmmy.mthmmy.R; |
|||
import gr.thmmy.mthmmy.base.BaseActivity; |
|||
import gr.thmmy.mthmmy.base.BaseApplication; |
|||
import gr.thmmy.mthmmy.model.UploadCategory; |
|||
import gr.thmmy.mthmmy.utils.AppCompatSpinnerWithoutDefault; |
|||
import gr.thmmy.mthmmy.utils.parsing.ParseException; |
|||
import gr.thmmy.mthmmy.utils.parsing.ParseTask; |
|||
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; |
|||
import timber.log.Timber; |
|||
|
|||
import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.UPLOADING_APP_SIGNATURE_ENABLE_KEY; |
|||
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_COURSE; |
|||
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.BUNDLE_UPLOAD_FIELD_BUILDER_SEMESTER; |
|||
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_DESCRIPTION; |
|||
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_FILENAME; |
|||
import static gr.thmmy.mthmmy.activities.upload.UploadFieldsBuilderActivity.RESULT_TITLE; |
|||
|
|||
public class UploadActivity extends BaseActivity { |
|||
/** |
|||
* The key to use when putting upload's category String to {@link UploadActivity}'s Bundle. |
|||
*/ |
|||
public static final String BUNDLE_UPLOAD_CATEGORY = "UPLOAD_CATEGORY"; |
|||
private static final String uploadIndexUrl = "https://www.thmmy.gr/smf/index.php?action=tpmod;dl=upload"; |
|||
private static final String uploadedFrommThmmyPromptHtml = "<br /><div style=\"text-align: right;\"><span style=\"font-style: italic;\">uploaded from <a href=\"https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy\">mTHMMY</a></span>"; |
|||
private static final int REQUEST_CODE_CHOOSE_FILE = 8; |
|||
private static final int REQUEST_CODE_CAMERA = 4; |
|||
private static final int REQUEST_CODE_FIELDS_BUILDER = 74; |
|||
|
|||
private static ArrayList<UploadCategory> uploadRootCategories = new ArrayList<>(); |
|||
private ParseUploadPageTask parseUploadPageTask; |
|||
private ArrayList<String> bundleCategory; |
|||
private String categorySelected = "-1"; |
|||
private String uploaderProfileIndex = "1"; |
|||
private String uploadFilename; |
|||
private Uri fileUri; |
|||
private String fileIcon; |
|||
|
|||
//UI elements
|
|||
private MaterialProgressBar progressBar; |
|||
private LinearLayout categoriesSpinners; |
|||
private AppCompatSpinnerWithoutDefault rootCategorySpinner; |
|||
private EditText uploadTitle; |
|||
private EditText uploadDescription; |
|||
private AppCompatButton titleDescriptionBuilderButton; |
|||
private AppCompatButton selectFileButton; |
|||
//private static AppCompatButton titleDescriptionBuilderButton;
|
|||
|
|||
@Override |
|||
protected void onCreate(Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
setContentView(R.layout.activity_upload); |
|||
|
|||
Bundle extras = getIntent().getExtras(); |
|||
if (extras != null) { |
|||
String tmpUploadCategoryNav = extras.getString(BUNDLE_UPLOAD_CATEGORY); |
|||
//something like "THMMY.gr > Downloads > Βασικός Κύκλος > 3ο εξάμηνο > Ηλεκτρικά Κυκλώματα ΙΙ"
|
|||
if (tmpUploadCategoryNav != null && !tmpUploadCategoryNav.equals("")) { |
|||
String[] tmpSplitUploadCategoryNav = tmpUploadCategoryNav.split(">"); |
|||
|
|||
for (int i = 0; i < tmpSplitUploadCategoryNav.length; ++i) { |
|||
tmpSplitUploadCategoryNav[i] = tmpSplitUploadCategoryNav[i].trim(); |
|||
} |
|||
|
|||
if (tmpSplitUploadCategoryNav.length > 2) { |
|||
bundleCategory = new ArrayList<>(Arrays.asList(tmpSplitUploadCategoryNav).subList(2, tmpSplitUploadCategoryNav.length)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
//Initialize toolbar
|
|||
toolbar = findViewById(R.id.toolbar); |
|||
toolbar.setTitle("Upload"); |
|||
setSupportActionBar(toolbar); |
|||
if (getSupportActionBar() != null) { |
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|||
getSupportActionBar().setDisplayShowHomeEnabled(true); |
|||
} |
|||
|
|||
createDrawer(); |
|||
drawer.setSelection(UPLOAD_ID); |
|||
|
|||
progressBar = findViewById(R.id.progressBar); |
|||
|
|||
findViewById(R.id.upload_outer_scrollview).setVerticalScrollBarEnabled(false); |
|||
categoriesSpinners = findViewById(R.id.upload_spinners); |
|||
rootCategorySpinner = findViewById(R.id.upload_spinner_category_root); |
|||
rootCategorySpinner.setOnItemSelectedListener(new CustomOnItemSelectedListener(uploadRootCategories)); |
|||
|
|||
titleDescriptionBuilderButton = findViewById(R.id.upload_title_description_builder); |
|||
titleDescriptionBuilderButton.setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View view) { |
|||
if (categorySelected.equals("-1")) { |
|||
Toast.makeText(view.getContext(), "Please choose category first", Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
|
|||
int numberOfSpinners = categoriesSpinners.getChildCount(); |
|||
|
|||
if (numberOfSpinners < 3) { |
|||
Toast.makeText(view.getContext(), "Please choose a course category", Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
|
|||
String maybeSemester = (String) ((AppCompatSpinnerWithoutDefault) |
|||
categoriesSpinners.getChildAt(numberOfSpinners - 2)).getSelectedItem(); |
|||
String maybeCourse = (String) ((AppCompatSpinnerWithoutDefault) |
|||
categoriesSpinners.getChildAt(numberOfSpinners - 1)).getSelectedItem(); |
|||
|
|||
if (!maybeSemester.contains("εξάμηνο") && !maybeSemester.contains("Εξάμηνο")) { |
|||
Toast.makeText(view.getContext(), "Please choose a course category", Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
if (maybeCourse == null) { |
|||
Toast.makeText(view.getContext(), "Please choose a course", Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
|
|||
//Fixes course and semester
|
|||
maybeCourse = maybeCourse.replaceAll("-", "").replace("(ΝΠΣ)", "").trim(); |
|||
maybeSemester = maybeSemester.replaceAll("-", "").trim().substring(0, 1); |
|||
|
|||
Intent intent = new Intent(UploadActivity.this, UploadFieldsBuilderActivity.class); |
|||
Bundle extras = new Bundle(); |
|||
extras.putString(BUNDLE_UPLOAD_FIELD_BUILDER_COURSE, maybeCourse); |
|||
extras.putString(BUNDLE_UPLOAD_FIELD_BUILDER_SEMESTER, maybeSemester); |
|||
intent.putExtras(extras); |
|||
startActivityForResult(intent, REQUEST_CODE_FIELDS_BUILDER); |
|||
} |
|||
}); |
|||
titleDescriptionBuilderButton.setEnabled(false); |
|||
|
|||
uploadTitle = findViewById(R.id.upload_title); |
|||
uploadDescription = findViewById(R.id.upload_description); |
|||
|
|||
selectFileButton = findViewById(R.id.upload_select_file_button); |
|||
selectFileButton.setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View v) { |
|||
final CharSequence[] options = {"Take photo", "Choose file", |
|||
"Cancel"}; |
|||
AlertDialog.Builder builder = new AlertDialog.Builder(UploadActivity.this); |
|||
builder.setTitle("Upload file"); |
|||
builder.setItems(options, new DialogInterface.OnClickListener() { |
|||
@Override |
|||
public void onClick(DialogInterface dialog, int item) { |
|||
if (options[item].equals("Take photo")) { |
|||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
|||
startActivityForResult(intent, REQUEST_CODE_CAMERA); |
|||
} else if (options[item].equals("Choose file")) { |
|||
String[] mimeTypes = {"image/jpeg", "text/html", "image/png", "image/jpg", "image/gif", |
|||
"application/pdf", "application/rar", "application/x-tar", "application/zip", |
|||
"application/msword", "image/vnd.djvu", "application/gz", "application/tar.gz"}; |
|||
|
|||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT) |
|||
//.setType("*/*")
|
|||
.setType("image/jpeg") |
|||
.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); |
|||
|
|||
startActivityForResult(intent, REQUEST_CODE_CHOOSE_FILE); |
|||
} else if (options[item].equals("Cancel")) { |
|||
dialog.dismiss(); |
|||
} |
|||
} |
|||
}); |
|||
builder.show(); |
|||
} |
|||
}); |
|||
|
|||
findViewById(R.id.upload_upload_button).setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View view) { |
|||
String uploadTitleText = uploadTitle.getText().toString(); |
|||
String uploadDescriptionText = uploadDescription.getText().toString(); |
|||
|
|||
if (uploadTitleText.equals("")) { |
|||
uploadTitle.setError("Required"); |
|||
} |
|||
if (fileUri == null) { |
|||
selectFileButton.setError("Required"); |
|||
} |
|||
if (categorySelected.equals("-1")) { |
|||
Toast.makeText(view.getContext(), "Please choose category first", Toast.LENGTH_SHORT).show(); |
|||
} |
|||
|
|||
if (categorySelected.equals("-1") || uploadTitleText.equals("") || fileUri == null) { |
|||
return; |
|||
} |
|||
|
|||
String tmpDescriptionText = uploadDescriptionText; |
|||
|
|||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(view.getContext()); |
|||
if (sharedPrefs.getBoolean(UPLOADING_APP_SIGNATURE_ENABLE_KEY, true)) { |
|||
tmpDescriptionText += uploadedFrommThmmyPromptHtml; |
|||
} |
|||
|
|||
String tempFilePath = null; |
|||
if (uploadFilename != null) { |
|||
tempFilePath = createTempFile(uploadFilename); |
|||
if (tempFilePath == null) { |
|||
//Something went wrong, abort
|
|||
return; |
|||
} |
|||
} |
|||
|
|||
try { |
|||
final String finalTempFilePath = tempFilePath; |
|||
new MultipartUploadRequest(view.getContext(), uploadIndexUrl) |
|||
.setUtf8Charset() |
|||
.addParameter("tp-dluploadtitle", uploadTitleText) |
|||
.addParameter("tp-dluploadcat", categorySelected) |
|||
.addParameter("tp-dluploadtext", tmpDescriptionText) |
|||
.addFileToUpload(tempFilePath == null |
|||
? fileUri.toString() |
|||
: tempFilePath |
|||
, "tp-dluploadfile") |
|||
.addParameter("tp_dluploadicon", fileIcon) |
|||
.addParameter("tp-uploaduser", uploaderProfileIndex) |
|||
.setNotificationConfig(new UploadNotificationConfig()) |
|||
.setMaxRetries(2) |
|||
.setDelegate(new UploadStatusDelegate() { |
|||
@Override |
|||
public void onProgress(Context context, UploadInfo uploadInfo) { |
|||
} |
|||
|
|||
@Override |
|||
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse, |
|||
Exception exception) { |
|||
Toast.makeText(context, "Upload failed", Toast.LENGTH_SHORT).show(); |
|||
if (finalTempFilePath != null) { |
|||
if (!deleteTempFile(finalTempFilePath)) { |
|||
Toast.makeText(context, "Failed to delete temp file", Toast.LENGTH_SHORT).show(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse) { |
|||
if (finalTempFilePath != null) { |
|||
if (!deleteTempFile(finalTempFilePath)) { |
|||
Toast.makeText(context, "Failed to delete temp file", Toast.LENGTH_SHORT).show(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onCancelled(Context context, UploadInfo uploadInfo) { |
|||
if (finalTempFilePath != null) { |
|||
if (!deleteTempFile(finalTempFilePath)) { |
|||
Toast.makeText(context, "Failed to delete temp file", Toast.LENGTH_SHORT).show(); |
|||
} |
|||
} |
|||
} |
|||
}) |
|||
.startUpload(); |
|||
} catch (Exception exception) { |
|||
Timber.e(exception, "AndroidUploadService: %s", exception.getMessage()); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
if (uploadRootCategories.isEmpty()) { |
|||
parseUploadPageTask = new ParseUploadPageTask(); |
|||
parseUploadPageTask.execute(uploadIndexUrl); |
|||
} else { |
|||
String[] tmpSpinnerArray = new String[uploadRootCategories.size()]; |
|||
for (int i = 0; i < uploadRootCategories.size(); ++i) { |
|||
tmpSpinnerArray[i] = uploadRootCategories.get(i).getCategoryTitle(); |
|||
} |
|||
|
|||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(BaseApplication.getInstance().getApplicationContext(), |
|||
android.R.layout.simple_spinner_dropdown_item, tmpSpinnerArray); |
|||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|||
rootCategorySpinner.setAdapter(spinnerArrayAdapter); |
|||
|
|||
//Sets bundle selection
|
|||
if (bundleCategory != null) { |
|||
int bundleSelectionIndex = -1, currentIndex = 0; |
|||
for (UploadCategory category : uploadRootCategories) { |
|||
if (category.getCategoryTitle().contains(bundleCategory.get(0))) { //TODO fix .contains, always false
|
|||
bundleSelectionIndex = currentIndex; |
|||
break; |
|||
} |
|||
++currentIndex; |
|||
} |
|||
|
|||
if (bundleSelectionIndex != -1) { |
|||
rootCategorySpinner.setSelection(bundleSelectionIndex, true); |
|||
} |
|||
} |
|||
|
|||
titleDescriptionBuilderButton.setEnabled(true); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onBackPressed() { |
|||
if (drawer.isDrawerOpen()) { |
|||
drawer.closeDrawer(); |
|||
return; |
|||
} |
|||
super.onBackPressed(); |
|||
} |
|||
|
|||
@Override |
|||
protected void onResume() { |
|||
drawer.setSelection(UPLOAD_ID); |
|||
super.onResume(); |
|||
} |
|||
|
|||
@Override |
|||
protected void onDestroy() { |
|||
super.onDestroy(); |
|||
if (parseUploadPageTask != null && parseUploadPageTask.getStatus() != AsyncTask.Status.RUNNING) |
|||
parseUploadPageTask.cancel(true); |
|||
} |
|||
|
|||
@Override |
|||
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
|||
if (requestCode == REQUEST_CODE_CHOOSE_FILE && data != null) { |
|||
if (resultCode == Activity.RESULT_CANCELED) { |
|||
return; |
|||
} |
|||
|
|||
fileUri = data.getData(); |
|||
if (fileUri != null) { |
|||
String filename = filenameFromUri(fileUri); |
|||
selectFileButton.setText(filename); |
|||
|
|||
filename = filename.toLowerCase(); |
|||
if (filename.endsWith(".jpg")) { |
|||
fileIcon = "jpg_image.gif"; |
|||
} else if (filename.endsWith(".gif")) { |
|||
fileIcon = "gif_image.gif"; |
|||
} else if (filename.endsWith(".png")) { |
|||
fileIcon = "png_image.gif"; |
|||
} else if (filename.endsWith(".html") || filename.endsWith(".htm")) { |
|||
fileIcon = "html_file.gif"; |
|||
} else if (filename.endsWith(".pdf") || filename.endsWith(".doc") || |
|||
filename.endsWith("djvu")) { |
|||
fileIcon = "text_file.gif"; |
|||
} else if (filename.endsWith(".zip") || filename.endsWith(".rar") || |
|||
filename.endsWith(".tar") || filename.endsWith(".tar.gz") || |
|||
filename.endsWith(".gz")) { |
|||
fileIcon = "archive.gif"; |
|||
} else { |
|||
fileIcon = "blank.gif"; |
|||
} |
|||
} |
|||
} else if (requestCode == REQUEST_CODE_CAMERA && data != null) { |
|||
if (resultCode == Activity.RESULT_CANCELED) { |
|||
return; |
|||
} |
|||
//TODO
|
|||
} else if (requestCode == REQUEST_CODE_FIELDS_BUILDER) { |
|||
if (resultCode == Activity.RESULT_CANCELED) { |
|||
return; |
|||
} |
|||
|
|||
uploadFilename = data.getStringExtra(RESULT_FILENAME); |
|||
uploadTitle.setText(data.getStringExtra(RESULT_TITLE)); |
|||
uploadDescription.setText(data.getStringExtra(RESULT_DESCRIPTION)); |
|||
} else { |
|||
super.onActivityResult(requestCode, resultCode, data); |
|||
} |
|||
} |
|||
|
|||
@NonNull |
|||
private String filenameFromUri(Uri uri) { |
|||
String filename = null; |
|||
if (uri.getScheme().equals("content")) { |
|||
try (Cursor cursor = getContentResolver().query(uri, null, null, null, null)) { |
|||
if (cursor != null && cursor.moveToFirst()) { |
|||
filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); |
|||
} |
|||
} |
|||
} |
|||
if (filename == null) { |
|||
filename = uri.getPath(); |
|||
int cut = filename.lastIndexOf('/'); |
|||
if (cut != -1) { |
|||
filename = filename.substring(cut + 1); |
|||
} |
|||
} |
|||
|
|||
return filename; |
|||
} |
|||
|
|||
@Nullable |
|||
private String createTempFile(String newFilename) { |
|||
String oldFilename = filenameFromUri(fileUri); |
|||
String fileExtension = oldFilename.substring(oldFilename.indexOf(".")); |
|||
String destinationFilename = android.os.Environment.getExternalStorageDirectory().getPath() + |
|||
File.separatorChar + "~tmp_mThmmy_uploads" + File.separatorChar + newFilename + fileExtension; |
|||
|
|||
File tempDirectory = new File(android.os.Environment.getExternalStorageDirectory().getPath() + |
|||
File.separatorChar + "~tmp_mThmmy_uploads"); |
|||
|
|||
if (!tempDirectory.exists()) { |
|||
if (!tempDirectory.mkdirs()) { |
|||
Timber.w("Temporary directory build returned false in %s", UploadActivity.class.getSimpleName()); |
|||
Toast.makeText(this, "Couldn't create temporary directory", Toast.LENGTH_SHORT).show(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
InputStream inputStream; |
|||
BufferedInputStream bufferedInputStream = null; |
|||
BufferedOutputStream bufferedOutputStream = null; |
|||
|
|||
try { |
|||
inputStream = getContentResolver().openInputStream(fileUri); |
|||
if (inputStream == null) { |
|||
Timber.w("Input stream was null, %s", UploadActivity.class.getSimpleName()); |
|||
return null; |
|||
} |
|||
|
|||
bufferedInputStream = new BufferedInputStream(inputStream); |
|||
bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(destinationFilename, false)); |
|||
byte[] buf = new byte[1024]; |
|||
bufferedInputStream.read(buf); |
|||
do { |
|||
bufferedOutputStream.write(buf); |
|||
} while (bufferedInputStream.read(buf) != -1); |
|||
} catch (IOException exception) { |
|||
exception.printStackTrace(); |
|||
} finally { |
|||
try { |
|||
if (bufferedInputStream != null) bufferedInputStream.close(); |
|||
if (bufferedOutputStream != null) bufferedOutputStream.close(); |
|||
} catch (IOException exception) { |
|||
exception.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
return destinationFilename; |
|||
} |
|||
|
|||
private boolean deleteTempFile(String destinationFilename) { |
|||
File file = new File(destinationFilename); |
|||
return file.delete(); |
|||
} |
|||
|
|||
private class CustomOnItemSelectedListener implements AdapterView.OnItemSelectedListener { |
|||
private ArrayList<UploadCategory> parentCategories, childCategories; |
|||
|
|||
// Suppresses default constructor
|
|||
@SuppressWarnings("unused") |
|||
private CustomOnItemSelectedListener() { |
|||
} |
|||
|
|||
CustomOnItemSelectedListener(ArrayList<UploadCategory> parentCategories) { |
|||
this.parentCategories = parentCategories; |
|||
} |
|||
|
|||
@Override |
|||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
|||
//Removes old, unneeded sub-category spinner(s)
|
|||
int viewIndex = categoriesSpinners.indexOfChild((AppCompatSpinnerWithoutDefault) view.getParent()); |
|||
|
|||
if (viewIndex + 1 != categoriesSpinners.getChildCount()) { //Makes sure this is not the last child
|
|||
categoriesSpinners.removeViews(viewIndex + 1, categoriesSpinners.getChildCount() - viewIndex - 1); |
|||
} |
|||
|
|||
categorySelected = parentCategories.get(position).getValue(); |
|||
|
|||
//Adds new sub-category spinner
|
|||
if (parentCategories.get(position).hasSubCategories()) { |
|||
childCategories = parentCategories.get(position).getSubCategories(); |
|||
|
|||
String[] tmpSpinnerArray = new String[childCategories.size()]; |
|||
for (int i = 0; i < tmpSpinnerArray.length; ++i) { |
|||
tmpSpinnerArray[i] = childCategories.get(i).getCategoryTitle(); |
|||
} |
|||
|
|||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(getApplicationContext(), |
|||
android.R.layout.simple_spinner_dropdown_item, tmpSpinnerArray); |
|||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|||
|
|||
AppCompatSpinnerWithoutDefault subSpinner = new AppCompatSpinnerWithoutDefault(categoriesSpinners.getContext()); |
|||
subSpinner.setPromptId(R.string.upload_spinners_hint); |
|||
subSpinner.setPopupBackgroundResource(R.color.primary); |
|||
subSpinner.setAdapter(spinnerArrayAdapter); |
|||
subSpinner.setOnItemSelectedListener(new CustomOnItemSelectedListener(childCategories)); |
|||
categoriesSpinners.addView(subSpinner); |
|||
|
|||
//Sets bundle selection
|
|||
if (bundleCategory != null && viewIndex < bundleCategory.size()) { |
|||
int bundleSelectionIndex = -1, currentIndex = 0; |
|||
for (UploadCategory category : parentCategories) { |
|||
if (category.getCategoryTitle().contains(bundleCategory.get(viewIndex))) { |
|||
bundleSelectionIndex = currentIndex; |
|||
break; |
|||
} |
|||
++currentIndex; |
|||
} |
|||
|
|||
if (bundleSelectionIndex != -1) { |
|||
subSpinner.setSelection(bundleSelectionIndex, true); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onNothingSelected(AdapterView<?> parent) { |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* An {@link ParseTask} that handles asynchronous fetching of the upload page and parsing the |
|||
* upload categories. |
|||
*/ |
|||
private class ParseUploadPageTask extends ParseTask { |
|||
@Override |
|||
protected void onPreExecute() { |
|||
progressBar.setVisibility(ProgressBar.VISIBLE); |
|||
} |
|||
|
|||
@Override |
|||
protected void parse(Document uploadPage) throws ParseException { |
|||
Elements categoriesElements; |
|||
Element uploaderProfileIndexElement; |
|||
|
|||
try { |
|||
categoriesElements = uploadPage.select("select[name='tp-dluploadcat']>option"); |
|||
uploaderProfileIndexElement = uploadPage.select("input[name=\"tp-uploaduser\"]").first(); |
|||
} catch (Exception e) { |
|||
throw new ParseException("Parsing failed (UploadActivity)"); |
|||
} |
|||
|
|||
uploaderProfileIndex = uploaderProfileIndexElement.attr("value"); |
|||
|
|||
for (Element category : categoriesElements) { |
|||
String categoryValue = category.attr("value"); |
|||
String categoryText = category.text(); |
|||
|
|||
if (categoryText.startsWith("- ")) { |
|||
//This is a level one subcategory
|
|||
uploadRootCategories.get(uploadRootCategories.size() - 1).addSubCategory(categoryValue, categoryText); |
|||
} else if (categoryText.startsWith("-- ")) { |
|||
//This is a level two subcategory
|
|||
UploadCategory rootLevelCategory = uploadRootCategories.get(uploadRootCategories.size() - 1); |
|||
UploadCategory firstLevelCategory = rootLevelCategory.getSubCategories().get(rootLevelCategory.getSubCategories().size() - 1); |
|||
firstLevelCategory.addSubCategory(categoryValue, categoryText); |
|||
} else if (categoryText.startsWith("--- ")) { |
|||
//This is a level three subcategory
|
|||
UploadCategory rootLevelCategory = uploadRootCategories.get(uploadRootCategories.size() - 1); |
|||
UploadCategory firstLevelCategory = rootLevelCategory.getSubCategories().get(rootLevelCategory.getSubCategories().size() - 1); |
|||
UploadCategory secondLevelCategory = firstLevelCategory.getSubCategories().get(firstLevelCategory.getSubCategories().size() - 1); |
|||
secondLevelCategory.addSubCategory(categoryValue, categoryText); |
|||
} else if (categoryText.startsWith("---- ")) { |
|||
//This is a level three subcategory
|
|||
UploadCategory rootLevelCategory = uploadRootCategories.get(uploadRootCategories.size() - 1); |
|||
UploadCategory firstLevelCategory = rootLevelCategory.getSubCategories().get(rootLevelCategory.getSubCategories().size() - 1); |
|||
UploadCategory secondLevelCategory = firstLevelCategory.getSubCategories().get(firstLevelCategory.getSubCategories().size() - 1); |
|||
UploadCategory thirdLevelCategory = secondLevelCategory.getSubCategories().get(secondLevelCategory.getSubCategories().size() - 1); |
|||
thirdLevelCategory.addSubCategory(categoryValue, categoryText); |
|||
} else { |
|||
//This is a root category
|
|||
uploadRootCategories.add(new UploadCategory(categoryValue, categoryText)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
protected void postExecution(ResultCode result) { |
|||
String[] tmpSpinnerArray = new String[uploadRootCategories.size()]; |
|||
for (int i = 0; i < uploadRootCategories.size(); ++i) { |
|||
tmpSpinnerArray[i] = uploadRootCategories.get(i).getCategoryTitle(); |
|||
} |
|||
|
|||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(BaseApplication.getInstance().getApplicationContext(), |
|||
android.R.layout.simple_spinner_dropdown_item, tmpSpinnerArray); |
|||
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|||
rootCategorySpinner.setAdapter(spinnerArrayAdapter); |
|||
|
|||
//Sets bundle selection
|
|||
if (bundleCategory != null) { |
|||
int bundleSelectionIndex = -1, currentIndex = 0; |
|||
for (UploadCategory category : uploadRootCategories) { |
|||
if (category.getCategoryTitle().contains(bundleCategory.get(0))) { //TODO fix .contains, always false
|
|||
bundleSelectionIndex = currentIndex; |
|||
break; |
|||
} |
|||
++currentIndex; |
|||
} |
|||
|
|||
if (bundleSelectionIndex != -1) { |
|||
rootCategorySpinner.setSelection(bundleSelectionIndex, true); |
|||
} |
|||
} |
|||
|
|||
titleDescriptionBuilderButton.setEnabled(true); |
|||
progressBar.setVisibility(ProgressBar.GONE); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,481 @@ |
|||
package gr.thmmy.mthmmy.activities.upload; |
|||
|
|||
import android.app.Activity; |
|||
import android.content.Intent; |
|||
import android.os.Bundle; |
|||
import android.support.annotation.Nullable; |
|||
import android.support.v7.app.AppCompatActivity; |
|||
import android.support.v7.widget.Toolbar; |
|||
import android.text.Editable; |
|||
import android.text.TextWatcher; |
|||
import android.view.View; |
|||
import android.widget.EditText; |
|||
import android.widget.LinearLayout; |
|||
import android.widget.RadioGroup; |
|||
import android.widget.Toast; |
|||
|
|||
import java.util.Calendar; |
|||
|
|||
import gr.thmmy.mthmmy.R; |
|||
import timber.log.Timber; |
|||
|
|||
public class UploadFieldsBuilderActivity extends AppCompatActivity { |
|||
static final String BUNDLE_UPLOAD_FIELD_BUILDER_COURSE = "UPLOAD_FIELD_BUILDER_COURSE"; |
|||
static final String BUNDLE_UPLOAD_FIELD_BUILDER_SEMESTER = "UPLOAD_FIELD_BUILDER_SEMESTER"; |
|||
|
|||
static final String RESULT_FILENAME = "RESULT_FILENAME"; |
|||
static final String RESULT_TITLE = "RESULT_TITLE"; |
|||
static final String RESULT_DESCRIPTION = "RESULT_DESCRIPTION"; |
|||
|
|||
private String course, semester; |
|||
|
|||
private LinearLayout semesterChooserLinear; |
|||
private RadioGroup typeRadio, semesterRadio; |
|||
private EditText year; |
|||
|
|||
private TextWatcher customYearWatcher = new TextWatcher() { |
|||
|
|||
@Override |
|||
public void onTextChanged(CharSequence s, int start, int before, int count) { |
|||
String working = s.toString(); |
|||
boolean isValid; |
|||
|
|||
if (working.length() == 4) { |
|||
int currentYear = Calendar.getInstance().get(Calendar.YEAR); |
|||
int inputYear = Integer.parseInt(working); |
|||
|
|||
isValid = inputYear <= currentYear && inputYear > 2000; |
|||
} else { |
|||
isValid = false; |
|||
} |
|||
|
|||
if (!isValid) { |
|||
year.setError("Please enter a valid year"); |
|||
} else { |
|||
year.setError(null); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void afterTextChanged(Editable s) { |
|||
} |
|||
|
|||
@Override |
|||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
|||
} |
|||
}; |
|||
|
|||
@Override |
|||
protected void onCreate(Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
setContentView(R.layout.activity_upload_fields_builder); |
|||
|
|||
Bundle extras = getIntent().getExtras(); |
|||
if (extras != null) { |
|||
course = extras.getString(BUNDLE_UPLOAD_FIELD_BUILDER_COURSE); |
|||
semester = extras.getString(BUNDLE_UPLOAD_FIELD_BUILDER_SEMESTER); |
|||
if (course == null || course.equals("") || semester == null || semester.equals("")) { |
|||
Toast.makeText(this, "Something went wrong!", Toast.LENGTH_SHORT).show(); |
|||
Timber.e("Bundle came empty in %s", UploadFieldsBuilderActivity.class.getSimpleName()); |
|||
|
|||
Intent returnIntent = new Intent(); |
|||
setResult(Activity.RESULT_CANCELED, returnIntent); |
|||
finish(); |
|||
} |
|||
} |
|||
|
|||
//Initialize toolbar
|
|||
Toolbar toolbar = findViewById(R.id.toolbar); |
|||
toolbar.setTitle("Upload fields builder"); |
|||
setSupportActionBar(toolbar); |
|||
if (getSupportActionBar() != null) { |
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|||
getSupportActionBar().setDisplayShowHomeEnabled(true); |
|||
} |
|||
|
|||
semesterChooserLinear = findViewById(R.id.upload_fields_builder_choose_semester); |
|||
semesterRadio = findViewById(R.id.upload_fields_builder_semester_radio_group); |
|||
year = findViewById(R.id.upload_fields_builder_year); |
|||
year.addTextChangedListener(customYearWatcher); |
|||
|
|||
typeRadio = findViewById(R.id.upload_fields_builder_type_radio_group); |
|||
typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
|||
@Override |
|||
public void onCheckedChanged(RadioGroup group, int checkedId) { |
|||
if (checkedId == R.id.upload_fields_builder_radio_button_notes) { |
|||
semesterChooserLinear.setVisibility(View.GONE); |
|||
} else { |
|||
semesterChooserLinear.setVisibility(View.VISIBLE); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
findViewById(R.id.upload_fields_builder_submit).setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View view) { |
|||
int typeId = typeRadio.getCheckedRadioButtonId(), |
|||
semesterId = semesterRadio.getCheckedRadioButtonId(); |
|||
if (typeId == -1) { |
|||
Toast.makeText(view.getContext(), "Please choose a type for the upload", Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} else if (semesterChooserLinear.getVisibility() == View.VISIBLE && semesterId == -1) { |
|||
Toast.makeText(view.getContext(), "Please choose a semester for the upload", Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} else if (year.getText().toString().isEmpty()) { |
|||
Toast.makeText(view.getContext(), "Please choose a year for the upload", Toast.LENGTH_SHORT).show(); |
|||
return; |
|||
} |
|||
|
|||
Intent returnIntent = new Intent(); |
|||
returnIntent.putExtra(RESULT_FILENAME, buildFilename()); |
|||
returnIntent.putExtra(RESULT_TITLE, buildTitle()); |
|||
returnIntent.putExtra(RESULT_DESCRIPTION, buildDescription()); |
|||
setResult(Activity.RESULT_OK, returnIntent); |
|||
finish(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
@Nullable |
|||
private String buildFilename() { |
|||
switch (typeRadio.getCheckedRadioButtonId()) { |
|||
case R.id.upload_fields_builder_radio_button_exams: |
|||
return getGreeklishCourseName() + "_" + getGreeklishPeriod() + "_" + year.getText().toString(); |
|||
case R.id.upload_fields_builder_radio_button_exam_solutions: |
|||
return getGreeklishCourseName() + "_" + getGreeklishPeriod() + "_" + year.getText().toString() + "_Lyseis"; |
|||
case R.id.upload_fields_builder_radio_button_notes: |
|||
return getGreeklishCourseName() + "_" + year.getText().toString() + "_Shmeiwseis"; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@Nullable |
|||
private String buildTitle() { |
|||
switch (typeRadio.getCheckedRadioButtonId()) { |
|||
case R.id.upload_fields_builder_radio_button_exams: |
|||
return getMinifiedCourseName() + " - " + "Θέματα εξετάσεων " + getPeriod() + " " + year.getText().toString(); |
|||
case R.id.upload_fields_builder_radio_button_exam_solutions: |
|||
return getMinifiedCourseName() + " - " + "Λύσεις θεμάτων " + getPeriod() + " " + year.getText().toString(); |
|||
case R.id.upload_fields_builder_radio_button_notes: |
|||
return getMinifiedCourseName() + " - " + "Σημειώσεις παραδόσεων " + year.getText().toString(); |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
private String buildDescription() { |
|||
switch (typeRadio.getCheckedRadioButtonId()) { |
|||
case R.id.upload_fields_builder_radio_button_exams: |
|||
return "Θέματα εξετάσεων " + getPeriod() + " " + year.getText().toString() + " του μαθήματος \"" + course + "\""; |
|||
case R.id.upload_fields_builder_radio_button_exam_solutions: |
|||
return "Λύσεις των θεμάτων των εξετάσεων " + getPeriod() + " " + year.getText().toString() + " του μαθήματος \"" + course + "\""; |
|||
case R.id.upload_fields_builder_radio_button_notes: |
|||
return "Σημειώσεις των παραδόσεων του μαθήματος \"" + course + "\" από το " + year.getText().toString(); |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
private String getGreeklishPeriod() { |
|||
switch (semesterRadio.getCheckedRadioButtonId()) { |
|||
case R.id.upload_fields_builder_radio_button_feb: |
|||
return "FEB"; |
|||
case R.id.upload_fields_builder_radio_button_jun: |
|||
return "IOY"; |
|||
case R.id.upload_fields_builder_radio_button_sept: |
|||
return "SEP"; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
private String getPeriod() { |
|||
switch (semesterRadio.getCheckedRadioButtonId()) { |
|||
case R.id.upload_fields_builder_radio_button_feb: |
|||
return "Φεβρουαρίου"; |
|||
case R.id.upload_fields_builder_radio_button_jun: |
|||
return "Ιουνίου"; |
|||
case R.id.upload_fields_builder_radio_button_sept: |
|||
return "Σεπτεμβρίου"; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@Nullable |
|||
private String getGreeklishCourseName() { |
|||
return getGreeklishOrMinifiedCourseName(true); |
|||
} |
|||
|
|||
@Nullable |
|||
private String getMinifiedCourseName() { |
|||
return getGreeklishOrMinifiedCourseName(false); |
|||
} |
|||
|
|||
|
|||
@Nullable |
|||
private String getGreeklishOrMinifiedCourseName(boolean greeklish) { |
|||
//TODO fill missing values
|
|||
if (course.contains("Συστήματα Υπολογιστών (Υπολογιστικά Συστήματα)")) { |
|||
return greeklish ? "sys_ypologistwn" : "Συσ. Υπολογιστών"; |
|||
} else if (course.contains("Τεχνική Μηχανική")) { |
|||
return greeklish ? "texn_mhxan" : "Τεχν. Μηχαν."; |
|||
} else if (course.contains("Διαφορικές Εξισώσεις")) { |
|||
return greeklish ? "diaforikes" : "Διαφορικές"; |
|||
} else if (course.contains("Θεωρία Πιθανοτήτων και Στατιστική")) { |
|||
return greeklish ? "pithanothtes" : "Πιθανότητες"; |
|||
} else if (course.contains("Εφαρμοσμένα Μαθηματικά Ι")) { |
|||
return greeklish ? "efarmosmena_math_I" : "Εφαρμοσμένα 1"; |
|||
} else if (course.contains("Ηλεκτρικά Κυκλώματα ΙΙ")) { |
|||
return greeklish ? "kyklwmata_II" : "Κυκλώματα 2"; |
|||
} else if (course.contains("Ηλεκτρολογικά Υλικά")) { |
|||
return greeklish ? "ylika" : "Ηλεκτρ. Υλικά"; |
|||
} else if (course.contains("Ηλεκτρομαγνητικό Πεδίο Ι")) { |
|||
return greeklish ? "pedio_I" : "Πεδίο 1"; |
|||
} else if (course.contains("Θεωρία Σημάτων και Γραμμικών Συστημάτων")) { |
|||
return greeklish ? "analog_shma" : "Σύματα & Συστήματα"; |
|||
} else if (course.contains("Προγραμματιστικές Τεχνικές")) { |
|||
return greeklish ? "cpp" : "Προγραμματ. Τεχν."; |
|||
} else if (course.contains("Αριθμητική Ανάλυση")) { |
|||
return greeklish ? "arith_anal" : "Αριθμ. Ανάλυση"; |
|||
} else if (course.contains("Αρχιτεκτονική Υπολογιστών")) { |
|||
return greeklish ? "arx_ypologistwn" : "Αρχ. Υπολογιστών"; |
|||
} else if (course.contains("Εισαγωγή στην Ενεργειακή Τεχνολογία Ι")) { |
|||
return greeklish ? "EET_I" : "ΕΕΤ 1"; |
|||
} else if (course.contains("Ηλεκτρικά Κυκλώματα ΙΙΙ")) { |
|||
return greeklish ? "kyklwmata_I" : "Κυκλώματα 3"; |
|||
} else if (course.contains("Ηλεκτρομαγνητικό Πεδίο ΙΙ")) { |
|||
return greeklish ? "pedio_II" : "Πεδίο 2"; |
|||
} else if (course.contains("Στοχαστικό Σήμα")) { |
|||
return greeklish ? "stox_shma" : "Στοχ. Σήμα"; |
|||
} else if (course.contains("Ψηφιακά Συστήματα Ι")) { |
|||
return greeklish ? "pshfiaka_I" : "Ψηφιακά 1"; |
|||
} else if (course.contains("Αναλογικές Τηλεπικοινωνίες (πρώην Τηλεπικοινωνιακά Συστήματα Ι)")) { |
|||
return greeklish ? "anal_thlep" : "Αναλογικές Τηλεπ."; |
|||
} else if (course.contains("Διάδοση Ηλεκτρομαγνητικού Κύματος Ι (πρώην Πεδίο ΙΙΙ)")) { |
|||
return greeklish ? "diadosi_1" : "Διάδοση 1"; |
|||
} else if (course.contains("Δομές Δεδομένων")) { |
|||
return greeklish ? "dom_dedomenwn" : "Δομ. Δεδομ."; |
|||
} else if (course.contains("Εισαγωγή στην Ενεργειακή Τεχνολογία ΙΙ")) { |
|||
return greeklish ? "EET_2" : "ΕΕΤ2"; |
|||
} else if (course.contains("Ηλεκτρικές Μετρήσεις Ι")) { |
|||
return greeklish ? "metrhseis_1" : "Μετρήσεις 1"; |
|||
} else if (course.contains("Ηλεκτρονική ΙΙ")) { |
|||
return greeklish ? "hlektronikh_2" : "Ηλεκτρονική 2"; |
|||
} else if (course.contains("Συστήματα Αυτομάτου Ελέγχου Ι")) { |
|||
return greeklish ? "SAE_1" : "ΣΑΕ 1"; |
|||
} else if (course.contains("Γραμμική Άλγεβρα")) { |
|||
return greeklish ? "grammikh_algebra" : "Γραμμ. Άλγεβρ."; |
|||
} else if (course.contains("Δομημένος Προγραμματισμός")) { |
|||
return greeklish ? "C" : "Δομ. Προγραμμ."; |
|||
} else if (course.contains("Λογική Σχεδίαση")) { |
|||
return greeklish ? "logiki_sxediash" : "Λογική Σχεδίαση"; |
|||
} else if (course.contains("Λογισμός Ι")) { |
|||
return greeklish ? "logismos_I" : "Λογισμός 1"; |
|||
} else if (course.contains("Τεχνικές Σχεδίασης με Η/Υ")) { |
|||
return greeklish ? "sxedio" : "Σχέδιο"; |
|||
} else if (course.contains("Φυσική Ι")) { |
|||
return greeklish ? "fysikh_I" : "Φυσική 1"; |
|||
} else if (course.contains("Αντικειμενοστραφής Προγραμματισμός")) { |
|||
return greeklish ? "OOP" : "Αντικειμενοστραφής"; |
|||
} else if (course.contains("Εφαρμοσμένη Θερμοδυναμική")) { |
|||
return greeklish ? "thermodynamikh" : "Θερμοδυναμική"; |
|||
} else if (course.contains("Ηλεκτρικά Κυκλώματα Ι")) { |
|||
return greeklish ? "kyklwmata_I" : "Κυκλώματα 1"; |
|||
} else if (course.contains("Λογισμός ΙΙ")) { |
|||
return greeklish ? "logismos_II" : "Λογισμός 2"; |
|||
} else if (course.contains("Οργάνωση Υπολογιστών")) { |
|||
return greeklish ? "org_ypol" : "Οργάνωση Υπολ."; |
|||
} else if (course.contains("Ηλεκτρονική Ι")) { |
|||
return greeklish ? "hlektronikh_1" : "Ηλεκτρονική 1"; |
|||
} else if (course.contains("Διακριτά μαθηματικά")) { |
|||
return greeklish ? "diakrita" : "Διακριτά Μαθηματικά"; |
|||
} else if (course.contains("Σήματα και Συστήματα")) { |
|||
return greeklish ? "analog_shma" : "Σύματα & Συστήματα"; |
|||
} else if (course.contains("Εισαγωγή στις εφαρμογές Πυρηνικής Τεχνολογίας")) { |
|||
return greeklish ? "Intro_Purhnikh_Texn" : "Εισ. Πυρηνικη Τεχν."; |
|||
} else if (course.contains("Επιχειρησιακή Έρευνα")) { |
|||
return greeklish ? "epixeirisiaki" : "Επιχειρησιακή Έρευνα"; |
|||
} else if (course.contains("Ημιαγωγά Υλικά: Θεωρία-Διατάξεις")) { |
|||
return greeklish ? "Hmiagwga_Ylika" : "Ημιαγωγά Υλικά"; |
|||
} else if (course.contains("Μετάδοση Θερμότητας")) { |
|||
return greeklish ? "metadosi_therm" : "Μετάδοση Θερμ."; |
|||
} else if (course.contains("Συστήματα Ηλεκτρικής Ενέργειας Ι")) { |
|||
return greeklish ? "SHE_I" : "ΣΗΕ 1"; |
|||
} else if (course.contains("Υψηλές Τάσεις Ι")) { |
|||
return greeklish ? "ypshles_I" : "Υψηλές 1"; |
|||
} else if (course.contains("Θεωρία και Τεχνολογία Πυρηνικών Αντιδραστήρων")) { |
|||
return greeklish ? "texn_antidrasthrwn" : "Τεχνολογία Αντιδραστήρων"; |
|||
} else if (course.contains("Τεχνολογία Ηλεκτροτεχνικών Υλικών")) { |
|||
return greeklish ? "Hlektrotexnika_Ylika" : "Ηλεκτροτεχνικά Υλικά"; |
|||
} else if (course.contains("Ηλεκτρικές Μηχανές Α'")) { |
|||
return greeklish ? "mhxanes_A" : "Μηχανές Α"; |
|||
} else if (course.contains("Σταθμοί Παραγωγής Ηλεκτρικής Ενέργειας")) { |
|||
return greeklish ? "SPHE" : "ΣΠΗΕ"; |
|||
} else if (course.contains("Συστήματα Ηλεκτρικής Ενέργειας ΙΙ")) { |
|||
return greeklish ? "SHE_II" : "ΣΗΕ 2"; |
|||
} else if (course.contains("Υψηλές Τάσεις ΙΙ")) { |
|||
return greeklish ? "ypshles_II" : "Υψηλές 2"; |
|||
} else if (course.contains("Αρχές Οικονομίας")) { |
|||
return greeklish ? "arx_oikonomias" : "Αρχές Οικονομίας"; |
|||
} else if (course.contains("Διανεμημένη Παραγωγή")) { |
|||
return greeklish ? "dian_paragwgh" : "Διανεμημένη Παραγωγή"; |
|||
} else if (course.contains("Διαχείριση Συστημάτων Ηλεκτρικής Ενέργειας")) { |
|||
return greeklish ? "dshe" : "ΔΣΗΕ"; |
|||
} else if (course.contains("Υψηλές Τάσεις ΙΙΙ")) { |
|||
return greeklish ? "ypshles_III" : "Υψηλές 3"; |
|||
} else if (course.contains("Ανάλυση Συστημάτων Ηλεκτρικής Ενέργειας")) { |
|||
return greeklish ? "ASHE" : "ΑΣΗΕ"; |
|||
} else if (course.contains("Ηλεκτρικές Μηχανές Β'")) { |
|||
return greeklish ? "mhxanes_B" : "Μηχανές Β"; |
|||
} else if (course.contains("Ηλεκτρονικά Ισχύος Ι")) { |
|||
return greeklish ? "isxyos_I" : "Ισχύος 1"; |
|||
} else if (course.contains("Συστήματα Ηλεκτρικής Ενέργειας ΙΙΙ")) { |
|||
return greeklish ? "SHE_III" : "ΣΗΕ 3"; |
|||
} else if (course.contains("Σερβοκινητήρια Συστήματα")) { |
|||
return greeklish ? "servo" : "Σέρβο"; |
|||
} else if (course.contains("Συστήματα Ηλεκτροκίνησης")) { |
|||
return greeklish ? "hlektrokinhsh" : "Ηλεκτροκίνηση"; |
|||
} else if (course.contains("Υπολογιστικές Μέθοδοι στα Ενεργειακά Συστήματα")) { |
|||
return greeklish ? "ymes" : "ΥΜΕΣ"; |
|||
} else if (course.contains("Υψηλές Τάσεις 4")) { |
|||
return greeklish ? "ypshles_IV" : "Υψηλές 4"; |
|||
} else if (course.contains("Ηλεκτρικές Μηχανές Γ'")) { |
|||
return greeklish ? "mhxanes_C" : "Μηχανές Γ"; |
|||
} else if (course.contains("Ηλεκτρική Οικονομία")) { |
|||
return greeklish ? "hlektr_oikonomia" : "Ηλεκτρική Οικονομία"; |
|||
} else if (course.contains("Ηλεκτρονικά Ισχύος ΙΙ")) { |
|||
return greeklish ? "isxyos_II" : "Ισχύος 2"; |
|||
} else if (course.contains("Ανάλυση και Σχεδίαση Αλγορίθμων")) { |
|||
return greeklish ? "algorithms" : "Αλγόριθμοι"; |
|||
} else if (course.contains("Διακριτά Μαθηματικά")) { |
|||
return greeklish ? "diakrita" : "Διακριτά Μαθηματικά"; |
|||
} else if (course.contains("Κβαντική Φυσική")) { |
|||
return greeklish ? "kvantikh" : "Κβαντική"; |
|||
} else if (course.contains("Ρομποτική")) { |
|||
return greeklish ? "rompotikh" : "Ρομποτική"; |
|||
} else if (course.contains("Τεχνικές Βελτιστοποίησης")) { |
|||
return greeklish ? "veltistopoihsh" : "Βελτιστοποίηση"; |
|||
} else if (course.contains("Ηλεκτρικές Μετρήσεις ΙΙ")) { |
|||
return greeklish ? "metrhseis_II" : "Μετρήσεις 2"; |
|||
} else if (course.contains("Ηλεκτρονική ΙΙΙ")) { |
|||
return greeklish ? "hlektronikh_III" : "Ηλεκτρονική 3"; |
|||
} else if (course.contains("Συστήματα Αυτομάτου Ελέγχου ΙΙ")) { |
|||
return greeklish ? "SAE_II" : "ΣΑΕ 2"; |
|||
} else if (course.contains("Ψηφιακά Συστήματα ΙΙ")) { |
|||
return greeklish ? "pshfiaka_II" : "Ψηφιακά 2"; |
|||
} else if (course.contains("Ανάλυση Χρονοσειρών")) { |
|||
return greeklish ? "xronoseires" : "Χρονοσειρές"; |
|||
} else if (course.contains("Θεωρία Υπολογισμών και Αλγορίθμων")) { |
|||
return greeklish ? "thya" : "ΘΥΑ"; |
|||
} else if (course.contains("Παράλληλα και Κατανεμημένα Συστήματα")) { |
|||
return greeklish ? "parallhla" : "Παράλληλα"; |
|||
} else if (course.contains("Προγραμματιζόμενα Κυκλώματα ASIC")) { |
|||
return greeklish ? "asic" : "ASIC"; |
|||
} else if (course.contains("Προσομοίωση και Μοντελοποίηση Συστημάτων")) { |
|||
return greeklish ? "montelopoihsh" : "Μοντελοποίηση"; |
|||
} else if (course.contains("Συστήματα Αυτομάτου Ελέγχου ΙΙI")) { |
|||
return greeklish ? "SAE_III" : "ΣΑΕ 3"; |
|||
} else if (course.contains("Σύνθεση Ενεργών και Παθητικών Κυκλωμάτων")) { |
|||
return greeklish ? "synthesh" : "Σύνθεση"; |
|||
} else if (course.contains("Δίκτυα Υπολογιστών Ι")) { |
|||
return greeklish ? "diktya_I" : "Δίκτυα 1"; |
|||
} else if (course.contains("Λειτουργικά Συστήματα")) { |
|||
return greeklish ? "OS" : "Λειτουργικά"; |
|||
} else if (course.contains("Συστήματα Μικροϋπολογιστών")) { |
|||
return greeklish ? "mikro_I" : "Μίκρο 1"; |
|||
} else if (course.contains("Ασαφή Συστήματα")) { |
|||
return greeklish ? "asafh" : "Ασαφή"; |
|||
} else if (course.contains("Γραφική με Υπολογιστές")) { |
|||
return greeklish ? "grafikh" : "Γραφική"; |
|||
} else if (course.contains("Ενσωματωμένα Συστήματα Πραγματικού Χρόνου")) { |
|||
return greeklish ? "enswmatwmena" : "Ενσωματωμένα"; |
|||
} else if (course.contains("Τηλεπικοινωνιακή Ηλεκτρονική")) { |
|||
return greeklish ? "tilep_ilektr" : "Τηλεπ. Ηλεκτρ."; |
|||
} else if (course.contains("Ψηφιακά Συστήματα ΙΙΙ")) { |
|||
return greeklish ? "pshfiaka_III" : "Ψηφιακά 3"; |
|||
} else if (course.contains("Ψηφιακή Επεξεργασία Εικόνας")) { |
|||
return greeklish ? "psee" : "ΨΕΕ"; |
|||
} else if (course.contains("Δίκτυα Υπολογιστών ΙΙ")) { |
|||
return greeklish ? "diktya_II" : "Δίκτυα 2"; |
|||
} else if (course.contains("Μικροεπεξεργαστές και Περιφερειακά")) { |
|||
return greeklish ? "mikro_II" : "Μίκρο 2"; |
|||
} else if (course.contains("Τεχνολογία Λογισμικού")) { |
|||
return greeklish ? "SE" : "Τεχνολογία Λογισμικού"; |
|||
} else if (course.contains("Ψηφιακά Φίλτρα")) { |
|||
return greeklish ? "filtra" : "Φίλτρα"; |
|||
} else if (course.contains("Αναγνώριση Προτύπων")) { |
|||
return greeklish ? "protipa" : "Αναγνώριση Προτύπων"; |
|||
} else if (course.contains("Ασφάλεια Πληροφοριακών Συστημάτων")) { |
|||
return greeklish ? "asfaleia" : "Ασφάλεια"; |
|||
} else if (course.contains("Βάσεις Δεδομένων")) { |
|||
return greeklish ? "vaseis" : "Βάσεις"; |
|||
} else if (course.contains("Βιομηχανική Πληροφορική")) { |
|||
return greeklish ? "viomix_plir" : "Βιομηχανική Πληρ"; |
|||
} else if (course.contains("Ευφυή Συστήματα Ρομπότ")) { |
|||
return greeklish ? "eufuh" : "Ευφυή"; |
|||
} else if (course.contains("Συστήματα Πολυμέσων και Εικονική Πραγματικότητα")) { |
|||
return greeklish ? "polymesa" : "Πολυμέσα"; |
|||
} else if (course.contains("Σχεδίαση Συστημάτων VLSI")) { |
|||
return greeklish ? "VLSI" : "VLSI"; |
|||
} else if (course.contains("Ακουστική Ι")) { |
|||
return greeklish ? "akoystikh_I" : "Ακουστική 1"; |
|||
} else if (course.contains("Εφαρμοσμένα Μαθηματικά ΙΙ")) { |
|||
return greeklish ? "efarmosmena_math_II" : "Εφαρμοσμένα 2"; |
|||
} else if (course.contains("Ηλεκτρακουστική Ι")) { |
|||
return greeklish ? "hlektroakoystikh_I" : "Ηλεκτροακουστική 1"; |
|||
} else if (course.contains("Οπτική Ι")) { |
|||
return greeklish ? "optikh_I" : "Οπτική 1"; |
|||
} else if (course.contains("Διάδοση Η/Μ Κύματος ΙΙ")) { |
|||
return greeklish ? "diadosi_II" : "Διάδοση 2"; |
|||
} else if (course.contains("Ψηφιακές Τηλεπικοινωνίες Ι")) { |
|||
return greeklish ? "pshf_thlep_I" : "Ψηφιακές Τηλεπ. 1"; |
|||
} else if (course.contains("Ακουστική ΙΙ")) { |
|||
return greeklish ? "akoystikh_II" : "Ακουστική 2"; |
|||
} else if (course.contains("Βιοϊατρική Τεχνολογία")) { |
|||
return greeklish ? "vioiatriki" : "Βιοιατρική"; |
|||
} else if (course.contains("Ηλεκτρακουστική ΙΙ")) { |
|||
return greeklish ? "hlektroakoystikh_II" : "Ηλεκτροακουστική 2"; |
|||
} else if (course.contains("Οπτική ΙΙ")) { |
|||
return greeklish ? "optikh_II" : "Οπτική 2"; |
|||
} else if (course.contains("Ασύρματος Τηλεπικοινωνία Ι")) { |
|||
return greeklish ? "asyrmatos_I" : "Ασύρματος 1"; |
|||
} else if (course.contains("Μικροκύματα I")) { |
|||
return greeklish ? "mikrokymata_I" : "Μικροκύματα 1"; |
|||
} else if (course.contains("Ψηφιακές Τηλεπικοινωνίες ΙΙ")) { |
|||
return greeklish ? "pshf_thlep_II" : "Ψηφιακές Τηλεπ. 2"; |
|||
} else if (course.contains("Ψηφιακή Επεξεργασία Σήματος")) { |
|||
return greeklish ? "PSES" : "ΨΕΣ"; |
|||
} else if (course.contains("Εισαγωγή στην Πολιτική Οικονομία")) { |
|||
return greeklish ? "polit_oik" : "Πολιτική Οικονομία"; |
|||
} else if (course.contains("Θεωρία Σκέδασης")) { |
|||
return greeklish ? "skedash" : "Σκέδαση"; |
|||
} else if (course.contains("Προηγμένες Τεχνικές Επεξεργασίας Σήματος")) { |
|||
return greeklish ? "ptes" : "ΠΤΕΣ"; |
|||
} else if (course.contains("Τηλεοπτικά Συστήματα")) { |
|||
return greeklish ? "tileoptika" : "Τηλεοπτικά"; |
|||
} else if (course.contains("Ασύρματος Τηλεπικοινωνία ΙΙ")) { |
|||
return greeklish ? "asyrmatos_II" : "Ασύρματος 2"; |
|||
} else if (course.contains("Δίκτυα Τηλεπικοινωνιών")) { |
|||
return greeklish ? "diktya_thlep" : "Δίκτυα Τηλέπ."; |
|||
} else if (course.contains("Θεωρία Πληροφοριών")) { |
|||
return greeklish ? "theoria_plir" : "Θεωρία Πληρ."; |
|||
} else if (course.contains("Οπτικές Επικοινωνίες")) { |
|||
return greeklish ? "optikes_thlep" : "Οπτικές Τηλεπ."; |
|||
} else if (course.contains("Ευρυζωνικά Δίκτυα")) { |
|||
return greeklish ? "eyryzwnika" : "Ευρυζωνικά"; |
|||
} else if (course.contains("Τεχνικές μη Καταστρεπτικών Δοκιμών")) { |
|||
return greeklish ? "non_destructive_tests" : "Μη Καταστρεπτικές Δοκιμές"; |
|||
} else if (course.contains("Φωτονική Τεχνολογία")) { |
|||
return greeklish ? "fwtonikh" : "Φωτονική"; |
|||
} else if (course.contains("Μικροκυματική Τηλεπισκόπηση")) { |
|||
return greeklish ? "thlepiskophsh" : "Τηλεπισκόπηση"; |
|||
} else if (course.contains("Μικροκύματα II")) { |
|||
return greeklish ? "mikrokymata_II" : "Μικροκύματα 2"; |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
} |
Before Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 230 B |
Before Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 175 B |
Before Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 183 B |
Before Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 324 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 170 B |
Before Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 132 B |
Before Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 376 B |
Before Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 365 B |
Before Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 336 B |
Before Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 192 B |
Before Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 796 B |
Before Width: | Height: | Size: 249 B |
Before Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 419 B |
Before Width: | Height: | Size: 675 B |
Before Width: | Height: | Size: 396 B |
Before Width: | Height: | Size: 308 B |
Before Width: | Height: | Size: 478 B |
Before Width: | Height: | Size: 362 B |
Before Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 424 B |
Before Width: | Height: | Size: 421 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 364 B |
Before Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 553 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 451 B |
Before Width: | Height: | Size: 432 B |
Before Width: | Height: | Size: 620 B |
Before Width: | Height: | Size: 473 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 353 B |
Before Width: | Height: | Size: 317 B |
Before Width: | Height: | Size: 505 B |
Before Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 475 B |
Before Width: | Height: | Size: 406 B |
Before Width: | Height: | Size: 729 B |
Before Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="@color/accent" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M7,10l5,5 5,-5z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="@color/accent" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M7,14l5,-5 5,5z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="@color/accent" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M17,3L7,3c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3L19,5c0,-1.1 -0.9,-2 -2,-2zM17,18l-5,-2.18L7,18L7,5h10v13z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="@color/accent" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M17,3H7c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3V5c0,-1.1 -0.9,-2 -2,-2z"/> |
|||
</vector> |
Before Width: | Height: | Size: 2.1 KiB |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="#FFFFFF" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="@color/accent" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="#FFFFFF" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/> |
|||
</vector> |
@ -1,11 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|||
<vector |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportHeight="24.0" |
|||
android:viewportWidth="24.0"> |
|||
<path |
|||
android:fillColor="#FFFFFF" |
|||
android:pathData="M9,16h6v-6h4l-7,-7 -7,7h4zM5,18h14v2L5,20z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="#FFFFFF" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M9,16h6v-6h4l-7,-7 -7,7h4zM5,18h14v2L5,20z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="@color/accent" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M6,17h3l2,-4L11,7L5,7v6h3zM14,17h3l2,-4L19,7h-6v6h3z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="#4B4B4B" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M6,17h3l2,-4L11,7L5,7v6h3zM14,17h3l2,-4L19,7h-6v6h3z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="#FFFFFF" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="#FFFFFF" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6L6,2zM13,9L13,3.5L18.5,9L13,9z"/> |
|||
</vector> |
@ -0,0 +1,5 @@ |
|||
<vector android:height="24dp" android:tint="#FFFFFF" |
|||
android:viewportHeight="24.0" android:viewportWidth="24.0" |
|||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<path android:fillColor="#FF000000" android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/> |
|||
</vector> |