[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] type selection spinner
commit f6f4d26645594b62c8cc05310f409f5f38d5eeb4
Author: arrase <arrase@xxxxxxxxx>
Date: Tue Nov 29 01:41:41 2016 +0100
type selection spinner
---
.../ui/hiddenservices/HiddenServicesActivity.java | 40 +++++++++++++++++++++-
app/src/main/res/menu/hs_menu.xml | 10 +++++-
app/src/main/res/values/arrays.xml | 5 ++-
app/src/main/res/values/strings.xml | 1 +
4 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
index 5771701..99af182 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
@@ -8,13 +8,16 @@ import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
+import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.ListView;
+import android.widget.Spinner;
import android.widget.Toast;
import org.torproject.android.R;
@@ -29,6 +32,7 @@ public class HiddenServicesActivity extends AppCompatActivity {
public final int WRITE_EXTERNAL_STORAGE_FROM_ACTIONBAR = 1;
private ContentResolver mResolver;
private OnionListAdapter mAdapter;
+ private FloatingActionButton fab;
private String mWhere = HSContentProvider.HiddenService.CREATED_BY_USER + "=1";
@@ -43,7 +47,7 @@ public class HiddenServicesActivity extends AppCompatActivity {
mResolver = getContentResolver();
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -96,6 +100,40 @@ public class HiddenServicesActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.hs_menu, menu);
+
+ MenuItem item = menu.findItem(R.id.hs_type);
+ Spinner spinner = (Spinner) MenuItemCompat.getActionView(item);
+
+ ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
+ this, R.array.array_hs_types, android.R.layout.simple_spinner_item);
+
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+
+ spinner.setAdapter(adapter);
+
+ spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View v, int pos, long id) {
+ if (pos == 0) {
+ mWhere = HSContentProvider.HiddenService.CREATED_BY_USER + "=1";
+ fab.show();
+ } else {
+ mWhere = HSContentProvider.HiddenService.CREATED_BY_USER + "=0";
+ fab.hide();
+ }
+
+ mAdapter.changeCursor(mResolver.query(
+ HSContentProvider.CONTENT_URI, HSContentProvider.PROJECTION, mWhere, null, null
+ ));
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // Do nothing
+ }
+ });
+
return true;
}
diff --git a/app/src/main/res/menu/hs_menu.xml b/app/src/main/res/menu/hs_menu.xml
index cfe580d..e82a935 100644
--- a/app/src/main/res/menu/hs_menu.xml
+++ b/app/src/main/res/menu/hs_menu.xml
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/hs_type"
+ android:background="#ff00"
+ android:title="@string/service_type"
+ app:actionViewClass="android.widget.Spinner"
+ app:showAsAction="always" />
+
<item
android:id="@+id/menu_restore_backup"
android:title="@string/restore_backup" />
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 795a419..d0f2201 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -9,5 +9,8 @@
<item>Get New Bridges</item>
<item></item>
</string-array>
-
+ <string-array name="array_hs_types">
+ <item>User services</item>
+ <item>App services</item>
+ </string-array>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f189cd3..c8af6bb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -361,4 +361,5 @@
<string name="start_tor_again_for_finish_the_process">Start Tor again for finish the process</string>
<string name="confirm_service_deletion">Confirm service deletion</string>
<string name="click_again_for_backup">Click again for backup</string>
+ <string name="service_type">Service type</string>
</resources>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits