Browse Source

Minor improvements and fixes for uploads

pull/30/merge
Apostolos Fanakis 7 years ago
parent
commit
540d3d45ad
  1. 2
      app/src/main/AndroidManifest.xml
  2. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java
  3. 49
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java

2
app/src/main/AndroidManifest.xml

@ -107,7 +107,7 @@
</activity>
<activity
android:name=".activities.upload.UploadFieldsBuilderActivity"
android:parentActivityName=".activities.main.MainActivity"
android:parentActivityName=".activities.upload.UploadActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"

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

@ -14,7 +14,6 @@ import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.AppCompatButton;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;

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

@ -4,17 +4,22 @@ 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 gr.thmmy.mthmmy.base.BaseActivity;
import timber.log.Timber;
public class UploadFieldsBuilderActivity extends BaseActivity {
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";
@ -24,11 +29,43 @@ public class UploadFieldsBuilderActivity extends BaseActivity {
private String course, semester;
//UI elements
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 = true;
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);
@ -49,7 +86,7 @@ public class UploadFieldsBuilderActivity extends BaseActivity {
}
//Initialize toolbar
toolbar = findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("Upload fields builder");
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
@ -57,12 +94,10 @@ public class UploadFieldsBuilderActivity extends BaseActivity {
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
createDrawer();
drawer.setSelection(UPLOAD_ID);
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() {

Loading…
Cancel
Save