2017-09-21 04:42:15 +02:00
|
|
|
package com.stevesoltys.backup.activity;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import com.stevesoltys.backup.R;
|
|
|
|
|
|
|
|
public class MainActivity extends Activity implements View.OnClickListener {
|
|
|
|
|
2019-06-04 18:27:07 +02:00
|
|
|
public static final int OPEN_DOCUMENT_TREE_REQUEST_CODE = 1;
|
2017-09-21 04:42:15 +02:00
|
|
|
|
|
|
|
public static final int LOAD_DOCUMENT_REQUEST_CODE = 2;
|
|
|
|
|
|
|
|
private MainActivityController controller;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
|
|
findViewById(R.id.create_backup_button).setOnClickListener(this);
|
|
|
|
findViewById(R.id.restore_backup_button).setOnClickListener(this);
|
|
|
|
|
|
|
|
controller = new MainActivityController();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
int viewId = view.getId();
|
|
|
|
|
|
|
|
switch (viewId) {
|
|
|
|
|
|
|
|
case R.id.create_backup_button:
|
2019-06-04 18:27:07 +02:00
|
|
|
controller.showChooseFolderActivity(this);
|
2017-09-21 04:42:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case R.id.restore_backup_button:
|
|
|
|
controller.showLoadDocumentActivity(this);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent result) {
|
|
|
|
|
|
|
|
if (resultCode != Activity.RESULT_OK) {
|
|
|
|
Log.e(MainActivity.class.getName(), "Error in activity result: " + requestCode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (requestCode) {
|
|
|
|
|
2019-06-04 18:27:07 +02:00
|
|
|
case OPEN_DOCUMENT_TREE_REQUEST_CODE:
|
|
|
|
controller.handleChooseFolderResult(result, this);
|
2017-09-21 04:42:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LOAD_DOCUMENT_REQUEST_CODE:
|
|
|
|
controller.handleLoadDocumentResult(result, this);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|