diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cdd0c200..33944fd2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ diff --git a/app/src/main/java/com/stevesoltys/backup/activity/backup/CreateBackupActivity.java b/app/src/main/java/com/stevesoltys/backup/activity/backup/CreateBackupActivity.java index 3da9c37f..f9411f65 100644 --- a/app/src/main/java/com/stevesoltys/backup/activity/backup/CreateBackupActivity.java +++ b/app/src/main/java/com/stevesoltys/backup/activity/backup/CreateBackupActivity.java @@ -3,6 +3,9 @@ package com.stevesoltys.backup.activity.backup; import android.app.Activity; import android.net.Uri; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; @@ -10,6 +13,7 @@ import com.stevesoltys.backup.R; import java.util.HashSet; import java.util.Set; +import java.util.stream.IntStream; public class CreateBackupActivity extends Activity implements View.OnClickListener, AdapterView.OnItemClickListener { @@ -21,6 +25,18 @@ public class CreateBackupActivity extends Activity implements View.OnClickListen private Uri contentUri; + @Override + public void onClick(View view) { + int viewId = view.getId(); + + switch (viewId) { + + case R.id.create_confirm_button: + controller.backupPackages(selectedPackageList, contentUri, this); + break; + } + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -37,14 +53,30 @@ public class CreateBackupActivity extends Activity implements View.OnClickListen } @Override - public void onClick(View view) { - int viewId = view.getId(); + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.backup_menu, menu); + return true; + } - switch (viewId) { + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + + case R.id.action_select_all: + + IntStream.range(0, packageListView.getCount()) + .forEach(position -> { + selectedPackageList.add((String) packageListView.getItemAtPosition(position)); + packageListView.setItemChecked(position, true); + }); + + return true; + + default: + return super.onOptionsItemSelected(item); - case R.id.create_confirm_button: - controller.backupPackages(selectedPackageList, contentUri, this); - break; } } diff --git a/app/src/main/java/com/stevesoltys/backup/activity/restore/RestoreBackupActivity.java b/app/src/main/java/com/stevesoltys/backup/activity/restore/RestoreBackupActivity.java index a52ff4a3..3cf2b003 100644 --- a/app/src/main/java/com/stevesoltys/backup/activity/restore/RestoreBackupActivity.java +++ b/app/src/main/java/com/stevesoltys/backup/activity/restore/RestoreBackupActivity.java @@ -3,6 +3,9 @@ package com.stevesoltys.backup.activity.restore; import android.app.Activity; import android.net.Uri; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; @@ -10,6 +13,7 @@ import com.stevesoltys.backup.R; import java.util.HashSet; import java.util.Set; +import java.util.stream.IntStream; public class RestoreBackupActivity extends Activity implements View.OnClickListener, AdapterView.OnItemClickListener { @@ -21,6 +25,18 @@ public class RestoreBackupActivity extends Activity implements View.OnClickListe private Uri contentUri; + @Override + public void onClick(View view) { + int viewId = view.getId(); + + switch (viewId) { + + case R.id.restore_confirm_button: + controller.restorePackages(selectedPackageList, contentUri, this); + break; + } + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -37,14 +53,30 @@ public class RestoreBackupActivity extends Activity implements View.OnClickListe } @Override - public void onClick(View view) { - int viewId = view.getId(); + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.backup_menu, menu); + return true; + } - switch (viewId) { + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + + case R.id.action_select_all: + + IntStream.range(0, packageListView.getCount()) + .forEach(position -> { + selectedPackageList.add((String) packageListView.getItemAtPosition(position)); + packageListView.setItemChecked(position, true); + }); + + return true; + + default: + return super.onOptionsItemSelected(item); - case R.id.restore_confirm_button: - controller.restorePackages(selectedPackageList, contentUri, this); - break; } } diff --git a/app/src/main/res/menu/backup_menu.xml b/app/src/main/res/menu/backup_menu.xml new file mode 100644 index 00000000..4a0a4509 --- /dev/null +++ b/app/src/main/res/menu/backup_menu.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6f81ef95..8e512a59 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -18,4 +18,6 @@ Cancel + Select all +