Start working on Material Design

This commit is contained in:
Dominik Schürmann 2015-01-13 21:55:53 +01:00
parent 2f0eb3fbd6
commit 2e3545949b
20 changed files with 246 additions and 179 deletions

View File

@ -5,6 +5,7 @@ dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile project(':extern:openpgp-api-lib')
compile project(':extern:openkeychain-api-lib')
compile project(':extern:html-textview')

View File

@ -28,9 +28,12 @@ public class AppsListActivity extends DrawerActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.api_apps_list_activity);
activateDrawerNavigation(savedInstanceState);
}
@Override
protected int getLayoutResource() {
return R.layout.api_apps_list_activity;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2015 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sufficientlysecure.keychain.ui;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import org.sufficientlysecure.keychain.R;
/**
* Sets action bar
*/
public abstract class BaseActivity extends ActionBarActivity {
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResource());
toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
protected abstract int getLayoutResource();
protected void setActionBarIcon(int iconRes) {
toolbar.setNavigationIcon(iconRes);
}
}

View File

@ -40,8 +40,6 @@ public class DecryptActivity extends DrawerActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.decrypt_activity);
activateDrawerNavigation(savedInstanceState);
View actionFile = findViewById(R.id.decrypt_files);
@ -66,6 +64,11 @@ public class DecryptActivity extends DrawerActivity {
});
}
@Override
protected int getLayoutResource() {
return R.layout.decrypt_activity;
}
@TargetApi(VERSION_CODES.HONEYCOMB)
@Override
protected void onResume() {

View File

@ -42,7 +42,7 @@ import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
public class DrawerActivity extends ActionBarActivity {
public abstract class DrawerActivity extends BaseActivity {
private FixedDrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
@ -96,8 +96,9 @@ public class DrawerActivity extends ActionBarActivity {
// enable ActionBar app icon to behave as action to toggle nav drawer
// if the drawer is not locked
if (!mIsDrawerLocked) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
// TODO
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// getSupportActionBar().setHomeButtonEnabled(true);
}
// ActionBarDrawerToggle ties together the the proper interactions

View File

@ -309,8 +309,6 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.encrypt_files_activity);
// if called with an intent action, do not init drawer navigation
if (ACTION_ENCRYPT_DATA.equals(getIntent().getAction())) {
// lock drawer
@ -327,6 +325,11 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
mUseArmor = Preferences.getPreferences(this).getDefaultAsciiArmor();
}
@Override
protected int getLayoutResource() {
return R.layout.encrypt_files_activity;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.encrypt_file_activity, menu);

View File

@ -288,8 +288,6 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.encrypt_text_activity);
// if called with an intent action, do not init drawer navigation
if (ACTION_ENCRYPT_TEXT.equals(getIntent().getAction())) {
// lock drawer
@ -304,6 +302,11 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv
updateModeFragment();
}
@Override
protected int getLayoutResource() {
return R.layout.encrypt_text_activity;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.encrypt_text_activity, menu);

View File

@ -50,6 +50,7 @@ public class KeyListActivity extends DrawerActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setActionBarIcon(R.drawable.ic_ab_drawer);
setTitle(R.string.nav_keys);
@ -63,10 +64,13 @@ public class KeyListActivity extends DrawerActivity {
mExportHelper = new ExportHelper(this);
setContentView(R.layout.key_list_activity);
// now setup navigation drawer in DrawerActivity...
activateDrawerNavigation(savedInstanceState);
// activateDrawerNavigation(savedInstanceState);
}
@Override
protected int getLayoutResource() {
return R.layout.key_list_activity;
}
@Override

View File

@ -73,47 +73,15 @@ public class SafeSlingerActivity extends ActionBarActivity {
mMasterKeyId = getIntent().getLongExtra(EXTRA_MASTER_KEY_ID, 0);
// NOTE: there are two versions of this layout, for API >= 11 and one for < 11
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
NumberPicker picker = (NumberPicker) findViewById(R.id.safe_slinger_picker);
picker.setMinValue(2);
picker.setMaxValue(10);
picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
mSelectedNumber = newVal;
}
});
} else {
Spinner spinner = (Spinner) findViewById(R.id.safe_slinger_spinner);
List<String> list = new ArrayList<String>();
list.add("2");
list.add("3");
list.add("4");
list.add("5");
list.add("6");
list.add("7");
list.add("8");
list.add("9");
list.add("10");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mSelectedNumber = position + 2;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
NumberPicker picker = (NumberPicker) findViewById(R.id.safe_slinger_picker);
picker.setMinValue(2);
picker.setMaxValue(10);
picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
mSelectedNumber = newVal;
}
});
ImageView buttonIcon = (ImageView) findViewById(R.id.safe_slinger_button_image);
buttonIcon.setColorFilter(getResources().getColor(R.color.tertiary_text_light),

View File

@ -1,75 +0,0 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginTop="14dp"
android:text="@string/exchange_description"
android:layout_weight="1"
android:gravity="center_vertical"/>
<NumberPicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/safe_slinger_picker"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<LinearLayout
android:id="@+id/safe_slinger_button"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:clickable="true"
android:paddingRight="4dp"
style="@style/SelectableItem"
android:orientation="horizontal">
<TextView
android:paddingLeft="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="Start exchange"
android:layout_weight="1"
android:gravity="center_vertical" />
<!-- separate ImageView required for recoloring -->
<ImageView
android:id="@+id/safe_slinger_button_image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_safeslinger"
android:layout_gravity="center_vertical" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginBottom="4dp"
android:background="?android:attr/listDivider" />
</LinearLayout>
</ScrollView>

View File

@ -86,7 +86,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/create_key_rsa"
android:textColor="@color/android_green_dark"
android:textColor="@color/android_green_light"
android:textAppearance="?android:attr/textAppearanceMedium"
android:minHeight="?android:attr/listPreferredItemHeight"
android:clickable="true"
@ -128,7 +128,7 @@
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:text="@string/create_key_final_robot_text"
android:textColor="@color/android_green_dark"
android:textColor="@color/android_green_light"
android:textAppearance="?android:attr/textAppearanceMedium"
android:drawableLeft="@drawable/create_key_robot"
android:drawablePadding="8dp" />

View File

@ -1,47 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/notify_area" />
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<LinearLayout
android:id="@+id/content_frame"
android:layout_marginLeft="@dimen/drawer_content_padding"
android:orientation="vertical"
android:layout_below="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--<LinearLayout
<include layout="@layout/notify_area" />
<LinearLayout
android:id="@+id/content_frame"
android:layout_marginLeft="@dimen/drawer_content_padding"
android:orientation="vertical"
android:background="@color/holo_gray_bright"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<Spinner
android:id="@+id/key_list_filter_spinner"
<!--<LinearLayout
android:orientation="vertical"
android:background="@color/holo_gray_bright"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" />
android:layout_height="wrap_content">
<View
<Spinner
android:id="@+id/key_list_filter_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
</LinearLayout>-->
<fragment
android:id="@+id/key_list_fragment"
android:name="org.sufficientlysecure.keychain.ui.KeyListFragment"
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
</LinearLayout>-->
<fragment
android:id="@+id/key_list_fragment"
android:name="org.sufficientlysecure.keychain.ui.KeyListFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@ -16,17 +16,18 @@
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginTop="14dp"
android:text="@string/exchange_description"
android:layout_weight="1"/>
android:layout_weight="1"
android:gravity="center_vertical"/>
<Spinner
<NumberPicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/safe_slinger_spinner"
android:gravity="center_vertical"/>
android:id="@+id/safe_slinger_picker"
/>
</LinearLayout>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
app:theme="@style/KeychainToolbarOverflow"
app:popupTheme="@style/KeychainTheme" />

View File

@ -3,7 +3,7 @@
<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="KeychainTheme" parent="@style/_KeychainTheme"/>
<style name="KeychainThemeOLD" parent="@style/_KeychainTheme"/>
<style name="_KeychainTheme" parent="Theme.AppCompat.Light">

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="KeychainTheme" parent="KeychainTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>

View File

@ -1,8 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="emphasis">#aa66cc</color>
<color name="emphasis_dark">#9933cc</color>
<!--<color name="colorPrimary">@color/material_deep_teal_500</color>-->
<!--<color name="colorPrimaryDark">@color/material_blue_grey_900</color>-->
<!-- TODO: -->
<color name="colorSecondary">@color/material_deep_teal_200</color>
<color name="colorSecondaryDark">@color/material_deep_teal_500</color>
<!--<color name="windowBackgroundColor">#333333</color>-->
<color name="black_translucent">#80000000</color>
<!-- Palette generated by Material Palette materialpalette.com/green/indigo -->
<color name="colorPrimary">#4CAF50</color>
<color name="colorPrimaryDark">#388E3C</color>
<!-- TODO: -->
<color name="primary">#4CAF50</color>
<color name="primary_dark">#388E3C</color>
<color name="primary_light">#C8E6C9</color>
<color name="accent">#536DFE</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#727272</color>
<color name="icons">#FFFFFF</color>
<color name="divider">#B6B6B6</color>
<!-- set to text colors -->
<color name="emphasis">#212121</color>
<color name="emphasis_dark">#727272</color>
<color name="bg_gray">#cecbce</color>
<color name="tertiary_text_light">#808080</color>
<color name="alert">#ffdd3333</color>
@ -10,14 +37,18 @@
<color name="holo_gray_light">#33999999</color>
<color name="holo_gray_bright">#33CCCCCC</color>
<!-- http://developer.android.com/design/style/color.html -->
<color name="android_red_light">#ffff4444</color>
<color name="android_red_dark">#ffCC0000</color>
<color name="android_orange_light">#ffffbb33</color>
<color name="android_orange_dark">#ffFF8800</color>
<color name="android_green_light">#ff99cc00</color>
<color name="android_green_dark">#ff669900</color>
<color name="android_purple_light">#ffaa66cc</color>
<color name="android_purple_dark">#ff9933CC</color>
<!--
http://www.google.com/design/spec/style/color.html#color-color-palette
light = normal color
dark = 900
-->
<color name="android_red_light">#f44336</color>
<color name="android_red_dark">#b71c1c</color>
<color name="android_orange_light">#ff9800</color>
<color name="android_orange_dark">#e65100</color>
<color name="android_green_light">#4caf50</color>
<color name="android_green_dark">#1b5e20</color>
<color name="android_purple_light">#673ab7</color>
<color name="android_purple_dark">#311b92</color>
</resources>

View File

@ -2,7 +2,7 @@
<resources>
<!-- Used in Android < 4 -->
<style name="KeychainTheme" parent="@style/Theme.AppCompat.Light">
<style name="KeychainThemeOLD" parent="@style/Theme.AppCompat.Light">
<item name="android:alertDialogStyle">@style/CustomDialogTheme</item>
</style>
@ -34,4 +34,35 @@
<item name="android:background">@drawable/selector_transparent_button</item>
</style>
<!--
Make Toolbar with white text and white overflow menu
http://www.murrayc.com/permalink/2014/10/28/android-changing-the-toolbars-text-color-and-overflow-icon-color/
-->
<style name="KeychainToolbarOverflow" parent="KeychainTheme">
<!-- android:textColorPrimary is the color of the title text
in the Toolbar, in the Theme.AppCompat theme: -->
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<!-- android:textColorPrimaryInverse is the color of the title
text in the Toolbar, in the Theme.AppCompat.Light theme: -->
<!-- <item name="android:textColorPrimaryInverse">@color/abc_primary_text_material_light</item> -->
<!-- android:actionMenuTextColor is the color of the text of
action (menu) items in the Toolbar, at least in the
Theme.AppCompat theme.
For some reason, they already get the textColorPrimary
when running on API 21, but not on older versions of
Android, so this is only necessary to support older
Android versions.-->
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<!-- android:textColorSecondary is the color of the menu
overflow icon (three vertical dots) -->
<item name="android:textColorSecondary">@color/abc_primary_text_material_dark</item>
<!-- This would set the toolbar's background color,
but setting this also changes the popup menu's background,
even if we define popupTheme for our <Toolbar> -->
<!-- <item name="android:background">@color/color_primary</item> -->
</style>
</resources>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="KeychainTheme" parent="KeychainTheme.Base" />
<style name="KeychainTheme.Base" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>

View File

@ -0,0 +1,4 @@
https://github.com/google/material-design-icons
action:
ic_search_white_24dp.png