Skip to content

Commit

Permalink
Merge pull request thunderbird#3783 from ByteHamster/drawer-above
Browse files Browse the repository at this point in the history
Switch to Toolbar
  • Loading branch information
cketti authored Dec 8, 2018
2 parents 4a34243 + 3c16d2c commit 278e7d3
Show file tree
Hide file tree
Showing 54 changed files with 1,120 additions and 838 deletions.
2 changes: 1 addition & 1 deletion app/ui/src/main/java/com/fsck/k9/activity/AccountList.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void onCreate(Bundle icicle) {

setResult(RESULT_CANCELED);

setContentView(R.layout.account_list);
setLayout(R.layout.account_list);

ListView listView = getListView();
listView.setOnItemClickListener(this);
Expand Down
4 changes: 2 additions & 2 deletions app/ui/src/main/java/com/fsck/k9/activity/Accounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,8 @@ public void onCreate(Bundle icicle) {
}

requestWindowFeature(Window.FEATURE_PROGRESS);
actionBar = getSupportActionBar();
setLayout(R.layout.accounts);
initializeActionBar();
setContentView(R.layout.accounts);
ListView listView = getListView();
listView.setOnItemClickListener(this);
listView.setItemsCanFocus(false);
Expand Down Expand Up @@ -416,6 +415,7 @@ public void onCreate(Bundle icicle) {
}

private void initializeActionBar() {
actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.list_content_simple);
setLayout(R.layout.list_content_simple);

getListView().setFastScrollEnabled(true);
getListView().setItemsCanFocus(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.list_content_simple);
setLayout(R.layout.list_content_simple);

getListView().setTextFilterEnabled(true);
getListView().setItemsCanFocus(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onCreate(Bundle savedInstanceState) {
mIdentity = new Identity();
}

setContentView(R.layout.edit_identity);
setLayout(R.layout.edit_identity);

/*
* If we're being reloaded we override the original account with the one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class EmailAddressList extends K9ListActivity implements OnItemClickListe
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.email_address_list);
setLayout(R.layout.email_address_list);

Intent i = getIntent();
ContactItem contact = (ContactItem) i.getSerializableExtra(EXTRA_CONTACT_ITEM);
Expand Down
6 changes: 3 additions & 3 deletions app/ui/src/main/java/com/fsck/k9/activity/FolderList.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,9 @@ public void onCreate(Bundle savedInstanceState) {
return;
}

actionBarProgressView = getActionBarProgressView();
actionBar = getSupportActionBar();
setLayout(R.layout.folder_list);
initializeActionBar();
setContentView(R.layout.folder_list);
actionBarProgressView = getActionBarProgressView();
listView = getListView();
listView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
listView.setLongClickable(true);
Expand Down Expand Up @@ -293,6 +292,7 @@ private View getActionBarProgressView() {
}

private void initializeActionBar() {
actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
}

Expand Down
21 changes: 21 additions & 0 deletions app/ui/src/main/java/com/fsck/k9/activity/K9Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MotionEvent;

import android.view.View;
import com.fsck.k9.activity.K9ActivityCommon.K9ActivityMagic;
import com.fsck.k9.activity.misc.SwipeGestureDetector.OnSwipeGestureListener;
import com.fsck.k9.ui.R;
Expand Down Expand Up @@ -43,6 +46,24 @@ public void setupGestureDetector(OnSwipeGestureListener listener) {
mBase.setupGestureDetector(listener);
}

protected void setLayout(@LayoutRes int layoutResId) {
setContentView(layoutResId);
Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar == null) {
throw new IllegalArgumentException("K9 layouts must provide a toolbar with id='toolbar'.");
}
setSupportActionBar(toolbar);
}

protected void setLayout(View view) {
setContentView(view);
Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar == null) {
throw new IllegalArgumentException("K9 layouts must provide a toolbar with id='toolbar'.");
}
setSupportActionBar(toolbar);
}

public boolean hasPermission(Permission permission) {
return ContextCompat.checkSelfPermission(this, permission.permission) == PackageManager.PERMISSION_GRANTED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public static int getK9ThemeResourceId(Theme themeId) {
return (themeId == Theme.LIGHT) ? R.style.Theme_K9_Light : R.style.Theme_K9_Dark;
}

public static int getK9ActionBarThemeResourceId() {
return (getK9ThemeResourceId() == R.style.Theme_K9_Light) ?
R.style.Theme_K9_Light_ActionBar : R.style.Theme_K9_Dark_ActionBar;
}

public static int getK9ThemeResourceId() {
return getK9ThemeResourceId(K9.getK9Theme());
}
Expand Down
5 changes: 5 additions & 0 deletions app/ui/src/main/java/com/fsck/k9/activity/K9ListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
Expand Down Expand Up @@ -82,6 +83,10 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
protected ListView getListView() {
if (list == null) {
list = findViewById(android.R.id.list);
View emptyView = findViewById(android.R.id.empty);
if (emptyView != null) {
list.setEmptyView(emptyView);
}
}
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract class K9PreferenceActivity extends AppCompatPreferenceActivity i
@Override
public void onCreate(Bundle icicle) {
K9ActivityCommon.setLanguage(this, K9.getK9Language());
setTheme(K9ActivityCommon.getK9ThemeResourceId());
setTheme(K9ActivityCommon.getK9ActionBarThemeResourceId());
super.onCreate(icicle);
lifecycleRegistry = new LifecycleRegistry(this);
lifecycleRegistry.markState(State.CREATED);
Expand Down
4 changes: 2 additions & 2 deletions app/ui/src/main/java/com/fsck/k9/activity/MessageCompose.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ public void onCreate(Bundle savedInstanceState) {
// background color needs to be forced
themeContext.getTheme().resolveAttribute(R.attr.messageViewBackgroundColor, outValue, true);
v.setBackgroundColor(outValue.data);
setContentView(v);
setLayout(v);
} else {
setContentView(R.layout.message_compose);
setLayout(R.layout.message_compose);
}

initializeActionBar();
Expand Down
5 changes: 3 additions & 2 deletions app/ui/src/main/java/com/fsck/k9/activity/MessageList.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ public void onCreate(Bundle savedInstanceState) {
}

if (useSplitView()) {
setContentView(R.layout.split_message_list);
setLayout(R.layout.split_message_list);
} else {
setContentView(R.layout.message_list);
setLayout(R.layout.message_list);
viewSwitcher = findViewById(R.id.container);
viewSwitcher.setFirstInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left));
viewSwitcher.setFirstOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_right));
Expand Down Expand Up @@ -552,6 +552,7 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
private void initializeActionBar() {
actionBar = getSupportActionBar();

actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.actionbar_custom);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void onCreate(Bundle savedInstanceState) {
* Initialize the activity's layout
*/
private void initializeLayout() {
setContentView(R.layout.upgrade_databases);
setLayout(R.layout.upgrade_databases);

mUpgradeText = findViewById(R.id.databaseUpgradeText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void actionSelectAccountType(Context context, Account account, boo
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_account_type);
setLayout(R.layout.account_setup_account_type);
findViewById(R.id.pop).setOnClickListener(this);
findViewById(R.id.imap).setOnClickListener(this);
findViewById(R.id.webdav).setOnClickListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void actionNewAccount(Context context) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_basics);
setLayout(R.layout.account_setup_basics);
mEmailView = findViewById(R.id.account_email);
mPasswordView = findViewById(R.id.account_password);
mClientCertificateCheckBox = findViewById(R.id.account_client_certificate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static void actionCheckSettings(Activity context, Account account,
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_check_settings);
setLayout(R.layout.account_setup_check_settings);
mMessageView = findViewById(R.id.message);
mProgressBar = findViewById(R.id.progress);
findViewById(R.id.cancel).setOnClickListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onCreate(Bundle savedInstanceState) {
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);

setContentView(R.layout.account_setup_composition);
setLayout(R.layout.account_setup_composition);

/*
* If we're being reloaded we override the original account with the one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static Intent intentActionEditIncomingSettings(Context context, Account a
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_incoming);
setLayout(R.layout.account_setup_incoming);

mUsernameView = findViewById(R.id.account_username);
mPasswordView = findViewById(R.id.account_password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void actionSetNames(Context context, Account account) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_names);
setLayout(R.layout.account_setup_names);
mDescription = findViewById(R.id.account_description);
mName = findViewById(R.id.account_name);
mDoneButton = findViewById(R.id.done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void actionOptions(Context context, Account account, boolean makeD
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_options);
setLayout(R.layout.account_setup_options);

mCheckFrequencyView = findViewById(R.id.account_check_frequency);
mDisplayCountView = findViewById(R.id.account_display_count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void actionEditOutgoingSettings(Context context, String accountUui
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_outgoing);
setLayout(R.layout.account_setup_outgoing);

String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void showWelcomeMessage(Context context) {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.welcome_message);
setLayout(R.layout.welcome_message);

TextView welcome = findViewById(R.id.welcome_message);
welcome.setText(HtmlConverter.htmlToSpanned(getString(R.string.accounts_welcome)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AutocryptKeyTransferActivity : K9Activity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.crypto_key_transfer)
setLayout(R.layout.crypto_key_transfer)

val accountUuid = intent.getStringExtra(EXTRA_ACCOUNT)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AboutActivity : K9Activity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.about)
setLayout(R.layout.about)

supportActionBar!!.setDisplayHomeAsUpEnabled(true)
webView = findViewById(R.id.about_view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SettingsActivity : K9Activity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
setLayout(R.layout.activity_settings)

initializeActionBar()
initializeSettingsList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AccountSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_account_settings)
setLayout(R.layout.activity_account_settings)

initializeActionBar()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GeneralSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback, S

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.general_settings)
setLayout(R.layout.general_settings)

initializeActionBar()

Expand Down
17 changes: 13 additions & 4 deletions app/ui/src/main/res/layout/about.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/about_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">

<include layout="@layout/toolbar" />

<WebView
android:id="@+id/about_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
32 changes: 18 additions & 14 deletions app/ui/src/main/res/layout/account_list.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
android:orientation="vertical">

<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<include layout="@layout/toolbar" />

<LinearLayout
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_vertical|center_horizontal">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<ProgressBar
android:id="@android:id/empty"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"/>
android:visibility="gone"
android:layout_gravity="center_vertical|center_horizontal"
android:indeterminate="true" />

</FrameLayout>

</LinearLayout>
</LinearLayout>
Loading

0 comments on commit 278e7d3

Please sign in to comment.