Theme and Icons #260

Merged
mmarif merged 15 commits from light-theme into master 2020-03-08 13:52:34 +00:00
17 changed files with 155 additions and 23 deletions
Showing only changes of commit 61f953d70d - Show all commits

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.mian.gitnex">
<uses-permission android:name="android.permission.INTERNET" />
@ -11,7 +12,8 @@
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/app_logo_round"
android:supportsRtl="true">
android:supportsRtl="true"
tools:targetApi="n">
<activity android:name=".activities.MergePullRequestActivity" />
<activity
android:name=".activities.FileViewActivity"
@ -56,7 +58,7 @@
android:name=".activities.RepoDetailActivity"
android:label="@string/title_activity_repo_detail"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".activities.MainActivity">
<activity android:name=".activities.MainActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -50,6 +50,7 @@ public class FileViewActivity extends BaseActivity {
private PDFView pdfView;
private LinearLayout pdfViewFrame;
private byte[] decodedPdf;
private Boolean $nightMode;
Outdated
Review

why this variable start with $ ?

why this variable start with `$` ?

Good catch. I was into PHP mode. :)

Good catch. I was into PHP mode. :)
@Override
protected int getLayoutResourceId(){
@ -111,6 +112,8 @@ public class FileViewActivity extends BaseActivity {
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename) {
final TinyDB tinyDb = new TinyDB(getApplicationContext());
Call<Files> call = RetrofitClient
.getInstance(instanceUrl, getApplicationContext())
.getApiInterface()
@ -162,6 +165,8 @@ public class FileViewActivity extends BaseActivity {
singleCodeContents.setVisibility(View.GONE);
pdfViewFrame.setVisibility(View.VISIBLE);
$nightMode = tinyDb.getBoolean("enablePdfMode");
decodedPdf = Base64.decode(response.body().getContent(), Base64.DEFAULT);
pdfView.fromBytes(decodedPdf)
.enableSwipe(true)
@ -178,7 +183,7 @@ public class FileViewActivity extends BaseActivity {
.fitEachPage(true)
.pageSnap(false)
.pageFling(true)
.nightMode(false)
.nightMode($nightMode)
.load();
}

View File

@ -83,6 +83,7 @@ public class RepoStargazersAdapter extends BaseAdapter {
final TinyDB tinyDb = new TinyDB(mCtx);
Typeface myTypeface;
if(tinyDb.getInt("customFontId") == 0) {
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
@ -113,6 +114,16 @@ public class RepoStargazersAdapter extends BaseAdapter {
viewHolder.memberName.setTypeface(myTypeface);
}
if(tinyDb.getInt("themeId") == 0) { // dark
Outdated
Review

same as first comment - why not make if (is light) [else if (is other theme - not here jet)] else default -> dark theme

same as first comment - why not make if (is light) [else if (is other theme - not here jet)] else default -> dark theme

Yup, you are right.

Yup, you are right.
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
}
else if(tinyDb.getInt("themeId") == 1) { //light
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.lightThemeTextColor));
}
else {
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
}
}
}

View File

@ -83,6 +83,7 @@ public class RepoWatchersAdapter extends BaseAdapter {
final TinyDB tinyDb = new TinyDB(mCtx);
Typeface myTypeface;
if(tinyDb.getInt("customFontId") == 0) {
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
@ -113,6 +114,16 @@ public class RepoWatchersAdapter extends BaseAdapter {
viewHolder.memberName.setTypeface(myTypeface);
}
if(tinyDb.getInt("themeId") == 0) { // dark
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
}
else if(tinyDb.getInt("themeId") == 1) { //light
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.lightThemeTextColor));
}
else {
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
}
}
}

View File

@ -25,7 +25,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
private List<UserInfo> teamMembersList;
private Context mCtx;
private class ViewHolder {
private static class ViewHolder {
private ImageView memberAvatar;
private TextView memberName;
@ -65,7 +65,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
if (finalView == null) {
finalView = LayoutInflater.from(mCtx).inflate(R.layout.members_by_team_by_org_list, null);
viewHolder = new TeamMembersByOrgAdapter.ViewHolder(finalView);
viewHolder = new ViewHolder(finalView);
finalView.setTag(viewHolder);
}
else {
@ -84,6 +84,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
final TinyDB tinyDb = new TinyDB(mCtx);
Typeface myTypeface;
if(tinyDb.getInt("customFontId") == 0) {
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
@ -114,5 +115,15 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
viewHolder.memberName.setTypeface(myTypeface);
}
if(tinyDb.getInt("themeId") == 0) { // dark
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
}
else if(tinyDb.getInt("themeId") == 1) { //light
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.lightThemeTextColor));
}
else {
viewHolder.memberName.setTextColor(mCtx.getResources().getColor(R.color.white));
}
}
}

View File

@ -69,6 +69,7 @@ public class SettingsFragment extends Fragment {
LinearLayout themeFrame = v.findViewById(R.id.themeSelectionFrame);
Switch issuesSwitch = v.findViewById(R.id.switchIssuesBadge);
Switch pdfModeSwitch = v.findViewById(R.id.switchPdfMode);
TextView helpTranslate = v.findViewById(R.id.helpTranslate);
helpTranslate.setOnClickListener(new View.OnClickListener() {
@ -132,6 +133,16 @@ public class SettingsFragment extends Fragment {
if(tinyDb.getBoolean("enableCounterIssueBadge")) {
issuesSwitch.setChecked(true);
}
else {
issuesSwitch.setChecked(false);
}
if(tinyDb.getBoolean("enablePdfMode")) {
pdfModeSwitch.setChecked(true);
}
else {
pdfModeSwitch.setChecked(false);
}
// issues badge switcher
issuesSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -148,6 +159,21 @@ public class SettingsFragment extends Fragment {
}
});
// pdf night mode switcher
pdfModeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
tinyDb.putBoolean("enablePdfMode", true);
tinyDb.putString("enablePdfModeInit", "yes");
Toasty.info(getContext(), getResources().getString(R.string.settingsSave));
} else {
tinyDb.putBoolean("enablePdfMode", false);
tinyDb.putString("enablePdfModeInit", "yes");
Toasty.info(getContext(), getResources().getString(R.string.settingsSave));
}
}
});
// theme selection dialog
themeFrame.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
@ -14,7 +14,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:background="?attr/primaryBackgroundColor"
tools:ignore="UnusedAttribute">
<ImageView
@ -32,7 +32,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:maxLines="1"
android:textSize="20sp" />
@ -49,6 +49,7 @@
android:numColumns="4"
android:columnWidth="80dp"
android:stretchMode="columnWidth"
android:background="?attr/primaryBackgroundColor"
android:gravity="center"/>
<TextView
@ -58,7 +59,7 @@
android:layout_margin="15dp"
android:gravity="center"
android:text="@string/noDataMembers"
android:textColor="@color/white"
android:textColor="?attr/primaryTextColor"
android:textSize="20sp"
android:visibility="gone" />

View File

@ -49,6 +49,7 @@
android:numColumns="4"
android:columnWidth="80dp"
android:stretchMode="columnWidth"
android:background="?attr/primaryBackgroundColor"
android:gravity="center"/>
<TextView

View File

@ -49,6 +49,7 @@
android:numColumns="4"
android:columnWidth="80dp"
android:stretchMode="columnWidth"
android:background="?attr/primaryBackgroundColor"
android:gravity="center"/>
<TextView

View File

@ -19,10 +19,11 @@
android:inputType="text"
android:background="@drawable/shape_inputs"
android:textColor="?attr/inputTextColor"
android:textColorHint="?attr/primaryBackgroundColor"
android:textColorHint="?attr/hintColor"
android:hint="@string/exploreTextBoxHint"
android:textColorHighlight="?attr/primaryTextColor"
android:imeOptions="actionSend" />
android:imeOptions="actionSend"
android:autofillHints="@string/exploreTextBoxHint" />
<TextView
android:id="@+id/noData"

View File

@ -19,7 +19,7 @@
layout="@layout/layout_settings_appearance"/>
<View
android:id="@+id/translationDivider"
android:id="@+id/fileViewDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="44dp"
@ -29,6 +29,21 @@
android:layout_below="@id/timeLayout"
/>
<include
android:id="@+id/fileViewLayout"
layout="@layout/layout_settings_fileview"/>
<View
android:id="@+id/translationDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="44dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_below="@id/fileViewLayout"
/>
<include
android:id="@+id/langLayout"
layout="@layout/layout_settings_languages"/>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layoutFileView"
android:orientation="vertical"
android:layout_below="@+id/fileViewDivider"
android:background="?attr/primaryBackgroundColor">
<TextView
android:id="@+id/fileViewAppearance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:drawableStart="@drawable/ic_file"
android:drawablePadding="20dp"
android:text="@string/fileViewerHeader"
android:textStyle="bold"
android:textColor="@color/colorDarkGreen"/>
<RelativeLayout
android:id="@+id/pdfMode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
android:id="@+id/pdfModeHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginStart="44dp"
android:layout_marginEnd="4dp"
android:text="@string/settingsPdfModeHeaderText"
android:textColor="?attr/primaryTextColor"/>
<Switch
android:id="@+id/switchPdfMode"
android:layout_toEndOf="@+id/pdfModeHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:switchMinWidth="56dp"
android:layout_alignParentEnd="true"
android:gravity="end"
android:layout_gravity="end" />
</RelativeLayout>
</LinearLayout>

View File

@ -4,7 +4,6 @@
android:id="@+id/gridViewData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<ImageView
@ -21,7 +20,6 @@
android:gravity="top|center_horizontal"
android:layout_marginTop="1dp"
android:text="@string/orgMember"
android:textSize="14sp"
android:textColor="?attr/primaryTextColor" />
android:textSize="14sp" />
</LinearLayout>

View File

@ -4,7 +4,6 @@
android:id="@+id/gridViewData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<ImageView
@ -21,7 +20,6 @@
android:gravity="top|center_horizontal"
android:layout_marginTop="1dp"
android:text="@string/starMember"
android:textSize="14sp"
android:textColor="?attr/primaryTextColor" />
android:textSize="14sp" />
</LinearLayout>

View File

@ -4,7 +4,6 @@
android:id="@+id/gridViewData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<ImageView
@ -21,7 +20,6 @@
android:gravity="top|center_horizontal"
android:layout_marginTop="1dp"
android:text="@string/watcherMember"
android:textSize="14sp"
android:textColor="?attr/primaryTextColor" />
android:textSize="14sp" />
</LinearLayout>

View File

@ -265,6 +265,8 @@
<string name="themeSelectorDialogTitle">Select App Theme</string>
<string name="themeSelectionHeaderText">Theme</string>
<string name="themeSelectionSelectedText" translatable="false">Dark</string>
<string name="settingsPdfModeHeaderText">PDF Night Mode</string>
<string name="fileViewerHeader">File Viewer</string>
<!-- settings -->
<string name="noMoreData">No more data available</string>

View File

@ -4,7 +4,6 @@
<!-- Dark theme - default -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@color/colorPrimary</item>
<item name="android:windowBackground">@color/colorPrimary</item>
<item name="android:typeface">monospace</item>
<item name="colorAccent">@color/colorAccent</item>
@ -19,13 +18,13 @@
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back_24dp</item>
<item name="autoCompleteTextViewStyle">@style/AppThemeDarkSearchAutoCompleteTextView</item>
<item name="hintColor">@color/hintColor</item>
<item name="colorControlActivated">@color/darkGreen</item>
</style>
<!-- Dark theme - default -->
<!-- Light theme -->
<style name="AppThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@color/colorPrimary</item>
<item name="android:windowBackground">@color/lightThemeBackground</item>
<item name="android:typeface">monospace</item>
<item name="colorAccent">@color/colorAccent</item>
@ -40,6 +39,7 @@
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back_24dp</item>
<item name="autoCompleteTextViewStyle">@style/AppThemeLightSearchAutoCompleteTextView</item>
<item name="hintColor">@color/hintColor</item>
<item name="colorControlActivated">@color/darkGreen</item>
</style>
<!-- Light theme -->