Settings fragment and activity for apps
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package org.sufficientlysecure.keychain.remote_api;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
|
||||
public class AppSettingsActivity extends SherlockFragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.api_app_settings_activity);
|
||||
|
||||
// check if add new or edit existing
|
||||
Intent intent = getIntent();
|
||||
Uri appUri = intent.getData();
|
||||
if (appUri == null) {
|
||||
Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(Constants.TAG, "uri: " + appUri);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.sufficientlysecure.keychain.remote_api;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class AppSettingsFragment extends Fragment {
|
||||
|
||||
/**
|
||||
* Inflate the layout for this fragment
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.api_app_settings_fragment, container, false);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class RegisteredAppsListActivity extends SherlockFragmentActivity {
|
||||
|
||||
mActionBar = getSupportActionBar();
|
||||
|
||||
setContentView(R.layout.api_app_settings_list_activity);
|
||||
setContentView(R.layout.api_apps_list_activity);
|
||||
|
||||
mActionBar.setDisplayShowTitleEnabled(true);
|
||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.sufficientlysecure.keychain.remote_api;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumers;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
|
||||
import android.content.ContentUris;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -13,9 +15,11 @@ import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class RegisteredAppsFragment extends SherlockListFragment implements
|
||||
public class RegisteredAppsListFragment extends SherlockListFragment implements
|
||||
LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
// This is the Adapter being used to display the list's data.
|
||||
@@ -28,6 +32,17 @@ public class RegisteredAppsFragment extends SherlockListFragment implements
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
getListView().setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
// edit app settings
|
||||
Intent intent = new Intent(getActivity(), AppSettingsActivity.class);
|
||||
intent.setData(ContentUris.withAppendedId(
|
||||
KeychainContract.CryptoConsumers.CONTENT_URI, id));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
// Give some text to display if there is no data. In a real
|
||||
// application this would come from a resource.
|
||||
setEmptyText(getString(R.string.api_no_apps));
|
||||
@@ -44,12 +59,6 @@ public class RegisteredAppsFragment extends SherlockListFragment implements
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
// Insert desired behavior here.
|
||||
Log.i("FragmentComplexList", "Item clicked: " + id);
|
||||
}
|
||||
|
||||
// These are the Contacts rows that we will retrieve.
|
||||
static final String[] CONSUMERS_SUMMARY_PROJECTION = new String[] { CryptoConsumers._ID,
|
||||
CryptoConsumers.PACKAGE_NAME };
|
||||
@@ -133,7 +133,7 @@ public class ServiceActivity extends SherlockFragmentActivity {
|
||||
if (ACTION_REGISTER.equals(action)) {
|
||||
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
||||
|
||||
setContentView(R.layout.api_register_activity);
|
||||
setContentView(R.layout.api_app_settings_activity);
|
||||
LinearLayout layoutRegister = (LinearLayout) findViewById(R.id.register_crypto_consumer_register_layout);
|
||||
LinearLayout layoutEdit = (LinearLayout) findViewById(R.id.register_crypto_consumer_edit_layout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user