Add dashboard and condition functionality

This commit is contained in:
Marvin W 2016-11-14 01:45:12 +01:00
parent ea80c3d09e
commit c0b227d918
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
18 changed files with 807 additions and 70 deletions

View File

@ -34,6 +34,7 @@ import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
public abstract class AbstractAboutFragment extends Fragment { public abstract class AbstractAboutFragment extends Fragment {
@ -145,7 +146,7 @@ public abstract class AbstractAboutFragment extends Fragment {
@Override @Override
public int compareTo(Library another) { public int compareTo(Library another) {
return name.toLowerCase().compareTo(another.name.toLowerCase()); return name.toLowerCase(Locale.US).compareTo(another.name.toLowerCase(Locale.US));
} }
} }
} }

View File

@ -0,0 +1,115 @@
package org.microg.tools.ui;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractDashboardActivity extends AppCompatActivity {
protected int preferencesResource = 0;
private final List<Condition> conditions = new ArrayList<Condition>();
private ViewGroup conditionContainer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard_activity);
conditionContainer = (ViewGroup) findViewById(R.id.condition_container);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_wrapper, getFragment())
.commit();
}
@Override
protected void onResume() {
super.onResume();
forceConditionReevaluation();
}
private synchronized void resetConditionViews() {
conditionContainer.removeAllViews();
for (Condition condition : conditions) {
if (condition.isEvaluated()) {
if (condition.isActive(this)) {
addConditionToView(condition);
}
} else {
evaluateConditionAsync(condition);
}
}
}
private void evaluateConditionAsync(final Condition condition) {
if (condition.willBeEvaluating()) {
new Thread(new Runnable() {
@Override
public void run() {
if (condition.isActive(AbstractDashboardActivity.this)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (conditions.contains(condition) && condition.isEvaluated()) {
addConditionToView(condition);
}
}
});
}
}
}).start();
}
}
protected void forceConditionReevaluation() {
for (Condition condition : conditions) {
condition.resetEvaluated();
}
resetConditionViews();
}
protected void addAllConditions(Condition[] conditions) {
for (Condition condition : conditions) {
addCondition(condition);
}
}
protected void addCondition(Condition condition) {
conditions.add(condition);
if (conditionContainer == null) return;
if (condition.isEvaluated()) {
addConditionToView(condition);
} else {
evaluateConditionAsync(condition);
}
}
private synchronized void addConditionToView(Condition condition) {
for (int i = 0; i < conditionContainer.getChildCount(); i++) {
if (conditionContainer.getChildAt(i).getTag() == condition) return;
}
conditionContainer.addView(condition.createView(this, conditionContainer));
}
protected void clearConditions() {
conditions.clear();
resetConditionViews();
}
protected Fragment getFragment() {
if (preferencesResource == 0) {
throw new IllegalStateException("Neither preferencesResource given, nor overriden getFragment()");
}
ResourceSettingsFragment fragment = new ResourceSettingsFragment();
Bundle b = new Bundle();
b.putInt(ResourceSettingsFragment.EXTRA_PREFERENCE_RESOURCE, preferencesResource);
fragment.setArguments(b);
return fragment;
}
}

View File

@ -8,7 +8,7 @@ import android.support.v7.widget.Toolbar;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.ViewGroup; import android.view.ViewGroup;
public class AbstractSettingsActivity extends AppCompatActivity { public abstract class AbstractSettingsActivity extends AppCompatActivity {
protected boolean showHomeAsUp = false; protected boolean showHomeAsUp = false;
protected int preferencesResource = 0; protected int preferencesResource = 0;
private ViewGroup customBarContainer; private ViewGroup customBarContainer;

View File

@ -0,0 +1,276 @@
/*
* Copyright (C) 2013-2016 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.tools.ui;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v4.content.res.ResourcesCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class Condition {
@DrawableRes
private final int iconRes;
private final Drawable icon;
@StringRes
private final int titleRes;
private final CharSequence title;
@StringRes
private final int summaryRes;
private final CharSequence summary;
@StringRes
private final int firstActionTextRes;
private final CharSequence firstActionText;
private final View.OnClickListener firstActionListener;
@StringRes
private final int secondActionTextRes;
private final CharSequence secondActionText;
private final View.OnClickListener secondActionListener;
private final Evaluation evaluation;
private boolean evaluated = false;
private boolean evaluating = false;
private boolean active;
Condition(Builder builder) {
icon = builder.icon;
title = builder.title;
summary = builder.summary;
firstActionText = builder.firstActionText;
firstActionListener = builder.firstActionListener;
secondActionText = builder.secondActionText;
secondActionListener = builder.secondActionListener;
summaryRes = builder.summaryRes;
iconRes = builder.iconRes;
firstActionTextRes = builder.firstActionTextRes;
secondActionTextRes = builder.secondActionTextRes;
titleRes = builder.titleRes;
evaluation = builder.evaluation;
}
View createView(final Context context, ViewGroup container) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.condition_card, container, false);
Drawable icon = getIcon(context);
if (icon != null)
((ImageView) view.findViewById(android.R.id.icon)).setImageDrawable(icon);
((TextView) view.findViewById(android.R.id.title)).setText(getTitle(context));
((TextView) view.findViewById(android.R.id.summary)).setText(getSummary(context));
Button first = (Button) view.findViewById(R.id.first_action);
first.setText(getFirstActionText(context));
first.setOnClickListener(getFirstActionListener());
CharSequence secondActionText = getSecondActionText(context);
if (secondActionText != null) {
Button second = (Button) view.findViewById(R.id.second_action);
second.setText(secondActionText);
second.setOnClickListener(getSecondActionListener());
second.setVisibility(View.VISIBLE);
}
final View detailGroup = view.findViewById(R.id.detail_group);
final ImageView expandIndicator = (ImageView) view.findViewById(R.id.expand_indicator);
View.OnClickListener expandListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (detailGroup.getVisibility() == View.VISIBLE) {
expandIndicator.setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_expand_more, context.getTheme()));
detailGroup.setVisibility(View.GONE);
} else {
expandIndicator.setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_expand_less, context.getTheme()));
detailGroup.setVisibility(View.VISIBLE);
}
}
};
view.findViewById(R.id.collapsed_group).setOnClickListener(expandListener);
expandIndicator.setOnClickListener(expandListener);
view.setTag(this);
return view;
}
public Drawable getIcon(Context context) {
if (iconRes != 0) {
return ResourcesCompat.getDrawable(context.getResources(), iconRes, context.getTheme());
}
return icon;
}
public CharSequence getTitle(Context context) {
if (titleRes != 0) {
return context.getString(titleRes);
}
return title;
}
public CharSequence getSummary(Context context) {
if (summaryRes != 0) {
return context.getString(summaryRes);
}
return summary;
}
public View.OnClickListener getFirstActionListener() {
return firstActionListener;
}
public CharSequence getFirstActionText(Context context) {
if (firstActionTextRes != 0) {
return context.getString(firstActionTextRes);
}
return firstActionText;
}
public View.OnClickListener getSecondActionListener() {
return secondActionListener;
}
public CharSequence getSecondActionText(Context context) {
if (secondActionTextRes != 0) {
return context.getString(secondActionTextRes);
}
return secondActionText;
}
public synchronized boolean willBeEvaluating() {
if (!evaluating && !evaluated && evaluation != null) {
return evaluating = true;
} else {
return false;
}
}
public boolean isEvaluated() {
return evaluated || evaluation == null;
}
public synchronized void evaluate(Context context) {
active = evaluation == null || evaluation.isActive(context);
evaluated = true;
evaluating = false;
}
public boolean isActive(Context context) {
if (!evaluated && evaluation != null) evaluate(context);
return active;
}
public void resetEvaluated() {
this.evaluated = false;
}
public interface Evaluation {
boolean isActive(Context context);
}
public static class Builder {
@DrawableRes
private int iconRes;
private Drawable icon;
@StringRes
private int titleRes;
private CharSequence title;
@StringRes
private int summaryRes;
private CharSequence summary;
@StringRes
private int firstActionTextRes;
private CharSequence firstActionText;
private View.OnClickListener firstActionListener;
@StringRes
private int secondActionTextRes;
private CharSequence secondActionText;
private View.OnClickListener secondActionListener;
private Evaluation evaluation;
public Builder() {
}
public Builder icon(Drawable val) {
icon = val;
return this;
}
public Builder icon(@DrawableRes int val) {
iconRes = val;
return this;
}
public Builder title(CharSequence val) {
title = val;
return this;
}
public Builder title(@StringRes int val) {
titleRes = val;
return this;
}
public Builder summary(CharSequence val) {
summary = val;
return this;
}
public Builder summary(@StringRes int val) {
summaryRes = val;
return this;
}
public Builder firstAction(CharSequence text, View.OnClickListener listener) {
firstActionText = text;
firstActionListener = listener;
return this;
}
public Builder firstAction(@StringRes int val, View.OnClickListener listener) {
firstActionTextRes = val;
firstActionListener = listener;
return this;
}
public Builder secondAction(CharSequence text, View.OnClickListener listener) {
secondActionText = text;
secondActionListener = listener;
return this;
}
public Builder secondAction(@StringRes int val, View.OnClickListener listener) {
secondActionTextRes = val;
secondActionListener = listener;
return this;
}
public Builder evaluation(Evaluation evaluation) {
this.evaluation = evaluation;
return this;
}
public Condition build() {
return new Condition(this);
}
}
}

View File

@ -30,7 +30,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
@ -208,8 +207,8 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
*/ */
private SavedState(Parcel in) { private SavedState(Parcel in) {
super(in); super(in);
checked = (Boolean) in.readValue(null); checked = (Boolean) in.readValue(Boolean.class.getClassLoader());
visible = (Boolean) in.readValue(null); visible = (Boolean) in.readValue(Boolean.class.getClassLoader());
} }
@Override @Override

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2013-2016 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<selector/>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~ Copyright (C) 2015-2016 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12.0,8.0l-6.0,6.0 1.41,1.41L12.0,10.83l4.59,4.58L18.0,14.0z"/>
</vector>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~ Copyright (C) 2015-2016 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="@android:color/white"
android:pathData="M16.59,8.59L12.0,13.17 7.41,8.59 6.0,10.0l6.0,6.0 6.0,-6.0z"/>
</vector>

View File

@ -1,4 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2013-2016 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"

View File

@ -1,4 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2013-2016 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<color xmlns:android="http://schemas.android.com/apk/res/android" <color xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/switchbar_background_color"/> android:color="@color/switchbar_background_color"/>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider"/>
<TextView android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dip"
android:paddingBottom="8dip"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingTop="8dip"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
</LinearLayout>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
~ Copyright (C) 2015 The Android Open Source Project ~ Copyright (C) 2015 The Android Open Source Project
~ Copyright (C) 2015-2016 microG Project Team
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.
@ -19,63 +20,68 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:baselineAligned="false"
android:clipToPadding="false" android:clipToPadding="false"
android:focusable="true" > android:focusable="true"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingStart="?android:attr/listPreferredItemPaddingStart">
<LinearLayout <LinearLayout
android:id="@+id/icon_frame" android:id="@+id/icon_frame"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="56dp"
android:gravity="start|center_vertical" android:gravity="start|center_vertical"
android:minWidth="56dp"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="4dp"
android:paddingEnd="12dp" android:paddingEnd="12dp"
android:paddingTop="4dp" android:paddingTop="4dp">
android:paddingBottom="4dp">
<android.support.v7.internal.widget.PreferenceImageView <android.support.v7.internal.widget.PreferenceImageView
android:id="@android:id/icon" android:id="@android:id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:maxWidth="48dp" app:maxHeight="48dp"
app:maxHeight="48dp" /> app:maxWidth="48dp"/>
</LinearLayout> </LinearLayout>
<RelativeLayout <RelativeLayout
android:layout_width="wrap_content" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:paddingTop="16dp" android:paddingBottom="16dp"
android:paddingBottom="16dp"> android:paddingTop="16dp">
<TextView android:id="@android:id/title" <TextView
android:layout_width="wrap_content" android:id="@android:id/title"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:singleLine="true" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItem" android:ellipsize="marquee"
android:ellipsize="marquee" /> android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceListItem"/>
<TextView android:id="@android:id/summary" <TextView
android:layout_width="wrap_content" android:id="@android:id/summary"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_below="@android:id/title" android:layout_height="wrap_content"
android:layout_alignStart="@android:id/title" android:layout_alignStart="@android:id/title"
android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:layout_below="@android:id/title"
android:textColor="?android:attr/textColorSecondary" android:maxLines="10"
android:maxLines="10" /> android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"/>
</RelativeLayout> </RelativeLayout>
<!-- Preference should place its actual preference widget here. --> <!-- Preference should place its actual preference widget here. -->
<LinearLayout android:id="@android:id/widget_frame" <LinearLayout
android:layout_width="wrap_content" android:id="@android:id/widget_frame"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:gravity="end|center_vertical" android:layout_height="match_parent"
android:paddingStart="16dp" android:gravity="end|center_vertical"
android:orientation="vertical" /> android:orientation="vertical"
android:paddingStart="16dp"/>
</LinearLayout> </LinearLayout>

View File

@ -1,18 +1,19 @@
<!-- <!--
Copyright (C) 2014 The Android Open Source Project ~ Copyright (C) 2014 The Android Open Source Project
~ Copyright (C) 2014-2016 microG Project Team
Licensed under the Apache License, Version 2.0 (the "License"); ~
you may not use this file except in compliance with the License. ~ Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at ~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 ~
~ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software ~
distributed under the License is distributed on an "AS IS" BASIS, ~ Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. ~ See the License for the specific language governing permissions and
--> ~ limitations under the License.
-->
<RelativeLayout android:id="@+id/app_bar" <RelativeLayout android:id="@+id/app_bar"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~ Copyright (C) 2015-2016 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:layout_marginBottom="0.25dp"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorAccent"
android:clickable="true"
android:elevation="2dp"
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingStart="16dp">
<LinearLayout
android:id="@+id/collapsed_group"
android:layout_width="match_parent"
android:layout_height="56dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@android:id/icon"
android:src="@android:drawable/ic_dialog_alert"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_marginEnd="36dp"
android:layout_marginRight="36dp"
android:tint="?android:attr/textColorPrimaryInverse"/>
<TextView
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Test Condition"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimaryInverse"/>
<ImageView
android:id="@+id/expand_indicator"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:padding="16dp"
android:src="@drawable/ic_expand_more"
android:tint="?android:attr/textColorPrimaryInverse"/>
</LinearLayout>
<LinearLayout
android:id="@+id/detail_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="60dp"
android:paddingStart="60dp"
android:visibility="gone">
<TextView
android:id="@android:id/summary"
android:text="This condition just exists for testing. This is a summary describing it."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha=".7"
android:paddingBottom="16dp"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:textAppearance="?attr/textAppearanceListItemSmall"
android:textColor="?android:attr/textColorPrimaryInverse"/>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="0.25dp"
android:background="@android:color/white"/>
<android.support.v7.widget.ButtonBarLayout
android:id="@+id/buttonBar"
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:paddingTop="8dp">
<Button
android:id="@+id/first_action"
style="?attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:paddingLeft="0dp"
android:paddingStart="0dp"
android:text="Fix it!"
android:textColor="?android:attr/textColorPrimaryInverse"/>
<Button
android:id="@+id/second_action"
style="?attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:visibility="gone"
android:textColor="?android:attr/textColorPrimaryInverse"/>
</android.support.v7.widget.ButtonBarLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2013-2016 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<LinearLayout
android:id="@+id/condition_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
<FrameLayout
android:id="@+id/content_wrapper"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_weight="1"/>
</LinearLayout>

View File

@ -1,21 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
/* ~ Copyright (C) 2014 The Android Open Source Project
** Copyright 2014, The Android Open Source Project ~ Copyright (C) 2014-2016 microG Project Team
** ~
** Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.
** You may obtain a copy of the License at ~ You may obtain a copy of the License at
** ~
** http://www.apache.org/licenses/LICENSE-2.0 ~ http://www.apache.org/licenses/LICENSE-2.0
** ~
** Unless required by applicable law or agreed to in writing, software ~ Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, ~ distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
** limitations under the License. ~ limitations under the License.
*/ -->
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"> <merge xmlns:android="http://schemas.android.com/apk/res/android">
@ -40,6 +39,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:background="@null"/> android:background="@null"
android:theme="@style/Widget.AppCompat.Settings.SwitchBar.Switch"/>
</merge> </merge>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AppCompat.Settings.Dashboard">
<item name="preferenceTheme">@style/SettingsDashboardThemeOverlay</item>
</style>
<style name="SettingsDashboardFragment" parent="@style/PreferenceFragment">
<item name="android:divider">@drawable/empty</item>
<item name="divider">@drawable/empty</item>
<item name="android:dividerHeight">0dip</item>
</style>
<style name="SettingsDashboardThemeOverlay" parent="@style/PreferenceThemeOverlay.v14.Material">
<item name="preferenceCategoryStyle">@style/SettingsDashboardCategory</item>
<item name="preferenceFragmentStyle">@style/SettingsDashboardFragment</item>
<item name="preferenceFragmentCompatStyle">@style/SettingsDashboardFragment</item>
<item name="colorAccent">#666666</item>
</style>
<style name="SettingsDashboardCategory">
<item name="android:layout">@layout/preference_category_dashboard</item>
</style>
</resources>

View File

@ -16,11 +16,19 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<style name="SettingsTheme" parent="@style/PreferenceFixTheme.Light.NoActionBar"> <style name="Theme.AppCompat.Settings" parent="@style/PreferenceFixTheme.Light.NoActionBar">
<item name="colorPrimary">@color/settings_theme_primary</item> <item name="colorPrimary">@color/settings_theme_primary</item>
<item name="colorPrimaryDark">@color/settings_theme_primary_dark</item> <item name="colorPrimaryDark">@color/settings_theme_primary_dark</item>
<item name="colorAccent">@color/settings_theme_accent</item>
<item name="android:colorPrimary" tools:targetApi="21">@color/settings_theme_primary</item> <item name="android:colorPrimary" tools:targetApi="21">@color/settings_theme_primary</item>
<item name="android:colorPrimaryDark" tools:targetApi="21">@color/settings_theme_primary_dark</item> <item name="android:colorPrimaryDark" tools:targetApi="21">@color/settings_theme_primary_dark</item>
<item name="android:colorAccent" tools:targetApi="21">@color/settings_theme_accent</item> <item name="android:colorAccent" tools:targetApi="21">@color/settings_theme_accent</item>
</style> </style>
<style name="Widget.AppCompat.Settings.SwitchBar.Switch" parent="Widget.AppCompat.CompoundButton.Switch">
<item name="colorAccent">@color/switch_accent_color</item>
<item name="android:colorAccent" tools:targetApi="21">@color/switch_accent_color</item>
</style>
<style name="Theme.AppCompat.Settings.Dashboard"/>
</resources> </resources>