-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
3,110 additions
and
55 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> | ||
<uses-permission-sdk-23 android:maxSdkVersion="29" android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission-sdk-23 android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission-sdk-23 android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> | ||
|
||
<queries> | ||
<package android:name="jp.co.cygames.umamusume" /> | ||
<package android:name="com.kakaogames.umamusume" /> | ||
<!-- TODO Package by region --> | ||
</queries> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.UmamusumeLocalifyAndroid" /> | ||
android:theme="@style/Theme.UmamusumeLocalifyAndroid"> | ||
<activity | ||
android:name=".activity.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:label="@string/manage_translate" | ||
android:name=".activity.ManageTranslateActivity" | ||
android:exported="false" /> | ||
</application> | ||
|
||
</manifest> |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/kimjio/umamusumelocalify/settings/ColorUtils.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,10 @@ | ||
package com.kimjio.umamusumelocalify.settings; | ||
|
||
public final class ColorUtils { | ||
public static int argb(float alpha, int red, int green, int blue) { | ||
return ((int) (alpha * 255.0f + 0.5f) << 24) | | ||
(red << 16) | | ||
(green << 8) | | ||
blue; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/kimjio/umamusumelocalify/settings/Constants.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,13 @@ | ||
package com.kimjio.umamusumelocalify.settings; | ||
|
||
import java.util.List; | ||
|
||
public final class Constants { | ||
public static final String PREF_NAME = "pref_settings"; | ||
|
||
public static final List<String> targetPackageNames = List.of( | ||
"jp.co.cygames.umamusume", | ||
"com.kakaogames.umamusume" | ||
// TODO Package by region | ||
); | ||
} |
126 changes: 126 additions & 0 deletions
126
app/src/main/java/com/kimjio/umamusumelocalify/settings/activity/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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package com.kimjio.umamusumelocalify.settings.activity; | ||
|
||
import android.content.res.Configuration; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.ColorDrawable; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
|
||
import androidx.annotation.ColorInt; | ||
import androidx.annotation.LayoutRes; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.databinding.DataBindingUtil; | ||
import androidx.databinding.ViewDataBinding; | ||
|
||
import com.kimjio.umamusumelocalify.settings.ColorUtils; | ||
import com.kimjio.umamusumelocalify.settings.R; | ||
|
||
import java.lang.reflect.ParameterizedType; | ||
import java.util.Objects; | ||
import java.util.function.Consumer; | ||
|
||
|
||
public abstract class BaseActivity<VB extends ViewDataBinding> extends AppCompatActivity { | ||
protected VB binding; | ||
|
||
@ColorInt | ||
protected int backgroundColor; | ||
|
||
private final Consumer<Boolean> crossWindowBlurEnabledListener = enabled -> { | ||
getWindow().setBackgroundDrawable( | ||
enabled ? new ColorDrawable(backgroundColor) : new ColorDrawable(backgroundColor & (0xFF << 24))); | ||
}; | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
binding = DataBindingUtil.setContentView(this, getLayoutRes()); | ||
binding.setLifecycleOwner(this); | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | ||
getWindow().setDecorFitsSystemWindows(false); | ||
} else { | ||
View decorView = getWindow().getDecorView(); | ||
decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); | ||
} | ||
|
||
Window window = getWindow(); | ||
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER | WindowManager.LayoutParams.FLAG_BLUR_BEHIND); | ||
|
||
backgroundColor = ((ColorDrawable) getWindow().getDecorView().getBackground()).getColor(); | ||
|
||
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES) { | ||
backgroundColor = ColorUtils.argb(0.5f, Color.red(backgroundColor), Color.green(backgroundColor), Color.blue(backgroundColor)); | ||
} else { | ||
backgroundColor = ColorUtils.argb(0.7f, Color.red(backgroundColor), Color.green(backgroundColor), Color.blue(backgroundColor)); | ||
} | ||
|
||
getWindow().setBackgroundDrawable(new ColorDrawable(backgroundColor)); | ||
|
||
float density = getResources().getDisplayMetrics().density; | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
window.getAttributes().setBlurBehindRadius((int) (density * 20.0f)); | ||
window.getDecorView().addOnAttachStateChangeListener( | ||
new View.OnAttachStateChangeListener() { | ||
@Override | ||
public void onViewAttachedToWindow(View v) { | ||
getWindowManager().addCrossWindowBlurEnabledListener( | ||
crossWindowBlurEnabledListener); | ||
} | ||
|
||
@Override | ||
public void onViewDetachedFromWindow(View v) { | ||
getWindowManager().removeCrossWindowBlurEnabledListener( | ||
crossWindowBlurEnabledListener); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@NonNull | ||
public ActionBar requireSupportActionBar() { | ||
ActionBar actionBar = getSupportActionBar(); | ||
if (actionBar == null) | ||
throw new IllegalArgumentException("ActionBar does not set for this Activity"); | ||
return actionBar; | ||
} | ||
|
||
@LayoutRes | ||
private int getLayoutRes() { | ||
String[] split = ((Class<?>) ((ParameterizedType) Objects.requireNonNull(getClass().getGenericSuperclass())).getActualTypeArguments()[0]) | ||
.getSimpleName().replace("Binding", "").split("(?<=.)(?=\\p{Upper})"); | ||
StringBuilder name = new StringBuilder(); | ||
|
||
for (int i = 0; i < split.length; i++) { | ||
name.append(split[i].toLowerCase()); | ||
if (i != split.length - 1) | ||
name.append("_"); | ||
} | ||
|
||
try { | ||
return R.layout.class.getField(name.toString()).getInt(R.layout.class); | ||
} catch (IllegalAccessException | NoSuchFieldException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(@NonNull MenuItem item) { | ||
boolean result = false; | ||
if (item.getItemId() == android.R.id.home) { | ||
finish(); | ||
result = true; | ||
} | ||
return result || super.onOptionsItemSelected(item); | ||
} | ||
} |
Oops, something went wrong.