Skip to content

Commit

Permalink
Clean up theme usage, add night mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 committed Dec 27, 2018
1 parent 2b0f519 commit b99c7c1
Show file tree
Hide file tree
Showing 35 changed files with 148 additions and 207 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId 'com.stevenschoen.putionew'
minSdkVersion 21
targetSdkVersion 27
versionCode 135
versionName '4.4.0'
versionCode 136
versionName '4.5 beta 1'
multiDexEnabled true

kapt {
Expand Down Expand Up @@ -58,7 +58,7 @@ dependencies {

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'com.google.android.material:material:1.1.0-alpha02'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
Expand All @@ -38,7 +39,10 @@ public class LoginActivity extends AppCompatActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);

super.onCreate(savedInstanceState);

setContentView(R.layout.login);

sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.preference.PreferenceManager
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Application
import android.content.Context
import android.os.Build
import android.preference.PreferenceManager
import androidx.appcompat.app.AppCompatDelegate
import androidx.fragment.app.Fragment
import androidx.room.Room
import com.stevenschoen.putionew.files.FileDownloadDatabase
Expand Down Expand Up @@ -44,6 +45,8 @@ class PutioApplication : Application() {
if (Build.VERSION.SDK_INT >= 26) {
createNotificationChannels(this)
}

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}

val isLoggedIn: Boolean
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/stevenschoen/putionew/PutioUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.widget.Button;
import android.widget.Toast;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand All @@ -46,7 +47,6 @@
import java.util.List;
import java.util.Locale;

import androidx.appcompat.app.AlertDialog;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand Down Expand Up @@ -83,7 +83,7 @@ public PutioUtils(Context context) throws NoTokenException {
}

public static Dialog showPutioDialog(Context context, String title, int contentViewId) {
return new AlertDialog.Builder(context)
return new MaterialAlertDialogBuilder(context)
.setTitle(title)
.setView(contentViewId)
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.stevenschoen.putionew.files
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.fragment.app.Fragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.stevenschoen.putionew.R

class ConfirmDeleteFragment : AppCompatDialogFragment() {
Expand All @@ -25,7 +25,7 @@ class ConfirmDeleteFragment : AppCompatDialogFragment() {
var callbacks: Callbacks? = null

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return AlertDialog.Builder(context!!)
return MaterialAlertDialogBuilder(context!!)
.setTitle(resources.getQuantityString(R.plurals.deletetitle, amount, amount))
.setMessage(resources.getQuantityString(R.plurals.deletebody, amount, amount))
.setPositiveButton(R.string.delete) { _, _ -> callbacks?.onDeleteSelected() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.textfield.TextInputLayout
import com.stevenschoen.putionew.R
import com.stevenschoen.putionew.model.files.PutioFile
Expand All @@ -30,7 +30,7 @@ class CreateFolderFragment : DialogFragment() {
lateinit var nameView: EditText

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = AlertDialog.Builder(context!!)
val dialog = MaterialAlertDialogBuilder(context!!)
.setTitle(R.string.create_folder)
.setView(R.layout.create_folder_dialog)
.setPositiveButton(R.string.create) { _, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DestinationFolderActivity : AppCompatActivity() {

val toolbarView = findViewById<Toolbar>(R.id.destination_toolbar)
setSupportActionBar(toolbarView)
toolbarView.setNavigationIcon(R.drawable.ic_toolbar_nav_close_black)
toolbarView.setNavigationIcon(R.drawable.ic_toolbar_nav_close)
toolbarView.setNavigationOnClickListener { finish() }

findViewById<View>(R.id.destination_cancel).setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.PopupMenu
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.widget.PopupMenu
import androidx.core.content.res.use
import androidx.core.view.updatePaddingRelative
import androidx.core.widget.ImageViewCompat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class FolderFragment : FileListFragment<FileListFragment.Callbacks>() {
override val isRefreshing
get() = folderLoader!!.isRefreshing()

val folder by lazy { arguments!!.getParcelable<PutioFile>(EXTRA_FOLDER) }
val padForFab by lazy { arguments!!.getBoolean(EXTRA_PAD_FOR_FAB) }
val showSearch by lazy { arguments!!.getBoolean(EXTRA_SHOW_SEARCH) }
val showCreateFolder by lazy { arguments!!.getBoolean(EXTRA_SHOW_CREATEFOLDER) }
val folder by lazy { arguments!!.getParcelable<PutioFile>(EXTRA_FOLDER)!! }
val padForFab by lazy { arguments!!.getBoolean(EXTRA_PAD_FOR_FAB)!! }
val showSearch by lazy { arguments!!.getBoolean(EXTRA_SHOW_SEARCH)!! }
val showCreateFolder by lazy { arguments!!.getBoolean(EXTRA_SHOW_CREATEFOLDER)!! }

var folderLoader: FolderLoader? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.stevenschoen.putionew.R
import com.stevenschoen.putionew.model.files.PutioFile
import com.trello.rxlifecycle2.components.support.RxAppCompatDialogFragment
Expand All @@ -30,7 +30,7 @@ class RenameFragment : RxAppCompatDialogFragment() {
lateinit var nameView: EditText

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = AlertDialog.Builder(context!!)
val dialog = MaterialAlertDialogBuilder(context!!)
.setTitle(R.string.renametitle)
.setView(R.layout.rename_dialog)
.setPositiveButton(R.string.rename) { _, _ ->
Expand Down
96 changes: 0 additions & 96 deletions app/src/main/java/de/ankri/views/AutoScaleTextView.java

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/res/color/bottom_nav_item_tint.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="1.0" android:color="?colorOnSurface" android:state_checked="true"/>
<item android:alpha="0.6" android:color="?colorOnSurface"/>
<item android:alpha="1.0" android:color="?colorOnSurface" android:state_checked="true" />
<item android:alpha="0.6" android:color="?colorOnSurface" />
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:viewportHeight="24.0"
>
<path
android:fillColor="#000"
android:fillColor="?colorOnSurface"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"
/>
</vector>
6 changes: 5 additions & 1 deletion app/src/main/res/layout/about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:id="@+id/about_header"
android:layout_width="0dp"
android:layout_height="136dp"
android:background="?colorPrimary"
android:background="?putio_colorTopBar"
android:elevation="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -76,6 +76,7 @@
android:background="?selectableItemBackground"
android:drawableStart="@drawable/ic_about_github"
android:drawablePadding="24dp"
android:drawableTint="?colorOnBackground"
android:gravity="center_vertical"
android:minHeight="48dp"
android:paddingStart="24dp"
Expand All @@ -93,6 +94,7 @@
android:background="?selectableItemBackground"
android:drawableStart="@drawable/ic_about_email"
android:drawablePadding="24dp"
android:drawableTint="?colorOnBackground"
android:gravity="center_vertical"
android:minHeight="48dp"
android:paddingStart="24dp"
Expand All @@ -110,6 +112,7 @@
android:background="?selectableItemBackground"
android:drawableStart="@drawable/ic_about_translate"
android:drawablePadding="24dp"
android:drawableTint="?colorOnBackground"
android:gravity="center_vertical"
android:minHeight="48dp"
android:paddingStart="24dp"
Expand All @@ -127,6 +130,7 @@
android:background="?selectableItemBackground"
android:drawableStart="@drawable/ic_about_visit"
android:drawablePadding="24dp"
android:drawableTint="?colorOnBackground"
android:gravity="center_vertical"
android:minHeight="48dp"
android:paddingStart="24dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
android:layout_marginEnd="32dp"
android:gravity="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:textColor="@android:color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/addtransfer_file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
android:src="@drawable/ic_close"
/>

<de.ankri.views.AutoScaleTextView
<TextView
android:id="@+id/addtransfer_file_notatorrent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -51,7 +51,7 @@
android:layout_marginBottom="12dp"
android:paddingStart="16dp"
android:text="@string/notatorrent"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textAppearance="?textAppearanceCaption"
android:textColor="@color/putio_lightred"
/>

Expand Down Expand Up @@ -87,7 +87,7 @@

<Button
android:id="@+id/addtransfer_file_add"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.Putio.Button.Unelevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="48dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/addtransfer_link.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

<Button
android:id="@+id/addtransfer_link_add"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.Putio.Button.Unelevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="48dp"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/destination_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/cancel"
/>

<Button
android:id="@+id/destination_choose"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
style="@style/Widget.Putio.Button.Unelevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/choose_folder"
Expand Down
Loading

0 comments on commit b99c7c1

Please sign in to comment.