Floating Action Button added in app settings

This commit is contained in:
Dominik Schürmann 2015-02-03 14:28:54 +01:00
parent c763ea3503
commit e2a8819385
40 changed files with 450 additions and 714 deletions

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 137 KiB

View File

@ -15,3 +15,6 @@ python copy OpenKeychain action black lock_outline 24
python copy OpenKeychain navigation black apps 24 python copy OpenKeychain navigation black apps 24
python copy OpenKeychain action black help 24 python copy OpenKeychain action black help 24
python copy OpenKeychain action black settings 24 python copy OpenKeychain action black settings 24
# floating action button
python copy OpenKeychain av white play_arrow 24

View File

@ -28,6 +28,7 @@ dependencies {
compile 'com.jpardogo.materialtabstrip:library:1.0.8' compile 'com.jpardogo.materialtabstrip:library:1.0.8'
compile 'it.neokree:MaterialNavigationDrawer:1.3' compile 'it.neokree:MaterialNavigationDrawer:1.3'
compile 'com.nispok:snackbar:2.7.4' compile 'com.nispok:snackbar:2.7.4'
compile 'com.getbase:floatingactionbutton:1.7.0'
} }
android { android {

View File

@ -21,12 +21,18 @@ import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.getbase.floatingactionbutton.FloatingActionButton;
import org.spongycastle.util.encoders.Hex;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.operations.results.OperationResult;
@ -36,13 +42,22 @@ import org.sufficientlysecure.keychain.remote.AppSettings;
import org.sufficientlysecure.keychain.ui.BaseActivity; import org.sufficientlysecure.keychain.ui.BaseActivity;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class AppSettingsActivity extends BaseActivity { public class AppSettingsActivity extends BaseActivity {
private Uri mAppUri; private Uri mAppUri;
private AppSettingsHeaderFragment mSettingsFragment;
private AccountsListFragment mAccountsListFragment; private AccountsListFragment mAccountsListFragment;
private AppSettingsAllowedKeysListFragment mAllowedKeysFragment; private AppSettingsAllowedKeysListFragment mAllowedKeysFragment;
private TextView mAppNameView;
private ImageView mAppIconView;
private TextView mPackageName;
private TextView mPackageSignature;
private FloatingActionButton mStartFab;
// model // model
AppSettings mAppSettings; AppSettings mAppSettings;
@ -50,14 +65,20 @@ public class AppSettingsActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setFullScreenDialogDoneClose(R.string.api_settings_save, mAppNameView = (TextView) findViewById(R.id.api_app_settings_app_name);
new View.OnClickListener() { mAppIconView = (ImageView) findViewById(R.id.api_app_settings_app_icon);
mPackageName = (TextView) findViewById(R.id.api_app_settings_package_name);
mPackageSignature = (TextView) findViewById(R.id.api_app_settings_package_signature);
mStartFab = (FloatingActionButton) findViewById(R.id.fab);
mStartFab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
save(); startApp();
} }
}, });
new View.OnClickListener() {
setFullScreenDialogClose(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
cancel(); cancel();
@ -65,9 +86,6 @@ public class AppSettingsActivity extends BaseActivity {
}); });
setTitle(null); setTitle(null);
mSettingsFragment = (AppSettingsHeaderFragment) getSupportFragmentManager().findFragmentById(
R.id.api_app_settings_fragment);
Intent intent = getIntent(); Intent intent = getIntent();
mAppUri = intent.getData(); mAppUri = intent.getData();
if (mAppUri == null) { if (mAppUri == null) {
@ -109,8 +127,8 @@ public class AppSettingsActivity extends BaseActivity {
case R.id.menu_api_settings_revoke: case R.id.menu_api_settings_revoke:
revokeAccess(); revokeAccess();
return true; return true;
case R.id.menu_api_settings_start: case R.id.menu_api_save:
startApp(); save();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@ -134,18 +152,37 @@ public class AppSettingsActivity extends BaseActivity {
private void loadData(Bundle savedInstanceState, Uri appUri) { private void loadData(Bundle savedInstanceState, Uri appUri) {
mAppSettings = new ProviderHelper(this).getApiAppSettings(appUri); mAppSettings = new ProviderHelper(this).getApiAppSettings(appUri);
mSettingsFragment.setAppSettings(mAppSettings);
// String appName; // get application name and icon from package manager
// PackageManager pm = getPackageManager(); String appName;
// try { Drawable appIcon = null;
// ApplicationInfo ai = pm.getApplicationInfo(mAppSettings.getPackageName(), 0); PackageManager pm = getApplicationContext().getPackageManager();
// appName = (String) pm.getApplicationLabel(ai); try {
// } catch (PackageManager.NameNotFoundException e) { ApplicationInfo ai = pm.getApplicationInfo(mAppSettings.getPackageName(), 0);
// // fallback
// appName = mAppSettings.getPackageName(); appName = (String) pm.getApplicationLabel(ai);
// } appIcon = pm.getApplicationIcon(ai);
// setTitle(appName); } catch (PackageManager.NameNotFoundException e) {
// fallback
appName = mAppSettings.getPackageName();
}
mAppNameView.setText(appName);
mAppIconView.setImageDrawable(appIcon);
// advanced info: package name
mPackageName.setText(mAppSettings.getPackageName());
// advanced info: package signature SHA-256
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(mAppSettings.getPackageSignature());
byte[] digest = md.digest();
String signature = new String(Hex.encode(digest));
mPackageSignature.setText(signature);
} catch (NoSuchAlgorithmException e) {
Log.e(Constants.TAG, "Should not happen!", e);
}
Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build(); Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build();
Log.d(Constants.TAG, "accountsUri: " + accountsUri); Log.d(Constants.TAG, "accountsUri: " + accountsUri);

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -1,26 +1,66 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<include <RelativeLayout
android:id="@+id/toolbar_big"
android:layout_width="match_parent"
android:layout_height="120dp"
android:elevation="4dp"
android:background="?attr/colorPrimaryDark"
android:orientation="horizontal">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
android:overScrollMode="always"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
tools:ignore="UnusedAttribute"
android:transitionGroup="false"
android:touchscreenBlocksFocus="false" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@+id/toolbar"
android:paddingLeft="48dp"
android:paddingBottom="8dp"
android:paddingRight="72dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/api_app_settings_app_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/api_app_settings_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name (set in-code)longlong"
android:textColor="@color/icons"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingLeft="8dp"
android:layout_gravity="center_vertical" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/body"
android:layout_below="@id/toolbar_big"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<fragment
android:id="@+id/api_app_settings_fragment"
android:name="org.sufficientlysecure.keychain.remote.ui.AppSettingsHeaderFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/api_app_settings_fragment" />
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -55,7 +95,56 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" /> android:orientation="vertical" />
<org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/icons"
custom:foldedLabel="@string/api_settings_show_info"
custom:unFoldedLabel="@string/api_settings_hide_info">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/api_settings_package_name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/api_app_settings_package_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="com.example"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/api_settings_package_signature"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/api_app_settings_package_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Base64 encoded hash of signature"
android:textAppearance="?android:attr/textAppearanceSmall" />
</org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_alignBottom="@id/toolbar_big"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:layout_marginBottom="-40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="4dp"
fab:fab_icon="@drawable/ic_play_arrow_white_24dp"
fab:fab_colorNormal="@color/fab"
fab:fab_colorPressed="@color/fab_pressed" />
</RelativeLayout> </RelativeLayout>

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<ScrollView <ScrollView
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -6,13 +6,14 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:elevation="4dp">
<com.astuetz.PagerSlidingTabStrip <com.astuetz.PagerSlidingTabStrip
android:id="@+id/sliding_tab_layout" android:id="@+id/sliding_tab_layout"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,6 +5,6 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
</LinearLayout> </LinearLayout>

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<ScrollView <ScrollView
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<RelativeLayout <RelativeLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<ScrollView <ScrollView
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -6,7 +6,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -5,7 +5,7 @@
<include <include
android:id="@+id/toolbar" android:id="@+id/toolbar"
layout="@layout/toolbar" /> layout="@layout/toolbar_standalone" />
<LinearLayout <LinearLayout
android:layout_below="@id/toolbar" android:layout_below="@id/toolbar"

View File

@ -3,9 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/menu_api_settings_start" android:id="@+id/menu_api_save"
android:title="@string/api_settings_start" android:title="@string/api_settings_save"
android:icon="@drawable/ic_action_play"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item

View File

@ -20,6 +20,8 @@
<color name="primary_dark">#388E3C</color> <color name="primary_dark">#388E3C</color>
<color name="primary_light">#C8E6C9</color> <color name="primary_light">#C8E6C9</color>
<color name="accent">#00BCD4</color> <color name="accent">#00BCD4</color>
<color name="fab">#00BCD4</color>
<color name="fab_pressed">#0097A7</color>
<color name="primary_text">#212121</color> <color name="primary_text">#212121</color>
<color name="secondary_text">#727272</color> <color name="secondary_text">#727272</color>
<color name="icons">#FFFFFF</color> <color name="icons">#FFFFFF</color>