-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'heads/final-ui' into ui
- Loading branch information
Showing
27 changed files
with
384 additions
and
50 deletions.
There are no files selected for viewing
41 changes: 40 additions & 1 deletion
41
src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/BaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,44 @@ | ||
package com.panda3ds.pandroid.app; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
public class BaseActivity extends AppCompatActivity {} | ||
import com.panda3ds.pandroid.R; | ||
import com.panda3ds.pandroid.data.config.GlobalConfig; | ||
|
||
public class BaseActivity extends AppCompatActivity { | ||
private int currentTheme = GlobalConfig.get(GlobalConfig.KEY_APP_THEME); | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
applyTheme(); | ||
super.onCreate(savedInstanceState); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
if (GlobalConfig.get(GlobalConfig.KEY_APP_THEME) != currentTheme){ | ||
recreate(); | ||
} | ||
} | ||
|
||
private void applyTheme(){ | ||
switch (GlobalConfig.get(GlobalConfig.KEY_APP_THEME)){ | ||
case GlobalConfig.VALUE_THEME_ANDROID: | ||
setTheme(R.style.Theme_Pandroid); | ||
break; | ||
case GlobalConfig.VALUE_THEME_LIGHT: | ||
setTheme(R.style.Theme_Pandroid_Light); | ||
break; | ||
case GlobalConfig.VALUE_THEME_DARK: | ||
setTheme(R.style.Theme_Pandroid_Dark); | ||
break; | ||
case GlobalConfig.VALUE_THEME_BLACK: | ||
setTheme(R.style.Theme_Pandroid_Black); | ||
break; | ||
} | ||
currentTheme = GlobalConfig.get(GlobalConfig.KEY_APP_THEME); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ndroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/AppearancePreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.panda3ds.pandroid.app.preferences; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.panda3ds.pandroid.R; | ||
import com.panda3ds.pandroid.app.BaseActivity; | ||
import com.panda3ds.pandroid.app.base.BasePreferenceFragment; | ||
import com.panda3ds.pandroid.data.config.GlobalConfig; | ||
import com.panda3ds.pandroid.view.preferences.SingleSelectionPreferences; | ||
|
||
public class AppearancePreferences extends BasePreferenceFragment { | ||
@Override | ||
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { | ||
setPreferencesFromResource(R.xml.appearance_preference, rootKey); | ||
|
||
((BaseActivity) requireActivity()).getSupportActionBar().setTitle(R.string.appearance); | ||
|
||
SingleSelectionPreferences themePreference = findPreference("theme"); | ||
themePreference.setSelectedItem(GlobalConfig.get(GlobalConfig.KEY_APP_THEME)); | ||
themePreference.setOnPreferenceChangeListener((preference, value) -> { | ||
GlobalConfig.set(GlobalConfig.KEY_APP_THEME, (int) value); | ||
return false; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
.../app/src/main/java/com/panda3ds/pandroid/view/preferences/SingleSelectionPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.panda3ds.pandroid.view.preferences; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.ColorDrawable; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Build; | ||
import android.util.AttributeSet; | ||
import android.util.Log; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.core.content.ContextCompat; | ||
import androidx.preference.Preference; | ||
import androidx.preference.PreferenceCategory; | ||
|
||
import com.panda3ds.pandroid.R; | ||
import com.panda3ds.pandroid.utils.Constants; | ||
|
||
public class SingleSelectionPreferences extends PreferenceCategory implements Preference.OnPreferenceClickListener { | ||
private final Drawable transparent = new ColorDrawable(Color.TRANSPARENT); | ||
private final Drawable doneDrawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_done); | ||
|
||
public SingleSelectionPreferences(@NonNull Context context) { | ||
super(context); | ||
} | ||
|
||
public SingleSelectionPreferences(@NonNull Context context, @Nullable AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public SingleSelectionPreferences(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
public SingleSelectionPreferences(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
{ | ||
try { | ||
TypedArray color = getContext().obtainStyledAttributes(new int[]{ | ||
android.R.attr.textColorSecondary | ||
}); | ||
doneDrawable.setTint(color.getColor(0, Color.RED)); | ||
color.recycle(); | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
color.close(); | ||
} | ||
} catch (Exception e) { | ||
Log.e(Constants.LOG_TAG, "Error on obtain text color secondary: ", e); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAttached() { | ||
super.onAttached(); | ||
for (int i = 0; i < getPreferenceCount();i++) { | ||
getPreference(i).setOnPreferenceClickListener(this); | ||
} | ||
} | ||
|
||
public void setSelectedItem(int index){ | ||
onPreferenceClick(getPreference(index)); | ||
} | ||
|
||
@Override | ||
public boolean onPreferenceClick(@NonNull Preference preference) { | ||
int index = 0; | ||
for (int i = 0; i < getPreferenceCount(); i++){ | ||
Preference item = getPreference(i); | ||
if (item == preference){ | ||
index = i; | ||
item.setIcon(R.drawable.ic_done); | ||
} else { | ||
item.setIcon(transparent); | ||
} | ||
} | ||
|
||
callChangeListener(index); | ||
return false; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/pandroid/app/src/main/res/color/bottom_navigation_indicator_tint.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="?colorOnSecondary" android:state_checked="true"/> | ||
<item android:color="?colorOnSurface"/> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_focused="true" android:state_enabled="true" android:color="#000"/> | ||
|
||
<item android:state_activated="false" android:color="#8000"/> | ||
<item android:state_enabled="false" android:color="#8000"/> | ||
|
||
<item android:color="#000"/> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_focused="true" android:state_enabled="true" android:color="#FFF"/> | ||
|
||
<item android:state_activated="false" android:color="#AFFF"/> | ||
<item android:state_enabled="false" android:color="#AFFF"/> | ||
<item android:color="#FFF"/> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#000000" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,3c-4.97,0 -9,4.03 -9,9s4.03,9 9,9c0.83,0 1.5,-0.67 1.5,-1.5 0,-0.39 -0.15,-0.74 -0.39,-1.01 -0.23,-0.26 -0.38,-0.61 -0.38,-0.99 0,-0.83 0.67,-1.5 1.5,-1.5L16,16c2.76,0 5,-2.24 5,-5 0,-4.42 -4.03,-8 -9,-8zM6.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S5.67,9 6.5,9 8,9.67 8,10.5 7.33,12 6.5,12zM9.5,8C8.67,8 8,7.33 8,6.5S8.67,5 9.5,5s1.5,0.67 1.5,1.5S10.33,8 9.5,8zM14.5,8c-0.83,0 -1.5,-0.67 -1.5,-1.5S13.67,5 14.5,5s1.5,0.67 1.5,1.5S15.33,8 14.5,8zM17.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S16.67,9 17.5,9s1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/> | ||
</vector> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.