Skip to content

Commit

Permalink
Layouts rename
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliturin committed Feb 21, 2017
1 parent 625a5d0 commit d492b96
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void numberListAddRow(String number, int type) {
(LinearLayout) parent.findViewById(R.id.layout_number_list);
LayoutInflater inflater = getActivity().getLayoutInflater();
// create new row
View row = inflater.inflate(R.layout.contact_number_row, numberRowsListLayout, false);
View row = inflater.inflate(R.layout.row_contact_number, numberRowsListLayout, false);
// init row with number data
setNumberType(row, type);
setNumber(row, number);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public View newView(Context context, Cursor cursor, ViewGroup parent) {
if(cursor == null) return null;

LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.contacts_row, parent, false);
View view = inflater.inflate(R.layout.row_contacts, parent, false);

// view holder for the new row
ViewHolder viewHolder = new ViewHolder(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class JournalCursorAdapter extends CursorAdapter {
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// TODO remove sample data from layout
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.journal_row, parent, false);
View view = inflater.inflate(R.layout.row_journal, parent, false);

// view holder for the row
ViewHolder viewHolder = new ViewHolder(view);
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/kaliturin/blacklist/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {

public static final String ACTION_SHOW_JOURNAL = "ACTION_SHOW_JOURNAL";
public static final String ACTION_SHOW_SMS_CONVERSATIONS = "ACTION_SHOW_SMS_CONVERSATIONS";
public static final String ACTION_SHOW_SMS_SEND_TO = "android.intent.action.SENDTO";
public static final String ACTION_JOURNAL = "ACTION_JOURNAL";
public static final String ACTION_SMS_CONVERSATIONS = "ACTION_SMS_CONVERSATIONS";
public static final String ACTION_SMS_SEND_TO = "android.intent.action.SENDTO";

private static final String CURRENT_ITEM_ID = "CURRENT_ITEM_ID";
private FragmentSwitcher fragmentSwitcher = new FragmentSwitcher();
Expand Down Expand Up @@ -64,7 +64,7 @@ protected void onCreate(Bundle savedInstanceState) {
} else {
// process actions
String action = getIntent().getAction();
if(action != null && action.equals(ACTION_SHOW_SMS_SEND_TO)) {
if(action != null && action.equals(ACTION_SMS_SEND_TO)) {
// switch to SMS conversations fragment
navigationView.setCheckedItem(R.id.nav_sms);
fragmentSwitcher.switchFragment(R.id.nav_sms);
Expand All @@ -82,7 +82,7 @@ protected void onCreate(Bundle savedInstanceState) {
SendSMSFragment.class, arguments);
}
} else
if(action != null && action.equals(ACTION_SHOW_SMS_CONVERSATIONS)) {
if(action != null && action.equals(ACTION_SMS_CONVERSATIONS)) {
// switch to SMS conversations fragment
navigationView.setCheckedItem(R.id.nav_sms);
fragmentSwitcher.switchFragment(R.id.nav_sms);
Expand Down Expand Up @@ -161,7 +161,7 @@ private class FragmentSwitcher {
private ContactsFragment whiteListFragment = new ContactsFragment();
private JournalFragment journalFragment = new JournalFragment();
private SettingsFragment settingsFragment = new SettingsFragment();
private SMSAllConversationsFragment smsFragment = new SMSAllConversationsFragment();
private SMSConversationsListFragment smsFragment = new SMSConversationsListFragment();
private int currentItemId;

boolean onBackPressed() {
Expand Down Expand Up @@ -202,7 +202,7 @@ void switchFragment(@IdRes int itemId, Bundle arguments) {
switchFragment(whiteListFragment, arguments);
break;
case R.id.nav_sms:
arguments.putString(SMSAllConversationsFragment.TITLE, getString(R.string.sms_title));
arguments.putString(SMSConversationsListFragment.TITLE, getString(R.string.sms_title));
switchFragment(smsFragment, arguments);
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public MenuDialogBuilder addMenuItem(String title, final View.OnClickListener li
public MenuDialogBuilder addMenuItem(String title, final boolean dismissOnClick,
final View.OnClickListener listener) {
LayoutInflater inflater = activity.getLayoutInflater();
View itemView = inflater.inflate(R.layout.menu_dialog_row, null);
View itemView = inflater.inflate(R.layout.row_dialog_menu, null);
LinearLayout listLayout = (LinearLayout) getView().findViewById(R.id.items_list);
listLayout.addView(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
Expand All @@ -58,7 +58,7 @@ public void onClick(View v) {
public View getView() {
if (view == null) {
LayoutInflater inflater = activity.getLayoutInflater();
view = inflater.inflate(R.layout.menu_dialog, null);
view = inflater.inflate(R.layout.dialog_menu, null);
}

return view;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/kaliturin/blacklist/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ static void onSmsReceived(Context context, String address) {
private static void showNotification(Context context, String message, int icon, boolean blocked) {
Intent activityIntent = new Intent(context, MainActivity.class);
if(blocked) {
activityIntent.setAction(MainActivity.ACTION_SHOW_JOURNAL);
activityIntent.setAction(MainActivity.ACTION_JOURNAL);
} else {
activityIntent.setAction(MainActivity.ACTION_SHOW_SMS_CONVERSATIONS);
activityIntent.setAction(MainActivity.ACTION_SMS_CONVERSATIONS);
}
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0);

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/kaliturin/blacklist/Permissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ static boolean notifyIfNotGranted(@NonNull Activity activity, @NonNull String pe
return false;
}

// TODO: test
// Notifies the user that permission isn't granted
// Notifies the user about permission isn't granted
static void notify(@NonNull final Activity activity, @NonNull String permission) {
PackageManager pm = activity.getPackageManager();
PermissionInfo info = null;
Expand Down Expand Up @@ -100,7 +99,8 @@ static void checkAndRequest(@NonNull Activity context) {
ActivityCompat.requestPermissions(context, PERMISSIONS, REQUEST_CODE);
}

static void reset() {
// Resets permissions results cache
static void resetCache() {
permissionsResults.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SMSConversationCursorAdapter extends CursorAdapter {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.sms_conversation_row, parent, false);
View view = inflater.inflate(R.layout.row_sms_conversation, parent, false);

// view holder for the row
ViewHolder viewHolder = new ViewHolder(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
/**
* Cursor adapter for all SMS conversations
*/
class SMSAllConversationsCursorAdapter extends CursorAdapter {
class SMSConversationsListCursorAdapter extends CursorAdapter {
private final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
private Date datetime = new Date();
private View.OnClickListener outerOnClickListener = null;
private View.OnLongClickListener outerOnLongClickListener = null;
private RowOnClickListener rowOnClickListener = new RowOnClickListener();
private RowOnLongClickListener rowOnLongClickListener = new RowOnLongClickListener();

SMSAllConversationsCursorAdapter(Context context) {
SMSConversationsListCursorAdapter(Context context) {
super(context, null, 0);
}

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.sms_all_conversations_row, parent, false);
View view = inflater.inflate(R.layout.row_sms_conversations_list, parent, false);

// view holder for the row
ViewHolder viewHolder = new ViewHolder(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
/**
* Fragment for showing all SMS conversations
*/
public class SMSAllConversationsFragment extends Fragment {
public class SMSConversationsListFragment extends Fragment {
public static String TITLE = "TITLE";
private SMSAllConversationsCursorAdapter cursorAdapter = null;
private SMSConversationsListCursorAdapter cursorAdapter = null;

public SMSAllConversationsFragment() {
public SMSConversationsListFragment() {
// Required empty public constructor
}

Expand All @@ -54,7 +54,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_sms_all_conversations, container, false);
return inflater.inflate(R.layout.fragment_sms_conversations_list, container, false);
}

@Override
Expand All @@ -77,7 +77,7 @@ public void onResume() {
super.onResume();

// cursor adapter
cursorAdapter = new SMSAllConversationsCursorAdapter(getContext());
cursorAdapter = new SMSConversationsListCursorAdapter(getContext());
cursorAdapter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View row) {
Expand Down Expand Up @@ -181,10 +181,10 @@ public Cursor loadInBackground() {
// SMS conversations loader callbacks
private static class SMSAllConversationsLoaderCallbacks implements LoaderManager.LoaderCallbacks<Cursor> {
private Context context;
private SMSAllConversationsCursorAdapter cursorAdapter;
private SMSConversationsListCursorAdapter cursorAdapter;

SMSAllConversationsLoaderCallbacks(Context context,
SMSAllConversationsCursorAdapter cursorAdapter) {
SMSConversationsListCursorAdapter cursorAdapter) {
this.context = context;
this.cursorAdapter = cursorAdapter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import android.widget.CheckBox;
import android.widget.TextView;

import java.security.Permission;

/**
* Settings array adapter
*/
Expand All @@ -37,9 +35,9 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par
// create row by model
LayoutInflater inflater = LayoutInflater.from(getContext());
if (model.property == null && model.listener == null) {
row = inflater.inflate(R.layout.settings_title, parent, false);
row = inflater.inflate(R.layout.row_title_settings, parent, false);
} else {
row = inflater.inflate(R.layout.settings_row, parent, false);
row = inflater.inflate(R.layout.row_settings, parent, false);
}
setModel(row, model);
rowsArray.put(position, row);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class SettingsFragment extends Fragment {
public void onClick(View v) {
Activity activity = SettingsFragment.this.getActivity();
DefaultSMSAppHelper.askForDefaultAppChange(activity, 0);
Permissions.reset();
Permissions.resetCache();
}
};

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.kaliturin.blacklist.SMSAllConversationsFragment">
tools:context="com.kaliturin.blacklist.SMSConversationsListFragment">

<ListView
android:id="@+id/rows_list"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d492b96

Please sign in to comment.