mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-04-20 19:45:17 +00:00
Added an initial swipe to refresh tutorial. Small bug fixes.
This commit is contained in:
parent
b763d113f1
commit
b27fc86dc5
7 changed files with 98 additions and 1 deletions
|
@ -8,8 +8,10 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Path;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
@ -94,6 +96,24 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
Inquiry.init(this, DB_NAME, 1);
|
||||
}
|
||||
|
||||
private void showRefreshTutorial() {
|
||||
if (mAdapter.getItemCount() == 0) return;
|
||||
final SharedPreferences pr = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (pr.getBoolean("shown_swipe_refresh_tutorial", false)) return;
|
||||
|
||||
final View tutorialView = findViewById(R.id.swipeRefreshTutorial);
|
||||
tutorialView.setVisibility(View.VISIBLE);
|
||||
tutorialView.setAlpha(0f);
|
||||
tutorialView.animate().cancel();
|
||||
tutorialView.animate().setDuration(300).alpha(1f).start();
|
||||
|
||||
findViewById(R.id.understoodBtn).setOnClickListener(view -> {
|
||||
view.setOnClickListener(null);
|
||||
findViewById(R.id.swipeRefreshTutorial).setVisibility(View.GONE);
|
||||
pr.edit().putBoolean("shown_swipe_refresh_tutorial", true).commit();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
@ -135,6 +155,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
mAdapter.set(models);
|
||||
mEmptyText.setVisibility(mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
AlarmUtil.setSiteChecks(this, models);
|
||||
showRefreshTutorial();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -204,7 +225,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
AlarmUtil.setSiteChecks(MainActivity.this, model);
|
||||
checkSite(MainActivity.this, model);
|
||||
});
|
||||
} else if(requestCode == VIEW_SITE_RQ) {
|
||||
} else if (requestCode == VIEW_SITE_RQ) {
|
||||
Inquiry.get()
|
||||
.update(MainActivity.SITES_TABLE_NAME, ServerModel.class)
|
||||
.where("_id = ?", model.id)
|
||||
|
|
|
@ -52,6 +52,7 @@ public class AlarmUtil {
|
|||
}
|
||||
|
||||
public static void setSiteChecks(Context context, ServerModel[] sites) {
|
||||
if (sites == null || sites.length == 0) return;
|
||||
for (ServerModel site : sites)
|
||||
setSiteChecks(context, site);
|
||||
}
|
||||
|
|
9
app/src/main/res/drawable/ic_down_arrow.xml
Normal file
9
app/src/main/res/drawable/ic_down_arrow.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="84dp"
|
||||
android:height="84dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z"
|
||||
android:fillColor="#fff"/>
|
||||
</vector>
|
|
@ -43,4 +43,62 @@
|
|||
app:rippleColor="#40ffffff"
|
||||
app:useCompatPadding="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/swipeRefreshTutorial"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#BF000000"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/content_inset"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_down_arrow"
|
||||
android:tint="#fff"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_down_arrow"
|
||||
android:tint="#fff"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/content_inset_more"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:gravity="center"
|
||||
android:lineSpacingMultiplier="1.6"
|
||||
android:text="@string/swipe_refresh_hint"
|
||||
android:textColor="#fff"
|
||||
android:textSize="@dimen/medium_text_size" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/understoodBtn"
|
||||
android:layout_width="@dimen/tutorial_button_width"
|
||||
android:layout_height="@dimen/button_height"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/content_inset_double"
|
||||
android:text="@string/understood"
|
||||
android:theme="@style/AccentButton" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -17,5 +17,6 @@
|
|||
<dimen name="fab_elevation">4dp</dimen>
|
||||
<dimen name="fab_elevation_pressed">8dp</dimen>
|
||||
<dimen name="button_height">52dp</dimen>
|
||||
<dimen name="tutorial_button_width">300dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -42,6 +42,8 @@
|
|||
<string name="none">None</string>
|
||||
|
||||
<string name="refresh_status">Refresh Status</string>
|
||||
<string name="swipe_refresh_hint">Drag the list down to manually refresh site statuses! Otherwise, they will be updated automatically in the background on chosen intervals.</string>
|
||||
<string name="understood">Understood!</string>
|
||||
|
||||
<string-array name="interval_options">
|
||||
<item>Minute(s)</item>
|
||||
|
|
|
@ -27,4 +27,9 @@
|
|||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="AccentButton" parent="Widget.AppCompat.Button.Colored">
|
||||
<item name="android:textColor">#fff</item>
|
||||
<item name="android:colorButtonNormal">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue