Theme and Icons #260

Merged
mmarif merged 15 commits from light-theme into master 2020-03-08 13:52:34 +00:00
12 changed files with 196 additions and 80 deletions
Showing only changes of commit 14addf5ed0 - Show all commits

View File

@ -15,13 +15,21 @@ public abstract class BaseActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppThemeLight);
final TinyDB tinyDb = new TinyDB(getApplicationContext());
if(tinyDb.getInt("themeId") == 0) {
Outdated
Review

can you test for == 1 and else set default theme?

can you test for == 1 and else set default theme?

Yes, that will work too.

Yes, that will work too.
setTheme(R.style.AppTheme);
}
else if(tinyDb.getInt("themeId") == 1) {
setTheme(R.style.AppThemeLight);
}
else {
setTheme(R.style.AppTheme);
}
super.onCreate(savedInstanceState);
setContentView(getLayoutResourceId());
final TinyDB tinyDb = new TinyDB(getApplicationContext());
if(tinyDb.getInt("customFontId") == 0) {
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");

View File

@ -104,6 +104,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
fMenuHelper.setAccessible(true);
menuHelper = fMenuHelper.get(popupMenu);
argTypes = new Class[] { boolean.class };
assert menuHelper != null;
menuHelper.getClass().getDeclaredMethod("setForceShowIcon",
argTypes).invoke(menuHelper, true);

View File

@ -44,6 +44,9 @@ public class SettingsFragment extends Fragment {
private static String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
private static int customFontSelectedChoice = 0;
private static String[] themeList = {"Dark", "Light"};
private static int themeSelectedChoice = 0;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -56,12 +59,14 @@ public class SettingsFragment extends Fragment {
final TextView codeBlockSelected = v.findViewById(R.id.codeBlockSelected); // setter for code block
final TextView homeScreenSelected = v.findViewById(R.id.homeScreenSelected); // setter for home screen
final TextView customFontSelected = v.findViewById(R.id.customFontSelected); // setter for custom font
final TextView themeSelected = v.findViewById(R.id.themeSelected); // setter for theme
LinearLayout langFrame = v.findViewById(R.id.langFrame);
LinearLayout timeFrame = v.findViewById(R.id.timeFrame);
LinearLayout codeBlockFrame = v.findViewById(R.id.codeBlockFrame);
LinearLayout homeScreenFrame = v.findViewById(R.id.homeScreenFrame);
LinearLayout customFontFrame = v.findViewById(R.id.customFontFrame);
LinearLayout themeFrame = v.findViewById(R.id.themeSelectionFrame);
Switch issuesSwitch = v.findViewById(R.id.switchIssuesBadge);
TextView helpTranslate = v.findViewById(R.id.helpTranslate);
@ -96,6 +101,10 @@ public class SettingsFragment extends Fragment {
customFontSelected.setText(tinyDb.getString("customFontStr"));
}
if(!tinyDb.getString("themeStr").isEmpty()) {
themeSelected.setText(tinyDb.getString("themeStr"));
}
if(langSelectedChoice == 0) {
langSelectedChoice = tinyDb.getInt("langId");
}
@ -116,6 +125,10 @@ public class SettingsFragment extends Fragment {
customFontSelectedChoice = tinyDb.getInt("customFontId");
}
if(themeSelectedChoice == 0) {
themeSelectedChoice = tinyDb.getInt("themeId");
}
if(tinyDb.getBoolean("enableCounterIssueBadge")) {
issuesSwitch.setChecked(true);
}
@ -135,6 +148,44 @@ public class SettingsFragment extends Fragment {
}
});
// theme selection dialog
themeFrame.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(ctx);
tsBuilder.setTitle(R.string.themeSelectorDialogTitle);
if(themeSelectedChoice != -1) {
tsBuilder.setCancelable(true);
}
else {
tsBuilder.setCancelable(false);
}
tsBuilder.setSingleChoiceItems(themeList, themeSelectedChoice, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterfaceTheme, int i) {
themeSelectedChoice = i;
themeSelected.setText(themeList[i]);
tinyDb.putString("themeStr", themeList[i]);
tinyDb.putInt("themeId", i);
Objects.requireNonNull(getActivity()).recreate();
getActivity().overridePendingTransition(0, 0);
dialogInterfaceTheme.dismiss();
Toasty.info(getContext(), getResources().getString(R.string.settingsSave));
}
});
AlertDialog cfDialog = tsBuilder.create();
cfDialog.show();
}
});
// custom font dialog
customFontFrame.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#368F73" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

View File

@ -64,30 +64,35 @@
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_dropdown"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" >
<Spinner
android:id="@+id/httpsSpinner"
android:layout_width="120dp"
android:layout_height="44dp"
android:dropDownWidth="120dp"
android:background="@drawable/spinner"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="10dp" />
android:spinnerMode="dropdown"
android:padding="10dp" />
</RelativeLayout>
<LinearLayout
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/info"
android:layout_width="28dp"
android:layout_height="28dp"
android:src="@drawable/ic_info_24dp"
android:layout_marginStart="20dp"
android:layout_marginTop="15dp"
android:layout_marginStart="120dp"
android:layout_marginTop="10dp"
android:contentDescription="@string/urlInfoTooltip"
/>
@ -106,8 +111,8 @@
android:inputType="textUri"
android:background="@drawable/shape_inputs"
android:textColor="?attr/inputTextColor"
android:textColorHint="?attr/primaryBackgroundColor"
android:textColorHighlight="?attr/primaryTextColor"
android:textColorHint="?attr/hintColor"
android:textColorHighlight="?attr/hintColor"
android:hint="@string/instanceUrl" />
<EditText
@ -122,8 +127,8 @@
android:drawablePadding="10dp"
android:background="@drawable/shape_inputs"
android:textColor="?attr/inputTextColor"
android:textColorHint="?attr/primaryBackgroundColor"
android:textColorHighlight="?attr/primaryTextColor"
android:textColorHint="?attr/hintColor"
android:textColorHighlight="?attr/hintColor"
android:hint="@string/userName"
android:inputType="text" />
@ -139,8 +144,8 @@
android:drawablePadding="10dp"
android:background="@drawable/shape_inputs"
android:textColor="?attr/inputTextColor"
android:textColorHint="?attr/primaryBackgroundColor"
android:textColorHighlight="?attr/primaryTextColor"
android:textColorHint="?attr/hintColor"
android:textColorHighlight="?attr/hintColor"
android:hint="@string/passWord"
android:inputType="textPassword" />
@ -156,8 +161,8 @@
android:drawablePadding="10dp"
android:background="@drawable/shape_inputs"
android:textColor="?attr/inputTextColor"
android:textColorHint="?attr/primaryBackgroundColor"
android:textColorHighlight="?attr/primaryTextColor"
android:textColorHint="?attr/hintColor"
android:textColorHighlight="?attr/hintColor"
android:hint="@string/loginOTP"
android:inputType="number" />
@ -173,8 +178,8 @@
android:drawablePadding="10dp"
android:background="@drawable/shape_inputs"
android:textColor="?attr/inputTextColor"
android:textColorHint="?attr/primaryBackgroundColor"
android:textColorHighlight="?attr/primaryTextColor"
android:textColorHint="?attr/hintColor"
android:textColorHighlight="?attr/hintColor"
android:hint="@string/copyToken"
android:inputType="text"
android:visibility="gone" />

View File

@ -13,7 +13,6 @@
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
@ -42,6 +41,7 @@
app:tabTextAppearance="@style/customTabLayout"
app:tabMode="scrollable"
app:tabTextColor="?attr/primaryTextColor"
android:background="?attr/primaryBackgroundColor"
android:layout_width="match_parent"
android:layout_height="wrap_content">

View File

@ -13,7 +13,6 @@
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar

View File

@ -80,6 +80,7 @@
app:tabTextAppearance="@style/customTabLayout"
android:layout_width="match_parent"
app:tabTextColor="?attr/primaryTextColor"
android:background="?attr/primaryBackgroundColor"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem

View File

@ -17,6 +17,66 @@
android:textStyle="bold"
android:textColor="@color/colorDarkGreen"/>
<LinearLayout
android:id="@+id/themeSelectionFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/themeHeaderSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginTop="10dp"
android:layout_marginStart="44dp"
android:layout_marginEnd="4dp"
android:text="@string/themeSelectionHeaderText"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:id="@+id/themeSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginStart="44dp"
android:layout_marginEnd="4dp"
android:text="@string/themeSelectionSelectedText"
android:textColor="?attr/selectedTextColor"/>
</LinearLayout>
<LinearLayout
android:id="@+id/customFontFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/customFontHeaderSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginTop="10dp"
android:layout_marginStart="44dp"
android:layout_marginEnd="4dp"
android:text="@string/settingsCustomFontHeaderText"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:id="@+id/customFontSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginStart="44dp"
android:layout_marginEnd="4dp"
android:text="@string/defaultCopy"
android:textColor="?attr/selectedTextColor"/>
</LinearLayout>
<LinearLayout
android:id="@+id/timeFrame"
android:layout_width="match_parent"
@ -136,34 +196,4 @@
</LinearLayout>
<LinearLayout
android:id="@+id/customFontFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/customFontHeaderSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginTop="10dp"
android:layout_marginStart="44dp"
android:layout_marginEnd="4dp"
android:text="@string/settingsCustomFontHeaderText"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:id="@+id/customFontSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginStart="44dp"
android:layout_marginEnd="4dp"
android:text="@string/defaultCopy"
android:textColor="?attr/selectedTextColor"/>
</LinearLayout>
</LinearLayout>

View File

@ -3,6 +3,7 @@
<attr name="primaryTextColor" format="reference"/>
<attr name="primaryBackgroundColor" format="reference" />
<attr name="inputBackgroundColor" format="reference" />
<attr name="hintColor" format="reference" />
<attr name="inputTextColor" format="reference" />
<attr name="selectedTextColor" format="reference" />
<attr name="alertDialogTheme" format="reference" />

View File

@ -259,6 +259,12 @@
<string name="settingsHomeScreenHeaderText">Home Screen</string>
<string name="settingsHomeScreenSelectedText">My Repositories</string>
<string name="settingshomeScreenSelectorDialogTitle">Select Home Screen</string>
<string name="settingsCustomFontHeaderText">Font</string>
<string name="settingsCustomFontSelectorDialogTitle">Choose Font</string>
<string name="settingsCustomFontDefault">Roboto</string>
<string name="themeSelectorDialogTitle">Select App Theme</string>
<string name="themeSelectionHeaderText">Theme</string>
<string name="themeSelectionSelectedText" translatable="false">Dark</string>
<!-- settings -->
<string name="noMoreData">No more data available</string>
@ -543,8 +549,4 @@
<string name="mergePRSuccessMsg">Pull Request was merged successfully</string>
<string name="mergePR404ErrorMsg">Pull Request is not available for merge</string>
<string name="settingsCustomFontHeaderText">Font</string>
<string name="settingsCustomFontSelectorDialogTitle">Choose Font</string>
<string name="settingsCustomFontDefault">Roboto</string>
</resources>

View File

@ -14,8 +14,11 @@
<item name="inputTextColor">@color/colorWhite</item>
<item name="checkboxStyle">@style/AppThemeCheckBoxStyle</item>
<item name="selectedTextColor">@color/darkGreen</item>
<item name="dialogTheme">@style/AppThemeConfirmDialog</item>
<item name="alertDialogTheme">@style/AppThemeConfirmDialog</item>
<item name="popupMenuStyle">@style/AppThemePopupMenuStyle</item>
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back_24dp</item>
<item name="autoCompleteTextViewStyle">@style/AppThemeDarkSearchAutoCompleteTextView</item>
<item name="hintColor">@color/hintColor</item>
</style>
<!-- Dark theme - default -->
@ -32,41 +35,51 @@
<item name="inputTextColor">@color/lightThemeInputTextColor</item>
<item name="checkboxStyle">@style/AppThemeLightCheckBoxStyle</item>
<item name="selectedTextColor">@color/darkGreen</item>
<item name="dialogTheme">@style/AppThemeLightConfirmDialog</item>
<item name="popupMenuStyle">@style/AppThemePopupMenuStyle</item>
<item name="alertDialogTheme">@style/AppThemeLightConfirmDialog</item>
<item name="popupMenuStyle">@style/AppThemeLightPopupMenuStyle</item>
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back_24dp</item>
<item name="autoCompleteTextViewStyle">@style/AppThemeLightSearchAutoCompleteTextView</item>
<item name="hintColor">@color/hintColor</item>
</style>
<!-- Light theme -->
<style name="AppThemeLightSearchAutoCompleteTextView" parent="Widget.AppCompat.Light.AutoCompleteTextView">
<item name="android:textColor">@color/lightThemeTextColor</item>
<item name="android:textColorHint">@color/lightThemeTextColor</item>
</style>
<style name="AppThemeDarkSearchAutoCompleteTextView" parent="Widget.AppCompat.Light.AutoCompleteTextView">
<item name="android:textColor">@color/colorWhite</item>
<item name="android:textColorHint">@color/colorWhite</item>
</style>
<style name="AppThemeConfirmDialog" parent="Theme.AppCompat.Dialog.Alert">
<item name="android:background">@color/colorPrimary</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="android:textColor">@color/white</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
<item name="colorControlActivated">@color/darkGreen</item>
</style>
<style name="AppThemeLightConfirmDialog" parent="Theme.AppCompat.Dialog.Alert">
<item name="android:background">@color/colorPrimary</item>
<item name="android:textColorPrimary">@color/colorPrimary</item>
<style name="AppThemeLightConfirmDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:background">@color/white</item>
<item name="android:textColorPrimary">@color/lightThemeTextColor</item>
<item name="android:textColor">@color/lightThemeTextColor</item>
<item name="colorControlNormal">@color/lightThemeTextColor</item>
<item name="colorControlActivated">@color/lightThemeTextColor</item>
<item name="colorControlActivated">@color/darkGreen</item>
</style>
<style name="AppThemePopupMenuStyle">
<item name="android:itemBackground">@color/colorPrimary</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:colorBackground">@color/colorPrimary</item>
<style name="AppThemePopupMenuStyle" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@color/colorPrimary</item>
<item name="android:textColor">@color/white</item>
<item name="android:layout_marginStart">3dp</item>
<item name="android:layout_marginEnd">3dp</item>
</style>
<style name="AppThemeLightPopupMenuStyle">
<style name="AppThemeLightPopupMenuStyle" parent="Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">@color/white</item>
<item name="android:itemBackground">@color/lightThemeBackground</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:textColor">@color/lightThemeTextColor</item>
<item name="android:colorBackground">@color/lightThemeBackground</item>
<item name="android:layout_marginStart">3dp</item>
<item name="android:layout_marginEnd">3dp</item>
</style>