Loading app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java 0 → 100644 +97 −0 Original line number Diff line number Diff line package foundation.e.blisslauncher.features.weather; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.AttributeSet; import android.view.View; import android.widget.LinearLayout; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.features.launcher.LauncherActivity; import foundation.e.blisslauncher.features.weather.ForecastBuilder; import foundation.e.blisslauncher.features.weather.WeatherPreferences; import foundation.e.blisslauncher.features.weather.WeatherUpdateService; public class WeatherInfoView extends LinearLayout { private View mWeatherPanel; private View mWeatherSetupTextView; private final BroadcastReceiver mWeatherReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!intent.getBooleanExtra(WeatherUpdateService.EXTRA_UPDATE_CANCELLED, false)) { updateWeatherPanel(); } } }; private final BroadcastReceiver mResumeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateWeatherPanel(); } }; public WeatherInfoView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onFinishInflate() { super.onFinishInflate(); mWeatherSetupTextView = findViewById(R.id.weather_setup_textview); mWeatherPanel = findViewById(R.id.weather_panel); mWeatherPanel.setOnClickListener(v -> { Intent launchIntent = getContext().getPackageManager().getLaunchIntentForPackage( "foundation.e.weather"); if (launchIntent != null) { launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(launchIntent); } }); findViewById(R.id.weather_setting_imageview).setOnClickListener(v -> startWeatherPreferences()); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext()); broadcastManager.registerReceiver(mWeatherReceiver, new IntentFilter( WeatherUpdateService.ACTION_UPDATE_FINISHED)); broadcastManager.registerReceiver(mResumeReceiver, new IntentFilter( LauncherActivity.ACTION_LAUNCHER_RESUME)); updateWeatherPanel(); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext()); broadcastManager.unregisterReceiver(mWeatherReceiver); broadcastManager.unregisterReceiver(mResumeReceiver); } private void updateWeatherPanel() { if (Preferences.getCachedWeatherInfo(getContext()) == null) { mWeatherSetupTextView.setVisibility(VISIBLE); mWeatherPanel.setVisibility(GONE); mWeatherSetupTextView.setOnClickListener(v -> startWeatherPreferences()); return; } mWeatherSetupTextView.setVisibility(GONE); mWeatherPanel.setVisibility(VISIBLE); ForecastBuilder.buildLargePanel(getContext(), mWeatherPanel, Preferences.getCachedWeatherInfo(getContext())); } private void startWeatherPreferences() { Intent intent = new Intent(getContext(), WeatherPreferences.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); } } app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +5 −48 Original line number Diff line number Diff line Loading @@ -166,6 +166,8 @@ public class LauncherActivity extends AppCompatActivity implements private static final int REQUEST_PERMISSION_CALL_PHONE = 14; private static final int REQUEST_LOCATION_SOURCE_SETTING = 267; private static final int STORAGE_PERMISSION_REQUEST_CODE = 586; public static final String ACTION_LAUNCHER_RESUME = "foundation.e.blisslauncher.LauncherActivity.LAUNCHER_RESUME"; public static boolean longPressed; private final Alarm mReorderAlarm = new Alarm(); private final Alarm mDockReorderAlarm = new Alarm(); Loading Loading @@ -202,8 +204,6 @@ public class LauncherActivity extends AppCompatActivity implements private boolean mLongClickStartsDrag = true; private boolean isDragging; private BlissDragShadowBuilder dragShadowBuilder; private View mWeatherPanel; private View mWeatherSetupTextView; private boolean allAppsDisplayed; private boolean forceRefreshSuggestedApps = false; Loading @@ -213,14 +213,6 @@ public class LauncherActivity extends AppCompatActivity implements private InsettableRelativeLayout workspace; private View blurLayer; // Blur layer for folders and search container. private BroadcastReceiver mWeatherReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!intent.getBooleanExtra(WeatherUpdateService.EXTRA_UPDATE_CANCELLED, false)) { updateWeatherPanel(); } } }; private FolderItem activeFolder; private BlissFrameLayout activeFolderView; private int activeDot; Loading Loading @@ -452,14 +444,14 @@ public class LauncherActivity extends AppCompatActivity implements @Override protected void onResume() { super.onResume(); if (mWeatherPanel != null) { updateWeatherPanel(); } if (widgetsPage != null) { refreshSuggestedApps(widgetsPage, forceRefreshSuggestedApps); } Intent resumeIntent = new Intent(ACTION_LAUNCHER_RESUME); LocalBroadcastManager.getInstance(this).sendBroadcast(resumeIntent); if (widgetContainer != null) { WidgetManager widgetManager = WidgetManager.getInstance(); Integer id = widgetManager.dequeRemoveId(); Loading Loading @@ -511,7 +503,6 @@ public class LauncherActivity extends AppCompatActivity implements // Unregister active receivers TimeChangeBroadcastReceiver.unregister(this, timeChangedReceiver); ManagedProfileBroadcastReceiver.unregister(this, managedProfileReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(mWeatherReceiver); // Dispose CompositeDisposable getCompositeDisposable().dispose(); Loading Loading @@ -1422,31 +1413,12 @@ public class LauncherActivity extends AppCompatActivity implements findViewById(R.id.edit_widgets_button).setOnClickListener( view -> startActivity(new Intent(this, WidgetsActivity.class))); // Prepare weather widget view // [[BEGIN]] findViewById(R.id.weather_setting_imageview).setOnClickListener( v -> startActivity(new Intent(this, WeatherPreferences.class))); mWeatherSetupTextView = findViewById(R.id.weather_setup_textview); mWeatherPanel = findViewById(R.id.weather_panel); mWeatherPanel.setOnClickListener(v -> { Intent launchIntent = getPackageManager().getLaunchIntentForPackage( "foundation.e.weather"); if (launchIntent != null) { launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(launchIntent); } }); updateWeatherPanel(); if (WeatherUtils.isWeatherServiceAvailable( this)) { startService(new Intent(this, WeatherSourceListenerService.class)); startService(new Intent(this, DeviceStatusService.class)); } LocalBroadcastManager.getInstance(this).registerReceiver(mWeatherReceiver, new IntentFilter( WeatherUpdateService.ACTION_UPDATE_FINISHED)); if (!Preferences.useCustomWeatherLocation(this)) { if (!WeatherPreferences.hasLocationPermission(this)) { Loading Loading @@ -1522,21 +1494,6 @@ public class LauncherActivity extends AppCompatActivity implements } } private void updateWeatherPanel() { if (Preferences.getCachedWeatherInfo(this) == null) { mWeatherSetupTextView.setVisibility(VISIBLE); mWeatherPanel.setVisibility(GONE); mWeatherSetupTextView.setOnClickListener( v -> startActivity( new Intent(LauncherActivity.this, WeatherPreferences.class))); return; } mWeatherSetupTextView.setVisibility(GONE); mWeatherPanel.setVisibility(VISIBLE); ForecastBuilder.buildLargePanel(this, mWeatherPanel, Preferences.getCachedWeatherInfo(this)); } private void showLocationEnableDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Build and show the dialog Loading app/src/main/res/layout/layout_weather_info.xml +2 −2 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <foundation.e.blisslauncher.features.weather.WeatherInfoView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" Loading Loading @@ -161,4 +161,4 @@ </LinearLayout> </FrameLayout> </LinearLayout> No newline at end of file </foundation.e.blisslauncher.features.weather.WeatherInfoView> Loading
app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/WeatherInfoView.java 0 → 100644 +97 −0 Original line number Diff line number Diff line package foundation.e.blisslauncher.features.weather; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.AttributeSet; import android.view.View; import android.widget.LinearLayout; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import foundation.e.blisslauncher.R; import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.features.launcher.LauncherActivity; import foundation.e.blisslauncher.features.weather.ForecastBuilder; import foundation.e.blisslauncher.features.weather.WeatherPreferences; import foundation.e.blisslauncher.features.weather.WeatherUpdateService; public class WeatherInfoView extends LinearLayout { private View mWeatherPanel; private View mWeatherSetupTextView; private final BroadcastReceiver mWeatherReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!intent.getBooleanExtra(WeatherUpdateService.EXTRA_UPDATE_CANCELLED, false)) { updateWeatherPanel(); } } }; private final BroadcastReceiver mResumeReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateWeatherPanel(); } }; public WeatherInfoView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onFinishInflate() { super.onFinishInflate(); mWeatherSetupTextView = findViewById(R.id.weather_setup_textview); mWeatherPanel = findViewById(R.id.weather_panel); mWeatherPanel.setOnClickListener(v -> { Intent launchIntent = getContext().getPackageManager().getLaunchIntentForPackage( "foundation.e.weather"); if (launchIntent != null) { launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(launchIntent); } }); findViewById(R.id.weather_setting_imageview).setOnClickListener(v -> startWeatherPreferences()); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext()); broadcastManager.registerReceiver(mWeatherReceiver, new IntentFilter( WeatherUpdateService.ACTION_UPDATE_FINISHED)); broadcastManager.registerReceiver(mResumeReceiver, new IntentFilter( LauncherActivity.ACTION_LAUNCHER_RESUME)); updateWeatherPanel(); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext()); broadcastManager.unregisterReceiver(mWeatherReceiver); broadcastManager.unregisterReceiver(mResumeReceiver); } private void updateWeatherPanel() { if (Preferences.getCachedWeatherInfo(getContext()) == null) { mWeatherSetupTextView.setVisibility(VISIBLE); mWeatherPanel.setVisibility(GONE); mWeatherSetupTextView.setOnClickListener(v -> startWeatherPreferences()); return; } mWeatherSetupTextView.setVisibility(GONE); mWeatherPanel.setVisibility(VISIBLE); ForecastBuilder.buildLargePanel(getContext(), mWeatherPanel, Preferences.getCachedWeatherInfo(getContext())); } private void startWeatherPreferences() { Intent intent = new Intent(getContext(), WeatherPreferences.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); } }
app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +5 −48 Original line number Diff line number Diff line Loading @@ -166,6 +166,8 @@ public class LauncherActivity extends AppCompatActivity implements private static final int REQUEST_PERMISSION_CALL_PHONE = 14; private static final int REQUEST_LOCATION_SOURCE_SETTING = 267; private static final int STORAGE_PERMISSION_REQUEST_CODE = 586; public static final String ACTION_LAUNCHER_RESUME = "foundation.e.blisslauncher.LauncherActivity.LAUNCHER_RESUME"; public static boolean longPressed; private final Alarm mReorderAlarm = new Alarm(); private final Alarm mDockReorderAlarm = new Alarm(); Loading Loading @@ -202,8 +204,6 @@ public class LauncherActivity extends AppCompatActivity implements private boolean mLongClickStartsDrag = true; private boolean isDragging; private BlissDragShadowBuilder dragShadowBuilder; private View mWeatherPanel; private View mWeatherSetupTextView; private boolean allAppsDisplayed; private boolean forceRefreshSuggestedApps = false; Loading @@ -213,14 +213,6 @@ public class LauncherActivity extends AppCompatActivity implements private InsettableRelativeLayout workspace; private View blurLayer; // Blur layer for folders and search container. private BroadcastReceiver mWeatherReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!intent.getBooleanExtra(WeatherUpdateService.EXTRA_UPDATE_CANCELLED, false)) { updateWeatherPanel(); } } }; private FolderItem activeFolder; private BlissFrameLayout activeFolderView; private int activeDot; Loading Loading @@ -452,14 +444,14 @@ public class LauncherActivity extends AppCompatActivity implements @Override protected void onResume() { super.onResume(); if (mWeatherPanel != null) { updateWeatherPanel(); } if (widgetsPage != null) { refreshSuggestedApps(widgetsPage, forceRefreshSuggestedApps); } Intent resumeIntent = new Intent(ACTION_LAUNCHER_RESUME); LocalBroadcastManager.getInstance(this).sendBroadcast(resumeIntent); if (widgetContainer != null) { WidgetManager widgetManager = WidgetManager.getInstance(); Integer id = widgetManager.dequeRemoveId(); Loading Loading @@ -511,7 +503,6 @@ public class LauncherActivity extends AppCompatActivity implements // Unregister active receivers TimeChangeBroadcastReceiver.unregister(this, timeChangedReceiver); ManagedProfileBroadcastReceiver.unregister(this, managedProfileReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(mWeatherReceiver); // Dispose CompositeDisposable getCompositeDisposable().dispose(); Loading Loading @@ -1422,31 +1413,12 @@ public class LauncherActivity extends AppCompatActivity implements findViewById(R.id.edit_widgets_button).setOnClickListener( view -> startActivity(new Intent(this, WidgetsActivity.class))); // Prepare weather widget view // [[BEGIN]] findViewById(R.id.weather_setting_imageview).setOnClickListener( v -> startActivity(new Intent(this, WeatherPreferences.class))); mWeatherSetupTextView = findViewById(R.id.weather_setup_textview); mWeatherPanel = findViewById(R.id.weather_panel); mWeatherPanel.setOnClickListener(v -> { Intent launchIntent = getPackageManager().getLaunchIntentForPackage( "foundation.e.weather"); if (launchIntent != null) { launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(launchIntent); } }); updateWeatherPanel(); if (WeatherUtils.isWeatherServiceAvailable( this)) { startService(new Intent(this, WeatherSourceListenerService.class)); startService(new Intent(this, DeviceStatusService.class)); } LocalBroadcastManager.getInstance(this).registerReceiver(mWeatherReceiver, new IntentFilter( WeatherUpdateService.ACTION_UPDATE_FINISHED)); if (!Preferences.useCustomWeatherLocation(this)) { if (!WeatherPreferences.hasLocationPermission(this)) { Loading Loading @@ -1522,21 +1494,6 @@ public class LauncherActivity extends AppCompatActivity implements } } private void updateWeatherPanel() { if (Preferences.getCachedWeatherInfo(this) == null) { mWeatherSetupTextView.setVisibility(VISIBLE); mWeatherPanel.setVisibility(GONE); mWeatherSetupTextView.setOnClickListener( v -> startActivity( new Intent(LauncherActivity.this, WeatherPreferences.class))); return; } mWeatherSetupTextView.setVisibility(GONE); mWeatherPanel.setVisibility(VISIBLE); ForecastBuilder.buildLargePanel(this, mWeatherPanel, Preferences.getCachedWeatherInfo(this)); } private void showLocationEnableDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Build and show the dialog Loading
app/src/main/res/layout/layout_weather_info.xml +2 −2 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <foundation.e.blisslauncher.features.weather.WeatherInfoView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" Loading Loading @@ -161,4 +161,4 @@ </LinearLayout> </FrameLayout> </LinearLayout> No newline at end of file </foundation.e.blisslauncher.features.weather.WeatherInfoView>