pull/1/head
FongMi 4 years ago
parent 964d06fdb6
commit 6dc3f130d0
  1. 15
      app/src/main/AndroidManifest.xml
  2. 14
      app/src/main/java/com/fongmi/bear/MainActivity.java
  3. 42
      app/src/main/java/com/fongmi/bear/ui/BaseActivity.java
  4. 15
      app/src/main/java/com/fongmi/bear/ui/HomeActivity.java
  5. 33
      app/src/main/java/com/fongmi/bear/ui/SplashActivity.java
  6. 42
      app/src/main/java/com/fongmi/bear/utils/Prefers.java
  7. 109
      app/src/main/java/com/fongmi/bear/utils/Utils.java
  8. BIN
      app/src/main/res/drawable-nodpi/wallpaper_1.webp
  9. BIN
      app/src/main/res/drawable-nodpi/wallpaper_2.webp
  10. BIN
      app/src/main/res/drawable-nodpi/wallpaper_3.webp
  11. 0
      app/src/main/res/layout/activity_home.xml
  12. 6
      app/src/main/res/layout/activity_splash.xml
  13. 1
      app/src/main/res/values/colors.xml

@ -1,6 +1,5 @@
<?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="com.fongmi.bear">
<uses-permission android:name="android.permission.INTERNET" />
@ -29,29 +28,35 @@
<meta-data
android:name="android.max_aspect"
android:value="2.5" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<activity
android:name=".MainActivity"
android:name=".ui.SplashActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:exported="true"
android:screenOrientation="sensorLandscape"
tools:ignore="LockedOrientationActivity">
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.HomeActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:screenOrientation="sensorLandscape" />
</application>
</manifest>

@ -1,14 +0,0 @@
package com.fongmi.bear;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

@ -0,0 +1,42 @@
package com.fongmi.bear.ui;
import android.content.res.Configuration;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewbinding.ViewBinding;
import com.fongmi.bear.utils.Utils;
public abstract class BaseActivity extends AppCompatActivity {
protected abstract ViewBinding getBinding();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getBinding().getRoot());
Utils.hideSystemUI(this);
initView();
initEvent();
}
protected void initView() {
}
protected void initEvent() {
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Utils.hideSystemUI(this);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) Utils.hideSystemUI(this);
}
}

@ -0,0 +1,15 @@
package com.fongmi.bear.ui;
import androidx.viewbinding.ViewBinding;
import com.fongmi.bear.databinding.ActivityHomeBinding;
public class HomeActivity extends BaseActivity {
private ActivityHomeBinding binding;
@Override
protected ViewBinding getBinding() {
return binding = ActivityHomeBinding.inflate(getLayoutInflater());
}
}

@ -0,0 +1,33 @@
package com.fongmi.bear.ui;
import android.content.Intent;
import android.os.Handler;
import androidx.viewbinding.ViewBinding;
import com.fongmi.bear.databinding.ActivitySplashBinding;
public class SplashActivity extends BaseActivity {
@Override
protected ViewBinding getBinding() {
return ActivitySplashBinding.inflate(getLayoutInflater());
}
@Override
protected void initView() {
loadConfig();
openHome();
}
private void loadConfig() {
}
private void openHome() {
new Handler().postDelayed(() -> {
startActivity(new Intent(this, HomeActivity.class));
finish();
}, 2000);
}
}

@ -0,0 +1,42 @@
package com.fongmi.bear.utils;
import android.content.SharedPreferences;
import androidx.preference.PreferenceManager;
import com.fongmi.bear.App;
public class Prefers {
private static SharedPreferences getPreferences() {
return PreferenceManager.getDefaultSharedPreferences(App.get());
}
private static String getString(String key, String defaultValue) {
return getPreferences().getString(key, defaultValue);
}
private static void putString(String key, String value) {
getPreferences().edit().putString(key, value).apply();
}
private static int getInt(String key, int defaultValue) {
return getPreferences().getInt(key, defaultValue);
}
private static void putInt(String key, int value) {
getPreferences().edit().putInt(key, value).apply();
}
private static boolean getBoolean(String key) {
return getBoolean(key, false);
}
private static boolean getBoolean(String key, boolean defaultValue) {
return getPreferences().getBoolean(key, defaultValue);
}
private static void putBoolean(String key, boolean value) {
getPreferences().edit().putBoolean(key, value).apply();
}
}

@ -0,0 +1,109 @@
package com.fongmi.bear.utils;
import android.app.Activity;
import android.app.PictureInPictureParams;
import android.content.pm.PackageManager;
import android.os.Build;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Rational;
import android.view.KeyEvent;
import android.view.View;
import com.fongmi.bear.App;
import com.google.android.exoplayer2.util.Util;
public class Utils {
private static DisplayMetrics getDisplayMetrics() {
return App.get().getResources().getDisplayMetrics();
}
public static String getString(int resId) {
return App.get().getString(resId);
}
public static boolean hasEvent(KeyEvent event) {
return isArrowKey(event) || isBackKey(event) || isMenuKey(event) || isDigitKey(event) || event.isLongPress();
}
private static boolean isArrowKey(KeyEvent event) {
return isEnterKey(event) || isUpKey(event) || isDownKey(event) || isLeftKey(event) || isRightKey(event);
}
static boolean isBackKey(KeyEvent event) {
return event.getKeyCode() == KeyEvent.KEYCODE_BACK;
}
static boolean isMenuKey(KeyEvent event) {
return event.getKeyCode() == KeyEvent.KEYCODE_MENU;
}
public static boolean isDigitKey(KeyEvent event) {
return event.getKeyCode() >= KeyEvent.KEYCODE_0 && event.getKeyCode() <= KeyEvent.KEYCODE_9 || event.getKeyCode() >= KeyEvent.KEYCODE_NUMPAD_0 && event.getKeyCode() <= KeyEvent.KEYCODE_NUMPAD_9;
}
static boolean isEnterKey(KeyEvent event) {
return event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER || event.getKeyCode() == KeyEvent.KEYCODE_ENTER || event.getKeyCode() == KeyEvent.KEYCODE_SPACE || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER;
}
static boolean isUpKey(KeyEvent event) {
return event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP || event.getKeyCode() == KeyEvent.KEYCODE_CHANNEL_UP || event.getKeyCode() == KeyEvent.KEYCODE_PAGE_UP || event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PREVIOUS;
}
static boolean isDownKey(KeyEvent event) {
return event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN || event.getKeyCode() == KeyEvent.KEYCODE_CHANNEL_DOWN || event.getKeyCode() == KeyEvent.KEYCODE_PAGE_DOWN || event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_NEXT;
}
static boolean isLeftKey(KeyEvent event) {
return event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT;
}
static boolean isRightKey(KeyEvent event) {
return event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT;
}
public static void showViews(View... views) {
for (View view : views) showView(view);
}
public static void hideViews(View... views) {
for (View view : views) hideView(view);
}
public static void showView(View view) {
view.setVisibility(View.VISIBLE);
}
public static void hideView(View view) {
view.setVisibility(View.GONE);
}
public static void hideSystemUI(Activity activity) {
int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
activity.getWindow().getDecorView().setSystemUiVisibility(flags);
}
public static boolean hasPIP() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && App.get().getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
}
public static void enterPIP(Activity activity) {
try {
if (!hasPIP() || activity.isInPictureInPictureMode()) return;
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder();
builder.setAspectRatio(new Rational(16, 9)).build();
activity.enterPictureInPictureMode(builder.build());
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getUUID() {
return Settings.Secure.getString(App.get().getContentResolver(), Settings.Secure.ANDROID_ID);
}
public static String getUserAgent() {
return Util.getUserAgent(App.get(), App.get().getPackageName().concat(".").concat(getUUID()));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_browse_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/wallpaper_1" />

@ -6,6 +6,7 @@
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
<color name="blue_500">#2196F3</color>
<color name="grey_700">#616161</color>
<color name="grey_900">#212121</color>

Loading…
Cancel
Save