Merge branch 'new-ui--more-fixes' into 'master'

More misc UI fixes, mainly for older devices.

Closes #906 and #866

See merge request !465
This commit is contained in:
Hans-Christoph Steiner 2017-04-07 07:47:42 +00:00
commit 1054d57b02
17 changed files with 123 additions and 24 deletions

View File

@ -501,6 +501,8 @@
android:value=".views.main.MainActivity" />
</activity>
<activity android:name=".AboutActivity" android:theme="@style/Theme.AppCompat.Light.Dialog" />
</application>
</manifest>

View File

@ -0,0 +1,34 @@
package org.fdroid.fdroid;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setFinishOnTouchOutside(false);
}
String versionName = Utils.getVersionName(this);
if (versionName != null) {
((TextView) findViewById(R.id.version)).setText(versionName);
}
findViewById(R.id.ok_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}

View File

@ -623,4 +623,19 @@ public final class Utils {
Resources r = ctx.getResources();
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
}
@SuppressWarnings("unused")
public static class Profiler {
public final long startTime = System.currentTimeMillis();
public final String logTag;
public Profiler(String logTag) {
this.logTag = logTag;
}
public void log(String message) {
long duration = System.currentTimeMillis() - startTime;
Utils.debugLog(logTag, "[" + duration + "ms] " + message);
}
}
}

View File

@ -207,6 +207,13 @@ public class PreferencesFragment extends PreferenceFragment
*/
private void initPrivilegedInstallerPreference() {
final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);
// This code will be run each time the activity is resumed, and so we may have already removed
// this preference.
if (pref == null) {
return;
}
Preferences p = Preferences.get();
boolean enabled = p.isPrivilegedInstallerEnabled();
boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity())

View File

@ -53,19 +53,27 @@ public class WhatsNewAdapter extends RecyclerView.Adapter<AppCardController> {
}
return new AppCardController(activity, activity.getLayoutInflater().inflate(layout, parent, false));
}
@Override
public int getItemViewType(int position) {
if (position == 0) {
return R.id.whats_new_feature;
} else if (position <= 2) {
return R.id.whats_new_large_tile;
} else if (position <= 4) {
return R.id.whats_new_small_tile;
} else {
return R.id.whats_new_regular_list;
int relativePositionInCycle = position % 5;
switch (relativePositionInCycle) {
case 1:
case 2:
return R.id.whats_new_large_tile;
case 3:
case 4:
return R.id.whats_new_small_tile;
case 0:
default:
return R.id.whats_new_regular_list;
}
}
}
@ -85,17 +93,14 @@ public class WhatsNewAdapter extends RecyclerView.Adapter<AppCardController> {
notifyDataSetChanged();
}
// TODO: Replace with https://github.com/lucasr/twoway-view which looks really really cool, but
// no longer under active development (despite heaps of forks/stars on github).
public static class SpanSizeLookup extends GridLayoutManager.SpanSizeLookup {
@Override
public int getSpanSize(int position) {
if (position == 0) {
int relativePositionInCycle = position % 5;
if (relativePositionInCycle == 0) {
return 2;
} else if (position <= 4) {
return 1;
} else {
return 2;
return 1;
}
}
}
@ -119,18 +124,18 @@ public class WhatsNewAdapter extends RecyclerView.Adapter<AppCardController> {
int horizontalPadding = (int) context.getResources().getDimension(R.dimen.whats_new__padding__app_card__horizontal);
int verticalPadding = (int) context.getResources().getDimension(R.dimen.whats_new__padding__app_card__vertical);
int relativePositionInCycle = position % 5;
if (position == 0) {
// Don't set any padding for the first item as the FeatureImage behind it needs to butt right
// up against the left/top/right of the screen.
outRect.set(0, 0, 0, verticalPadding);
} else if (position <= 4) {
// Odd items are on the left, even on the right.
} else if (relativePositionInCycle != 0) {
// The item on the left will have both left and right padding. The item on the right
// will only have padding on the right. This will allow the same amount of padding
// on the left, centre, and right of the grid, rather than double the padding in the
// middle (which would happen if both left+right paddings were set for both items).
boolean isLtr = ViewCompat.getLayoutDirection(parent) == ViewCompat.LAYOUT_DIRECTION_LTR;
boolean isAtStart = (position % 2) == 1;
boolean isAtStart = relativePositionInCycle == 1 || relativePositionInCycle == 3;
int paddingStart = isAtStart ? horizontalPadding : 0;
int paddingLeft = isLtr ? paddingStart : horizontalPadding;
int paddingRight = isLtr ? horizontalPadding : paddingStart;

View File

@ -50,6 +50,25 @@
android:text="@string/license_gplv3_later"
style="@style/BodyText" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_marginTop="12dp"
android:paddingBottom="16dp"
android:clipToPadding="false">
<Button
android:layout_width="wrap_content"
android:minWidth="100dp"
android:layout_height="wrap_content"
style="@style/DetailsPrimaryButtonStyle"
android:id="@+id/ok_button"
android:text="@string/ok" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -14,10 +14,10 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp">
android:paddingStart="16dp"
android:paddingLeft="16dp"
android:paddingEnd="16dp"
android:paddingRight="16dp">
<ImageView
android:id="@+id/back"

View File

@ -42,7 +42,7 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp">
android:padding="12dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->

View File

@ -10,7 +10,7 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
android:padding="8dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->

View File

@ -10,7 +10,7 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp">
android:padding="8dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->

View File

@ -10,7 +10,7 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp">
android:padding="8dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->

View File

@ -16,6 +16,7 @@
android:layout_height="wrap_content"
android:textSize="15sp"
android:textAlignment="center"
android:gravity="center"
tools:text="F-Droid is created by F-Droid Limited and Contributors. Buy them a coffee!"
android:layout_marginBottom="12dp" />

View File

@ -38,6 +38,7 @@
app:layout_constraintRight_toRightOf="parent"
android:padding="16dp"
android:textAlignment="center"
android:gravity="center"
android:textColor="#424242"
android:textSize="14sp"
android:text="Tap and hold on an app for more options"

View File

@ -18,6 +18,7 @@
android:layout_marginTop="48dp"
android:text="@string/nearby_splash__download_apps_from_people_nearby"
android:textAlignment="center"
android:gravity="center"
android:textSize="20sp"
android:textColor="#4a4a4a"
app:layout_constraintLeft_toLeftOf="parent"
@ -42,6 +43,7 @@
tools:text="@string/nearby_splash__both_parties_need_fdroid"
android:textSize="15sp"
android:textAlignment="center"
android:gravity="center"
android:textColor="#5B5B5B"
app:layout_constraintTop_toBottomOf="@+id/button"
app:layout_constraintRight_toRightOf="parent"

View File

@ -11,10 +11,10 @@
android:id="@+id/heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="20sp"
android:padding="30dp"
android:textAlignment="center"
android:gravity="center"
tools:text="Connecting with Nexus 4"
tools:ignore="UnusedAttribute" />
@ -30,6 +30,7 @@
android:id="@+id/error"
android:textSize="20sp"
android:textAlignment="center"
android:gravity="center"
android:text="@string/swap_connection_misc_error"
android:visibility="gone"
android:padding="30dp"

View File

@ -15,19 +15,23 @@
<style name="SwapTheme.AppList.SwapSuccess" parent="SwapTheme.AppList.SwapSuccessBase">
<item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="SwapTheme.AppList.SwapSuccessDetails" parent="SwapTheme.AppList.SwapSuccessDetailsBase">
<item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
</style>
<style name="SwapTheme.StartSwap.MainText" parent="SwapTheme.StartSwap.MainTextBase">
<item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
</style>
<style name="SwapTheme.Wizard.Text" parent="SwapTheme.Wizard.TextBase">
<item name="android:textAlignment">center</item>
<item name="android:gravity">center</item>
</style>
<style name="SwapTheme.Wizard.MainText" parent="SwapTheme.Wizard.MainTextBase">

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/menu_about">
<PreferenceScreen android:title="@string/about_title">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="org.fdroid.fdroid"
android:targetClass="org.fdroid.fdroid.AboutActivity" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/preference_category__my_apps">
<PreferenceScreen android:title="@string/preference_manage_installed_apps">
<intent