Start working on Material Design
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user